public inbox for dev@dpdk.org
 help / color / mirror / Atom feed
* [PATCH] examples/vm_power: fix format-truncation warning
@ 2026-02-25 17:36 Kevin Traynor
  2026-02-25 18:32 ` Stephen Hemminger
  2026-03-17 16:20 ` Thomas Monjalon
  0 siblings, 2 replies; 5+ messages in thread
From: Kevin Traynor @ 2026-02-25 17:36 UTC (permalink / raw)
  To: dev
  Cc: thomas, david.marchand, Kevin Traynor, stable, Anatoly Burakov,
	David Hunt, Sivaprasad Tummala

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


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-03-17 16:26 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-25 17:36 [PATCH] examples/vm_power: fix format-truncation warning Kevin Traynor
2026-02-25 18:32 ` Stephen Hemminger
2026-02-26 10:48   ` Kevin Traynor
2026-03-17 16:26     ` Thomas Monjalon
2026-03-17 16:20 ` Thomas Monjalon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox