From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Gibson To: passt-dev@passt.top Subject: Re: [PATCH] tcp: Work around gcc 12 bogus warning in tcp_rtt_dst_check() Date: Tue, 24 May 2022 19:09:37 +1000 Message-ID: In-Reply-To: <20220520090111.2510593-1-sbrivio@redhat.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1212317020991430644==" --===============1212317020991430644== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable On Fri, May 20, 2022 at 11:01:11AM +0200, Stefano Brivio wrote: > gcc 12.1.x (e.g. current OpenSUSE Tumbleweed, x86_64 only, > gcc-12-1.4.x86_64) reports: >=20 > tcp.c: In function =E2=80=98tcp_send_flag=E2=80=99: > tcp.c:1014:9: warning: writing 16 bytes into a region of size 0 [-Wstringop= -overflow=3D] > 1014 | memcpy(low_rtt_dst + hole++, &conn->a.a6, sizeof(conn->a.a6= )); > | ^ > tcp.c:559:24: note: at offset -16 into destination object =E2=80=98low_rtt_= dst=E2=80=99 of size 128 > 559 | static struct in6_addr low_rtt_dst[LOW_RTT_TABLE_SIZE]; > | >=20 > but 'hole' can't be -1, because the low_rtt_dst table is guaranteed > to have a hole: if we happened to write to the last entry, we'll go > back to index 0 and clear that one. >=20 > Signed-off-by: Stefano Brivio Reviewed-by: David Gibson > --- > tcp.c | 6 ++++++ > 1 file changed, 6 insertions(+) >=20 > diff --git a/tcp.c b/tcp.c > index e68409a..53af3db 100644 > --- a/tcp.c > +++ b/tcp.c > @@ -1011,6 +1011,12 @@ static void tcp_rtt_dst_check(const struct tcp_conn = *conn, > hole =3D i; > } > =20 > + /* Keep gcc 12 happy: this won't actually happen because the table is > + * guaranteed to have a hole, see the second memcpy() below. > + */ > + if (hole =3D=3D -1) > + return; > + > memcpy(low_rtt_dst + hole++, &conn->a.a6, sizeof(conn->a.a6)); > if (hole =3D=3D LOW_RTT_TABLE_SIZE) > hole =3D 0; --=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 --===============1212317020991430644== Content-Type: application/pgp-signature Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="signature.asc" MIME-Version: 1.0 LS0tLS1CRUdJTiBQR1AgU0lHTkFUVVJFLS0tLS0KCmlRSXpCQUVCQ0FBZEZpRUVvVUx4V3U0L1dz MGRCK1h0Z3lwWTRnRXdZU0lGQW1LTW9Nb0FDZ2tRZ3lwWTRnRXcKWVNKTWlRLzlIQTVFYTU0RVVF MzB1L25EZHdidkhHUnkvUXk3aENLZTJ1ZW52NVB0eStOMk54Qzd0ZFJtdmZxVAptSlN0WGZGbGxS NXBFdG1mSkNraVdqVTAyQUNFeWNPVzU4d29wMkdhZnFSbzhyZXFjc2dCVHlzNHA1U1FIR0JZCnFq TnpBUXFGOVF4T3lDS21GSUQ3Yk5YKzI2Zk0rTGV6aWh0c1Rrand2UmdmN1dUb0puQ2lSLzJTKytt RmlpSk0KVXhEbXBwS25zWm9pb21BU2x5L0FrN2x1NEN4T0kyVHBPQnYrZnVjSlc5VXg3R01FZ0lR dG82emQxeTRPOElGYQpzTzQzQ2VWWmlGYW15ZTM5ZmViU0JvdFpqTk9SMjQxQWZJenprVWsrUVo2 enpCTTV4bGorRXhhb0VueGtpK0dtCm0yWEtiOWRnNFBFTlVBMzdqZUxYVlAva2ZoU0s1K0hTOWZW ZkQ2UVEvTFlGMUVJaFk5cUlPWXJVdmVrdTJYQnUKenBYeWV4QjF6L3RER3BRMEFBNHRhOEtPbmFw UXdIdGRNbGxNS2NwaG9DQVJpbmVaVGJyZU1KNzJGWCtKK0d0bAoweTZNeUZnTWNJWnZ0bjNUQUx5 enVtVW5IaEM0WlhQdktPTjE4b25raG5teHk5YnBxV0d2OGRZaHE0Wmxxd2tBCmdlL2Zoc0FubU1U L2grMjV4OTgyQW5sRS9tMHhZdzl4bTdCOHRHaVFxZkRuMWhZTWJRU0MxQkg5L2FYWS9HSk4KZTdF MUtTZ3JPeGtIS2l0QndpMXJBKzBTdVEzNGVoWmhtZDNsdXBScmN1R2NuVnVLSE9UejQ2VmRnT0tZ eThVQwo1WFBDQXdCS0s1ZW1ybzYxU1Y5MVluajVoRzFSOFlmdGhaaXMxOFZxdlY1ellpMG5VZ0U9 Cj1obGEyCi0tLS0tRU5EIFBHUCBTSUdOQVRVUkUtLS0tLQo= --===============1212317020991430644==--