]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
ctdb-scripts: Avoid shellcheck warning SC2034 (unused variables)
authorMartin Schwenke <martin@meltin.net>
Wed, 6 Jul 2016 07:16:44 +0000 (17:16 +1000)
committerAmitay Isaacs <amitay@samba.org>
Thu, 21 Jul 2016 00:24:26 +0000 (02:24 +0200)
SC2034: VAR appears unused. Verify it or export it.

Drop some variables that are unnecessarily used.  Use shellcheck
directive for false-positives.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
14 files changed:
ctdb/config/debug_locks.sh
ctdb/config/events.d/06.nfs
ctdb/config/events.d/11.natgw
ctdb/config/events.d/13.per_ip_routing
ctdb/config/events.d/20.multipathd
ctdb/config/events.d/31.clamd
ctdb/config/events.d/41.httpd
ctdb/config/events.d/49.winbind
ctdb/config/events.d/50.samba
ctdb/config/events.d/60.nfs
ctdb/config/events.d/70.iscsi
ctdb/config/functions
ctdb/config/statd-callout
ctdb/tools/onnode

index 62b679923409a8b6910d51f4180def53768177a1..dee719adcc256cfc801c7f367859b8bd85c93ff9 100755 (executable)
@@ -56,6 +56,8 @@ loadconfig ctdb
        # For each process waiting, log stack trace
        for pid in $pids ; do
            echo "----- Stack trace for PID=$pid -----"
+           # x is intentionally ignored
+           # shellcheck disable=SC2034
            read x x state x <"/proc/${pid}/stat"
            if [ "$state" = "D" ] ; then
                # Don't run gstack on a process in D state since
index d0611a59ea7f8a9df809da1c751a40ba057d4bc3..623911aefa7f4142152ae9b80aca904f044c3fc7 100755 (executable)
@@ -6,7 +6,10 @@
 
 . "${CTDB_BASE}/functions"
 
+# service_name is used by various functions
+# shellcheck disable=SC2034
 service_name="nfs"
+
 loadconfig
 ctdb_setup_service_state_dir
 
index 2cfe75b6acfe3232fb7b0cb7a9ebefda08e8deea..bf99ad5a05f0bfff97f8624bde642834027378af 100755 (executable)
@@ -10,6 +10,8 @@
 
 . "${CTDB_BASE}/functions"
 
+# service_name is used by various functions
+# shellcheck disable=SC2034
 service_name=natgw
 
 loadconfig
index 7dbf15818ab3caa6d3e83de1233a27f2e4b55c24..b14c95e5b992827776ff57a51b3ae8f43b44e2f1 100755 (executable)
@@ -7,6 +7,8 @@
 
 loadconfig
 
+# service_name is used by various functions
+# shellcheck disable=SC2034
 service_name=per_ip_routing
 
 # Do nothing if unconfigured 
@@ -322,6 +324,8 @@ remove_bogus_routes ()
     # Get a IPs current hosted by this node, each anchored with '@'.
     _ips=$($CTDB ip -v -X | awk -F'|' 'NR > 1 && $4 != "" {printf "@%s@\n", $2}')
 
+    # x is intentionally ignored
+    # shellcheck disable=SC2034
     ip rule show |
     while read _p _x _i _x _t ; do
        # Remove trailing colon after priority/preference.
@@ -375,6 +379,8 @@ shutdown)
 takeip)
        iface=$2
        ip=$3
+       # maskbits included here so argument order is obvious
+       # shellcheck disable=SC2034
        maskbits=$4
 
        ensure_ipv4_is_valid_addr "$1" "$ip"
@@ -387,9 +393,12 @@ takeip)
        ;;
 
 updateip)
+       # oiface, maskbits included here so argument order is obvious
+       # shellcheck disable=SC2034
        oiface=$2
        niface=$3
        ip=$4
+       # shellcheck disable=SC2034
        maskbits=$5
 
        ensure_ipv4_is_valid_addr "$1" "$ip"
@@ -405,6 +414,8 @@ updateip)
 releaseip)
        iface=$2
        ip=$3
+       # maskbits included here so argument order is obvious
+       # shellcheck disable=SC2034
        maskbits=$4
 
        ensure_ipv4_is_valid_addr "$1" "$ip"
index 0fe140f839daf547a2cdcd5e32fa5db3cb130373..2c153946f1d53902dbb3246cebe1140e22179a2e 100755 (executable)
@@ -11,6 +11,8 @@
 
 . "${CTDB_BASE}/functions"
 
+# service_name is used by various functions
+# shellcheck disable=SC2034
 service_name="multipathd"
 
 loadconfig
index c2ee8de5369ed6af5e25d6d91807ba7df7be91cd..c7b542e214823d14a798d4297c6fc438cdf1b3ff 100755 (executable)
@@ -11,10 +11,14 @@ detect_init_style
 case $CTDB_INIT_STYLE in
 redhat)
        service_name="clamd"
+       # service_config is used by loadconfig()
+       # shellcheck disable=SC2034
        service_config="clamd"
        ;;
 *)
        service_name="clamav"
+       # service_config is used by loadconfig()
+       # shellcheck disable=SC2034
        service_config="clamav"
        ;;
 esac
index 4a55231c48a050b7d4c243a4fe4f7968fb4bc77b..9e0f6f65857510d048b6dd88e12434f727f4fd34 100755 (executable)
@@ -11,10 +11,14 @@ detect_init_style
 case $CTDB_INIT_STYLE in
 redhat)
        service_name="httpd"
+       # service_config is used by loadconfig()
+       # shellcheck disable=SC2034
        service_config="http"
        ;;
 suse|debian|*)
        service_name="apache2"
+       # service_config is used by loadconfig()
+       # shellcheck disable=SC2034
        service_config="apache2"
        ;;
 esac
index 495ac5791e3e3ec465fe41ed268be400fe40350d..8fcccfca724d7bdebc1bb2454ae74cb9724ab202 100755 (executable)
@@ -8,6 +8,8 @@
 
 CTDB_SERVICE_WINBIND=${CTDB_SERVICE_WINBIND:-winbind}
 
+# service_name is used by various functions
+# shellcheck disable=SC2034
 service_name="winbind"
 
 loadconfig
index 82b9b96029dc3d10afc7d4cfbd22f0f72c73e98c..b2a5fa460139dc4002bd0f1688cf604a3415cea2 100755 (executable)
@@ -24,6 +24,8 @@ case $CTDB_INIT_STYLE in
                ;;
 esac
 
+# service_name is used by various functions
+# shellcheck disable=SC2034
 service_name="samba"
 
 loadconfig
index 15def341873af3a7c61588c629c3b3605ecfbb7f..3bb6e65b88d4dfc91057b6c0d0c6e94e1c0a6fb7 100755 (executable)
@@ -6,7 +6,10 @@
 
 . "${CTDB_BASE}/functions"
 
+# service_name is used by various functions
+# shellcheck disable=SC2034
 service_name="nfs"
+
 loadconfig
 ctdb_setup_service_state_dir
 
index 83f69bf0001fce488261b441ba0ba25a14ab3b4b..d99a060cda4156b00bfdc108bcc61884f1863882 100755 (executable)
@@ -7,6 +7,8 @@
 
 . "${CTDB_BASE}/functions"
 
+# service_name is used by various functions
+# shellcheck disable=SC2034
 service_name="iscsi"
 
 loadconfig
@@ -29,6 +31,8 @@ ipreallocated)
        # being unavailable on an IPv4-only system.
        have_ipv4=false
        have_ipv6=false
+       # x is intentionally ignored
+       # shellcheck disable=SC2034
        while IFS='|' read x ip pnn x ; do
            case "$ip" in
                *:*) have_ipv6=true ;;
index bc7abcc2e1223469a3b0b8ed92e2e2032f31940c..1f0ac8d6926e99a1333dd1b92f7fd47daf6f8e5f 100755 (executable)
@@ -8,6 +8,8 @@ if [ -z "$CTDB_BASE" ] ; then
 fi
 export CTDB_BASE
 
+# CTDB_VARDIR is used elsewhere
+# shellcheck disable=SC2034
 CTDB_VARDIR="/usr/local/var/lib/ctdb"
 ctdb_rundir="/usr/local/var/run/ctdb"
 
@@ -41,13 +43,15 @@ rewrite_ctdb_options ()
            else
                _opts="${CTDB_DBDIR#tmpfs:}"
            fi
-           # This is an internal variable, only used by ctdbd_wrapper.
-           # It is OK to repeat mount options - last value wins
+           # It is OK to repeat mount options - last value wins.
+           # CTDB_DBDIR_TMPFS_OPTIONS is used by ctdbd_wrapper
+           # shellcheck disable=SC2034
            CTDB_DBDIR_TMPFS_OPTIONS="${_opts_defaults}${_opts:+,}${_opts}"
 
            CTDB_DBDIR="${ctdb_rundir}/CTDB_DBDIR"
            ;;
        *)
+           # shellcheck disable=SC2034
            CTDB_DBDIR_TMPFS_OPTIONS=""
     esac
 }
@@ -262,6 +266,8 @@ ctdb_get_ip_address ()
            awk -F '|' 'NR == 2 { print $3 }' >"$_ip_addr_file"
     fi
 
+    # ip_address is used by caller
+    # shellcheck disable=SC2034
     read ip_address <"$_ip_addr_file"
 }
 
@@ -637,9 +643,11 @@ drop_ip ()
 
 drop_all_public_ips ()
 {
-    while read _ip _x ; do
-       drop_ip "$_ip"
-    done <"${CTDB_PUBLIC_ADDRESSES:-/dev/null}"
+       # _x is intentionally ignored
+       # shellcheck disable=SC2034
+       while read _ip _x ; do
+               drop_ip "$_ip"
+       done <"${CTDB_PUBLIC_ADDRESSES:-/dev/null}"
 }
 
 flush_route_cache ()
index af3af9d1a7c697136b5cec6b2968c8a740748c09..04e80f4dd4f4e601c362b564de3c53d4c19e2b60 100755 (executable)
@@ -49,6 +49,8 @@ case "$1" in
        cip="$2"
        ctdb_get_pnn
        date=$(date '+%s')
+       # x is intentionally ignored
+       # shellcheck disable=SC2034
        $CTDB ip -X |
        tail -n +2 |
        while IFS="|" read x sip node x ; do
@@ -63,6 +65,8 @@ case "$1" in
        # so we must add it to all the IPs that we serve
        cip="$2"
        ctdb_get_pnn
+       # x is intentionally ignored
+       # shellcheck disable=SC2034
        $CTDB ip -X |
        tail -n +2 |
        while IFS="|" read x sip node x ; do
index 9b1a5803573287b0a647c42860f54b071668b142..626261669a4c8c8b0b44cacddc2b0385e0d92047 100755 (executable)
@@ -165,7 +165,7 @@ get_nodes_with_status ()
            set -- $i # split line on colons
            shift     # line starts with : so 1st field is empty
            local pnn="$1" ; shift
-           local ip="$1" ; shift
+           shift # ignore IP address but need status bits below
 
            case "$status" in
                healthy)