[pve-devel] [PATCH common] cleanup: regex match group reference

Wolfgang Bumiller w.bumiller at proxmox.com
Wed Mar 9 13:23:23 CET 2016


Don't refer to the regex match group via $1 after running
other code.
---
 src/PVE/Network.pm | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/PVE/Network.pm b/src/PVE/Network.pm
index ac2c168..56af2ed 100644
--- a/src/PVE/Network.pm
+++ b/src/PVE/Network.pm
@@ -539,13 +539,13 @@ sub get_active_interfaces {
     while(defined(my $line = <$fh>)) {
 	next if $line !~ /^\s*([^:\s]+):/;
 	my $ifname = $1;
-	my $ifreq = pack($STRUCT_IFREQ_SIOCGIFFLAGS, $1, 0);
+	my $ifreq = pack($STRUCT_IFREQ_SIOCGIFFLAGS, $ifname, 0);
 	if (!defined(ioctl($sock, SIOCGIFFLAGS, $ifreq))) {
 	    warn "failed to get interface flags for: $ifname\n";
 	    next;
 	}
 	my ($name, $flags) = unpack($STRUCT_IFREQ_SIOCGIFFLAGS, $ifreq);
-	push @$ifaces, $1 if ($flags & IFF_UP);
+	push @$ifaces, $ifname if ($flags & IFF_UP);
     }
     close $fh;
     close $sock;
-- 
2.1.4





More information about the pve-devel mailing list