Suppress new gcc-15 -Wunterminated-string-initialization#796
Conversation
|
Fixes optee-test yocto builds from meta-arm. |
|
Thanks @denix0
|
|
|
|
|
|
FWIW, our clang builds fail with this patch: |
#797 should help by disabling Werror. Maybe we can backport this to meta-arm... |
Yes, I'd approve that. |
|
Is clang behind gcc for once? :) Anyway, according to the manual clang 21 does have support for this attribute, but in Yocto we have 20.1 for now: |
|
I hope #ifdef's for gcc/clang and/or versions are not needed... or feature checks? |
|
|
This nonstring attribute has been added to clang only last week: |
I've just updated the commit with this check. Should I collect all the early reviews in the commit message, or wait for the new ones? |
Thanks! |
GCC 15 now warns when character arrays are being initialized by strings and terminating NUL character doesn't fit. GCC 15.1 also allows marking such arrays with nonstring attribute to suppress the warning. W/o such attribute, the warning becomes error due to the global -Werror. Add the attribute accordingly. Fixes these errors: | ./regression_4000_data.h:7919:9: error: initializer-string for array of 'unsigned char' truncates NUL terminator but destination lacks 'nonstring' attribute (20 chars into 19 available) [-Werror=unterminated-string-initialization] | 7919 | "encryption standard"; | | ^~~~~~~~~~~~~~~~~~~~~ | ./regression_4000_data.h:8387:9: error: initializer-string for array of 'unsigned char' truncates NUL terminator but destination lacks 'nonstring' attribute (113 chars into 112 available) [-Werror=unterminated-string-initialization] | 8387 | "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomn" | | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ./regression_4000.c:1295:47: error: initializer-string for array of 'unsigned char' truncates NUL terminator but destination lacks 'nonstring' attribute (4 chars into 3 available) [-Werror=unterminated-string-initialization] | 1295 | static const uint8_t hash_data_sm3_a1_in[3] = "abc"; | | ^~~~~ Signed-off-by: Denys Dmytriyenko <denys@konsulko.com> Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org> Acked-by: Jens Wiklander <jens.wiklander@linaro.org> Acked-by: Etienne Carriere <etienne.carriere@foss.st.com>
Ok, updated the commit one more time with reviews and acks. Thanks for all the feedback. |
GCC 15 now warns when character arrays are being initialized by strings
and terminating NUL character doesn't fit. GCC 15.1 also allows marking
such arrays with nonstring attribute to suppress the warning. W/o such
attribute, the warning becomes error due to the global -Werror. Add the
attribute accordingly.