[PATCH] examples/vm_power: fix format-truncation warning
Thomas Monjalon
thomas at monjalon.net
Tue Mar 17 17:26:40 CET 2026
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 at 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 at dpdk.org
> >>
> >> Signed-off-by: Kevin Traynor <ktraynor at 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.
More information about the dev
mailing list