Fix the misuse of == to compare strings in perl

This commit is contained in:
Casandra Qiu 2015-02-05 12:02:25 -05:00
parent 3369dfb94f
commit ef1556e494
11 changed files with 42 additions and 42 deletions

View File

@ -407,7 +407,7 @@ sub lshwconn_parse_args
}
if (scalar(@error_type_nodes)) {
my $tmp_nodelist = join ',', @error_type_nodes;
my $link = (scalar(@error_type_nodes) == '1')? 'is':'are';
my $link = (scalar(@error_type_nodes) eq '1')? 'is':'are';
return( ["Node type of node(s) $tmp_nodelist $link not supported for this command in FSPAPI.\n"]);
}
#$nodetypetab->close();

View File

@ -141,13 +141,13 @@ sub chvm_parse_extra_options {
} elsif ($cmd eq "vmmemory") {
if ($value =~ /^([\d|.]+)([G|M]?)\/([\d|.]+)([G|M]?)\/([\d|.]+)([G|M]?)$/i) {
my ($mmin, $mcur, $mmax);
if ($2 == "G" or $2 == '') {
if ($2 eq "G" or $2 eq '') {
$mmin = $1 * 1024;
}
if ($4 == "G" or $4 == '') {
if ($4 eq "G" or $4 eq '') {
$mcur = $3 * 1024;
}
if ($6 == "G" or $6 == '') {
if ($6 eq "G" or $6 eq '') {
$mmax = $5 * 1024;
}
unless ($mmin <= $mcur and $mcur <= $mmax) {
@ -872,17 +872,17 @@ sub do_op_extra_cmds {
if ($param =~ /(\d+)([G|M]?)\/(\d+)([G|M]?)\/(\d+)([G|M]?)/i) {
my $memsize = $memhash->{mem_region_size};
my $min = $1;
if ($2 == "G" or $2 == '') {
if ($2 eq "G" or $2 eq '') {
$min = $min * 1024;
}
$min = int($min/$memsize);
my $cur = $3;
if ($4 == "G" or $4 == '') {
if ($4 eq "G" or $4 eq '') {
$cur = $cur * 1024;
}
$cur = int($cur/$memsize);
my $max = $5;
if ($6 == "G" or $6 == '') {
if ($6 eq "G" or $6 eq '') {
$max = $max * 1024;
}
$max = int($max/$memsize);
@ -1183,7 +1183,7 @@ sub get_cec_lpar_name {
my @value = split(/\n/, $lpar_info);
foreach my $v (@value) {
if($v =~ /lparname:\s*([^\,]*),\s*lparid:\s*([\d]+),/) {
if($2 == $lparid) {
if($2 eq $lparid) {
return $1;
}
}
@ -2347,13 +2347,13 @@ sub mkspeclpar {
next;
}
my ($mmin, $mcur, $mmax);
if ($2 == "G" or $2 == '') {
if ($2 eq "G" or $2 eq '') {
$mmin = $1 * 1024;
}
if ($4 == "G" or $4 == '') {
if ($4 eq "G" or $4 eq '') {
$mcur = $3 * 1024;
}
if ($6 == "G" or $6 == '') {
if ($6 eq "G" or $6 eq '') {
$mmax = $5 * 1024;
}
unless ($mmin <= $mcur and $mcur <= $mmax) {

View File

@ -339,7 +339,7 @@ sub lshwconn_parse_args
}
if (scalar(@error_type_nodes)) {
my $tmp_nodelist = join ',', @error_type_nodes;
my $link = (scalar(@error_type_nodes) == '1')? 'is':'are';
my $link = (scalar(@error_type_nodes) eq '1')? 'is':'are';
return( ["Node type of node(s) $tmp_nodelist $link not supported for this command.\n"]);
}
$request->{nodetype} = $nodetype;

View File

@ -3,9 +3,9 @@
$RES::Condition{'CheckFTPonSN_AIX'} = {
Name => q(CheckFTPonSN_AIX),
ResourceClass => q(IBM.Sensor),
EventExpression => q(String != "ftpd is active"),
EventExpression => q(String ne "ftpd is active"),
EventDescription => q(For AIX only. An event will be generated when the FTP server is down on the service node. There may be other nodes in this management domain such as HMCs. To exclude them, just change the SelectionString to: "ProgramName=='vsftpd' && NodeNameList >< {'hmc1','hmc2}" where hmc1 and hmc2 are the names for the nodes that you want to exclude.),
RearmExpression => q(String == "ftpd is active"),
RearmExpression => q(String eq "ftpd is active"),
RearmDescription => q(A rearm event will be generated when the FTP server is up on the service node.),
SelectionString => q(Name="CheckFTPSensor_AIX"),
ManagementScope => q(4),

View File

@ -3,9 +3,9 @@
$RES::Condition{'CheckxCATonSN'} = {
Name => q(CheckxCATonSN),
ResourceClass => q(IBM.Sensor),
EventExpression => q(String != "xcatd is ok"),
EventExpression => q(String ne "xcatd is ok"),
EventDescription => q(An event will be generated when xcatd is not working.),
RearmExpression => q(String == "xcatd is ok"),
RearmExpression => q(String eq "xcatd is ok"),
RearmDescription => q(An rearm event will be generated when xcatd resumes working state.),
SelectionString => q(Name="CheckxCATSensor"),
ManagementScope => q(4),

View File

@ -610,7 +610,7 @@ sub set_route {
# ipv6 network
if ($net =~ /:/) {
if (xCAT::Utils->isLinux()) {
if ( $gw_ip == "" || $gw_ip == "::" ) {
if ( $gw_ip eq "" || $gw_ip eq "::" ) {
$cmd="ip -6 route add $net/$mask dev $ifname";
} else {
$cmd="ip -6 route add $net/$mask via $gw_ip";
@ -620,7 +620,7 @@ sub set_route {
}
} else {
if (xCAT::Utils->isLinux()) {
if ( $gw_ip == "" || $gw_ip == "0.0.0.0" ) {
if ( $gw_ip eq "" || $gw_ip eq "0.0.0.0" ) {
$cmd="route add -net $net netmask $mask dev $ifname";
} else {
$cmd="route add -net $net netmask $mask gw $gw_ip";
@ -691,7 +691,7 @@ sub delete_route {
my $cmd;
if ($net =~ /:/) {
if (xCAT::Utils->isLinux()) {
if ( $gw_ip == "" || $gw_ip == "::" ) {
if ( $gw_ip eq "" || $gw_ip eq "::" ) {
$cmd = "ip -6 route delete $net/$mask dev $ifname";
} else {
$cmd = "ip -6 route delete $net/$mask via $gw_ip";
@ -701,7 +701,7 @@ sub delete_route {
}
} else {
if (xCAT::Utils->isLinux()) {
if ( $gw_ip == "" || $gw_ip == "0.0.0.0" ) {
if ( $gw_ip eq "" || $gw_ip eq "0.0.0.0" ) {
$cmd="route delete -net $net netmask $mask dev $ifname";
} else {
$cmd="route delete -net $net netmask $mask gw $gw_ip";
@ -850,13 +850,13 @@ sub addPersistentRoute_Sles {
#print "hasConfiged=$hasConfiged\n";
my $new_config;
if ($net =~ /:/) {
if ( $gw_ip == "" || $gw_ip == "::" ) {
if ( $gw_ip eq "" || $gw_ip eq "::" ) {
$new_config = "$net/$mask :: - $ifname\n";
} else {
$new_config = "$net/$mask $gw_ip - -\n";
}
} else {
if ( $gw_ip == "" || $gw_ip == "0.0.0.0" ) {
if ( $gw_ip eq "" || $gw_ip eq "0.0.0.0" ) {
$new_config="$net 0.0.0.0 $mask $ifname\n";
} else {
$new_config="$net $gw_ip $mask $ifname\n";
@ -1026,7 +1026,7 @@ sub addPersistentRoute_RH {
$new_config="$ifname $net/$mask $gw_ip";
} else {
if ( $gw_ip == "" || $gw_ip == "0.0.0.0" ) {
if ( $gw_ip eq "" || $gw_ip eq "0.0.0.0" ) {
$new_config="any net $net netmask $mask dev $ifname\n";
} else {
$new_config="any net $net netmask $mask gw $gw_ip\n";
@ -1170,7 +1170,7 @@ sub addPersistentRoute_Debian{
#ipv6
if ( $net =~ /:/){
if ( $gw_ip == "" || $gw_ip == "::" ) {
if ( $gw_ip eq "" || $gw_ip eq "::" ) {
$cmd = "grep \"$net/$mask dev $ifname\" $conf_file";
$route_conf = " up route -A inet6 add $net/$mask dev $ifname \n down route -A inet6 del $net/$mask dev $ifname \n";
} else {
@ -1180,7 +1180,7 @@ sub addPersistentRoute_Debian{
}
else { #ipv4
$cmd = "grep \"-net $net netmask $mask gw $gw_ip\" $conf_file";
if ( $gw_ip == "" || $gw_ip == "0.0.0.0" ) {
if ( $gw_ip eq "" || $gw_ip eq "0.0.0.0" ) {
$route_conf = " up route add -net $net netmask $mask dev $ifname \n down route del -net $net netmask $mask dev $ifname \n";
} else {
$route_conf = " up route add -net $net netmask $mask gw $gw_ip \n down route del -net $net netmask $mask gw $gw_ip\n";
@ -1242,14 +1242,14 @@ sub deletePersistentRoute_Debian{
preParse_Debian();
#ipv6
if ( $net =~ /:/){
if ( $gw_ip == "" || $gw_ip == "::" ) {
if ( $gw_ip eq "" || $gw_ip eq "::" ) {
$match = "$net/$mask dev $ifname";
} else {
$match = "$net/$mask gw $gw_ip";
}
}
else {
if ( $gw_ip == "" || $gw_ip == "0.0.0.0" ) {
if ( $gw_ip eq "" || $gw_ip eq "0.0.0.0" ) {
$match = "net $net netmask $mask dev $ifname";
} else {
$match = "net $net netmask $mask gw $gw_ip";

View File

@ -786,7 +786,7 @@ sub liteItem {
# the /etc/mtab should be handled every time even the parent /etc/ has been handled.
# if adding /etc/ to litefile, only tmpfs should be used.
if ($entry[1] == "/etc/mtab") {
if ($entry[1] eq "/etc/mtab") {
$isChild = 0;
}

View File

@ -139,10 +139,10 @@ until ($quit) {
my $winboot = $winpepath."Boot/pxeboot.0";
if ($archp) {
my $clienttype = substr($data, $archp, 5);
if ($clienttype == "00000") {
if ($clienttype eq "00000") {
#if ("$package[$archp]$package[$archp+1]$package[$archp+2]$package[$archp+3]$package[$archp+4]" == "00000") {
$winboot = $winpepath."Boot/pxeboot.0";
} elsif ($clienttype == "00007") {
} elsif ($clienttype eq "00007") {
$winboot = $winpepath."Boot/bootmgfw.efi";
}
}
@ -322,7 +322,7 @@ sub my_ip_facing
(my $curnet, my $maskbits) = split /\//, $elems[2];
my $curmask = 2**$maskbits - 1 << (32 - $maskbits);
my $curn = unpack("N", inet_aton($curnet));
if (($noden & $curmask) == ($curn & $curmask))
if (($noden & $curmask) eq ($curn & $curmask))
{
return inet_aton($curnet);
}

View File

@ -200,7 +200,7 @@ END
}
# Add dasd to template
if ($dasd_option == '1') {
if ($dasd_option eq '1') {
# Get virtual address
$addr = ask(" What is the virtual address? ");
while (length($addr) < 4) { # Address length must be 4
@ -228,7 +228,7 @@ END
}
# Remove dasd from template
elsif ($dasd_option == '2') {
elsif ($dasd_option eq '2') {
$addr = ask(" What is the virtual address to remove? ");
while (length($addr) < 4) { # Address length must be 4
$addr = '0' . $addr;
@ -239,7 +239,7 @@ END
delete $dasd{$addr};
}
elsif ($dasd_option == '3') {
elsif ($dasd_option eq '3') {
# Show configuration
print <<END;
# | Address | Type
@ -252,7 +252,7 @@ END
}
}
elsif ($dasd_option == '4') {
elsif ($dasd_option eq '4') {
# Do nothing, go to next step
} else {
print " Unknown value!\n"
@ -433,7 +433,7 @@ END
$lvm_option = <>;
# Add an LVM volume to template
if ($lvm_option == '1') {
if ($lvm_option eq '1') {
# Get dasd virtual address
$lvm_vol_name = ask(" What is the LVM volume name? ");
@ -463,14 +463,14 @@ END
}
# Remove an LVM volume from template
elsif ($lvm_option == '2') {
elsif ($lvm_option eq '2') {
my $name = ask(" What is the LVM volume to remove? ");
# Remove from hash
delete $partitions{$device_name}{'lvm'}{$name};
}
elsif ($lvm_option == '3') {
elsif ($lvm_option eq '3') {
# Show configuration
print <<END;
Group | Volume | Mount | Size
@ -484,7 +484,7 @@ END
}
}
elsif ($lvm_option == '4') {
elsif ($lvm_option eq '4') {
# Do nothing, go to next step
} else {
print " Unknown value!\n"
@ -2736,4 +2736,4 @@ AUTOYASTEND
</profile>
AUTOYASTEND
return $tmpl;
}
}

View File

@ -163,7 +163,7 @@ while (<FILE>) {
if ($::VERBOSE) {
print "The server I found: mac = $chaddr, clientip = $ciaddr, serverip = $siaddr, offer = $offer.\n";
}
if ($os == "sles") { $offer = 1;}
if ($os eq "sles") { $offer = 1;}
if ($chaddr =~ /$MAC/i && $offer && $ciaddr && $siaddr && $rsiaddr) {
$output{$rsiaddr}{'client'} = $ciaddr;
$output{$rsiaddr}{'nextsv'} = $siaddr;

View File

@ -596,7 +596,7 @@ sub find_key
my $tmp = $$en; # keey head
$$en .= "$val:";
my $t1 = find_key($$input{$val}, $en, $ou);
if ($$en == ""){
if ($$en eq ""){
$$en = $tmp; #restore head
}
}