From d6ffeb10c8682f44e32db2c28923cdb91ff5713a Mon Sep 17 00:00:00 2001 From: Sergey Ivanov <seriv@cs.umd.edu> Date: Thu, 14 Jun 2012 17:30:22 -0400 Subject: [PATCH] check if $bits is defined To avoid warning messages like: "Use of uninitialized value $bits in string eq at /opt/resmon/lib/Resmon/Config.pm line 16..." $bits variable should be checked if it is defined before comparison with empty string --- lib/Resmon/Config.pm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/Resmon/Config.pm b/lib/Resmon/Config.pm index 0731d92..b8fdb9d 100755 --- a/lib/Resmon/Config.pm +++ b/lib/Resmon/Config.pm @@ -13,11 +13,12 @@ sub split_ip_list { my (@result,$quad,$bits,$matchbits,$int,$mask); for (split (/\s*[,\s]\s*/, $string)) { ($quad, $bits) = m!^(\d+\.\d+\.\d+\.\d+)(?:/(\d+))?!g; - $bits = 32 if ($bits eq ''); + $bits = 32 unless (defined($bits) && $bits ne ''); $matchbits = 32 - $bits; $int = unpack("N", pack("C4", split(/\./,$quad))); $mask = $int >> $matchbits; push @result => {mask => $mask, bits => $matchbits, allow => $allow}; +print STDERR "mask=$mask,bits=$matchbits,allow=$allow\n"; } return \@result; } -- GitLab