Skip to content

Commit c8e6b33

Browse files
committed
Fix compiler errors and new warnings
1 parent 8d68117 commit c8e6b33

File tree

8 files changed

+21
-72
lines changed

8 files changed

+21
-72
lines changed

src/System.Device.Gpio/Interop/Unix/libbcm_host/Interop.libbcmhost.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99

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

src/System.Device.Gpio/System/Diagnostics/CodeAnalysis/ExperimentalAttribute.cs

Lines changed: 0 additions & 55 deletions
This file was deleted.

src/devices/Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<SystemDeviceModelPath>$(MSBuildThisFileDirectory)$(SystemDeviceModelProjectName)/$(SystemDeviceModelProjectName).csproj</SystemDeviceModelPath>
1515
<CommonProjectName>Common</CommonProjectName>
1616
<CommonProjectPath>$(MSBuildThisFileDirectory)$(CommonProjectName)/$(CommonProjectName).csproj</CommonProjectPath>
17-
<LangVersion>9</LangVersion>
17+
<LangVersion>latest</LangVersion>
1818
<Nullable>enable</Nullable>
1919
</PropertyGroup>
2020

src/devices/Media/VideoDevice/Devices/Interop.videodev2.struct.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ internal struct v4l2_meta_format
241241
}
242242

243243
[StructLayout(LayoutKind.Explicit)]
244-
internal unsafe struct fmt
244+
internal unsafe struct V412_Fmt
245245
{
246246
[FieldOffset(0)]
247247
public v4l2_pix_format pix;
@@ -263,7 +263,7 @@ internal unsafe struct fmt
263263
internal struct v4l2_format
264264
{
265265
public v4l2_buf_type type;
266-
public fmt fmt;
266+
public V412_Fmt fmt;
267267
}
268268

269269
[StructLayout(LayoutKind.Sequential)]
@@ -339,7 +339,9 @@ internal struct v4l2_buffer
339339
public v4l2_field field;
340340

341341
[StructLayout(LayoutKind.Sequential)]
342+
#pragma warning disable CS8981 // The type name only contains lower-cased ascii characters. Such names may become reserved for the language.
342343
public struct timeval
344+
#pragma warning restore CS8981 // The type name only contains lower-cased ascii characters. Such names may become reserved for the language.
343345
{
344346
public nint tv_sec;
345347
public nint tv_usec;

src/devices/Media/VideoDevice/Devices/UnixVideoDevice.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ private unsafe void SetVideoConnectionSettings()
404404
InteropVideodev2.v4l2_format format = new InteropVideodev2.v4l2_format
405405
{
406406
type = InteropVideodev2.v4l2_buf_type.V4L2_BUF_TYPE_VIDEO_CAPTURE,
407-
fmt = new InteropVideodev2.fmt
407+
fmt = new InteropVideodev2.V412_Fmt
408408
{
409409
pix = new InteropVideodev2.v4l2_pix_format
410410
{

src/devices/Media/VideoDevice/samples/MjpegStream/Controllers/Image.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ public void GetStream()
6969

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

7676
try
@@ -122,8 +122,8 @@ public void GetModifiedStream()
122122

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

129129
try

src/devices/SocketCan/Interop.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ internal class Interop
3434
private static extern int CreateNativeSocket(int domain, int type, CanProtocol protocol);
3535

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

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

131-
if (name.Length >= MaxLen)
131+
if (name.Length >= maxLen)
132132
{
133-
throw new ArgumentException($"Value exceeds maximum allowed length of {MaxLen} size.", nameof(name));
133+
throw new ArgumentException($"Value exceeds maximum allowed length of {maxLen} size.", nameof(name));
134134
}
135135

136-
ifreq ifr = new ifreq();
137-
fixed (char* inIntefaceName = name)
136+
InterfaceIndexQuery ifr = new InterfaceIndexQuery();
137+
fixed (char* inInterfaceName = name)
138138
{
139-
int written = Encoding.ASCII.GetBytes(inIntefaceName, name.Length, ifr.ifr_name, MaxLen);
139+
int written = Encoding.ASCII.GetBytes(inInterfaceName, name.Length, ifr.ifr_name, maxLen);
140140
ifr.ifr_name[written] = 0;
141141
}
142142

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

152-
internal unsafe struct ifreq
152+
internal unsafe struct InterfaceIndexQuery
153153
{
154154
internal const int IFNAMSIZ = 16;
155155
public fixed byte ifr_name[IFNAMSIZ];

tools/ArduinoCsCompiler/Runtime/MiniBuffer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public static unsafe void ZeroMemory(ref byte b, uint byteLength)
5656
{
5757
fixed (byte* bytePointer = &b)
5858
{
59-
ZeroMemory(bytePointer, byteLength);
59+
ZeroMemory((void*)bytePointer, byteLength);
6060
}
6161
}
6262

0 commit comments

Comments
 (0)