From b356b62e04d4b5b862c5561229e00425f1ca3dd9 Mon Sep 17 00:00:00 2001 From: David Gibson Date: Tue, 12 May 2026 15:52:51 +1000 Subject: cppcheck, clang-tidy: Static checkers don't need non-preprocessor flags Currently we pass all our compiler flags to clang-tidy, except -pie, which it won't accept. In fact in order to run the checker, we only need the preprocessor flags. Simplify the command line by passing only those. For cppcheck we already filter out just -D options from the compiler flags. Simplify this by only passing preprocessor flags, now that we've split those out into their own variables. Furthermore, one of cppcheck's features which we're currently not exploiting is to check multiple / all preprocessor option combinations in a single pass. Therefore, pass only $(BASE_CPPFLAGS), which contains the mandatory options with which we can't compile at all. While we're there remove a redundant $^ that slipped in at some point. Signed-off-by: David Gibson Signed-off-by: Stefano Brivio --- Makefile | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 3bc5c35..2b5d49a 100644 --- a/Makefile +++ b/Makefile @@ -194,9 +194,7 @@ CLANG_TIDY = clang-tidy CLANG_TIDY_FLAGS = -DCLANG_TIDY_58992 clang-tidy: $(PASST_SRCS) - $(CLANG_TIDY) $^ -- \ - $(filter-out -pie,$(BASE_CPPFLAGS) $(CPPFLAGS) $(BASE_CFLAGS) $(CFLAGS)) \ - $(CLANG_TIDY_FLAGS) + $(CLANG_TIDY) $^ -- $(BASE_CPPFLAGS) $(CPPFLAGS) $(CLANG_TIDY_FLAGS) CPPCHECK = cppcheck CPPCHECK_FLAGS = --std=c11 --error-exitcode=1 --enable=all --force \ @@ -212,6 +210,4 @@ CPPCHECK_FLAGS = --std=c11 --error-exitcode=1 --enable=all --force \ -D CPPCHECK_6936 cppcheck: $(PASST_SRCS) $(PASST_HEADERS) seccomp.h - $(CPPCHECK) $(CPPCHECK_FLAGS) \ - $(filter -D%,$(BASE_CPPFLAGS) $(CPPFLAGS) $(BASE_CFLAGS) $(CFLAGS)) $^ \ - $^ + $(CPPCHECK) $(CPPCHECK_FLAGS) $(BASE_CPPFLAGS) $^ -- cgit v1.2.3