* Re: [PATCH v4] test/argparse: change initialization to workaround LTO
[not found] ` <20250909135010.345224-1-stephen@networkplumber.org>
@ 2025-10-23 19:09 ` Thomas Monjalon
0 siblings, 0 replies; only message in thread
From: Thomas Monjalon @ 2025-10-23 19:09 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: dev, Chengwen Feng, Bruce Richardson, stable
09/09/2025 15:49, Stephen Hemminger:
> When compiled with Link Time Optimization, the existing code
> generated an error, because the compiler was unable to intuit
> that there was space in the flexible array.
>
> In function ‘test_argparse_copy’,
> inlined from ‘test_argparse_init_obj’ at ../app/test/test_argparse.c:108:2,
> inlined from ‘test_argparse_opt_callback_parse_int_of_no_val’ at ../app/test/test_argparse.c:490:8:
> ../app/test/test_argparse.c:96:17: warning: ‘memcpy’ writing 56 bytes into a region of size 0 overflows the destination [-Wstringop-overflow=]
> 96 | memcpy(&dst->args[i], &src->args[i], sizeof(src->args[i]));
>
> Initializing a structure with flexible array is special case
> and compiler expands the structure to fit. But inside the copy
> function it no longer knew that.
>
> The workaround is to put the copy inside the same function
> and use structure assignment. Also macro should be upper case.
>
> Fixes: 6c5c6571601c ("argparse: verify argument config")
> Acked-by: Chengwen Feng <fengchengwen@huawei.com>
> Acked-by: Bruce Richardson <bruce.richardson@intel.com>
>
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Cc stable
Applied, thanks.
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2025-10-23 19:09 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <20250627162305.340042-1-stephen@networkplumber.org>
[not found] ` <20250909135010.345224-1-stephen@networkplumber.org>
2025-10-23 19:09 ` [PATCH v4] test/argparse: change initialization to workaround LTO Thomas Monjalon
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).