public inbox for dev@dpdk.org
 help / color / mirror / Atom feed
From: Kevin Traynor <ktraynor@redhat.com>
To: dev@dpdk.org
Cc: thomas@monjalon.net, david.marchand@redhat.com,
	Kevin Traynor <ktraynor@redhat.com>,
	stable@dpdk.org, Anatoly Burakov <anatoly.burakov@intel.com>,
	David Hunt <david.hunt@intel.com>,
	Sivaprasad Tummala <sivaprasad.tummala@amd.com>
Subject: [PATCH] examples/vm_power: fix format-truncation warning
Date: Wed, 25 Feb 2026 17:36:32 +0000	[thread overview]
Message-ID: <20260225173632.283928-1-ktraynor@redhat.com> (raw)

Without libbsd-devel strlcpy is defined as rte_strlcpy and a warning is
raised for format-truncation. Observed with gcc 15.2.1.

In function ‘rte_strlcpy’,
    inlined from ‘add_host_channels’ at
../examples/vm_power_manager/channel_manager.c:600:3:
../lib/eal/include/rte_string_fns.h:63:24:
warning: ‘%s’ directive output may be truncated writing up to
4095 bytes into a region of size 108 [-Wformat-truncation=]
63 |         return (size_t)snprintf(dst, size, "%s", src);
   |                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Check for truncation of socket_path[4096] into channel_path[108] to
remove warning.

Cc: stable@dpdk.org

Signed-off-by: Kevin Traynor <ktraynor@redhat.com>
---
 examples/vm_power_manager/channel_manager.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/examples/vm_power_manager/channel_manager.c b/examples/vm_power_manager/channel_manager.c
index 7d7efdd05a..b69449c61d 100644
--- a/examples/vm_power_manager/channel_manager.c
+++ b/examples/vm_power_manager/channel_manager.c
@@ -561,4 +561,5 @@ add_host_channels(void)
 	struct core_info *ci;
 	struct channel_info *chan_infos[RTE_MAX_LCORE];
+	size_t channel_path_size;
 	int i;
 
@@ -598,6 +599,13 @@ add_host_channels(void)
 		}
 		chan_infos[i] = chan_info;
-		strlcpy(chan_info->channel_path, socket_path,
-				sizeof(chan_info->channel_path));
+		channel_path_size = sizeof(chan_info->channel_path);
+		if (strlcpy(chan_info->channel_path, socket_path,
+			      channel_path_size) >= channel_path_size) {
+			RTE_LOG(ERR, CHANNEL_MANAGER, "Socket path is too long "
+				"'%s' >= %zu\n", socket_path, channel_path_size);
+			rte_free(chan_info);
+			chan_infos[i] = NULL;
+			goto error;
+		}
 
 		if (setup_host_channel_info(&chan_info, i) < 0) {
-- 
2.53.0


             reply	other threads:[~2026-02-25 17:37 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-25 17:36 Kevin Traynor [this message]
2026-02-25 18:32 ` [PATCH] examples/vm_power: fix format-truncation warning Stephen Hemminger
2026-02-26 10:48   ` Kevin Traynor
2026-03-17 16:26     ` Thomas Monjalon
2026-03-17 16:20 ` Thomas Monjalon

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=20260225173632.283928-1-ktraynor@redhat.com \
    --to=ktraynor@redhat.com \
    --cc=anatoly.burakov@intel.com \
    --cc=david.hunt@intel.com \
    --cc=david.marchand@redhat.com \
    --cc=dev@dpdk.org \
    --cc=sivaprasad.tummala@amd.com \
    --cc=stable@dpdk.org \
    --cc=thomas@monjalon.net \
    /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