* [PATCH] tcp: Work around gcc 12 bogus warning in tcp_rtt_dst_check()
@ 2022-05-20 9:01 Stefano Brivio
2022-05-24 9:09 ` David Gibson
0 siblings, 1 reply; 3+ messages in thread
From: Stefano Brivio @ 2022-05-20 9:01 UTC (permalink / raw)
To: passt-dev
[-- Attachment #1: Type: text/plain, Size: 1274 bytes --]
gcc 12.1.x (e.g. current OpenSUSE Tumbleweed, x86_64 only,
gcc-12-1.4.x86_64) reports:
tcp.c: In function ‘tcp_send_flag’:
tcp.c:1014:9: warning: writing 16 bytes into a region of size 0 [-Wstringop-overflow=]
1014 | memcpy(low_rtt_dst + hole++, &conn->a.a6, sizeof(conn->a.a6));
| ^
tcp.c:559:24: note: at offset -16 into destination object ‘low_rtt_dst’ of size 128
559 | static struct in6_addr low_rtt_dst[LOW_RTT_TABLE_SIZE];
|
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.
Signed-off-by: Stefano Brivio <sbrivio(a)redhat.com>
---
tcp.c | 6 ++++++
1 file changed, 6 insertions(+)
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 = i;
}
+ /* 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 == -1)
+ return;
+
memcpy(low_rtt_dst + hole++, &conn->a.a6, sizeof(conn->a.a6));
if (hole == LOW_RTT_TABLE_SIZE)
hole = 0;
--
@@ -1011,6 +1011,12 @@ static void tcp_rtt_dst_check(const struct tcp_conn *conn,
hole = i;
}
+ /* 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 == -1)
+ return;
+
memcpy(low_rtt_dst + hole++, &conn->a.a6, sizeof(conn->a.a6));
if (hole == LOW_RTT_TABLE_SIZE)
hole = 0;
--
2.35.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] tcp: Work around gcc 12 bogus warning in tcp_rtt_dst_check()
2022-05-20 9:01 [PATCH] tcp: Work around gcc 12 bogus warning in tcp_rtt_dst_check() Stefano Brivio
@ 2022-05-24 9:09 ` David Gibson
2022-05-25 11:31 ` Stefano Brivio
0 siblings, 1 reply; 3+ messages in thread
From: David Gibson @ 2022-05-24 9:09 UTC (permalink / raw)
To: passt-dev
[-- Attachment #1: Type: text/plain, Size: 1657 bytes --]
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:
>
> tcp.c: In function ‘tcp_send_flag’:
> tcp.c:1014:9: warning: writing 16 bytes into a region of size 0 [-Wstringop-overflow=]
> 1014 | memcpy(low_rtt_dst + hole++, &conn->a.a6, sizeof(conn->a.a6));
> | ^
> tcp.c:559:24: note: at offset -16 into destination object ‘low_rtt_dst’ of size 128
> 559 | static struct in6_addr low_rtt_dst[LOW_RTT_TABLE_SIZE];
> |
>
> 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.
>
> Signed-off-by: Stefano Brivio <sbrivio(a)redhat.com>
Reviewed-by: David Gibson <david(a)gibson.dropbear.id.au>
> ---
> tcp.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> 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 = i;
> }
>
> + /* 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 == -1)
> + return;
> +
> memcpy(low_rtt_dst + hole++, &conn->a.a6, sizeof(conn->a.a6));
> if (hole == LOW_RTT_TABLE_SIZE)
> hole = 0;
--
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
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] tcp: Work around gcc 12 bogus warning in tcp_rtt_dst_check()
2022-05-24 9:09 ` David Gibson
@ 2022-05-25 11:31 ` Stefano Brivio
0 siblings, 0 replies; 3+ messages in thread
From: Stefano Brivio @ 2022-05-25 11:31 UTC (permalink / raw)
To: passt-dev
[-- Attachment #1: Type: text/plain, Size: 1275 bytes --]
On Tue, 24 May 2022 19:09:37 +1000
David Gibson <david(a)gibson.dropbear.id.au> wrote:
> 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:
> >
> > tcp.c: In function ‘tcp_send_flag’:
> > tcp.c:1014:9: warning: writing 16 bytes into a region of size 0 [-Wstringop-overflow=]
> > 1014 | memcpy(low_rtt_dst + hole++, &conn->a.a6, sizeof(conn->a.a6));
> > | ^
> > tcp.c:559:24: note: at offset -16 into destination object ‘low_rtt_dst’ of size 128
> > 559 | static struct in6_addr low_rtt_dst[LOW_RTT_TABLE_SIZE];
> > |
> >
> > 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.
> >
> > Signed-off-by: Stefano Brivio <sbrivio(a)redhat.com>
>
> Reviewed-by: David Gibson <david(a)gibson.dropbear.id.au>
Thanks for the reviews! I pushed those two changes already on Friday,
as they were both rather simple and blocking continuous integration.
I guess it might make sense to set up Patchwork eventually, but it
feels a bit overkill for the moment...
--
Stefano
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-05-25 11:31 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-20 9:01 [PATCH] tcp: Work around gcc 12 bogus warning in tcp_rtt_dst_check() Stefano Brivio
2022-05-24 9:09 ` David Gibson
2022-05-25 11:31 ` Stefano Brivio
Code repositories for project(s) associated with this public inbox
https://passt.top/passt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).