From: Martin Schwenke Date: Wed, 6 Jul 2016 07:16:44 +0000 (+1000) Subject: ctdb-scripts: Avoid shellcheck warning SC2034 (unused variables) X-Git-Tag: tdb-1.3.10~272 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f6c25a455a62281fd4bf2e3e74cd0ae4233df132;p=thirdparty%2Fsamba.git ctdb-scripts: Avoid shellcheck warning SC2034 (unused variables) 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 Reviewed-by: Amitay Isaacs --- diff --git a/ctdb/config/debug_locks.sh b/ctdb/config/debug_locks.sh index 62b67992340..dee719adcc2 100755 --- a/ctdb/config/debug_locks.sh +++ b/ctdb/config/debug_locks.sh @@ -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 diff --git a/ctdb/config/events.d/06.nfs b/ctdb/config/events.d/06.nfs index d0611a59ea7..623911aefa7 100755 --- a/ctdb/config/events.d/06.nfs +++ b/ctdb/config/events.d/06.nfs @@ -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 diff --git a/ctdb/config/events.d/11.natgw b/ctdb/config/events.d/11.natgw index 2cfe75b6acf..bf99ad5a05f 100755 --- a/ctdb/config/events.d/11.natgw +++ b/ctdb/config/events.d/11.natgw @@ -10,6 +10,8 @@ . "${CTDB_BASE}/functions" +# service_name is used by various functions +# shellcheck disable=SC2034 service_name=natgw loadconfig diff --git a/ctdb/config/events.d/13.per_ip_routing b/ctdb/config/events.d/13.per_ip_routing index 7dbf15818ab..b14c95e5b99 100755 --- a/ctdb/config/events.d/13.per_ip_routing +++ b/ctdb/config/events.d/13.per_ip_routing @@ -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" diff --git a/ctdb/config/events.d/20.multipathd b/ctdb/config/events.d/20.multipathd index 0fe140f839d..2c153946f1d 100755 --- a/ctdb/config/events.d/20.multipathd +++ b/ctdb/config/events.d/20.multipathd @@ -11,6 +11,8 @@ . "${CTDB_BASE}/functions" +# service_name is used by various functions +# shellcheck disable=SC2034 service_name="multipathd" loadconfig diff --git a/ctdb/config/events.d/31.clamd b/ctdb/config/events.d/31.clamd index c2ee8de5369..c7b542e2148 100755 --- a/ctdb/config/events.d/31.clamd +++ b/ctdb/config/events.d/31.clamd @@ -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 diff --git a/ctdb/config/events.d/41.httpd b/ctdb/config/events.d/41.httpd index 4a55231c48a..9e0f6f65857 100755 --- a/ctdb/config/events.d/41.httpd +++ b/ctdb/config/events.d/41.httpd @@ -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 diff --git a/ctdb/config/events.d/49.winbind b/ctdb/config/events.d/49.winbind index 495ac5791e3..8fcccfca724 100755 --- a/ctdb/config/events.d/49.winbind +++ b/ctdb/config/events.d/49.winbind @@ -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 diff --git a/ctdb/config/events.d/50.samba b/ctdb/config/events.d/50.samba index 82b9b96029d..b2a5fa46013 100755 --- a/ctdb/config/events.d/50.samba +++ b/ctdb/config/events.d/50.samba @@ -24,6 +24,8 @@ case $CTDB_INIT_STYLE in ;; esac +# service_name is used by various functions +# shellcheck disable=SC2034 service_name="samba" loadconfig diff --git a/ctdb/config/events.d/60.nfs b/ctdb/config/events.d/60.nfs index 15def341873..3bb6e65b88d 100755 --- a/ctdb/config/events.d/60.nfs +++ b/ctdb/config/events.d/60.nfs @@ -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 diff --git a/ctdb/config/events.d/70.iscsi b/ctdb/config/events.d/70.iscsi index 83f69bf0001..d99a060cda4 100755 --- a/ctdb/config/events.d/70.iscsi +++ b/ctdb/config/events.d/70.iscsi @@ -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 ;; diff --git a/ctdb/config/functions b/ctdb/config/functions index bc7abcc2e12..1f0ac8d6926 100755 --- a/ctdb/config/functions +++ b/ctdb/config/functions @@ -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 () diff --git a/ctdb/config/statd-callout b/ctdb/config/statd-callout index af3af9d1a7c..04e80f4dd4f 100755 --- a/ctdb/config/statd-callout +++ b/ctdb/config/statd-callout @@ -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 diff --git a/ctdb/tools/onnode b/ctdb/tools/onnode index 9b1a5803573..626261669a4 100755 --- a/ctdb/tools/onnode +++ b/ctdb/tools/onnode @@ -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)