diff options
author | Ilya Maximets <i.maximets@ovn.org> | 2022-12-22 01:06:19 +0100 |
---|---|---|
committer | Ilya Maximets <i.maximets@ovn.org> | 2023-01-03 12:39:32 +0100 |
commit | 0d8318db633fb24936a0f55e869331f0c27f243f (patch) | |
tree | 64e4f02a4b3b372201e7df888754ae790bf80a20 /lib | |
parent | d83d7c4915f1fc538f52fd05076532b744e389dd (diff) | |
download | openvswitch-0d8318db633fb24936a0f55e869331f0c27f243f.tar.gz |
netdev-afxdp: Disable -Wfree-nonheap-object on receive.
GCC 11+ generates a warning:
In file included from lib/netdev-linux-private.h:30,
from lib/netdev-afxdp.c:19:
In function 'dp_packet_delete',
inlined from 'dp_packet_delete' at lib/dp-packet.h:246:1,
inlined from 'dp_packet_batch_add__' at lib/dp-packet.h:775:9,
inlined from 'dp_packet_batch_add' at lib/dp-packet.h:783:5,
inlined from 'netdev_afxdp_rxq_recv' at lib/netdev-afxdp.c:898:9:
lib/dp-packet.h:260:9: warning: 'free' called on pointer
'*umem.xpool.array' with nonzero offset [8, 2558044588346441168]
[-Wfree-nonheap-object]
260 | free(b);
| ^~~~~~~
But it is a false positive since the code path is not possible.
In this call chain the packet will always have source DPBUF_AFXDP
and the free() will never be called. GCC doesn't see that, because
initialization function dp_packet_use_afxdp() is part of a different
translation unit.
Disabling a warning in this particular place to avoid build failures.
Older versions of clang do not have the -Wfree-nonheap-object, so we
need to additionally guard the pragmas. Clang is using GCC pragmas
and complains about unknown ones.
Reported-at: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108187
Acked-by: Eelco Chaudron <echaudro@redhat.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/netdev-afxdp.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/netdev-afxdp.c b/lib/netdev-afxdp.c index ca3f2431e..4d57efa5c 100644 --- a/lib/netdev-afxdp.c +++ b/lib/netdev-afxdp.c @@ -868,9 +868,22 @@ netdev_afxdp_rxq_recv(struct netdev_rxq *rxq_, struct dp_packet_batch *batch, OVS_XDP_HEADROOM); dp_packet_set_size(packet, len); +#if __GNUC__ >= 11 && !__clang__ + /* GCC 11+ generates a false-positive warning about free() being + * called on DPBUF_AFXDP packet, but it is an imposisible code path. + * Disabling a warning to avoid build failures. + * https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108187 */ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wfree-nonheap-object" +#endif + /* Add packet into batch, increase batch->count. */ dp_packet_batch_add(batch, packet); +#if __GNUC__ && !__clang__ +#pragma GCC diagnostic pop +#endif + idx_rx++; } /* Release the RX queue. */ |