From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=none (p=none dis=none) header.from=gibson.dropbear.id.au Authentication-Results: passt.top; dkim=pass (2048-bit key; secure) header.d=gibson.dropbear.id.au header.i=@gibson.dropbear.id.au header.a=rsa-sha256 header.s=202602 header.b=FjwA1n8M; dkim-atps=neutral Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id 337975A026E for ; Tue, 05 May 2026 16:41:24 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202602; t=1777992079; bh=q6XXS72wtcXEEHalwqGaIB9mn8mfTy9c7gDi0KnreqY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=FjwA1n8MNyTqRLigg4cuxHoWbxCPBTNnro+El0MlCnwV8AC0v4coZA8rSDyQVeDIS OCrLfHR61NvQ/64q1sFeNZ17fiuEQTo3X3pA6LT2Qd3/6NI191k4XuMMcd76R2YqkI nYCjQKs8t1X6WqbB690bJWM6UbAnbVLLgg2N7uEF3DhuWuA54tXcsJTdtm1uDpzO78 sqMlFSHIyaYvKnZwg9htO+vZPR4DyZfdTuSrWVB7kO8cHUul0hqhEMSPPxgUlH6UAs ErkADLbqEZOIupyaHpC3cLbOt7CZlFpiWdQgnooO/WT+PM2lPpLPK3I2uEl4ehlWpB gOI3tY2dWE9fA== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4g91RM6DJ2z4wJ1; Wed, 06 May 2026 00:41:19 +1000 (AEST) Date: Wed, 6 May 2026 00:04:30 +1000 From: David Gibson To: Laurent Vivier Subject: Re: [PATCH v2 01/13] Makefile: Use make variables for static checker configuration Message-ID: References: <20260421032338.1909084-1-david@gibson.dropbear.id.au> <20260421032338.1909084-2-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="ggIbTOZJZMRyDzym" Content-Disposition: inline In-Reply-To: Message-ID-Hash: TATPBMLKLLLNJHRUJ4XQ2NQ6JFYWUSIR X-Message-ID-Hash: TATPBMLKLLLNJHRUJ4XQ2NQ6JFYWUSIR 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: Stefano Brivio , passt-dev@passt.top 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: --ggIbTOZJZMRyDzym Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, May 05, 2026 at 12:14:02PM +0200, Laurent Vivier wrote: > On 4/21/26 05:23, David Gibson wrote: > > Our cppcheck and clang-tidy rules don't really follow normal Makefile > > conventions. Usually any commands other than the very basics have their > > binary specified in a variable so it can be overridden on the command l= ine > > if they're in an unusual location. Implement that for $(CPPCHECK) and > > $(CLANG_TIDY) > >=20 > > Likewise flags to tools usually have their own Make variable. Do the s= ame > > with $(CLANG_TIDY_FLAGS) and $(CPPCHECK_FLAGS). Note that these only h= ave > > the options specifically for the static checker, not compiler flags whi= ch > > we are also supplying to the static checker - those are derived from > > FLAGS / CFLAGS / CPPFLAGS as before. > >=20 > > As part of that we change the probing for --check-level=3Dexhaustive fr= om > > being run as part of the cppcheck target, to being run when we build the > > CPPCHECK_FLAGS variable. That doesn't make any real difference now, but > > will make things nicer if we need multiple cppcheck targets in future (= e.g. > > for passt-repair). > >=20 > > Signed-off-by: David Gibson > > --- > > Makefile | 32 +++++++++++++++++++------------- > > 1 file changed, 19 insertions(+), 13 deletions(-) > >=20 > > diff --git a/Makefile b/Makefile > > index f697c12b..17e70d22 100644 > > --- a/Makefile > > +++ b/Makefile > > @@ -174,21 +174,27 @@ docs: README.md > > done < README.md; \ > > ) > README.plain.md > > +CLANG_TIDY =3D clang-tidy > > +CLANG_TIDY_FLAGS =3D -DCLANG_TIDY_58992 > > + > > clang-tidy: $(PASST_SRCS) > > - clang-tidy $^ -- $(filter-out -pie,$(FLAGS) $(CFLAGS) $(CPPFLAGS)) \ > > - -DCLANG_TIDY_58992 > > + $(CLANG_TIDY) $^ -- $(filter-out -pie,$(FLAGS) $(CFLAGS) $(CPPFLAGS))= \ > > + $(CLANG_TIDY_FLAGS) > > -cppcheck: $(PASST_SRCS) $(HEADERS) > > - if cppcheck --check-level=3Dexhaustive /dev/null > /dev/null 2>&1; th= en \ > > - CPPCHECK_EXHAUSTIVE=3D"--check-level=3Dexhaustive"; \ > > - else \ > > - CPPCHECK_EXHAUSTIVE=3D; \ > > - fi; \ > > - cppcheck --std=3Dc11 --error-exitcode=3D1 --enable=3Dall --force \ > > +CPPCHECK =3D cppcheck > > +CPPCHECK_FLAGS =3D --std=3Dc11 --error-exitcode=3D1 --enable=3Dall --f= orce \ > > --inconclusive --library=3Dposix --quiet \ > > - $${CPPCHECK_EXHAUSTIVE} \ > > --inline-suppr \ > > - --suppress=3DmissingIncludeSystem \ > > + $(shell if $(CPPCHECK) --quiet --check-level=3Dexhaustive /dev/null; = then \ > > + echo "--check-level=3Dexhaustive"; \ > > + else \ > > + echo ""; \ > > + fi) =09 >=20 > Perhaps we can add a reusable function to check flags: >=20 > check_flag =3D $(shell $(1) $(2) >/dev/null 2>&1 && echo $(2)) >=20 > Then > $(call check_flag, $(CPPCHECK) /dev/null, --check-level=3Dexhaustive) We could, but that seems orthogonal to what I'm trying to accomplish here. > > + --suppress=3DmissingIncludeSystem \ > > --suppress=3DunusedStructMember \ > > - $(filter -D%,$(FLAGS) $(CFLAGS) $(CPPFLAGS)) -D CPPCHECK_6936 \ > > - $^ > > + -D CPPCHECK_6936 > > + > > +cppcheck: $(PASST_SRCS) $(HEADERS) > > + $(CPPCHECK) $(CPPCHECK_FLAGS) \ > > + $(filter -D%,$(FLAGS) $(CFLAGS) $(CPPFLAGS)) $^ \ > > + $^ >=20 > You have duplicate '$^' here. Oops, that's a bug. --=20 David Gibson (he or they) | 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 --ggIbTOZJZMRyDzym Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmn5+OEACgkQzQJF27ox 2Gc1GQ//QcG3irRGfTjygXplhEFIIqxIq6iFZfOe4ow7GePEmANLirjjV/nNsLk5 kRkBLtIfNbjZOAFR02cN/cygWJ/7frpsYmECrj38k0TtZZvq4alcUMRYaFLfTpBS 1bbt5Jpj7PEDciqF+51542VfvRG74rH209amGWWGhNv8b4IoolIA9yisqqoTmNwV +HsFhFuVn2JYOAFyexc7i4zmnnZaM1V9fqsy4932zB9KJ7TvyVjAmN/2fFdWA6nE v+xs4+U1PRtoOU88otUK8DyajK1lubZj4cYSQy6k2yBqMBTf4t/WuuAPbgVwTe0i U8uYDQuMmcdVbupr38qti3G7ELu+UuQfknmis+xlmhn4lwkEM9AXeu6MKdRM4a0w sgR898CiUwJk9Jn9XOupMDxGtc1WHgxboC+3ALnyHqxKdKoFQXxozyR4/Xl6K6tX K0mkSe0BtnjtOMj6AKMMJ0NtBKxd08xYDitQ9I2B8S21MRh/H6rP5V1PUGRQ9JlI k8C2twEcFv0jGrb1bmS2c5V2WRhO/g91IlyInWYiugJbjzIeKhEE9Ji6QNxHAfkd 6+46gx59wVmsC3rVBeE0QZk+zd3MOgXe+7tyGjihfEvZPAkV3NYyxabXSppiaC2H 9yrL9FdqU4A6uGUoOEbRTbOMAsVjAXXUZv+OffL1SzEG5XXsGVU= =+fiA -----END PGP SIGNATURE----- --ggIbTOZJZMRyDzym--