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=SpcYZDKy; dkim-atps=neutral Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id D9A455A0265 for ; Wed, 06 May 2026 10:09:04 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202602; t=1778054942; bh=kdkmbq0MH1hWGHlfHFNnQexxA0Od/CH+1FhS/wuZRGI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=SpcYZDKy6ZQ9uH+bFMN7DvkEqLtSk+cMHEEn0F40q4YBSu67t7Bl7GXG+MHhHRulF XU9mJk2pGhdm4waSA8YwQG3Iq1XNvA8pLu3N8i4YRX0vxMla17xrjgWcfZBXYpePyW RZZo2GR57SuHl2nPX2nBBf0Xm9kgsUH6AffxXI61Pb+GmvO2voF6DRtCkDYOeYwz8a 4HlgAS+o9BE+8fq31jBWlU1KdqalPuWimg7hInfFNZ8F3kMAG1MukXIMtx6Loc7hKY xjMIV2nvj+SvinoudxdWu/9DydCE6LNZLqrrKiESo6wpYXDWlyFwCAMGWoBh7p8+tu dQ/3MsqTUD66g== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4g9ShG4WFmz4wL2; Wed, 06 May 2026 18:09:02 +1000 (AEST) Date: Wed, 6 May 2026 18:08:52 +1000 From: David Gibson To: Stefano Brivio Subject: Re: [PATCH v2 02/13] cppcheck: Split out essential defines into a BASE_CPPFLAGS variable Message-ID: References: <20260421032338.1909084-1-david@gibson.dropbear.id.au> <20260421032338.1909084-3-david@gibson.dropbear.id.au> <20260506094650.17090699@elisabeth> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="5CYSkKilx9HgCRr3" Content-Disposition: inline In-Reply-To: <20260506094650.17090699@elisabeth> Message-ID-Hash: ACMTAVRKXZICRMZ7DOJ3CKIDAXQKXS3Q X-Message-ID-Hash: ACMTAVRKXZICRMZ7DOJ3CKIDAXQKXS3Q 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 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: --5CYSkKilx9HgCRr3 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, May 06, 2026 at 09:46:51AM +0200, Stefano Brivio wrote: > On Tue, 21 Apr 2026 13:23:27 +1000 > David Gibson wrote: >=20 > > Our cppcheck target need certain flags from the compiler so that they it > > can analyse the code correctly. Currently we extract these rather > > awkwardly from FLAGS / CFLAGS / CPPFLAGS. But this means we inhibit one > > of cppcheck's features: by default it will attempt to analyse paths for= all > > combinations of compile time options, not just a single one. > >=20 > > Analysing *all* paths doesn't work for us because many of the -D option= s we > > use are essential to compile at all, so unless we supply those to cppch= eck, > > overriding the default behaviour we get many spurious errors. At the > > moment, however, we give cppcheck *all* our -D options, including > > conditional / configurable ones, not just the essential ones. > >=20 > > All cppcheck really needs here is those essential -D options. Split th= ose > > into a separate variable, and use that directly rather than the clunky > > $(filter) expression. > >=20 > > Signed-off-by: David Gibson > > --- > > Makefile | 14 ++++++++------ > > 1 file changed, 8 insertions(+), 6 deletions(-) > >=20 > > diff --git a/Makefile b/Makefile > > index 17e70d22..0de98375 100644 > > --- a/Makefile > > +++ b/Makefile > > @@ -30,11 +30,15 @@ ifeq ($(shell $(CC) -O2 -dM -E - < /dev/null 2>&1 |= grep ' _FORTIFY_SOURCE ' > / > > FORTIFY_FLAG :=3D -D_FORTIFY_SOURCE=3D2 > > endif > > =20 > > +# Require preprocessor flags we can't build without > > +BASE_CPPFLAGS :=3D -D_XOPEN_SOURCE=3D700 -D_GNU_SOURCE \ > > + -DPAGE_SIZE=3D$(shell getconf PAGE_SIZE) \ > > + -DVERSION=3D\"$(VERSION)\" > > + > > FLAGS :=3D -Wall -Wextra -Wno-format-zero-length -Wformat-security > > -FLAGS +=3D -pedantic -std=3Dc11 -D_XOPEN_SOURCE=3D700 -D_GNU_SOURCE > > +FLAGS +=3D -pedantic -std=3Dc11 >=20 > I tried a bit harder but this distinction looks bogus to me (we must I'm not sure which distinction you're referring to. There are two options AFAICT: the distinction between "required" and "default only" flags. That one I'll grant is a bit tenuous. Mind you, that's kind of already the split between FLAGS and CFLAGS. The other is the distinction between flags for the preprocessor versus for the compiler proper. That's the one I actually need to do what this series is aiming to do. > *not* build without -std=3Dc11, FORTIFY_SOURCE, -pie, -fPIE, or > DUAL_STACK_SOCKETS anyway) Agreed for -pie and -fPIE. Maybe for -std=3Dc11. FORTIFY_SOURCE seems like something we want to encourage, but by no means essential to the build. DUAL_STACK_SOCKETS seems like it should be configurable. Omitting when possible will waste memory, but should not result in a failed or incorrect build. > and adapting the whole series to a > BASE_CPPFLAGS / CPPFLAGS / CFLAGS split is rather time consuming, even > if I drop unrelated patches such as 5/13 to 8/13 and 10/13 to 13/13, so > I would drop this series for now. >=20 > I'm running static checkers on pesto manually for the moment. Eh, ok. I'll rework on top of whatever once I'm back. > Note that the rationale given for 3/13 and 4/13 ignores documented > reasons behind the current sets of flags. It can be changed indeed but > functionality needs to be maintained, as I already mentioned in the > discussion about 4/13. >=20 > > FLAGS +=3D $(FORTIFY_FLAG) -O2 -pie -fPIE > > -FLAGS +=3D -DPAGE_SIZE=3D$(shell getconf PAGE_SIZE) > > -FLAGS +=3D -DVERSION=3D\"$(VERSION)\" > > +FLAGS +=3D $(BASE_CPPFLAGS) > > FLAGS +=3D -DDUAL_STACK_SOCKETS=3D$(DUAL_STACK_SOCKETS) > > =20 > > PASST_SRCS =3D arch.c arp.c bitmap.c checksum.c conf.c dhcp.c dhcpv6.c= \ > > @@ -195,6 +199,4 @@ CPPCHECK_FLAGS =3D --std=3Dc11 --error-exitcode=3D1= --enable=3Dall --force \ > > -D CPPCHECK_6936 > > =20 > > cppcheck: $(PASST_SRCS) $(HEADERS) > > - $(CPPCHECK) $(CPPCHECK_FLAGS) \ > > - $(filter -D%,$(FLAGS) $(CFLAGS) $(CPPFLAGS)) $^ \ > > - $^ > > + $(CPPCHECK) $(CPPCHECK_FLAGS) $(BASE_CPPFLAGS) $^ >=20 > --=20 > Stefano >=20 --=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 --5CYSkKilx9HgCRr3 Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmn69wsACgkQzQJF27ox 2GfqDw/+JLsEfNhXvibgb1m3EvvVhwDbhpCoC0bJyC5WYJuwrlMKDUMiGNJg1LFq z0ZlMjddNDk/uh6+rhqpeaNhOv5dv8wXibcIUukg940HkxyF5kaT5Sc7Hw84Vtan Wj0GkQPZEe2QBBdQ5PinDIBNX7FiBU5iQAkXPEwVXqRQ7efk3qdMSDuEeDEWYCpA N3w4iAPYRwnkSRalKJnW247xltG5kwskT4K4zG547Bd7QN3U+dnIzaIeALpNHXYA TNv8uDdWCMON1CNa5MnAxoyWSKizoSGEtPgUrQoo97si9dVZBj5mtamB0MvlsWXh WtDHA2Gw7i86F5gDVmaKnGFCPwUqpsUFZi3FOkARpt7abWHfPhSiix5JNyfR8boN Sjqk8vg4hwmrWvHlJHBc5oPqsEJgw+aIYpr8chKDZv+2O4/8Rmac1j2nqFLQaPnO WAOKz4gsDFfeNHt9kJ5fqBnNMHlurQZ6NFJkcAowJ12TjdPU3HEd1cIQfhCLEsjW LZIiW3nwog88zymrzO6Bb4lC/ShSkUSIn343BUfnGewQ0AJm9WZNoMXZ1FChGFfG 6905vgHB/hpOJzptZ3jx432LfcVyHrZ7xt58Zkrj9H8NaXtDm+kD+KWV0f6U6S6b +ANyJY5n+5UzlD3hGDW+ctoJgZoBmUrwRImJa4hyhLg1XIywK7s= =yQ0m -----END PGP SIGNATURE----- --5CYSkKilx9HgCRr3--