make: Add CPPCHECK_OPTS to allow excluding files from the check

With swig we now have C files that are generated with tools that are
not under our control, so provide an escape hatch for them.
This commit is contained in:
Christian Decker 2021-04-28 15:05:43 +02:00 committed by Rusty Russell
parent a4c19ba6ba
commit 6c67afeb03
2 changed files with 7 additions and 2 deletions

View File

@ -84,6 +84,10 @@ PYTHONPATH=$(shell pwd)/contrib/pyln-client:$(shell pwd)/contrib/pyln-testing:$(
# Collect generated python files to be excluded from lint checks # Collect generated python files to be excluded from lint checks
PYTHON_GENERATED= PYTHON_GENERATED=
# Options to pass to cppcheck. Mostly used to exclude files that are
# generated with external tools that we don't have control over
CPPCHECK_OPTS=-q --language=c --std=c11 --error-exitcode=1 --suppressions-list=.cppcheck-suppress --inline-suppr
# This is where we add new features as bitcoin adds them. # This is where we add new features as bitcoin adds them.
FEATURES := FEATURES :=
@ -471,10 +475,10 @@ check-includes: check-src-includes check-hdr-includes
# cppcheck gets confused by list_for_each(head, i, list): thinks i is uninit. # cppcheck gets confused by list_for_each(head, i, list): thinks i is uninit.
.cppcheck-suppress: .cppcheck-suppress:
@git ls-files -- "*.c" "*.h" | grep -vE '^ccan/' | xargs grep -n '_for_each' | sed 's/\([^:]*:.*\):.*/uninitvar:\1/' > $@ @git ls-files -- "*.c" "*.h" | grep -vE '^(ccan|contrib)/' | xargs grep -n '_for_each' | sed 's/\([^:]*:.*\):.*/uninitvar:\1/' > $@
check-cppcheck: .cppcheck-suppress check-cppcheck: .cppcheck-suppress
@trap 'rm -f .cppcheck-suppress' 0; git ls-files -- "*.c" "*.h" | grep -vE '^ccan/' | xargs cppcheck -q --language=c --std=c11 --error-exitcode=1 --suppressions-list=.cppcheck-suppress --inline-suppr @trap 'rm -f .cppcheck-suppress' 0; git ls-files -- "*.c" "*.h" | grep -vE '^ccan/' | xargs cppcheck ${CPPCHECK_OPTS}
check-shellcheck: check-shellcheck:
@git ls-files -- "*.sh" | xargs shellcheck @git ls-files -- "*.sh" | xargs shellcheck

View File

@ -4,6 +4,7 @@ LIBHSMD_PY_GEN_FILES := contrib/libhsmd_python/swig_wrap.c \
contrib/libhsmd_python/libhsmd.py contrib/libhsmd_python/libhsmd.py
PYTHON_GENERATED += contrib/libhsmd_python/libhsmd.py PYTHON_GENERATED += contrib/libhsmd_python/libhsmd.py
CPPCHECK_OPTS += --suppress=nullPointer:contrib/libhsmd_python/swig_wrap.c
# Swig by default generates stubs in the file's directory, which is # Swig by default generates stubs in the file's directory, which is
# what we want. # what we want.