From ef1556e49490917d0bfe046b9bcac5d4e2f47fc9 Mon Sep 17 00:00:00 2001 From: Casandra Qiu Date: Thu, 5 Feb 2015 12:02:25 -0500 Subject: [PATCH] Fix the misuse of == to compare strings in perl --- perl-xCAT/xCAT/FSPconn.pm | 2 +- perl-xCAT/xCAT/FSPvm.pm | 20 ++++++++--------- perl-xCAT/xCAT/PPCconn.pm | 2 +- .../mn/IBM.Condition/CheckFTPonSN_AIX.pm | 4 ++-- .../mn/IBM.Condition/CheckxCATonSN.pm | 4 ++-- xCAT-server/lib/xcat/plugins/route.pm | 22 +++++++++---------- xCAT-server/lib/xcat/plugins/statelite.pm | 2 +- xCAT-server/sbin/proxydhcp-xcat | 6 ++--- xCAT-server/share/xcat/scripts/mkay4z | 18 +++++++-------- xCAT-server/share/xcat/tools/detect_dhcpd | 2 +- xCAT-test/restapitest | 2 +- 11 files changed, 42 insertions(+), 42 deletions(-) diff --git a/perl-xCAT/xCAT/FSPconn.pm b/perl-xCAT/xCAT/FSPconn.pm index c7eef4b13..a62a5a83f 100644 --- a/perl-xCAT/xCAT/FSPconn.pm +++ b/perl-xCAT/xCAT/FSPconn.pm @@ -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(); diff --git a/perl-xCAT/xCAT/FSPvm.pm b/perl-xCAT/xCAT/FSPvm.pm index ac311b8d6..28eaea952 100644 --- a/perl-xCAT/xCAT/FSPvm.pm +++ b/perl-xCAT/xCAT/FSPvm.pm @@ -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) { diff --git a/perl-xCAT/xCAT/PPCconn.pm b/perl-xCAT/xCAT/PPCconn.pm index f34d9b137..b5836beae 100644 --- a/perl-xCAT/xCAT/PPCconn.pm +++ b/perl-xCAT/xCAT/PPCconn.pm @@ -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; diff --git a/xCAT-rmc/resources/mn/IBM.Condition/CheckFTPonSN_AIX.pm b/xCAT-rmc/resources/mn/IBM.Condition/CheckFTPonSN_AIX.pm index bf0c8ba77..161e8e07e 100644 --- a/xCAT-rmc/resources/mn/IBM.Condition/CheckFTPonSN_AIX.pm +++ b/xCAT-rmc/resources/mn/IBM.Condition/CheckFTPonSN_AIX.pm @@ -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), diff --git a/xCAT-rmc/resources/mn/IBM.Condition/CheckxCATonSN.pm b/xCAT-rmc/resources/mn/IBM.Condition/CheckxCATonSN.pm index a72dc0611..dd0c9ec7e 100644 --- a/xCAT-rmc/resources/mn/IBM.Condition/CheckxCATonSN.pm +++ b/xCAT-rmc/resources/mn/IBM.Condition/CheckxCATonSN.pm @@ -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), diff --git a/xCAT-server/lib/xcat/plugins/route.pm b/xCAT-server/lib/xcat/plugins/route.pm index 1da3055f8..583a46c01 100644 --- a/xCAT-server/lib/xcat/plugins/route.pm +++ b/xCAT-server/lib/xcat/plugins/route.pm @@ -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"; diff --git a/xCAT-server/lib/xcat/plugins/statelite.pm b/xCAT-server/lib/xcat/plugins/statelite.pm index 41ee78520..bac31cac3 100644 --- a/xCAT-server/lib/xcat/plugins/statelite.pm +++ b/xCAT-server/lib/xcat/plugins/statelite.pm @@ -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; } diff --git a/xCAT-server/sbin/proxydhcp-xcat b/xCAT-server/sbin/proxydhcp-xcat index 89efeab0e..e64331be4 100755 --- a/xCAT-server/sbin/proxydhcp-xcat +++ b/xCAT-server/sbin/proxydhcp-xcat @@ -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); } diff --git a/xCAT-server/share/xcat/scripts/mkay4z b/xCAT-server/share/xcat/scripts/mkay4z index 7e5961b1a..be9d342c4 100644 --- a/xCAT-server/share/xcat/scripts/mkay4z +++ b/xCAT-server/share/xcat/scripts/mkay4z @@ -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 <; # 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 < AUTOYASTEND return $tmpl; -} \ No newline at end of file +} diff --git a/xCAT-server/share/xcat/tools/detect_dhcpd b/xCAT-server/share/xcat/tools/detect_dhcpd index 5afad8ad9..f0ba37801 100755 --- a/xCAT-server/share/xcat/tools/detect_dhcpd +++ b/xCAT-server/share/xcat/tools/detect_dhcpd @@ -163,7 +163,7 @@ while () { 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; diff --git a/xCAT-test/restapitest b/xCAT-test/restapitest index 47eed21f3..1621a116b 100755 --- a/xCAT-test/restapitest +++ b/xCAT-test/restapitest @@ -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 } }