DPDK-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Dragos Tarcatu <dragos.tarcatu@keysight.com>
To: dev@dpdk.org
Cc: skori@marvell.com, pbhagavatula@marvell.com, stable@dpdk.org,
	Dragos Tarcatu <dragos.tarcatu@keysight.com>
Subject: [PATCH] examples/l2fwd-event: fix memset of port statistics array
Date: Wed, 29 Jul 2026 10:32:36 +0000	[thread overview]
Message-ID: <20260729103236.3878391-1-dragos.tarcatu@keysight.com> (raw)

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@dpdk.org

Signed-off-by: Dragos Tarcatu <dragos.tarcatu@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


                 reply	other threads:[~2026-07-29 10:32 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260729103236.3878391-1-dragos.tarcatu@keysight.com \
    --to=dragos.tarcatu@keysight.com \
    --cc=dev@dpdk.org \
    --cc=pbhagavatula@marvell.com \
    --cc=skori@marvell.com \
    --cc=stable@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox