* [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* Re: [PATCH] examples/vm_power: fix format-truncation warning
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:20 ` Thomas Monjalon
1 sibling, 1 reply; 5+ messages in thread
From: Stephen Hemminger @ 2026-02-25 18:32 UTC (permalink / raw)
To: Kevin Traynor
Cc: dev, thomas, david.marchand, stable, Anatoly Burakov, David Hunt,
Sivaprasad Tummala
On Wed, 25 Feb 2026 17:36:32 +0000
Kevin Traynor <ktraynor@redhat.com> wrote:
> 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>
Since socket_path is a unix domain socket path.
It should be UNIX_PATH_MAX (108) not PATH_MAX (4096)
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] examples/vm_power: fix format-truncation warning
2026-02-25 18:32 ` Stephen Hemminger
@ 2026-02-26 10:48 ` Kevin Traynor
2026-03-17 16:26 ` Thomas Monjalon
0 siblings, 1 reply; 5+ messages in thread
From: Kevin Traynor @ 2026-02-26 10:48 UTC (permalink / raw)
To: Stephen Hemminger
Cc: dev, thomas, david.marchand, stable, Anatoly Burakov,
Sivaprasad Tummala
On 25/02/2026 18:32, Stephen Hemminger wrote:
> On Wed, 25 Feb 2026 17:36:32 +0000
> Kevin Traynor <ktraynor@redhat.com> wrote:
>
>> 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>
>
> Since socket_path is a unix domain socket path.
> It should be UNIX_PATH_MAX (108) not PATH_MAX (4096)
>
Yeah, I had adjusted all the socket_path/names in the file to
UNIX_PATH_MAX as an initial fix but it spewed a different truncation
warning as one of them gets a copy from dirent->d_name which is 256.
So considering it's just an optimization of example code and hasn't
really been developed over the last few years, I just fixed the warning
that showed up.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] examples/vm_power: fix format-truncation warning
2026-02-26 10:48 ` Kevin Traynor
@ 2026-03-17 16:26 ` Thomas Monjalon
0 siblings, 0 replies; 5+ messages in thread
From: Thomas Monjalon @ 2026-03-17 16:26 UTC (permalink / raw)
To: Kevin Traynor
Cc: Stephen Hemminger, dev, david.marchand, stable, Anatoly Burakov,
Sivaprasad Tummala
26/02/2026 11:48, Kevin Traynor:
> On 25/02/2026 18:32, Stephen Hemminger wrote:
> > On Wed, 25 Feb 2026 17:36:32 +0000
> > Kevin Traynor <ktraynor@redhat.com> wrote:
> >
> >> 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>
> >
> > Since socket_path is a unix domain socket path.
> > It should be UNIX_PATH_MAX (108) not PATH_MAX (4096)
> >
>
> Yeah, I had adjusted all the socket_path/names in the file to
> UNIX_PATH_MAX as an initial fix but it spewed a different truncation
> warning as one of them gets a copy from dirent->d_name which is 256.
>
> So considering it's just an optimization of example code and hasn't
> really been developed over the last few years, I just fixed the warning
> that showed up.
Yes I suspect this example to have many other problems.
The whole example should be reconsidered.
Applied, thanks.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] examples/vm_power: fix format-truncation warning
2026-02-25 17:36 [PATCH] examples/vm_power: fix format-truncation warning Kevin Traynor
2026-02-25 18:32 ` Stephen Hemminger
@ 2026-03-17 16:20 ` Thomas Monjalon
1 sibling, 0 replies; 5+ messages in thread
From: Thomas Monjalon @ 2026-03-17 16:20 UTC (permalink / raw)
To: Kevin Traynor
Cc: dev, david.marchand, stable, Anatoly Burakov, David Hunt,
Sivaprasad Tummala
25/02/2026 18:36, Kevin Traynor:
> 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>
Applied, thanks.
^ permalink raw reply [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