From mboxrd@z Thu Jan 1 00:00:00 1970 Received: by passt.top (Postfix, from userid 1000) id 510335A0277; Tue, 27 Feb 2024 17:29:47 +0100 (CET) From: Stefano Brivio To: passt-dev@passt.top Subject: [PATCH] Makefile: check for cppcheck's --check-level option in cppcheck target Date: Tue, 27 Feb 2024 17:29:47 +0100 Message-Id: <20240227162947.2442020-1-sbrivio@redhat.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: NO64H6G2KHGPPEEEFOVTZ6ZICAIKBLGB X-Message-ID-Hash: NO64H6G2KHGPPEEEFOVTZ6ZICAIKBLGB X-MailFrom: sbrivio@passt.top X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Rahil Bhimjiani , David Gibson X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Don't run cppcheck to find out if the --check-level=exhaustive option is available, unless we're actually going to run cppcheck later. To avoid this, move this check under the cppcheck target, and implement it in shell script instead of using Makefile directives, because we can't easily implement conditionals in recipes. Reported-by: Rahil Bhimjiani Link: https://bugs.gentoo.org/920795 Fixes: 8640d62af719 ("cppcheck: Use "exhaustive" level checking when available") Signed-off-by: Stefano Brivio --- Makefile | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index af4fa87..75d0bf3 100644 --- a/Makefile +++ b/Makefile @@ -287,17 +287,17 @@ clang-tidy: $(SRCS) $(HEADERS) -config='{CheckOptions: [{key: bugprone-suspicious-string-compare.WarnOnImplicitComparison, value: "false"}]}' \ --warnings-as-errors=* $(SRCS) -- $(filter-out -pie,$(FLAGS) $(CFLAGS) $(CPPFLAGS)) -DCLANG_TIDY_58992 -CPPCHECK_EXHAUSTIVE := -ifeq ($(shell cppcheck --check-level=exhaustive /dev/null > /dev/null 2>&1; echo $$?),0) - CPPCHECK_EXHAUSTIVE += --check-level=exhaustive -endif - SYSTEM_INCLUDES := /usr/include $(wildcard /usr/include/$(TARGET)) ifeq ($(shell $(CC) -v 2>&1 | grep -c "gcc version"),1) VER := $(shell $(CC) -dumpversion) SYSTEM_INCLUDES += /usr/lib/gcc/$(TARGET)/$(VER)/include endif cppcheck: $(SRCS) $(HEADERS) + if cppcheck --check-level=exhaustive /dev/null > /dev/null 2>&1; then \ + CPPCHECK_EXHAUSTIVE="--check-level=exhaustive"; \ + else \ + CPPCHECK_EXHAUSTIVE=; \ + fi; \ cppcheck --std=c11 --error-exitcode=1 --enable=all --force \ --inconclusive --library=posix --quiet \ $(CPPCHECK_EXHAUSTIVE) \ -- 2.39.2