Skip to content

Commit 94f0114

Browse files
committed
Suppress new gcc-15 -Wunterminated-string-initialization
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>
1 parent d068b66 commit 94f0114

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

host/xtest/regression_4000.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1292,6 +1292,9 @@ static const uint8_t hash_data_shake256_out2[] = {
12921292
* https://tools.ietf.org/html/draft-sca-cfrg-sm3-02
12931293
* Appendix A.1
12941294
*/
1295+
#if __has_attribute(nonstring)
1296+
__attribute__((nonstring))
1297+
#endif
12951298
static const uint8_t hash_data_sm3_a1_in[3] = "abc";
12961299

12971300
static const uint8_t hash_data_sm3_a1_out[] = {

host/xtest/regression_4000_data.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7914,6 +7914,9 @@ static struct derive_key_ecdh_t {
79147914
};
79157915

79167916
/* G/MT 0003 (SM2) Part 5 Annex C.2 - encryption/decryption */
7917+
#if __has_attribute(nonstring)
7918+
__attribute__((nonstring))
7919+
#endif
79177920
static const uint8_t gmt_0003_part5_c2_sm2_testvector_ptx[19] =
79187921
/* M */
79197922
"encryption standard";
@@ -8383,6 +8386,9 @@ static const uint8_t mac_data_sha3_512_out1[] = {
83838386
* GM/T 0042-2015
83848387
* Section D.3 Test vector 1
83858388
*/
8389+
#if __has_attribute(nonstring)
8390+
__attribute__((nonstring))
8391+
#endif
83868392
static const uint8_t mac_data_sm3_d31_in[112] =
83878393
"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomn"
83888394
"opnopqabcdbcdecdefdefgefghfghighijhijkijkljklmklmn"

0 commit comments

Comments
 (0)