From cf54da50e400231b3baa83d1ade7dbb4e829acf9 Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Wed, 28 Aug 2024 02:26:17 -0400 Subject: [PATCH] read_recap: Invert condition (for readability) --- ddclient.in | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/ddclient.in b/ddclient.in index 51c88c8..9d9d11a 100755 --- a/ddclient.in +++ b/ddclient.in @@ -1599,23 +1599,22 @@ sub read_recap { my $config = shift; my $globals = {}; %{$config} = (); - if (-e $file) { - my %saved = %opt; - %opt = (); - $saved_recap = _read_config($config, $globals, "##\\s*$program-$version\\s*", $file); - %opt = %saved; - for my $h (keys(%recap)) { - next if !exists($config->{$h}); - # TODO: Why is this limited to this set of variables? Why not copy every recap var - # defined for the host's protocol? - for (qw(atime mtime wtime ip ipv4 ipv6 status-ipv4 status-ipv6)) { - # TODO: Isn't $config equal to \%recap here? If so, this is a no-op. What was the - # original intention behind this? To copy %recap values into %config? If so, is - # it better to just delete this and live with the current behavior (which doesn't - # seem to be causing users any problems) or to "fix" it to match the original - # intention, which might introduce a bug? - $config->{$h}{$_} = $recap{$h}{$_} if exists $recap{$h}{$_}; - } + return if !(-e $file); + my %saved = %opt; + %opt = (); + $saved_recap = _read_config($config, $globals, "##\\s*$program-$version\\s*", $file); + %opt = %saved; + for my $h (keys(%recap)) { + next if !exists($config->{$h}); + # TODO: Why is this limited to this set of variables? Why not copy every recap var defined + # for the host's protocol? + for (qw(atime mtime wtime ip ipv4 ipv6 status-ipv4 status-ipv6)) { + # TODO: Isn't $config equal to \%recap here? If so, this is a no-op. What was the + # original intention behind this? To copy %recap values into %config? If so, is it + # better to just delete this and live with the current behavior (which doesn't seem to + # be causing users any problems) or to "fix" it to match the original intention, which + # might introduce a bug? + $config->{$h}{$_} = $recap{$h}{$_} if exists $recap{$h}{$_}; } } }