Skip to content

Commit

Permalink
.github/workflows, scripts: Improve checkpatch compliance
Browse files Browse the repository at this point in the history
Use checkpatch --strict to detect more style issues.
  • Loading branch information
lnocturno committed Oct 1, 2024
1 parent 878bbad commit 1925094
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/checkpatch_pull.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
for commit in $commits; do
echo "Running checkpatch.pl for commit $commit"
echo "========================================"
git format-patch -1 --stdout $commit | ./checkpatch.pl --no-tree --show-types --ignore="${ignore_str// /,}" - || err=1
git format-patch -1 --stdout $commit | ./checkpatch.pl --no-tree --show-types --strict --ignore="${ignore_str// /,}" - || err=1
echo
done
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/checkpatch_push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ jobs:
)
ignore_str=${ignore[*]}
git format-patch -1 --stdout | ./checkpatch.pl --no-tree --show-types --ignore="${ignore_str// /,}" -
git format-patch -1 --stdout | ./checkpatch.pl --no-tree --show-types --strict --ignore="${ignore_str// /,}" -
24 changes: 14 additions & 10 deletions scripts/checkpatch
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
#!/bin/bash
#!/usr/bin/env bash

ignore=(
CONSTANT_COMPARISON
LINUX_VERSION_CODE
LONG_LINE
LONG_LINE_COMMENT
LONG_LINE_STRING
RETURN_VOID
SPDX_LICENSE_TAG
SYMBOLIC_PERMS
CONSTANT_COMPARISON
LINUX_VERSION_CODE
LONG_LINE
LONG_LINE_COMMENT
LONG_LINE_STRING
RETURN_VOID
SPDX_LICENSE_TAG
SYMBOLIC_PERMS
)
../linux-kernel/scripts/checkpatch.pl -f --show-types --ignore="$(echo "${ignore[@]}" | sed 's/ /,/g')" $(list-source-files | grep -vE '^debian/|^fcst/linux-patches|patch$|pdf$|png$|^iscsi-scst/usr|^qla|^scripts/|^scstadmin/|^usr/|^www/') | sed 's/^#[0-9]*: FILE: \(.*\):/\1:1:/'
ignore_str=${ignore[*]}

src_files=$(list-source-files | grep -vE '^debian/|^fcst/linux-patches|patch$|pdf$|png$|^iscsi-scst/usr|^qla|^scripts/|^scstadmin/|^usr/|^www/')

../linux-kernel/scripts/checkpatch.pl -f --show-types --strict --ignore="${ignore_str// /,}" $src_files | sed 's/^#[0-9]*: FILE: \(.*\):/\1:1:/'
14 changes: 9 additions & 5 deletions scripts/run-regression-tests
Original file line number Diff line number Diff line change
Expand Up @@ -231,25 +231,29 @@ function run_checkpatch {
if [ "${multiple_patches}" = "false" ]; then
echo "Running checkpatch on the SCST kernel patch ..."
( cd "${outputdir}/linux-$1" \
&& scripts/checkpatch.pl --no-tree --no-signoff - < "${patchfile}" &> "${outputfile}")
&& scripts/checkpatch.pl --no-tree --no-signoff --strict - < "${patchfile}" &> "${outputfile}")
else
echo "Running checkpatch on the SCST kernel patches ..."
rm -f "${outputfile}"
( cd "${outputdir}/linux-$1" \
&& for p in "${outputdir}/${patchdir}"/*
do
echo "==== $p" >>"${outputfile}"
scripts/checkpatch.pl --no-tree --no-signoff - < "$p" >> "${outputfile}" 2>&1
scripts/checkpatch.pl --no-tree --no-signoff --strict - < "$p" >> "${outputfile}" 2>&1
done
)
fi

errors=$(grep -c '^ERROR' "${outputfile}")
warnings=$(grep -c '^WARNING' "${outputfile}")
echo "${errors} errors / ${warnings} warnings."
grep -E '^WARNING|^ERROR' "${outputfile}" |
checks=$(grep -c '^CHECK' "${outputfile}")

echo "${errors} errors / ${warnings} warnings / ${checks} checks."

grep -E '^WARNING|^ERROR|^CHECK' "${outputfile}" |
sort |
grep -v 'WARNING: missing space after return type' |
sed 's/^WARNING: Avoid CamelCase:.*/WARNING: Avoid CamelCase/' |
sed 's/^CHECK: Avoid CamelCase:.*/CHECK: Avoid CamelCase/' |
uniq -c
else
echo "Skipping checkpatch step for kernel $1."
Expand Down

0 comments on commit 1925094

Please sign in to comment.