From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gandalf.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by passt.top (Postfix) with ESMTPS id 58CEA5A0271 for ; Tue, 27 Feb 2024 22:25:20 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202312; t=1709069116; bh=+t3bhom7WFKI/aWPOjHehEA5Z46AfROby0kQmtPxNsE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=e4M+jL2KKKxVayRvpjXYqDW9IJcT9l1xV7eH39sToQdZb3NLL8353XHTj+9IPhmfF IoIB/M1WPBjw8uQI5eLkjPbKjRfO3+LNgSNhFNsE+NO4KIr0nZ2mY6mEO1OCmTp/Xm C8ZdHo4tCAa7faZPuI5eBbtxVaNdDgszJq4aVf0ZjAWn63JETROl7IQBurxO/sKR7R Qkez1yfes3tLrRlCsdpFFzoks26865V9klw0NHoMCrv8jMaLl665/4upNazakKJZfi Tf0Q5DHjkLbDC50xl2VOikbgCZCaDpG6UbgpibTwsa4E2C7SF6o14UfZvR2hT2N3TK 0tSxlBH1S4NnQ== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4Tkr9m30K1z4wc6; Wed, 28 Feb 2024 08:25:16 +1100 (AEDT) Date: Wed, 28 Feb 2024 08:24:49 +1100 From: David Gibson To: Stefano Brivio Subject: Re: [PATCH] Makefile: check for cppcheck's --check-level option in cppcheck target Message-ID: References: <20240227162947.2442020-1-sbrivio@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="CvyCJem75aeByVV8" Content-Disposition: inline In-Reply-To: <20240227162947.2442020-1-sbrivio@redhat.com> Message-ID-Hash: 5HLQMUHP3FLHWYSQHBTOLSDZE3LJBYH2 X-Message-ID-Hash: 5HLQMUHP3FLHWYSQHBTOLSDZE3LJBYH2 X-MailFrom: dgibson@gandalf.ozlabs.org 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: passt-dev@passt.top, Rahil Bhimjiani 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: --CvyCJem75aeByVV8 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Feb 27, 2024 at 05:29:47PM +0100, Stefano Brivio wrote: > Don't run cppcheck to find out if the --check-level=3Dexhaustive option > is available, unless we're actually going to run cppcheck later. >=20 > 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. >=20 > Reported-by: Rahil Bhimjiani > Link: https://bugs.gentoo.org/920795 > Fixes: 8640d62af719 ("cppcheck: Use "exhaustive" level checking when avai= lable") > Signed-off-by: Stefano Brivio > --- > Makefile | 10 +++++----- > 1 file changed, 5 insertions(+), 5 deletions(-) >=20 > diff --git a/Makefile b/Makefile > index af4fa87..75d0bf3 100644 > --- a/Makefile > +++ b/Makefile > @@ -287,17 +287,17 @@ clang-tidy: $(SRCS) $(HEADERS) > -config=3D'{CheckOptions: [{key: bugprone-suspicious-string-compare.War= nOnImplicitComparison, value: "false"}]}' \ > --warnings-as-errors=3D* $(SRCS) -- $(filter-out -pie,$(FLAGS) $(CFLAGS= ) $(CPPFLAGS)) -DCLANG_TIDY_58992 > =20 > -CPPCHECK_EXHAUSTIVE :=3D > -ifeq ($(shell cppcheck --check-level=3Dexhaustive /dev/null > /dev/null = 2>&1; echo $$?),0) > - CPPCHECK_EXHAUSTIVE +=3D --check-level=3Dexhaustive > -endif > - > SYSTEM_INCLUDES :=3D /usr/include $(wildcard /usr/include/$(TARGET)) > ifeq ($(shell $(CC) -v 2>&1 | grep -c "gcc version"),1) > VER :=3D $(shell $(CC) -dumpversion) > SYSTEM_INCLUDES +=3D /usr/lib/gcc/$(TARGET)/$(VER)/include > endif > cppcheck: $(SRCS) $(HEADERS) > + if cppcheck --check-level=3Dexhaustive /dev/null > /dev/null 2>&1; then= \ > + CPPCHECK_EXHAUSTIVE=3D"--check-level=3Dexhaustive"; \ > + else \ > + CPPCHECK_EXHAUSTIVE=3D; \ > + fi; \ > cppcheck --std=3Dc11 --error-exitcode=3D1 --enable=3Dall --force \ > --inconclusive --library=3Dposix --quiet \ > $(CPPCHECK_EXHAUSTIVE) \ IIUC, this is essentially moving CPPCHECK_EXHAUSTIVE from a make variable to a shell variable in the shell that make invokes. Which is fine, but I believe $(CPPCHECK_EXHAUSTIVE) will only expand to a make variable. To get the shell variable you'll need $${CPPCHECK_EXHAUSTIVE}. I suspect as written, this will always expand empty. --=20 David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson --CvyCJem75aeByVV8 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmXeUyAACgkQzQJF27ox 2GdD9A//UgzgpCTNnYnd1s+Fk02TAQhHwKcCXtA/SoixqrR/Op9Eg5zfPUfryl2P oUVHemTqTA49uVj9/DOBLrYeM/rbNZ7wQ9R7f0Nfzyq6+exV18jjJrykR8gIBGZG FpZO3KqdPeBEJq5j/C3UDP+fXSkib95ZQUy4T6qmijqsXdQGYZ0TaK00xK2uw9n5 CEWfKYV1yFepLIR+6SygH2+FnkomuVrncbdLExp59/chlVjtNsdqBDgDwnD+PFZK ku1g+jOZkgq908w6XkkKa8Haq/tWXgUXC2lWThIhtnSQipPp9G0Ip48iijy6rsp5 hshhGxy7oq7i0VBMnqPZxiZJizB2+ogm7e804WQ2WFmQ92zgujH2aC90TQiKH41P k+Cs+UsDkGLi5TvDwfRSuVipev9LtQinr2PfpCgbXXBLK6fil7dyU91dANIUZZjK WgVavTPOWmKhq0rTtJVoHPalNhIoM1orJ5+xFsYJv/QRvTkUqBWtk4RDef/wPcMy B1qcjoy/ImLNkFXHELO+2tM0VaLFL5ILPlKekH1XtSuUrEmo1xjCUet+CfkWJCe3 p1NzVMvYWo/7gSCaYjwb5P6wyxu+fR1nhdtNutovnE9QR/xTSfCc8RbsGloMpgtL MJBNVMzItighQLxRGGA1yWBTMWO/mzikEcfyjhCrqhROosq81Ko= =M0pJ -----END PGP SIGNATURE----- --CvyCJem75aeByVV8--