From 1925094cb04f19de3ceb419a2fe40dc52db66169 Mon Sep 17 00:00:00 2001 From: Gleb Chesnokov Date: Tue, 1 Oct 2024 12:45:10 +0300 Subject: [PATCH] .github/workflows, scripts: Improve checkpatch compliance Use checkpatch --strict to detect more style issues. --- .github/workflows/checkpatch_pull.yml | 2 +- .github/workflows/checkpatch_push.yml | 2 +- scripts/checkpatch | 24 ++++++++++++++---------- scripts/run-regression-tests | 14 +++++++++----- 4 files changed, 25 insertions(+), 17 deletions(-) diff --git a/.github/workflows/checkpatch_pull.yml b/.github/workflows/checkpatch_pull.yml index b19aa58e5..50c23267a 100644 --- a/.github/workflows/checkpatch_pull.yml +++ b/.github/workflows/checkpatch_pull.yml @@ -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 diff --git a/.github/workflows/checkpatch_push.yml b/.github/workflows/checkpatch_push.yml index 12b692470..ac3755ed0 100644 --- a/.github/workflows/checkpatch_push.yml +++ b/.github/workflows/checkpatch_push.yml @@ -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// /,}" - diff --git a/scripts/checkpatch b/scripts/checkpatch index 8cdcfcd4b..40937e523 100755 --- a/scripts/checkpatch +++ b/scripts/checkpatch @@ -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:/' diff --git a/scripts/run-regression-tests b/scripts/run-regression-tests index e87bb64f4..05b81a6c7 100755 --- a/scripts/run-regression-tests +++ b/scripts/run-regression-tests @@ -231,7 +231,7 @@ 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}" @@ -239,17 +239,21 @@ function run_checkpatch { && 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."