From f22e9bd58a02e19f27ef6f07c42f12bc383b0c68 Mon Sep 17 00:00:00 2001 From: Eugeni Dodonov Date: Sat, 11 Jul 2009 01:49:19 +0000 Subject: Simplify duplicated IP check and prevent crashing if not found. --- lib/network/connection/ethernet.pm | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'lib/network/connection/ethernet.pm') diff --git a/lib/network/connection/ethernet.pm b/lib/network/connection/ethernet.pm index 1818826..6d4d25b 100644 --- a/lib/network/connection/ethernet.pm +++ b/lib/network/connection/ethernet.pm @@ -185,10 +185,9 @@ sub check_address_settings { return 0; } #- test if IP address is already used - if (my $conflict = find_index { text2bool($_->{ONBOOT}) && $_->{DEVICE} ne $self->get_interface && $_->{IPADDR} eq $self->{address}{ip_address} } values %{$net->{ifcfg}} ) { + if (my $conflict = find { text2bool($_->{ONBOOT}) && $_->{DEVICE} ne $self->get_interface && $_->{IPADDR} eq $self->{address}{ip_address} } values %{$net->{ifcfg}} ) { # find out what connection we are conflicting with - my @conflicting_conn = values %{$net->{ifcfg}}; - my $conflict_device = @conflicting_conn[$conflict]->{DEVICE}; + my $conflict_device = $conflict->{DEVICE}; $self->{address}{error}{message} = N("%s is already used by connection that starts on boot (%s). To use this address with this connection, first disable all other devices which use it, or configure them not to start on boot", $self->{address}{ip_address}, $conflict_device); $self->{address}{error}{field} = \$self->{address}{ip_address}; -- cgit v1.2.1