From: Jan Kiszka <
jan.k...@siemens.com>
This drops a couple of suppressions that are no longer needed with the
version 2.13.0 using in CI. At the same time, it adds some that become
necessary with newer 2.17.x as found in Debian 13, enables exhaustive
check level, and brings parallel checking.
For parallel checking, we now need a build dir which is created as
tempdir and deleted after cppcheck execution.
A few extra suppressions are then needed only for the old 2.13 version.
Those are guarded by a version check so that they do not shadow real
issues with new cppcheck.
Signed-off-by: Jan Kiszka <
jan.k...@siemens.com>
---
.github/workflows/main.yaml | 2 +-
scripts/cppcheck.sh | 43 ++++++++++++++++++++++++-------------
2 files changed, 29 insertions(+), 16 deletions(-)
diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml
index 6e192d7..4f73b04 100644
--- a/.github/workflows/main.yaml
+++ b/.github/workflows/main.yaml
@@ -111,7 +111,7 @@ jobs:
if: ${{ matrix.target == 'cppcheck' }}
run: |
sudo apt-get update
- sudo apt-get install --no-install-recommends cppcheck
+ sudo apt-get install --no-install-recommends cppcheck mdm
- name: Prepare build
run: |
diff --git a/scripts/cppcheck.sh b/scripts/cppcheck.sh
index d6e4aba..1a7c333 100755
--- a/scripts/cppcheck.sh
+++ b/scripts/cppcheck.sh
@@ -25,32 +25,38 @@ suppress+=" --suppress=*:/usr/include/bits/*"
# Function 'efi_main' is called by efi:
suppress+=" --suppress=unusedFunction:main.c"
suppress+=" --suppress=unusedFunction:kernel-stub/main.c"
+# Usage of register_driver is not understood:
+suppress+=" --suppress=unusedFunction:drivers/watchdog/wdat.c"
# Some functions are defined for API only
-suppress+=" --suppress=unusedFunction:utils.c"
suppress+=" --suppress=unusedFunction:env/env_api.c"
suppress+=" --suppress=unusedFunction:env/fatvars.c"
+# False positive, ped_device_get_next_custom_fake is used for testing
suppress+=" --suppress=unusedFunction:tools/tests/fake_devices.c"
-suppress+=" --suppress=unusedFunction:tools/tests/test_environment.c"
-suppress+=" --suppress=unusedFunction:env/env_api_fat.c"
-# Some functions are used by linker wrapping
-suppress+=" --suppress=unusedFunction:tools/tests/test_probe_config_file.c"
-suppress+=" --suppress=unusedFunction:tools/tests/test_ebgenv_api.c"
-# False positive on wdfuncs iteration
-suppress+=" --suppress=comparePointers:main.c"
-# False positive on constructors, first hit
-suppress+=" --suppress=unusedFunction:drivers/watchdog/amdfch_wdt.c"
-# False positive, noreturn is not recognized
-suppress+=" --suppress=nullPointerRedundantCheck:kernel-stub/main.c"
# Avoid noise regarding Ignore* or otherwise unused fields
suppress+=" --suppress=unusedStructMember:kernel-stub/main.c"
suppress+=" --suppress=unusedStructMember:kernel-stub/fdt.c"
# Not applicable because of API requirements
+suppress+=" --suppress=constParameterPointer:drivers/watchdog/ipcbx21a.c"
suppress+=" --suppress=constParameterPointer:drivers/watchdog/ipc4x7e_wdt.c"
suppress+=" --suppress=constParameterPointer:drivers/watchdog/w83627hf_wdt.c"
+suppress+=" --suppress=constParameterPointer:env/env_api.c"
# Not applicable because of API requirements
suppress+=" --suppress=constParameterCallback:kernel-stub/initrd.c"
-enable="--enable=warning \
+# Suppressions only needed for older cppcheck
+if [ $( (cppcheck --version | cut -d' ' -f2; echo "2.17") | sort -V | head -1 ) != "2.17" ]; then
+ # Some functions are used by linker wrapping
+ suppress+=" --suppress=unusedFunction:tools/tests/test_probe_config_file.c"
+ suppress+=" --suppress=unusedFunction:tools/tests/test_ebgenv_api.c"
+ # Unclear reasons
+ suppress+=" --suppress=unusedFunction:tools/fat.c"
+ suppress+=" --suppress=unusedFunction:tools/tests/test_uservars.c"
+ suppress+=" --suppress=unusedFunction:tools/tests/test_ebgenv_api.c"
+ suppress+=" --suppress=unusedFunction:tools/tests/test_probe_config_file.c"
+fi
+
+enable="--check-level=exhaustive \
+ --enable=warning \
--enable=style \
--enable=performance \
--enable=portability \
@@ -68,7 +74,14 @@ includes="-I . \
cpp_conf="-U__WINT_TYPE__ -U__GNUC__"
path=${1-.}
+build_tmp=$(mktemp -d)
+
# Exit code '1' is returned if arguments are not valid or if no input
# files are provided. Compare 'cppcheck --help'.
-cppcheck -f -q --error-exitcode=2 $enable $suppress $ignore \
- $cpp_conf $includes $path "$@"
+cppcheck -f -q --error-exitcode=2 \
+ -j $(ncpus) --cppcheck-build-dir="$build_tmp" \
+ $enable $suppress $ignore $cpp_conf $includes $path "$@"
+res=$?
+
+rm -r "$build_tmp"
+exit $res
--
2.47.3