cppcheck: Avoid excessive scanning due to system headers

make cppcheck takes a long time, because it checks a large number of
different configurations.  It's assembling this very large set of
configurations not because of conditionals in the passt code itself,
but from those in the system headers.  By adding --config-exclude
directives to stop considering those configs, make cppcheck becomes
around 60x faster on my system.

Similarly, any problems that are found in the system headers are not our
problem, and so we can uniformly suppress them, rather than having specific
suppressions for particular problems in particular files (which might not
be correct for all different distro / version combinations either).

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
This commit is contained in:
David Gibson 2022-09-26 20:43:43 +10:00 committed by Stefano Brivio
parent 1fcce70caa
commit d0629ff2b2

View file

@ -269,27 +269,19 @@ clang-tidy: $(SRCS) $(HEADERS)
-config='{CheckOptions: [{key: bugprone-suspicious-string-compare.WarnOnImplicitComparison, value: "false"}]}' \ -config='{CheckOptions: [{key: bugprone-suspicious-string-compare.WarnOnImplicitComparison, value: "false"}]}' \
--warnings-as-errors=* $(SRCS) -- $(filter-out -pie,$(FLAGS) $(CFLAGS)) --warnings-as-errors=* $(SRCS) -- $(filter-out -pie,$(FLAGS) $(CFLAGS))
SYSTEM_INCLUDES := /usr/include
ifeq ($(shell $(CC) -v 2>&1 | grep -c "gcc version"),1) ifeq ($(shell $(CC) -v 2>&1 | grep -c "gcc version"),1)
TARGET := $(shell ${CC} -v 2>&1 | sed -n 's/Target: \(.*\)/\1/p') TARGET := $(shell ${CC} -v 2>&1 | sed -n 's/Target: \(.*\)/\1/p')
VER := $(shell $(CC) -dumpversion) VER := $(shell $(CC) -dumpversion)
EXTRA_INCLUDES := /usr/lib/gcc/$(TARGET)/$(VER)/include SYSTEM_INCLUDES += /usr/lib/gcc/$(TARGET)/$(VER)/include
EXTRA_INCLUDES_OPT := -I$(EXTRA_INCLUDES)
else
EXTRA_INCLUDES_OPT :=
endif endif
cppcheck: $(SRCS) $(HEADERS) cppcheck: $(SRCS) $(HEADERS)
cppcheck --std=c99 --error-exitcode=1 --enable=all --force \ cppcheck --std=c99 --error-exitcode=1 --enable=all --force \
--inconclusive --library=posix \ --inconclusive --library=posix \
-I/usr/include $(EXTRA_INCLUDES_OPT) \ $(SYSTEM_INCLUDES:%=-I%) \
\ $(SYSTEM_INCLUDES:%=--config-exclude=%) \
--suppress=syntaxError:/usr/include/stdlib.h \ $(SYSTEM_INCLUDES:%=--suppress=*:%/*) \
--suppress=missingIncludeSystem \ $(SYSTEM_INCLUDES:%=--suppress=unmatchedSuppression:%/*) \
--suppress="*:$(EXTRA_INCLUDES)/avx512fintrin.h" \
--suppress="*:$(EXTRA_INCLUDES)/xmmintrin.h" \
--suppress="*:$(EXTRA_INCLUDES)/emmintrin.h" \
--suppress="*:$(EXTRA_INCLUDES)/avxintrin.h" \
--suppress="*:$(EXTRA_INCLUDES)/bmiintrin.h" \
\
--suppress=objectIndex:tcp.c --suppress=objectIndex:udp.c \ --suppress=objectIndex:tcp.c --suppress=objectIndex:udp.c \
--suppress=va_list_usedBeforeStarted:util.c \ --suppress=va_list_usedBeforeStarted:util.c \
--suppress=unusedFunction \ --suppress=unusedFunction \