]> Savannah Git Hosting - gnulib.git/commitdiff
Silence some -Wunterminated-string-initialization warnings.
authorBruno Haible <bruno@clisp.org>
Wed, 2 Apr 2025 22:45:30 +0000 (00:45 +0200)
committerBruno Haible <bruno@clisp.org>
Wed, 2 Apr 2025 22:45:30 +0000 (00:45 +0200)
* 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.

ChangeLog
lib/base32.c
lib/base64.c
lib/bcp47.c
lib/striconveh.c
lib/unicase/special-casing.in.h

index fc34d49e7a607e67cac92410c2daca51b6d77b74..d680249a9524dc9a8d485593c682698927647da0 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2025-04-02  Bruno Haible  <bruno@clisp.org>
+
+       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  <bruno@clisp.org>
 
        getlocalename_l-unsafe: Avoid undefined behaviour on Solaris 11.4.
index a89111990b98f938cf686bbce7a5615c3bf4f341..cc74f921e0a7563ef4783d6b31091c4e6d856259 100644 (file)
@@ -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)
index 6b1b0c2bdab0bd7c4d3a4c45e5e9725a0a4552a5..8a0edd4a6e5ceae5350ae824cc49c2ef906495e9 100644 (file)
@@ -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
index 49bcace17855160994e80f1733d4fd4a25d6e5b3..46fd31b5d45132279686947cccd8932b9066681c 100644 (file)
@@ -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.
index 9e8d9c8600f56aea20a1724d63efce0d0e08fabb..8730e44ef7fcd849031731747b9ffefd4fb27552 100644 (file)
@@ -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)
index d174feba65e15e14b6c394014d8dab4ac6ac07e0..81ec05acbc13aaff42d9a65607a0c84f9728f9fd 100644 (file)
@@ -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;