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 B84F35A026D for ; Tue, 19 Sep 2023 04:09:13 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=201602; t=1695089350; bh=XJ3YLj/FMZ1fssEaFZtXbHtFkg820xQCP7kR95zBIe4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=gnCFNzgOVdtnbkqAC4oHItmjUmga2TVsDw1blflGsa2xoZ3eRjM/oEzUJ2q1UvTa4 k9XB6AQGld91OX8hoaQqyf0dhVQV0NTksnejZW+ZiQUoi+0fmjWnv0Uj+DDxKszvsM Ah8GyQpth+qOXkyLIZvsAFW8oA1sUnCgQNNyGz4Q= Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4RqQ8601QHz4xM7; Tue, 19 Sep 2023 12:09:09 +1000 (AEST) Date: Tue, 19 Sep 2023 11:08:51 +1000 From: David Gibson To: Stefano Brivio Subject: Re: [PATCH 2/2] util: Consolidate and improve workarounds for clang-tidy issue 58992 Message-ID: References: <20230915064337.2380211-1-david@gibson.dropbear.id.au> <20230915064337.2380211-3-david@gibson.dropbear.id.au> <20230918101608.00434c15@elisabeth> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="om3pNtf/jIkb7Kl/" Content-Disposition: inline In-Reply-To: <20230918101608.00434c15@elisabeth> Message-ID-Hash: Z3KZ66FRZBYWPO45U7EWFULMKCJ7HIKO X-Message-ID-Hash: Z3KZ66FRZBYWPO45U7EWFULMKCJ7HIKO 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: --om3pNtf/jIkb7Kl/ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Sep 18, 2023 at 10:16:08AM +0200, Stefano Brivio wrote: > On Fri, 15 Sep 2023 16:43:37 +1000 > David Gibson wrote: >=20 > > We have several workarounds for a clang-tidy bug where the checker does= n't > > recognize that a number of system calls write to - and therefore initia= lise > > - a socket address. We can't neatly use a suppression, because the bog= us > > warning shows up some time after the actual system call, when we access > > a field of the socket address which clang-tidy erroneously thinks is > > uninitialised. > >=20 > > Consolidate these workarounds into one place by using macros to impleme= nt > > wrappers around affected system calls which add a memset() of the socka= ddr > > to silence clang-tidy. This removes the need for the individual memset= () > > workarounds at the callers - and the somewhat longwinded explanatory > > comments. > >=20 > > We can then use a #define to not include the hack in "real" builds, but > > only consider it for clang-tidy. >=20 > I'm probably missing something, but wouldn't it be more obvious to > conditionally define the wrapper itself? That is, >=20 > #ifdef CLANG_TIDY_58992 > # define recvfrom(s, buf, len, flags, src, addrlen) \ > wrap_recvfrom((s), (buf), (len), (flags), (src), (addrlen)) > #endif >=20 > instead of doing that in sa_init()? Eh.. maybe? I was going for minimal differences in the preprocessed code between the two cases, to reduce the chances of missing some unrelated real problem due to the fact we're kind of lying to our static checker. I don't feel that strongly about it though, so whichever you'd prefer is fine. --=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 --om3pNtf/jIkb7Kl/ Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmUI9JwACgkQzQJF27ox 2Ge68BAAgfhepj1y/+m13aW0DpBNPBnuTJ/A8yhaUl7eeqrfUU2VJhrieshwcrYc s1UXcNcZXaexhnLs7z8TizbJxrA+X+o2oi/HucBIz7tVTQVjaQSTuIAC3AeCGzYn F6ybuYYAWm/9TH8YbKBAJvkXKD9zSAFs4ZXe112BKgv3XVdaEvObiwK4gVqdGAcW 7O18tFRcCw/1wl5S6JEZ52Z2yqsIZbF3z4veEIUHyAy06FNOp+HvVOBkiAUo1UCM WVVr3uA6dyVd/OSymvnD22wkEOTj+gN7yIj9VX8S89ZlhzGWZxYV2WKxgDjYgsVK d8lUBQbpwTwsJ2cxcpMRxN7xHvOiTF62+BoCYqyjEkibsYYxVm101DE+rsIOBqoz mnEsoNSB3tjbHLgFrr/hVUotNP1Ib620yVeq74w4B7X43NRDV+vwET8XijsByIec 4ZG5UoMpMF6s7+LIgj1skQY5U5pyKksWLS68japJBm8+I8No8WI61Qe3aDdFpc0S wp0aIM61L760B3+zFNJiJlFHm1ApjY8mN0NztLQrCJKWp3Ic0pJ1MZCtyLPukVVF 3BWz+qPwGh7UWLirSSr2Jop1V5XI2ASq7qZLwZdkyTBQLC9dvXcvDKemnHqanxie /TVKcI1YaNBwmlJoFGXsCzMkZeZ0bsDbfFU7BQhL02BKHC9U/vA= =qZ7t -----END PGP SIGNATURE----- --om3pNtf/jIkb7Kl/--