[PATCH] examples/l2fwd-event: fix memset of port statistics array

Dragos Tarcatu dragos.tarcatu at keysight.com
Wed Jul 29 12:32:36 CEST 2026


port_stats is declared as struct l2fwd_port_statistics[RTE_MAX_ETHPORTS],
but the memset passed sizeof(struct l2fwd_port_statistics) -- the size
of a single element -- leaving ports 1 through RTE_MAX_ETHPORTS-1 with
uninitialized stats. Use sizeof(rsrc->port_stats) to clear the whole
array regardless of RTE_MAX_ETHPORTS.

Surfaced as a -Wmemset-elt-size warning when building with
-Dmax_ethports=64 -Dexamples=all.

Fixes: 4ff457986f76 ("examples/l2fwd-event: add default poll mode routines")
Cc: stable at dpdk.org

Signed-off-by: Dragos Tarcatu <dragos.tarcatu at keysight.com>
---
 examples/l2fwd-event/main.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/examples/l2fwd-event/main.c b/examples/l2fwd-event/main.c
index 2d31d4c6ad..eff2bee503 100644
--- a/examples/l2fwd-event/main.c
+++ b/examples/l2fwd-event/main.c
@@ -696,8 +696,7 @@ main(int argc, char **argv)
 		l2fwd_poll_resource_setup(rsrc);
 
 	/* initialize port stats */
-	memset(&rsrc->port_stats, 0,
-					sizeof(struct l2fwd_port_statistics));
+	memset(rsrc->port_stats, 0, sizeof(rsrc->port_stats));
 
 	/* All settings are done. Now enable eth devices */
 	RTE_ETH_FOREACH_DEV(port_id) {
-- 
2.34.1



More information about the stable mailing list