You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
test/argparse: change initialization to workaround LTO
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
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: 6c5c657 ("argparse: verify argument config")
Cc: [email protected]
Signed-off-by: Stephen Hemminger <[email protected]>
Acked-by: Bruce Richardson <[email protected]>
Acked-by: Chengwen Feng <[email protected]>
0 commit comments