diff options
author | Damian Szuberski <[email protected]> | 2022-01-07 01:07:54 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2022-01-06 16:07:54 -0800 |
commit | c1d3be19d7646c2dfeec04a31c96542be77b9763 (patch) | |
tree | 72ca292f59dd912c1de7471158b932bad0746fcd /cmd | |
parent | a8f27ec6c5f89f721f0492ed7b07437ec439d83d (diff) |
Add ShellCheck's `--enable=all` inside `cmd/`
The only exception is `cmd/vdev_id/vdev_id` which might be a subject of
refactoring (see #12084)
Reviewed-by: Brian Behlendorf <[email protected]>
Reviewed-by: Ahelenia ZiemiaĆska <[email protected]>
Signed-off-by: szubersk <[email protected]>
Closes #12912
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/Makefile.am | 5 | ||||
-rw-r--r-- | cmd/fsck_zfs/Makefile.am | 2 | ||||
-rw-r--r-- | cmd/zed/Makefile.am | 1 | ||||
-rw-r--r-- | cmd/zed/zed.d/Makefile.am | 4 | ||||
-rwxr-xr-x | cmd/zed/zed.d/all-debug.sh | 1 | ||||
-rwxr-xr-x | cmd/zed/zed.d/all-syslog.sh | 1 | ||||
-rwxr-xr-x | cmd/zed/zed.d/data-notify.sh | 1 | ||||
-rwxr-xr-x | cmd/zed/zed.d/generic-notify.sh | 1 | ||||
-rwxr-xr-x | cmd/zed/zed.d/history_event-zfs-list-cacher.sh.in | 3 | ||||
-rwxr-xr-x | cmd/zed/zed.d/resilver_finish-start-scrub.sh | 1 | ||||
-rwxr-xr-x | cmd/zed/zed.d/scrub_finish-notify.sh | 1 | ||||
-rwxr-xr-x | cmd/zed/zed.d/statechange-led.sh | 42 | ||||
-rwxr-xr-x | cmd/zed/zed.d/statechange-notify.sh | 1 | ||||
-rwxr-xr-x | cmd/zed/zed.d/trim_finish-notify.sh | 1 | ||||
-rw-r--r-- | cmd/zed/zed.d/zed-functions.sh | 4 | ||||
-rw-r--r-- | cmd/zed/zed.d/zed.rc | 1 | ||||
-rw-r--r-- | cmd/zpool/Makefile.am | 2 | ||||
-rwxr-xr-x | cmd/zpool/zpool.d/dm-deps | 1 | ||||
-rwxr-xr-x | cmd/zpool/zpool.d/iostat | 3 | ||||
-rwxr-xr-x | cmd/zpool/zpool.d/lsblk | 1 | ||||
-rwxr-xr-x | cmd/zpool/zpool.d/media | 2 | ||||
-rwxr-xr-x | cmd/zpool/zpool.d/ses | 5 | ||||
-rwxr-xr-x | cmd/zpool/zpool.d/smart | 1 | ||||
-rwxr-xr-x | cmd/zpool/zpool.d/upath | 1 | ||||
-rw-r--r-- | cmd/zvol_wait/Makefile.am | 2 |
25 files changed, 61 insertions, 27 deletions
diff --git a/cmd/Makefile.am b/cmd/Makefile.am index 5fc9e8397..3994d1434 100644 --- a/cmd/Makefile.am +++ b/cmd/Makefile.am @@ -7,8 +7,9 @@ SUBDIRS += zpool_influxdb CPPCHECKDIRS = zfs zpool zdb zhack zinject zstream ztest CPPCHECKDIRS += raidz_test zfs_ids_to_path zpool_influxdb -# TODO: #12084: SHELLCHECKDIRS = fsck_zfs vdev_id zpool -SHELLCHECKDIRS = fsck_zfs zpool +# TODO: #12084: SHELLCHECKDIRS += vdev_id +SHELLCHECKDIRS = fsck_zfs zed zpool zvol_wait +SHELLCHECK_OPTS = --enable=all if USING_PYTHON SUBDIRS += arcstat arc_summary dbufstat diff --git a/cmd/fsck_zfs/Makefile.am b/cmd/fsck_zfs/Makefile.am index f8139f117..d86ea1f78 100644 --- a/cmd/fsck_zfs/Makefile.am +++ b/cmd/fsck_zfs/Makefile.am @@ -4,3 +4,5 @@ include $(top_srcdir)/config/Shellcheck.am dist_sbin_SCRIPTS = fsck.zfs SUBSTFILES += $(dist_sbin_SCRIPTS) + +SHELLCHECK_OPTS = --enable=all diff --git a/cmd/zed/Makefile.am b/cmd/zed/Makefile.am index 7b662994d..1492123e1 100644 --- a/cmd/zed/Makefile.am +++ b/cmd/zed/Makefile.am @@ -5,6 +5,7 @@ AM_CFLAGS += $(LIBUDEV_CFLAGS) $(LIBUUID_CFLAGS) SUBDIRS = zed.d SHELLCHECKDIRS = $(SUBDIRS) +SHELLCHECK_OPTS = --enable=all sbin_PROGRAMS = zed diff --git a/cmd/zed/zed.d/Makefile.am b/cmd/zed/zed.d/Makefile.am index 2c8173b3e..24efaa74f 100644 --- a/cmd/zed/zed.d/Makefile.am +++ b/cmd/zed/zed.d/Makefile.am @@ -10,6 +10,10 @@ dist_zedconf_DATA = \ zed-functions.sh \ zed.rc +SHELLCHECKSCRIPTS = zed-functions.sh zed.rc +SHELLCHECK_OPTS = --enable=all +SHELLCHECK_SHELL = dash + zedexecdir = $(zfsexecdir)/zed.d dist_zedexec_SCRIPTS = \ diff --git a/cmd/zed/zed.d/all-debug.sh b/cmd/zed/zed.d/all-debug.sh index 824c9fe42..ba19b96b0 100755 --- a/cmd/zed/zed.d/all-debug.sh +++ b/cmd/zed/zed.d/all-debug.sh @@ -1,4 +1,5 @@ #!/bin/sh +# shellcheck disable=SC2154 # # Log all environment variables to ZED_DEBUG_LOG. # diff --git a/cmd/zed/zed.d/all-syslog.sh b/cmd/zed/zed.d/all-syslog.sh index ea108c47b..5f601144a 100755 --- a/cmd/zed/zed.d/all-syslog.sh +++ b/cmd/zed/zed.d/all-syslog.sh @@ -1,4 +1,5 @@ #!/bin/sh +# shellcheck disable=SC2154 # # Copyright (C) 2013-2014 Lawrence Livermore National Security, LLC. # Copyright (c) 2020 by Delphix. All rights reserved. diff --git a/cmd/zed/zed.d/data-notify.sh b/cmd/zed/zed.d/data-notify.sh index 792d30a66..9846769b1 100755 --- a/cmd/zed/zed.d/data-notify.sh +++ b/cmd/zed/zed.d/data-notify.sh @@ -1,4 +1,5 @@ #!/bin/sh +# shellcheck disable=SC2154 # # Send notification in response to a DATA error. # diff --git a/cmd/zed/zed.d/generic-notify.sh b/cmd/zed/zed.d/generic-notify.sh index 9cf657e39..e73b05390 100755 --- a/cmd/zed/zed.d/generic-notify.sh +++ b/cmd/zed/zed.d/generic-notify.sh @@ -1,4 +1,5 @@ #!/bin/sh +# shellcheck disable=SC2154 # # Send notification in response to a given zevent. # diff --git a/cmd/zed/zed.d/history_event-zfs-list-cacher.sh.in b/cmd/zed/zed.d/history_event-zfs-list-cacher.sh.in index db40fa36d..8c5031a38 100755 --- a/cmd/zed/zed.d/history_event-zfs-list-cacher.sh.in +++ b/cmd/zed/zed.d/history_event-zfs-list-cacher.sh.in @@ -1,4 +1,5 @@ #!/bin/sh +# shellcheck disable=SC2154 # # Track changes to enumerated pools for use in early-boot set -ef @@ -72,7 +73,7 @@ PROPS="name,mountpoint,canmount,atime,relatime,devices,exec\ ,org.openzfs.systemd:wanted-by,org.openzfs.systemd:required-by\ ,org.openzfs.systemd:nofail,org.openzfs.systemd:ignore" -"${ZFS}" list -H -t filesystem -o $PROPS -r "${ZEVENT_POOL}" > "${FSLIST_TMP}" +"${ZFS}" list -H -t filesystem -o "${PROPS}" -r "${ZEVENT_POOL}" > "${FSLIST_TMP}" # Sort the output so that it is stable sort "${FSLIST_TMP}" -o "${FSLIST_TMP}" diff --git a/cmd/zed/zed.d/resilver_finish-start-scrub.sh b/cmd/zed/zed.d/resilver_finish-start-scrub.sh index c7cfd1ddb..cafce6fde 100755 --- a/cmd/zed/zed.d/resilver_finish-start-scrub.sh +++ b/cmd/zed/zed.d/resilver_finish-start-scrub.sh @@ -1,4 +1,5 @@ #!/bin/sh +# shellcheck disable=SC2154 # resilver_finish-start-scrub.sh # Run a scrub after a resilver # diff --git a/cmd/zed/zed.d/scrub_finish-notify.sh b/cmd/zed/zed.d/scrub_finish-notify.sh index 5c0124b8d..fc9dc23e0 100755 --- a/cmd/zed/zed.d/scrub_finish-notify.sh +++ b/cmd/zed/zed.d/scrub_finish-notify.sh @@ -1,4 +1,5 @@ #!/bin/sh +# shellcheck disable=SC2154 # # Send notification in response to a RESILVER_FINISH or SCRUB_FINISH. # diff --git a/cmd/zed/zed.d/statechange-led.sh b/cmd/zed/zed.d/statechange-led.sh index 26e6064fa..46bfc1b86 100755 --- a/cmd/zed/zed.d/statechange-led.sh +++ b/cmd/zed/zed.d/statechange-led.sh @@ -1,4 +1,5 @@ #!/bin/sh +# shellcheck disable=SC2154 # # Turn off/on vdevs' enclosure fault LEDs when their pool's state changes. # @@ -126,6 +127,9 @@ state_to_val() ONLINE) echo 0 ;; + *) + echo "invalid state: $state" + ;; esac } @@ -138,26 +142,24 @@ nvme_dev_to_slot() dev="$1" # Get the address "0000:01:00.0" - address=$(cat "/sys/class/block/$dev/device/address") - - # For each /sys/bus/pci/slots subdir that is an actual number - # (rather than weird directories like "1-3/"). - # shellcheck disable=SC2010 - for i in $(ls /sys/bus/pci/slots/ | grep -E "^[0-9]+$") ; do - this_address=$(cat "/sys/bus/pci/slots/$i/address") - - # The format of address is a little different between - # /sys/class/block/$dev/device/address and - # /sys/bus/pci/slots/ - # - # address= "0000:01:00.0" - # this_address = "0000:01:00" - # - if echo "$address" | grep -Eq ^"$this_address" ; then - echo "/sys/bus/pci/slots/$i" - break - fi - done + read -r address < "/sys/class/block/$dev/device/address" + + find /sys/bus/pci/slots -regex '.*/[0-9]+/address$' | \ + while read -r sys_addr; do + read -r this_address < "$sys_addr" + + # The format of address is a little different between + # /sys/class/block/$dev/device/address and + # /sys/bus/pci/slots/ + # + # address= "0000:01:00.0" + # this_address = "0000:01:00" + # + if echo "$address" | grep -Eq ^"$this_address" ; then + echo "${sys_addr%/*}" + break + fi + done } diff --git a/cmd/zed/zed.d/statechange-notify.sh b/cmd/zed/zed.d/statechange-notify.sh index ab11dfbc9..c475fdb36 100755 --- a/cmd/zed/zed.d/statechange-notify.sh +++ b/cmd/zed/zed.d/statechange-notify.sh @@ -1,4 +1,5 @@ #!/bin/sh +# shellcheck disable=SC2154 # # CDDL HEADER START # diff --git a/cmd/zed/zed.d/trim_finish-notify.sh b/cmd/zed/zed.d/trim_finish-notify.sh index 8fdb64531..a9ea48962 100755 --- a/cmd/zed/zed.d/trim_finish-notify.sh +++ b/cmd/zed/zed.d/trim_finish-notify.sh @@ -1,4 +1,5 @@ #!/bin/sh +# shellcheck disable=SC2154 # # Send notification in response to a TRIM_FINISH. The event # will be received for each vdev in the pool which was trimmed. diff --git a/cmd/zed/zed.d/zed-functions.sh b/cmd/zed/zed.d/zed-functions.sh index eb59036cf..bbff9c008 100644 --- a/cmd/zed/zed.d/zed-functions.sh +++ b/cmd/zed/zed.d/zed-functions.sh @@ -1,5 +1,5 @@ #!/bin/sh -# shellcheck disable=SC2039 +# shellcheck disable=SC2154,SC3043 # zed-functions.sh # # ZED helper functions for use in ZEDLETs @@ -266,7 +266,7 @@ zed_notify_email() | sed -e "s/@ADDRESS@/${ZED_EMAIL_ADDR}/g" \ -e "s/@SUBJECT@/${subject}/g")" - # shellcheck disable=SC2086 + # shellcheck disable=SC2086,SC2248 eval ${ZED_EMAIL_PROG} ${ZED_EMAIL_OPTS} < "${pathname}" >/dev/null 2>&1 rv=$? if [ "${rv}" -ne 0 ]; then diff --git a/cmd/zed/zed.d/zed.rc b/cmd/zed/zed.d/zed.rc index 9ac77f929..a8fdc86c3 100644 --- a/cmd/zed/zed.d/zed.rc +++ b/cmd/zed/zed.d/zed.rc @@ -3,6 +3,7 @@ # # This file should be owned by root and permissioned 0600. ## +# shellcheck disable=SC2034 ## # Absolute path to the debug output file. diff --git a/cmd/zpool/Makefile.am b/cmd/zpool/Makefile.am index fa494c030..b89b5db85 100644 --- a/cmd/zpool/Makefile.am +++ b/cmd/zpool/Makefile.am @@ -5,6 +5,8 @@ AM_CFLAGS += $(LIBBLKID_CFLAGS) $(LIBUUID_CFLAGS) DEFAULT_INCLUDES += -I$(srcdir) +SHELLCHECK_OPTS = --enable=all + sbin_PROGRAMS = zpool zpool_SOURCES = \ diff --git a/cmd/zpool/zpool.d/dm-deps b/cmd/zpool/zpool.d/dm-deps index 42af6a8d6..44224787f 100755 --- a/cmd/zpool/zpool.d/dm-deps +++ b/cmd/zpool/zpool.d/dm-deps @@ -9,6 +9,7 @@ if [ "$1" = "-h" ] ; then exit fi +# shellcheck disable=SC2154 dev="$VDEV_PATH" # If the VDEV path is a symlink, resolve it to a real device diff --git a/cmd/zpool/zpool.d/iostat b/cmd/zpool/zpool.d/iostat index 19be475e9..95c459a3f 100755 --- a/cmd/zpool/zpool.d/iostat +++ b/cmd/zpool/zpool.d/iostat @@ -27,6 +27,7 @@ elif [ "$script" = "iostat-10s" ] ; then brief="yes" fi +# shellcheck disable=SC2154 if [ -f "$VDEV_UPATH" ] ; then # We're a file-based vdev, iostat doesn't work on us. Do nothing. exit @@ -67,7 +68,7 @@ i=0 for col in $cols ; do i=$((i+1)) # Skip the first column since it's just the device name - if [ $i -eq 1 ]; then + if [ "$i" -eq 1 ]; then continue fi diff --git a/cmd/zpool/zpool.d/lsblk b/cmd/zpool/zpool.d/lsblk index 919783a1c..1ed146443 100755 --- a/cmd/zpool/zpool.d/lsblk +++ b/cmd/zpool/zpool.d/lsblk @@ -66,6 +66,7 @@ for i in $list ; do # Special case: Looking up the size of a file-based vdev can't # be done with lsblk. + # shellcheck disable=SC2154 if [ "$i" = "size" ] && [ -f "$VDEV_UPATH" ] ; then size=$(du -h --apparent-size "$VDEV_UPATH" | cut -f 1) echo "size=$size" diff --git a/cmd/zpool/zpool.d/media b/cmd/zpool/zpool.d/media index 660f78b74..095ac86dc 100755 --- a/cmd/zpool/zpool.d/media +++ b/cmd/zpool/zpool.d/media @@ -8,12 +8,14 @@ if [ "$1" = "-h" ] ; then exit fi +# shellcheck disable=SC2154 if [ -b "$VDEV_UPATH" ]; then device="${VDEV_UPATH##*/}" read -r val 2>/dev/null < "/sys/block/$device/queue/rotational" case "$val" in 0) MEDIA="ssd" ;; 1) MEDIA="hdd" ;; + *) MEDIA="invalid" ;; esac vpd_pg83="/sys/block/$device/device/vpd_pg83" diff --git a/cmd/zpool/zpool.d/ses b/cmd/zpool/zpool.d/ses index b51fe3189..638145c95 100755 --- a/cmd/zpool/zpool.d/ses +++ b/cmd/zpool/zpool.d/ses @@ -24,6 +24,7 @@ else fi for i in $scripts ; do + # shellcheck disable=SC2154 if [ -z "$VDEV_ENC_SYSFS_PATH" ] ; then echo "$i=" continue @@ -52,7 +53,9 @@ for i in $scripts ; do locate_led) val=$(cat "$VDEV_ENC_SYSFS_PATH/locate" 2>/dev/null) ;; + *) + val=invalid + ;; esac echo "$i=$val" done - diff --git a/cmd/zpool/zpool.d/smart b/cmd/zpool/zpool.d/smart index b95256d75..032491988 100755 --- a/cmd/zpool/zpool.d/smart +++ b/cmd/zpool/zpool.d/smart @@ -69,6 +69,7 @@ if [ "$1" = "-h" ] ; then exit fi +# shellcheck disable=SC2154 if [ -b "$VDEV_UPATH" ] && PATH="/usr/sbin:$PATH" command -v smartctl > /dev/null || [ -n "$samples" ] ; then if [ -n "$samples" ] ; then # cat a smartctl output text file instead of running smartctl diff --git a/cmd/zpool/zpool.d/upath b/cmd/zpool/zpool.d/upath index 16a4327d4..e37ee1b8c 100755 --- a/cmd/zpool/zpool.d/upath +++ b/cmd/zpool/zpool.d/upath @@ -4,4 +4,5 @@ if [ "$1" = "-h" ] ; then exit fi +# shellcheck disable=SC2154 echo upath="$VDEV_UPATH" diff --git a/cmd/zvol_wait/Makefile.am b/cmd/zvol_wait/Makefile.am index 2e5bf3323..ee66d51de 100644 --- a/cmd/zvol_wait/Makefile.am +++ b/cmd/zvol_wait/Makefile.am @@ -1,3 +1,5 @@ include $(top_srcdir)/config/Shellcheck.am dist_bin_SCRIPTS = zvol_wait + +SHELLCHECK_OPTS = --enable=all |