tcp: Work around gcc 12 bogus warning in tcp_rtt_dst_check()
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@redhat.com>
This commit is contained in:
parent
a951e0b9ef
commit
d27cc3e435
1 changed files with 6 additions and 0 deletions
6
tcp.c
6
tcp.c
|
@ -1011,6 +1011,12 @@ static void tcp_rtt_dst_check(const struct tcp_conn *conn,
|
||||||
hole = i;
|
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));
|
memcpy(low_rtt_dst + hole++, &conn->a.a6, sizeof(conn->a.a6));
|
||||||
if (hole == LOW_RTT_TABLE_SIZE)
|
if (hole == LOW_RTT_TABLE_SIZE)
|
||||||
hole = 0;
|
hole = 0;
|
||||||
|
|
Loading…
Reference in a new issue