@@ -55,16 +55,16 @@ clean:
5555
5656clang_supports_unsafe_buffer_usage := $(shell clang -x c -c /dev/null -o /dev/null -Werror -Wunsafe-buffer-usage > /dev/null 2>&1; echo $$? )
5757ifeq ($(clang_supports_unsafe_buffer_usage ) ,0)
58- extra_clang_flags := -Wno-unsafe-buffer-usage
58+ extra_clang_flags := -Wno-unsafe-buffer-usage -Wno-missing-include-dirs
5959else
60- extra_clang_flags :=
60+ extra_clang_flags := -Wno-missing-include-dirs
6161endif
6262
6363c_analyse_targets := $(c_files:%=%-analyse )
6464h_analyse_targets := $(h_files:%=%-analyse )
6565
6666analyse : CFLAGS+=$(debug_cflags )
67- analyse : $(c_analyse_targets ) $(h_analyse_targets )
67+ analyse : cppcheck $(c_analyse_targets ) $(h_analyse_targets )
6868
6969$(c_analyse_targets ) : % -analyse:
7070 # -W options here are not clang compatible, so out of generic CFLAGS
@@ -90,20 +90,39 @@ $(h_analyse_targets): %-analyse:
9090 $(MAKE ) $* -shared-analyse
9191
9292% -shared-analyse : %
93- # cppcheck is a bit dim about unused functions/variables, leave that to
94- # clang/GCC
95- cppcheck $< --std=c99 --quiet --inline-suppr --force \
96- --enable=all --suppress=missingIncludeSystem \
97- --suppress=unusedFunction --suppress=unmatchedSuppression \
98- --suppress=unreadVariable \
99- --suppress=checkersReport \
100- --suppress=normalCheckLevelMaxBranches \
101- --suppress=unusedStructMember \
102- --max-ctu-depth=32 --error-exitcode=1
10393 # clang-analyzer-unix.Malloc does not understand _drop_()
10494 clang-tidy $< --quiet -checks=-clang-analyzer-unix.Malloc -- -std=gnu99
10595 clang-format --dry-run --Werror $<
10696
97+ # --suppress=missingIncludeSystem:
98+ #
99+ # Without this there's a bunch of noise from cppcheck from the system headers
100+ # themselves.
101+ #
102+ # --suppress=unusedFunction:
103+ #
104+ # cppcheck does not understand _drop_ and marks those as unused. This is
105+ # already well checked by Clang/GCC, just leave it to them.
106+ #
107+ # --suppress=unmatchedSuppression:
108+ #
109+ # We run both locally and on CI, so there may be some suppressions that
110+ # depending on version do not match in one version but do on another.
111+ #
112+ # --suppress=unusedStructMember
113+ #
114+ # Structs are used across translation units and cppcheck gets this wrong.
115+ cppcheck : $(c_files ) $(h_files )
116+ cppcheck $(c_files ) $(h_files ) --std=c99 --quiet --inline-suppr --force \
117+ --enable=all \
118+ --suppress=missingIncludeSystem \
119+ --suppress=unusedFunction \
120+ --suppress=unmatchedSuppression \
121+ --suppress=checkersReport \
122+ --suppress=unusedStructMember \
123+ --check-level=exhaustive \
124+ --max-ctu-depth=10 --error-exitcode=1
125+
107126tests : tests/test_store
108127 tests/test_store
109128
@@ -113,4 +132,5 @@ integration_tests:
113132tests/test_store : tests/test_store.c src/store.o src/util.o
114133 $(CC ) $(CFLAGS ) $(CPPFLAGS ) -I./src -o $@ $^ $(LDLIBS )
115134
116- .PHONY : all debug install uninstall clean analyse tests integration_tests
135+ .PHONY : all debug install uninstall clean analyse tests integration_tests \
136+ cppcheck
0 commit comments