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
Signed-off-by: Ilya Maximets <[email protected]>
---
lib/netdev-afxdp.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
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. */
--
2.38.1
_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev