Skip to content

Commit 32f1fca

Browse files
committed
Fix: warnings
1 parent 692a7d0 commit 32f1fca

File tree

4 files changed

+39
-38
lines changed

4 files changed

+39
-38
lines changed

src/System.Net.IPNetwork/CidrClassFull.cs

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -29,40 +29,40 @@ public sealed class CidrClassFull : ICidrGuess
2929
/// <returns>true if ip was converted successfully; otherwise, false.</returns>
3030
public bool TryGuessCidr(string ip, out byte cidr)
3131
{
32-
bool parsed = IPAddress.TryParse($"{ip}", out var ipaddress);
33-
if (parsed == false)
34-
{
35-
cidr = 0;
36-
return false;
37-
}
38-
39-
if (ipaddress.AddressFamily == AddressFamily.InterNetworkV6)
40-
{
41-
cidr = 64;
42-
return true;
43-
}
32+
bool parsed = IPAddress.TryParse($"{ip}", out var ipaddress);
33+
if (parsed == false)
34+
{
35+
cidr = 0;
36+
return false;
37+
}
4438

45-
var uintIPAddress = IPNetwork2.ToBigInteger(ipaddress);
46-
uintIPAddress = uintIPAddress >> 30;
47-
if (uintIPAddress <= 1)
48-
{
49-
cidr = 8;
50-
return true;
51-
}
39+
if (ipaddress.AddressFamily == AddressFamily.InterNetworkV6)
40+
{
41+
cidr = 64;
42+
return true;
43+
}
5244

53-
if (uintIPAddress <= 2)
54-
{
55-
cidr = 16;
56-
return true;
57-
}
45+
var uintIPAddress = IPNetwork2.ToBigInteger(ipaddress);
46+
uintIPAddress = uintIPAddress >> 30;
47+
if (uintIPAddress <= 1)
48+
{
49+
cidr = 8;
50+
return true;
51+
}
5852

59-
if (uintIPAddress <= 3)
60-
{
61-
cidr = 24;
62-
return true;
63-
}
53+
if (uintIPAddress <= 2)
54+
{
55+
cidr = 16;
56+
return true;
57+
}
6458

65-
cidr = 0;
66-
return false;
59+
if (uintIPAddress <= 3)
60+
{
61+
cidr = 24;
62+
return true;
6763
}
64+
65+
cidr = 0;
66+
return false;
67+
}
6868
}

src/System.Net.IPNetwork/CidrClassLess.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace System.Net;
77
using System.Net.Sockets;
88

99
/// <summary>
10-
/// Try to guess a CIDR in a ClassLess way ie. ipv4 = 32, ipv6 = 128.
10+
/// Try to guess a CIDR in a ClassLess way: ipv4 = 32, ipv6 = 128.
1111
/// </summary>
1212
public sealed class CidrClassLess : ICidrGuess
1313
{
@@ -17,7 +17,7 @@ public sealed class CidrClassLess : ICidrGuess
1717
/// IPV6 : 128.
1818
///
1919
/// </summary>
20-
/// <param name="ip">A string representing an ipadress that will be used to guess CIDR.</param>
20+
/// <param name="ip">A string representing an IPAddress that will be used to guess CIDR.</param>
2121
/// <param name="cidr">A byte representing the netmask in cidr format (/24).</param>
2222
/// <returns>true if ip was converted successfully; otherwise, false.</returns>
2323
public bool TryGuessCidr(string ip, out byte cidr)

src/System.Net.IPNetwork/IPNetwork2WideSubnet.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ public static IPNetwork2 WideSubnet(string start, string end)
4848
throw new NotSupportedException("MixedAddressFamily");
4949
}
5050

51-
var ipnetwork = new IPNetwork2(0, startIP.AddressFamily, 0);
51+
IPNetwork2 ipnetwork;
5252

5353
// ReSharper disable once ConditionIsAlwaysTrueOrFalse
54-
for (byte cidr = 32; cidr >= 0; cidr--)
54+
for (byte cidr = 32; ; cidr--)
5555
{
5656
var wideSubnet = Parse(start, cidr);
5757
if (wideSubnet.Contains(endIP))
@@ -148,10 +148,9 @@ internal static void InternalWideSubnet(bool tryWide, IPNetwork2[] ipnetworks, o
148148
}
149149
}
150150

151-
var ipn = new IPNetwork2(0, family, 0);
151+
IPNetwork2 ipn;
152152

153-
// ReSharper disable once ConditionIsAlwaysTrueOrFalse
154-
for (byte cidr = nnin0.cidr; cidr >= 0; cidr--)
153+
for (byte cidr = nnin0.cidr; ; cidr--)
155154
{
156155
var wideSubnet = new IPNetwork2(uintNnin0, family, cidr);
157156
if (wideSubnet.Contains(ipaddressX))

src/ipnetwork.sln.DotSettings

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,7 @@
55
<s:Boolean x:Key="/Default/UserDictionary/Words/=bmask/@EntryIndexedValue">True</s:Boolean>
66
<s:Boolean x:Key="/Default/UserDictionary/Words/=ipnet/@EntryIndexedValue">True</s:Boolean>
77
<s:Boolean x:Key="/Default/UserDictionary/Words/=ipnetworks/@EntryIndexedValue">True</s:Boolean>
8+
<s:Boolean x:Key="/Default/UserDictionary/Words/=ipnx/@EntryIndexedValue">True</s:Boolean>
9+
<s:Boolean x:Key="/Default/UserDictionary/Words/=nnin/@EntryIndexedValue">True</s:Boolean>
810
<s:Boolean x:Key="/Default/UserDictionary/Words/=widesubnet/@EntryIndexedValue">True</s:Boolean>
911
<s:Boolean x:Key="/Default/UserDictionary/Words/=wildcardmask/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>

0 commit comments

Comments
 (0)