Skip to content

Commit

Permalink
Fix compiler errors and new warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
pgrawehr committed Sep 30, 2024
1 parent 8d68117 commit c8e6b33
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 72 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@

internal partial class Interop
{
#pragma warning disable CS8981 // The type name only contains lower-cased ascii characters. Such names may become reserved for the language.
internal partial class libbcmhost
#pragma warning restore CS8981 // The type name only contains lower-cased ascii characters. Such names may become reserved for the language.
{
private const string LibbcmhostLibrary = "libbcm_host";

Expand Down

This file was deleted.

2 changes: 1 addition & 1 deletion src/devices/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<SystemDeviceModelPath>$(MSBuildThisFileDirectory)$(SystemDeviceModelProjectName)/$(SystemDeviceModelProjectName).csproj</SystemDeviceModelPath>
<CommonProjectName>Common</CommonProjectName>
<CommonProjectPath>$(MSBuildThisFileDirectory)$(CommonProjectName)/$(CommonProjectName).csproj</CommonProjectPath>
<LangVersion>9</LangVersion>
<LangVersion>latest</LangVersion>
<Nullable>enable</Nullable>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ internal struct v4l2_meta_format
}

[StructLayout(LayoutKind.Explicit)]
internal unsafe struct fmt
internal unsafe struct V412_Fmt
{
[FieldOffset(0)]
public v4l2_pix_format pix;
Expand All @@ -263,7 +263,7 @@ internal unsafe struct fmt
internal struct v4l2_format
{
public v4l2_buf_type type;
public fmt fmt;
public V412_Fmt fmt;
}

[StructLayout(LayoutKind.Sequential)]
Expand Down Expand Up @@ -339,7 +339,9 @@ internal struct v4l2_buffer
public v4l2_field field;

[StructLayout(LayoutKind.Sequential)]
#pragma warning disable CS8981 // The type name only contains lower-cased ascii characters. Such names may become reserved for the language.
public struct timeval
#pragma warning restore CS8981 // The type name only contains lower-cased ascii characters. Such names may become reserved for the language.
{
public nint tv_sec;
public nint tv_usec;
Expand Down
2 changes: 1 addition & 1 deletion src/devices/Media/VideoDevice/Devices/UnixVideoDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ private unsafe void SetVideoConnectionSettings()
InteropVideodev2.v4l2_format format = new InteropVideodev2.v4l2_format
{
type = InteropVideodev2.v4l2_buf_type.V4L2_BUF_TYPE_VIDEO_CAPTURE,
fmt = new InteropVideodev2.fmt
fmt = new InteropVideodev2.V412_Fmt
{
pix = new InteropVideodev2.v4l2_pix_format
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ public void GetStream()

HttpContext.Response.StatusCode = 200;
HttpContext.Response.ContentType = "multipart/x-mixed-replace; boundary=--frame";
HttpContext.Response.Headers.Add("Connection", "Keep-Alive");
HttpContext.Response.Headers.Add("CacheControl", "no-cache");
HttpContext.Response.Headers["Connection"] = "Keep-Alive";
HttpContext.Response.Headers["CacheControl"] = "no-cache";
_camera.NewImageReady += WriteBufferBody;

try
Expand Down Expand Up @@ -122,8 +122,8 @@ public void GetModifiedStream()

HttpContext.Response.StatusCode = 200;
HttpContext.Response.ContentType = "multipart/x-mixed-replace; boundary=--frame";
HttpContext.Response.Headers.Add("Connection", "Keep-Alive");
HttpContext.Response.Headers.Add("CacheControl", "no-cache");
HttpContext.Response.Headers["Connection"] = "Keep-Alive";
HttpContext.Response.Headers["CacheControl"] = "no-cache";
_camera.NewImageReady += WriteModifiedBufferBody;

try
Expand Down
16 changes: 8 additions & 8 deletions src/devices/SocketCan/Interop.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ internal class Interop
private static extern int CreateNativeSocket(int domain, int type, CanProtocol protocol);

[DllImport("libc", EntryPoint = "ioctl", CallingConvention = CallingConvention.Cdecl)]
private static extern int Ioctl3(int fd, uint request, ref ifreq ifr);
private static extern int Ioctl3(int fd, uint request, ref InterfaceIndexQuery ifr);

[DllImport("libc", EntryPoint = "bind", CallingConvention = CallingConvention.Cdecl)]
private static extern int BindSocket(int fd, ref CanSocketAddress addr, uint addrlen);
Expand Down Expand Up @@ -126,17 +126,17 @@ private static unsafe void BindToInterface(int fd, string interfaceName)
private static unsafe int GetInterfaceIndex(int fd, string name)
{
const uint SIOCGIFINDEX = 0x8933;
const int MaxLen = ifreq.IFNAMSIZ - 1;
const int maxLen = InterfaceIndexQuery.IFNAMSIZ - 1;

if (name.Length >= MaxLen)
if (name.Length >= maxLen)
{
throw new ArgumentException($"Value exceeds maximum allowed length of {MaxLen} size.", nameof(name));
throw new ArgumentException($"Value exceeds maximum allowed length of {maxLen} size.", nameof(name));
}

ifreq ifr = new ifreq();
fixed (char* inIntefaceName = name)
InterfaceIndexQuery ifr = new InterfaceIndexQuery();
fixed (char* inInterfaceName = name)
{
int written = Encoding.ASCII.GetBytes(inIntefaceName, name.Length, ifr.ifr_name, MaxLen);
int written = Encoding.ASCII.GetBytes(inInterfaceName, name.Length, ifr.ifr_name, maxLen);
ifr.ifr_name[written] = 0;
}

Expand All @@ -149,7 +149,7 @@ private static unsafe int GetInterfaceIndex(int fd, string name)
return ifr.ifr_ifindex;
}

internal unsafe struct ifreq
internal unsafe struct InterfaceIndexQuery
{
internal const int IFNAMSIZ = 16;
public fixed byte ifr_name[IFNAMSIZ];
Expand Down
2 changes: 1 addition & 1 deletion tools/ArduinoCsCompiler/Runtime/MiniBuffer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public static unsafe void ZeroMemory(ref byte b, uint byteLength)
{
fixed (byte* bytePointer = &b)
{
ZeroMemory(bytePointer, byteLength);
ZeroMemory((void*)bytePointer, byteLength);
}
}

Expand Down

0 comments on commit c8e6b33

Please sign in to comment.