From 1266f86444f74230f52d7e86626918dad84c4f53 Mon Sep 17 00:00:00 2001 From: Steffen Maier Date: Mon, 24 Jul 2023 17:10:24 +0200 Subject: [PATCH] zdev/dracut: add shellcheck annotations for recently added code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The annotations and the one non-functional code change in zdev/dracut/95zdev-kdump/module-setup.sh check() clear all shellcheck reports. complements 73c46a30563d ("zdev/dracut: fix kdump by only activating required devices") Github-ID: https://github.com/ibm-s390-linux/s390-tools/pull/158 Reviewed-by: Vineeth Vijayan Acked-by: Vineeth Vijayan Acked-by: Peter Oberparleiter Signed-off-by: Steffen Maier Signed-off-by: Jan Höppner --- zdev/dracut/95zdev-kdump/module-setup.sh | 12 +++++++----- zdev/dracut/95zdev/module-setup.sh | 1 + zdev/dracut/95zdev/zdev-lib.sh | 2 ++ 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/zdev/dracut/95zdev-kdump/module-setup.sh b/zdev/dracut/95zdev-kdump/module-setup.sh index 4ce2fc67..0bab9af2 100755 --- a/zdev/dracut/95zdev-kdump/module-setup.sh +++ b/zdev/dracut/95zdev-kdump/module-setup.sh @@ -16,9 +16,10 @@ check() { local _arch=${DRACUT_ARCH:-$(uname -m)} # Ensure that we're running on s390 - [ "$_arch" = "s390" -o "$_arch" = "s390x" ] || return 1 + [ "$_arch" = "s390" ] || [ "$_arch" = "s390x" ] || return 1 - source "$moddir/../95zdev/zdev-lib.sh" + # shellcheck source=/dev/null + source "${moddir:?}/../95zdev/zdev-lib.sh" # Ensure this module is only included when building kdump initrd is_kdump || return 1 @@ -60,7 +61,7 @@ install() { # many zFCP LUNs inst_dir /etc/modprobe.d chzdev zfcp --type "allow_lun_scan=0" --persistent \ - --base "/etc=$initdir/etc" --yes --quiet --no-root-update \ + --base "/etc=${initdir:?}/etc" --yes --quiet --no-root-update \ --force >/dev/null # drop /etc/zfcp.conf from dracut module 95zfcp echo "rd.zfcp.conf=0" > "$initdir/etc/cmdline.d/00-no-zfcp-conf.conf" @@ -89,13 +90,14 @@ install() { # these are purely generated udev rules so we have to glob expand # within $initdir and strip the $initdir prefix for mark_hostonly local -a _array + # shellcheck disable=SC2155 local _nullglob=$(shopt -p nullglob) shopt -u nullglob readarray -t _array < \ - <(ls -1 $initdir/etc/udev/rules.d/41-*.rules 2> /dev/null) + <(ls -1 "$initdir"/etc/udev/rules.d/41-*.rules 2> /dev/null) [[ ${#_array[@]} -gt 0 ]] && mark_hostonly "${_array[@]#$initdir}" readarray -t _array < \ - <(ls -1 $initdir/etc/modprobe.d/s390x-*.conf 2> /dev/null) + <(ls -1 "$initdir"/etc/modprobe.d/s390x-*.conf 2> /dev/null) [[ ${#_array[@]} -gt 0 ]] && mark_hostonly "${_array[@]#$initdir}" $_nullglob diff --git a/zdev/dracut/95zdev/module-setup.sh b/zdev/dracut/95zdev/module-setup.sh index 1bae11ff..e81bd99e 100644 --- a/zdev/dracut/95zdev/module-setup.sh +++ b/zdev/dracut/95zdev/module-setup.sh @@ -19,6 +19,7 @@ check() { # Ensure that we're running on s390 [ "$_arch" = "s390" -o "$_arch" = "s390x" ] || return 1 + # shellcheck disable=SC2154 source=/dev/null source "$moddir/zdev-lib.sh" # Leave kdump device configuration to module zdev-kdump to diff --git a/zdev/dracut/95zdev/zdev-lib.sh b/zdev/dracut/95zdev/zdev-lib.sh index 48abd6bb..9f774435 100644 --- a/zdev/dracut/95zdev/zdev-lib.sh +++ b/zdev/dracut/95zdev/zdev-lib.sh @@ -14,10 +14,12 @@ is_kdump() { # https://src.fedoraproject.org/rpms/kexec-tools/c/4eedcae5e1540690a3761857fe2e692774c44960 # https://src.fedoraproject.org/rpms/kexec-tools/blob/rawhide/f/mkdumprd # https://src.fedoraproject.org/rpms/kexec-tools/blob/rawhide/f/dracut-module-setup.sh + # shellcheck disable=SC2154 if [[ $hostonly && "$hostonly_mode" == "strict" && -n "$IN_KDUMP" ]]; then return 0 fi # https://github.com/openSUSE/kdump/blob/master/dracut/module-setup.sh + # shellcheck disable=SC2154 if [[ " $dracutmodules $add_dracutmodules $force_add_dracutmodules " == *\ kdump\ * ]]; then return 0 fi