From 13e03de0d49cfb2bd7ca32b8c7bc72bea6bd2b58 Mon Sep 17 00:00:00 2001 From: Kamalesh Babulal Date: Sun, 12 May 2019 21:09:53 +0530 Subject: [PATCH] kpatch, kpatch-build: Use -n instead of ! -z make check using shellcheck version 0.6.0 suggests following improvements: In kpatch/kpatch line 160: if [[ ! -z "$checksum" ]] && [[ -e "$SYSFS/${modname}/checksum"]] ; then ^-- SC2236: Use -n instead of ! -z. In kpatch-build/kpatch-build line 953: [[ ! -z "$UNDEFINED" ]] && die "Undefined symbols: $UNDEFINED" ^-- SC2236: Use -n instead of ! -z. '-n' and '! -z' are used interchangeably across the scripts, let's use '-n' consistently to check a non-empty string instead of using negation. Signed-off-by: Kamalesh Babulal --- kpatch-build/kpatch-build | 2 +- kpatch/kpatch | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/kpatch-build/kpatch-build b/kpatch-build/kpatch-build index 4c2df0d..3cb7173 100755 --- a/kpatch-build/kpatch-build +++ b/kpatch-build/kpatch-build @@ -950,7 +950,7 @@ fi # column containing lines unique to first file. UNDEFINED=$(comm -23 <(sort -u "${TEMPDIR}"/undefined_references) \ <(sort -u "${TEMPDIR}"/new_symbols) | tr '\n' ' ') -[[ ! -z "$UNDEFINED" ]] && die "Undefined symbols: $UNDEFINED" +[[ -n "$UNDEFINED" ]] && die "Undefined symbols: $UNDEFINED" cp -f "$TEMPDIR/patch/$MODNAME.ko" "$BASE" || die diff --git a/kpatch/kpatch b/kpatch/kpatch index 4583ad1..328f119 100755 --- a/kpatch/kpatch +++ b/kpatch/kpatch @@ -157,7 +157,7 @@ verify_module_checksum () { checksum="$(readelf -p .kpatch.checksum "$1" 2>&1 | grep '\[.*\]' | awk '{print $3}')" # Fail checksum match only if both exist and diverge - if [[ ! -z "$checksum" ]] && [[ -e "$SYSFS/${modname}/checksum" ]] ; then + if [[ -n "$checksum" ]] && [[ -e "$SYSFS/${modname}/checksum" ]] ; then sysfs_checksum="$(cat "$SYSFS/${modname}/checksum")" [[ "$checksum" == "$sysfs_checksum" ]] || return 1 fi