Skip to content
Snippets Groups Projects
Commit d6ffeb10 authored by Sergey Joseph Ivanov's avatar Sergey Joseph Ivanov
Browse files

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
parent cd3c2b0f
No related branches found
No related tags found
No related merge requests found
......@@ -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;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment