diff options
author | Stefano Brivio <sbrivio@redhat.com> | 2021-10-21 09:41:13 +0200 |
---|---|---|
committer | Stefano Brivio <sbrivio@redhat.com> | 2021-10-21 09:41:13 +0200 |
commit | 627e18fa8ad000ed92405cff3a88c36fd5f3027e (patch) | |
tree | 5caf72002139dd6bc80cd424de1730f8602cbb9d /Makefile | |
parent | c3f8e4d2cd55e57419478ff849265d1e342e7990 (diff) | |
download | passt-627e18fa8ad000ed92405cff3a88c36fd5f3027e.tar passt-627e18fa8ad000ed92405cff3a88c36fd5f3027e.tar.gz passt-627e18fa8ad000ed92405cff3a88c36fd5f3027e.tar.bz2 passt-627e18fa8ad000ed92405cff3a88c36fd5f3027e.tar.lz passt-627e18fa8ad000ed92405cff3a88c36fd5f3027e.tar.xz passt-627e18fa8ad000ed92405cff3a88c36fd5f3027e.tar.zst passt-627e18fa8ad000ed92405cff3a88c36fd5f3027e.zip |
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 <sbrivio@redhat.com>
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 32 |
1 files changed, 31 insertions, 1 deletions
@@ -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 \ + . |