Skip to content

Commit fa221a7

Browse files
Christoph BauerChristoph Bauer
authored andcommitted
More Warnings fixed
1 parent 1f36ea1 commit fa221a7

20 files changed

+52
-41
lines changed

src/NetMQ.Tests/RouterTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public void ReceiveReadyDot35Bug()
4444
using (var server = new RouterSocket())
4545
{
4646
server.BindRandomPort("tcp://127.0.0.1");
47-
server.ReceiveReady += (s, e) => Assert.True(false, "Should not receive");
47+
server.ReceiveReady += (s, e) => Assert.Fail( "Should not receive");
4848

4949
Assert.False(server.Poll(TimeSpan.FromMilliseconds(1500)));
5050
}

src/NetMQ/AsyncReceiveExtensions.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public static async Task<NetMQMessage> ReceiveMultipartMessageAsync(
9191
registration = cancellationToken.Register(PropagateCancel);
9292
}
9393

94-
void Listener(object sender, NetMQSocketEventArgs args)
94+
void Listener(object? sender, NetMQSocketEventArgs args)
9595
{
9696
if (socket.TryReceive(ref msg, TimeSpan.Zero))
9797
{
@@ -174,7 +174,7 @@ void PropagateCancel()
174174
registration = cancellationToken.Register(PropagateCancel);
175175
}
176176

177-
void Listener(object sender, NetMQSocketEventArgs args)
177+
void Listener(object? sender, NetMQSocketEventArgs args)
178178
{
179179
if (socket.TryReceive(ref msg, TimeSpan.Zero))
180180
{
@@ -241,7 +241,7 @@ public static Task<bool> SkipFrameAsync(
241241
registration = cancellationToken.Register(PropagateCancel);
242242
}
243243

244-
void Listener(object sender, NetMQSocketEventArgs args)
244+
void Listener(object? sender, NetMQSocketEventArgs args)
245245
{
246246
if (socket.TryReceive(ref msg, TimeSpan.Zero))
247247
{

src/NetMQ/Core/Address.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public Address(EndPoint endpoint)
104104
}
105105

106106
Debug.Assert(endpoint != null);
107-
AddressString = endpoint.ToString()!;
107+
AddressString = endpoint!.ToString()!;
108108
}
109109

110110

src/NetMQ/Core/Patterns/Peer.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ protected override void XAttachPipe(Pipe pipe, bool icanhasall)
148148
/// <param name="pipe">the Pipe that is being removed</param>
149149
protected override void XTerminated(Pipe pipe)
150150
{
151-
m_outpipes.TryGetValue(pipe.RoutingId, out Outpipe old);
151+
m_outpipes.TryGetValue(pipe.RoutingId, out Outpipe? old);
152152
m_outpipes.Remove(pipe.RoutingId);
153153

154154
Debug.Assert(old != null);
@@ -208,7 +208,7 @@ protected override bool XSend(ref Msg msg)
208208
// Find the pipe associated with the routingId stored in the prefix.
209209
var routingId = BitConverter.ToUInt32(msg.UnsafeToArray(), 0);
210210

211-
if (m_outpipes.TryGetValue(routingId, out Outpipe op))
211+
if (m_outpipes.TryGetValue(routingId, out Outpipe? op))
212212
{
213213
m_currentOut = op.Pipe;
214214
if (!m_currentOut.CheckWrite())

src/NetMQ/Core/Patterns/Router.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ protected override void XTerminated(Pipe pipe)
214214
{
215215
Assumes.NotNull(pipe.Identity);
216216

217-
m_outpipes.TryGetValue(pipe.Identity, out Outpipe old);
217+
m_outpipes.TryGetValue(pipe.Identity, out Outpipe? old);
218218
m_outpipes.Remove(pipe.Identity);
219219

220220
Debug.Assert(old != null);
@@ -290,7 +290,7 @@ protected override bool XSend(ref Msg msg)
290290
// mandatory is set.
291291

292292
var identity = msg.UnsafeToArray();
293-
if (m_outpipes.TryGetValue(identity, out Outpipe op))
293+
if (m_outpipes.TryGetValue(identity, out Outpipe? op))
294294
{
295295
m_currentOut = op.Pipe;
296296
if (!m_currentOut.CheckWrite())
@@ -556,7 +556,7 @@ private bool IdentifyPeer(Pipe pipe)
556556
msg.Close();
557557

558558

559-
if (m_outpipes.TryGetValue(identity, out Outpipe existPipe))
559+
if (m_outpipes.TryGetValue(identity, out Outpipe? existPipe))
560560
{
561561
if (!m_handover)
562562
{

src/NetMQ/Core/Patterns/Stream.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ protected override void XTerminated(Pipe pipe)
143143
{
144144
Assumes.NotNull(pipe.Identity);
145145

146-
m_outpipes.TryGetValue(pipe.Identity, out Outpipe old);
146+
m_outpipes.TryGetValue(pipe.Identity, out Outpipe? old);
147147
m_outpipes.Remove(pipe.Identity);
148148

149149
Debug.Assert(old != null);
@@ -206,7 +206,7 @@ protected override bool XSend(ref Msg msg)
206206
// mandatory is set.
207207

208208
var identity = msg.UnsafeToArray();
209-
if (m_outpipes.TryGetValue(identity, out Outpipe op))
209+
if (m_outpipes.TryGetValue(identity, out Outpipe? op))
210210
{
211211
m_currentOut = op.Pipe;
212212
if (!m_currentOut.CheckWrite())

src/NetMQ/Core/SocketBase.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -929,7 +929,7 @@ public void TermEndpoint(string addr)
929929
if (UnregisterEndpoint(addr, this))
930930
return;
931931

932-
if (!m_inprocs.TryGetValue(addr, out Pipe pipe))
932+
if (!m_inprocs.TryGetValue(addr, out Pipe? pipe))
933933
throw new EndpointNotFoundException("Endpoint was not found and cannot be disconnected");
934934

935935
pipe.SendDisconnectMessage();
@@ -938,7 +938,7 @@ public void TermEndpoint(string addr)
938938
}
939939
else
940940
{
941-
if (!m_endpoints.TryGetValue(addr, out Endpoint endpoint))
941+
if (!m_endpoints.TryGetValue(addr, out Endpoint? endpoint))
942942
throw new EndpointNotFoundException("Endpoint was not found and cannot be disconnected");
943943

944944
endpoint.Pipe?.Terminate(false);

src/NetMQ/Core/Transports/Pgm/PgmAddress.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public void Resolve(string name, bool ip4Only)
6565
if (addrStr == "*")
6666
addrStr = "0.0.0.0";
6767

68-
if (!IPAddress.TryParse(addrStr, out IPAddress ipAddress))
68+
if (!IPAddress.TryParse(addrStr, out IPAddress? ipAddress))
6969
throw new InvalidException($"In PgmAddress.Resolve({name},{ip4Only}), addrStr ({addrStr}) must be a valid IPAddress.");
7070

7171
this.Address = new IPEndPoint(ipAddress, port);

src/NetMQ/Core/Transports/Tcp/TcpAddress.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public void Resolve(string name, bool ip4Only)
9191
}
9292
}
9393

94-
IPAddress ipAddress;
94+
IPAddress? ipAddress;
9595

9696
// Interpret * as Any.
9797
if (addrStr == "*")

src/NetMQ/Core/Utils/OpCode.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public static bool Open()
1717
// While this is supported in modern CPUs, the technique used for allocating executable memory, copying OP Code
1818
// for the read of the time stamp and invoking the OP Code can be detected as Malware by some anti-virus vendors.
1919
// https://github.com/zeromq/netmq/issues/1071
20-
string val = Environment.GetEnvironmentVariable("NETQM_SUPPRESS_RDTSC");
20+
string? val = Environment.GetEnvironmentVariable("NETQM_SUPPRESS_RDTSC");
2121
if (!string.IsNullOrEmpty(val))
2222
return false;
2323
#if NETSTANDARD || NET
@@ -83,8 +83,8 @@ private static bool IsARMArchitecture()
8383
{
8484
// force to load from mono gac
8585
Assembly currentAssembly = Assembly.Load("Mono.Posix, Version=2.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756");
86-
Type syscall = currentAssembly.GetType("Mono.Unix.Native.Syscall");
87-
Type utsname = currentAssembly.GetType("Mono.Unix.Native.Utsname");
86+
Type? syscall = currentAssembly.GetType("Mono.Unix.Native.Syscall");
87+
Type? utsname = currentAssembly.GetType("Mono.Unix.Native.Utsname");
8888
if (syscall is null || utsname is null) return false;
8989
MethodInfo? uname = syscall.GetMethod("uname");
9090
object?[] parameters = { null };
@@ -111,9 +111,9 @@ public static void Close()
111111
Assembly.Load("Mono.Posix, Version=2.0.0.0, Culture=neutral, " +
112112
"PublicKeyToken=0738eb9f132ed756");
113113

114-
Type syscall = assembly.GetType("Mono.Unix.Native.Syscall");
115-
MethodInfo munmap = syscall.GetMethod("munmap");
116-
munmap.Invoke(null, new object[] { s_codeBuffer, s_size });
114+
Type? syscall = assembly.GetType("Mono.Unix.Native.Syscall");
115+
MethodInfo? munmap = syscall?.GetMethod("munmap");
116+
munmap?.Invoke(null, new object[] { s_codeBuffer, s_size });
117117
}
118118
else
119119
{

0 commit comments

Comments
 (0)