mirror of
https://github.com/SCST-project/scst.git
synced 2026-05-14 01:01:27 +00:00
scripts: Fix shellcheck warnings for checkpatch scripts
- Switching from 'set -e' to 'set -euo pipefail' for better error handling.
- Quoting all variable expansions to prevent word splitting and globbing.
- Replacing legacy unquoted $(...) and $@ with quoted forms.
- Using array-safe idioms where necessary (e.g., "${src_files[@]}").
This patch doesn't change any functionality.
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
set -euo pipefail
|
||||
|
||||
scriptpath=${CHECKPATCH_PATH:-/lib/modules/$(uname -r)/build/scripts}
|
||||
scriptpath="${CHECKPATCH_PATH:-/lib/modules/$(uname -r)/build/scripts}"
|
||||
|
||||
ignore=(
|
||||
MISSING_SIGN_OFF
|
||||
@@ -20,6 +20,6 @@ ignore=(
|
||||
MACRO_ARG_REUSE
|
||||
IF_0
|
||||
)
|
||||
ignore_str=${ignore[*]}
|
||||
ignore_str="${ignore[*]}"
|
||||
|
||||
${scriptpath}/checkpatch.pl --no-tree --show-types --strict --ignore="${ignore_str// /,}" $@
|
||||
"${scriptpath}/checkpatch.pl" --no-tree --show-types --strict --ignore="${ignore_str// /,}" "$@"
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
set -euo pipefail
|
||||
|
||||
rootdir=$(readlink -f $(dirname $0)/..)
|
||||
scriptsdir=${rootdir}/scripts
|
||||
base_commit=${1:-master}
|
||||
rootdir="$(readlink -f "$(dirname "$0")/..")"
|
||||
scriptsdir="${rootdir}/scripts"
|
||||
base_commit="${1:-master}"
|
||||
|
||||
commits=$(cd ${rootdir} && git log --pretty=format:"%h" ${base_commit}..HEAD)
|
||||
commits=$(cd "${rootdir}" && git log --pretty=format:"%h" "${base_commit}"..HEAD)
|
||||
err=0
|
||||
|
||||
for commit in $commits; do
|
||||
echo "Running checkpatch for commit $commit"
|
||||
for commit in ${commits}; do
|
||||
echo "Running checkpatch for commit ${commit}"
|
||||
echo -e "========================================\n"
|
||||
|
||||
(cd ${rootdir} &&
|
||||
git format-patch -1 --stdout $commit | ${scriptsdir}/checkpatch -) || err=1
|
||||
(cd "${rootdir}" &&
|
||||
git format-patch -1 --stdout "${commit}" | "${scriptsdir}/checkpatch" -) || err=1
|
||||
echo -e "\n"
|
||||
done
|
||||
|
||||
exit $err
|
||||
exit "${err}"
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
set -euo pipefail
|
||||
|
||||
rootdir=$(readlink -f $(dirname $0)/..)
|
||||
scriptsdir=${rootdir}/scripts
|
||||
base_commit=${1:-master}
|
||||
rootdir="$(readlink -f "$(dirname "$0")/..")"
|
||||
scriptsdir="${rootdir}/scripts"
|
||||
base_commit="${1:-master}"
|
||||
|
||||
err=0
|
||||
|
||||
(cd ${rootdir} && git diff ${base_commit} | ${scriptsdir}/checkpatch -) || err=1
|
||||
(cd "${rootdir}" && git diff "${base_commit}" | "${scriptsdir}/checkpatch" -) || err=1
|
||||
|
||||
exit $err
|
||||
exit "${err}"
|
||||
|
||||
@@ -1,23 +1,23 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
set -euo pipefail
|
||||
|
||||
rootdir=$(readlink -f $(dirname $0)/..)
|
||||
scriptsdir=${rootdir}/scripts
|
||||
outputfile=checkpatch.out
|
||||
rootdir="$(readlink -f "$(dirname "$0")/..")"
|
||||
scriptsdir="${rootdir}/scripts"
|
||||
outputfile="checkpatch.out"
|
||||
|
||||
src_files=$(${scriptsdir}/list-source-files ${rootdir} | \
|
||||
mapfile -t src_files < <(
|
||||
"${scriptsdir}/list-source-files" "${rootdir}" | \
|
||||
grep -vE '^debian/|^fcst/linux-patches|patch$|pdf$|png$|^iscsi-scst/usr|^qla|^scripts/|^scstadmin/|^usr/|^www/' | \
|
||||
while read -r filename; do echo "${rootdir}/$filename"; done)
|
||||
|
||||
${scriptsdir}/checkpatch -f $src_files 1> ${outputfile} || true
|
||||
"${scriptsdir}/checkpatch" -f "${src_files[@]}" 1> "${outputfile}" || true
|
||||
|
||||
errors=$(grep -c '^ERROR' "${outputfile}")
|
||||
warnings=$(grep -c '^WARNING' "${outputfile}")
|
||||
checks=$(grep -c '^CHECK' "${outputfile}")
|
||||
errors=$(grep -c '^ERROR' "${outputfile}" || true)
|
||||
warnings=$(grep -c '^WARNING' "${outputfile}" || true)
|
||||
checks=$(grep -c '^CHECK' "${outputfile}" || true)
|
||||
|
||||
echo "${errors} errors / ${warnings} warnings / ${checks} checks."
|
||||
|
||||
grep -E '^WARNING|^ERROR|^CHECK' "${outputfile}" |
|
||||
sort |
|
||||
sed 's/^CHECK:CAMELCASE: Avoid CamelCase:.*/CHECK:CAMELCASE Avoid CamelCase/' |
|
||||
|
||||
Reference in New Issue
Block a user