[3/3] network-functions.pl : Use integer comparison rather than string

Message ID 20191224125652.12232-4-ipfr@tfitzgeorge.me.uk
State Dropped
Headers
Series network-functions.pl : Correct comparisons and enhance testsuite |

Commit Message

Tim FitzGeorge Dec. 24, 2019, 12:56 p.m. UTC
  Compare binary representation of networks using integer rather than string
comparison operators.

Signed-off-by: Tim FitzGeorge <ipfr@tfitzgeorge.me.uk>
---
 config/cfgroot/network-functions.pl | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
  

Patch

diff --git a/config/cfgroot/network-functions.pl b/config/cfgroot/network-functions.pl
index a3f574760..7f8bc7c52 100644
--- a/config/cfgroot/network-functions.pl
+++ b/config/cfgroot/network-functions.pl
@@ -115,7 +115,7 @@  sub network_equal {
 		return undef;
 	}
 
-	if ($bin1[0] eq $bin2[0] && $bin1[1] eq $bin2[1]) {
+	if ($bin1[0] == $bin2[0] && $bin1[1] == $bin2[1]) {
 		return 1;
 	}
 
@@ -295,7 +295,7 @@  sub ip_address_in_network($$) {
 	# Find end address
 	my $broadcast_bin = $network_bin ^ (~$netmask_bin % 2 ** 32);
 
-	return (($address_bin ge $network_bin) && ($address_bin le $broadcast_bin));
+	return (($address_bin >= $network_bin) && ($address_bin <= $broadcast_bin));
 }
 
 sub setup_upstream_proxy() {