]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
ctdb-scripts: Simplify by taking advantage of early return/exit
authorMartin Schwenke <mschwenke@ddn.com>
Thu, 9 Apr 2026 12:02:24 +0000 (22:02 +1000)
committerMartin Schwenke <martins@samba.org>
Thu, 16 Apr 2026 23:09:33 +0000 (23:09 +0000)
Negate the condition in the if-statement so the current else part goes
first.  It always returns or exits, so the remainder (current if part)
can just follow.

This makes a subsequent change easier to understand.

Probably best reviewed with "git show -w" or similar.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: John Mulligan <jmulligan@redhat.com>
ctdb/config/events/legacy/10.interface.script

index 82110b1e818ea97c817b3c008f403cafa285157f..124b1cbfa52182301088fccb5060ca24cc6ecc50 100755 (executable)
@@ -65,19 +65,7 @@ get_iface_ip_maskbits()
        # Intentional word splitting here
        # shellcheck disable=SC2046
        set -- $(ip_maskbits_iface "$ip")
-       if [ -n "$1" ]; then
-               maskbits="$1"
-               iface="$2"
-
-               if [ "$iface" != "$_iface_in" ]; then
-                       printf 'WARNING: Public IP %s hosted on interface %s but VNN says %s\n' \
-                               "$ip" "$iface" "$_iface_in"
-               fi
-               if [ "$maskbits" != "$_maskbits_in" ]; then
-                       printf 'WARNING: Public IP %s has %s bit netmask but VNN says %s\n' \
-                               "$ip" "$maskbits" "$_maskbits_in"
-               fi
-       else
+       if [ -z "$1" ]; then
                if [ "$_iface_in" = "__none__" ]; then
                        echo "WARNING: Unable to determine interface for IP ${ip}"
                        iface="$_iface_in"
@@ -85,6 +73,18 @@ get_iface_ip_maskbits()
                fi
                die "ERROR: Unable to determine interface for IP ${ip}"
        fi
+
+       maskbits="$1"
+       iface="$2"
+
+       if [ "$iface" != "$_iface_in" ]; then
+               printf 'WARNING: Public IP %s hosted on interface %s but VNN says %s\n' \
+                       "$ip" "$iface" "$_iface_in"
+       fi
+       if [ "$maskbits" != "$_maskbits_in" ]; then
+               printf 'WARNING: Public IP %s has %s bit netmask but VNN says %s\n' \
+                       "$ip" "$maskbits" "$_maskbits_in"
+       fi
 }
 
 ip_block()