From 627e18fa8ad000ed92405cff3a88c36fd5f3027e Mon Sep 17 00:00:00 2001 From: Stefano Brivio Date: Thu, 21 Oct 2021 09:41:13 +0200 Subject: passt: Add cppcheck target, test, and address resulting warnings ...mostly false positives, but a number of very relevant ones too, in tcp_get_sndbuf(), tcp_conn_from_tap(), and siphash PREAMBLE(). Signed-off-by: Stefano Brivio --- Makefile | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 9e7651b..32cc1d5 100644 --- a/Makefile +++ b/Makefile @@ -141,7 +141,7 @@ pkgs: # # - bugprone-suspicious-string-compare # Return value of memcmp(), not really suspicious -clang-tidy: $(wildcard *.c) +clang-tidy: $(wildcard *.c) $(wildcard *.h) clang-tidy -checks=*,-modernize-*,\ -clang-analyzer-valist.Uninitialized,\ -cppcoreguidelines-init-variables,\ @@ -163,3 +163,33 @@ clang-tidy: $(wildcard *.c) -cppcoreguidelines-avoid-non-const-global-variables,\ -bugprone-suspicious-string-compare \ --warnings-as-errors=* $(wildcard *.c) -- $(CFLAGS) + +ifeq ($(shell $(CC) -v 2>&1 | grep -c "gcc version"),1) +TARGET := $(shell ${CC} -v 2>&1 | sed -n 's/Target: \(.*\)/\1/p') +VER := $(shell $(CC) -dumpversion) +EXTRA_INCLUDES := /usr/lib/gcc/$(TARGET)/$(VER)/include +EXTRA_INCLUDES_OPT := -I$(EXTRA_INCLUDES) +else +EXTRA_INCLUDES_OPT := +endif +cppcheck: $(wildcard *.c) $(wildcard *.h) + cppcheck --std=c99 --error-exitcode=1 --enable=all --force \ + --inconclusive --library=posix \ + -I/usr/include $(EXTRA_INCLUDES_OPT) \ + --suppress=missingIncludeSystem \ + --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=va_list_usedBeforeStarted:util.c \ + --suppress=unusedFunction:igmp.c \ + --suppress=unusedFunction:siphash.c \ + --suppress=knownConditionTrueFalse:conf.c \ + --suppress=strtokCalled:conf.c --suppress=strtokCalled:qrap.c \ + --suppress=getpwnamCalled:passt.c \ + --suppress=localtimeCalled:pcap.c \ + --suppress=unusedStructMember:pcap.c \ + --suppress=funcArgNamesDifferent:util.h \ + . -- cgit v1.2.3