DPDK patches and discussions
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: Stephen Hemminger <stephen@networkplumber.org>,
	Harry van Haaren <harry.van.haaren@intel.com>
Subject: [PATCH v2 3/3] event/sw: avoid snprintf truncation
Date: Sat, 15 Jun 2024 09:00:14 -0700	[thread overview]
Message-ID: <20240615160215.117401-4-stephen@networkplumber.org> (raw)
In-Reply-To: <20240615160215.117401-1-stephen@networkplumber.org>

The string used for rte_malloc_socket gets truncated.
With Gcc-14, this warning is generated:
../drivers/event/sw/sw_evdev.c:263:3: warning: 'snprintf' will always be truncated;
    specified size is 12, but format string expands to at least 13 [-Wformat-truncation]
  263 |                 snprintf(buf, sizeof(buf), "sw%d_iq_%d_rob", dev_id, i);
      |                 ^

Replace IQ_ROB_NAMESIZE (12) with a bigger buffer and remove
it since no longer used.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/event/sw/iq_chunk.h | 2 --
 drivers/event/sw/sw_evdev.c | 2 +-
 2 files changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/event/sw/iq_chunk.h b/drivers/event/sw/iq_chunk.h
index 7a7a8782e6..e638142dbc 100644
--- a/drivers/event/sw/iq_chunk.h
+++ b/drivers/event/sw/iq_chunk.h
@@ -9,8 +9,6 @@
 #include <stdbool.h>
 #include <rte_eventdev.h>
 
-#define IQ_ROB_NAMESIZE 12
-
 struct __rte_cache_aligned sw_queue_chunk {
 	struct rte_event events[SW_EVS_PER_Q_CHUNK];
 	struct sw_queue_chunk *next;
diff --git a/drivers/event/sw/sw_evdev.c b/drivers/event/sw/sw_evdev.c
index 1c01b069fe..44698d8aff 100644
--- a/drivers/event/sw/sw_evdev.c
+++ b/drivers/event/sw/sw_evdev.c
@@ -230,7 +230,7 @@ qid_init(struct sw_evdev *sw, unsigned int idx, int type,
 	unsigned int i;
 	int dev_id = sw->data->dev_id;
 	int socket_id = sw->data->socket_id;
-	char buf[IQ_ROB_NAMESIZE];
+	char buf[64];
 	struct sw_qid *qid = &sw->qids[idx];
 
 	/* Initialize the FID structures to no pinning (-1), and zero packets */
-- 
2.43.0


  parent reply	other threads:[~2024-06-15 16:02 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-25 18:23 [RFC 0/4] malloc type argument cleanup (part 1) Stephen Hemminger
2024-04-25 18:23 ` [RFC 1/4] rte_malloc: document that type is unused Stephen Hemminger
2024-04-25 18:31   ` Tyler Retzlaff
2024-04-25 18:42     ` Stephen Hemminger
2024-04-25 18:23 ` [RFC 2/4] devtools/cocci: add script to find unnecessary malloc type Stephen Hemminger
2024-04-25 18:24 ` [RFC 3/4] devtools/cocci: add script to find where rte_calloc should be used Stephen Hemminger
2024-04-25 18:24 ` [RFC 4/4] eal/malloc: remove type argument from internal malloc routines Stephen Hemminger
2024-04-26 16:16   ` Tyler Retzlaff
2024-04-26 22:52     ` Stephen Hemminger
2024-04-26 23:06       ` Tyler Retzlaff
2024-05-07  7:04   ` Morten Brørup
2024-04-26 21:32 ` [RFC 0/4] malloc type argument cleanup (part 1) Patrick Robb
2024-06-15 16:00 ` [PATCH v2 0/3] malloc related cleanups Stephen Hemminger
2024-06-15 16:00   ` [PATCH v2 1/3] rte_malloc: document that type is for tracing Stephen Hemminger
2024-06-15 16:00   ` [PATCH v2 2/3] eal: remove type argument from internal routines Stephen Hemminger
2024-06-15 16:00   ` Stephen Hemminger [this message]
2024-06-15 21:40   ` [PATCH v2 0/3] malloc related cleanups Morten Brørup
2024-06-17 17:48   ` Patrick Robb
2024-06-18 14:44 ` [PATCH v3 0/2] malloc type cleanups Stephen Hemminger
2024-06-18 14:44   ` [PATCH v3 1/2] rte_malloc: document that type is for tracing Stephen Hemminger
2024-06-18 14:44   ` [PATCH v3 2/2] eal: remove type argument from internal routines Stephen Hemminger
2024-07-05 14:09   ` [PATCH v3 0/2] malloc type cleanups David Marchand

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=20240615160215.117401-4-stephen@networkplumber.org \
    --to=stephen@networkplumber.org \
    --cc=dev@dpdk.org \
    --cc=harry.van.haaren@intel.com \
    /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;
as well as URLs for NNTP newsgroup(s).