Skip to content

Commit 1fcb0d6

Browse files
committed
Fix warnings about uninitialized value $device
Remove warnings on autoinst-logs about the uninitialized value of the `$device`. When `$device` is initialized is gets the non-whitespace flag to pass to the grep
1 parent 678060a commit 1fcb0d6

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lib/mm_network.pm

+4-4
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,11 @@ sub configure_static_ip {
5858
my $ip = $args{ip};
5959
my $mtu = $args{mtu} // get_var('MM_MTU', 1380);
6060
my $is_nm = $args{is_nm} // is_networkmanager();
61-
my $device = $args{device};
61+
my $device = $args{device} // '\S';
6262

6363
if ($is_nm) {
6464
my $nm_id;
65-
my $nm_list = script_output("nmcli -t -f DEVICE,NAME c | grep -v ^lo: | grep '$device' | head -n1");
65+
my $nm_list = script_output("nmcli -t -f DEVICE,NAME c | grep -v '^lo:' | grep -e '$device' | head -n1");
6666
($device, $nm_id) = split(':', $nm_list);
6767

6868
record_info('set_ip', "Device: $device\n NM ID: $nm_id\nIP: $ip\nMTU: $mtu");
@@ -105,11 +105,11 @@ sub configure_dhcp {
105105
sub configure_default_gateway {
106106
my (%args) = @_;
107107
my $is_nm = $args{is_nm} // is_networkmanager();
108-
my $device = $args{device};
108+
my $device = $args{device} // '\S';
109109
if ($is_nm) {
110110
my $nm_id;
111111
# When $device is not specified grep just does nothing and first connection is selected
112-
my $nm_list = script_output("nmcli -t -f DEVICE,NAME c | grep -v ^lo: | grep '$device' | head -n1");
112+
my $nm_list = script_output("nmcli -t -f DEVICE,NAME c | grep -v '^lo:' | grep -e '$device' | head -n1");
113113
($device, $nm_id) = split(':', $nm_list);
114114

115115
assert_script_run "nmcli connection modify '$nm_id' ipv4.gateway 10.0.2.2";

0 commit comments

Comments
 (0)