From: Bruno Haible Date: Wed, 2 Apr 2025 22:45:30 +0000 (+0200) Subject: Silence some -Wunterminated-string-initialization warnings. X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=25df6dc4253480a343dde3376ce6fd99c316a532;p=gnulib.git Silence some -Wunterminated-string-initialization warnings. * lib/base32.c (base32_encode): Mark b32str as not NUL-terminated. * lib/base64.c (b64c): Mark as not NUL-terminated. * lib/bcp47.c (struct script): Mark the 'code' field as not NUL-terminated. * lib/striconveh.c (mem_cd_iconveh_internal): Mark hex as not NUL-terminated. * lib/unicase/special-casing.in.h (struct special_casing_rule): Mark the 'code' field as not NUL-terminated. --- diff --git a/ChangeLog b/ChangeLog index fc34d49e7a..d680249a95 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2025-04-02 Bruno Haible + + Silence some -Wunterminated-string-initialization warnings. + * lib/base32.c (base32_encode): Mark b32str as not NUL-terminated. + * lib/base64.c (b64c): Mark as not NUL-terminated. + * lib/bcp47.c (struct script): Mark the 'code' field as not + NUL-terminated. + * lib/striconveh.c (mem_cd_iconveh_internal): Mark hex as not + NUL-terminated. + * lib/unicase/special-casing.in.h (struct special_casing_rule): Mark the + 'code' field as not NUL-terminated. + 2025-04-02 Bruno Haible getlocalename_l-unsafe: Avoid undefined behaviour on Solaris 11.4. diff --git a/lib/base32.c b/lib/base32.c index a89111990b..cc74f921e0 100644 --- a/lib/base32.c +++ b/lib/base32.c @@ -65,7 +65,7 @@ void base32_encode (const char *restrict in, idx_t inlen, char *restrict out, idx_t outlen) { - static const char b32str[32] = + static const char b32str[32] _GL_ATTRIBUTE_NONSTRING = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"; while (inlen && outlen) diff --git a/lib/base64.c b/lib/base64.c index 6b1b0c2bda..8a0edd4a6e 100644 --- a/lib/base64.c +++ b/lib/base64.c @@ -59,7 +59,7 @@ to_uchar (char ch) return ch; } -static const char b64c[64] = +static const char b64c[64] _GL_ATTRIBUTE_NONSTRING = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; /* Base64 encode IN array of size INLEN into OUT array. OUT needs diff --git a/lib/bcp47.c b/lib/bcp47.c index 49bcace178..46fd31b5d4 100644 --- a/lib/bcp47.c +++ b/lib/bcp47.c @@ -91,8 +91,8 @@ struct script { - char name[12]; /* Script name, lowercased, NUL-terminated */ - char code[4]; /* Script code, not NUL-terminated */ + char name[12]; /* Script name, lowercased, NUL-terminated */ + char code[4] _GL_ATTRIBUTE_NONSTRING; /* Script code, not NUL-terminated */ }; /* Table of script names and four-letter script codes. diff --git a/lib/striconveh.c b/lib/striconveh.c index 9e8d9c8600..8730e44ef7 100644 --- a/lib/striconveh.c +++ b/lib/striconveh.c @@ -792,7 +792,8 @@ mem_cd_iconveh_internal (const char *src, size_t srclen, if (handler == iconveh_escape_sequence) { - static char const hex[16] = "0123456789ABCDEF"; + static char const hex[16] _GL_ATTRIBUTE_NONSTRING = + "0123456789ABCDEF"; scratchlen = 0; scratchbuf[scratchlen++] = '\\'; if (uc < 0x10000) diff --git a/lib/unicase/special-casing.in.h b/lib/unicase/special-casing.in.h index d174feba65..81ec05acbc 100644 --- a/lib/unicase/special-casing.in.h +++ b/lib/unicase/special-casing.in.h @@ -46,7 +46,7 @@ struct special_casing_rule { /* The first two bytes are the code, in big-endian order. The third byte only distinguishes different rules pertaining to the same code. */ - /*unsigned*/ char code[3]; + /*unsigned*/ char code[3] _GL_ATTRIBUTE_NONSTRING; /* True when this rule is not the last one for the given code. */ /*bool*/ unsigned int has_next : 1;