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>
# 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
. "${CTDB_BASE}/functions"
+# service_name is used by various functions
+# shellcheck disable=SC2034
service_name="nfs"
+
loadconfig
ctdb_setup_service_state_dir
. "${CTDB_BASE}/functions"
+# service_name is used by various functions
+# shellcheck disable=SC2034
service_name=natgw
loadconfig
loadconfig
+# service_name is used by various functions
+# shellcheck disable=SC2034
service_name=per_ip_routing
# Do nothing if unconfigured
# 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.
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"
;;
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"
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"
. "${CTDB_BASE}/functions"
+# service_name is used by various functions
+# shellcheck disable=SC2034
service_name="multipathd"
loadconfig
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
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
CTDB_SERVICE_WINBIND=${CTDB_SERVICE_WINBIND:-winbind}
+# service_name is used by various functions
+# shellcheck disable=SC2034
service_name="winbind"
loadconfig
;;
esac
+# service_name is used by various functions
+# shellcheck disable=SC2034
service_name="samba"
loadconfig
. "${CTDB_BASE}/functions"
+# service_name is used by various functions
+# shellcheck disable=SC2034
service_name="nfs"
+
loadconfig
ctdb_setup_service_state_dir
. "${CTDB_BASE}/functions"
+# service_name is used by various functions
+# shellcheck disable=SC2034
service_name="iscsi"
loadconfig
# 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 ;;
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"
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
}
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"
}
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 ()
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
# 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
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)