]> Savannah Git Hosting - gnulib.git/commitdiff
strerror_r-posix: Silence gcc 14 warning.
authorBruno Haible <bruno@clisp.org>
Tue, 3 Dec 2024 19:38:12 +0000 (20:38 +0100)
committerBruno Haible <bruno@clisp.org>
Tue, 3 Dec 2024 19:38:12 +0000 (20:38 +0100)
* lib/strerror_r.c (strerror_r): Silence -Wformat-truncation warning.

ChangeLog
lib/strerror_r.c

index 89f552e28f0f4387954a79143518ec9fe00ba010..74e5a9632306c301f229e1b425d1101cf1934ae6 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2024-12-03  Bruno Haible  <bruno@clisp.org>
+
+       strerror_r-posix: Silence gcc 14 warning.
+       * lib/strerror_r.c (strerror_r): Silence -Wformat-truncation warning.
+
 2024-12-02  Bruno Haible  <bruno@clisp.org>
 
        gettext: Sync with gettext 0.23.
index 87fc1142629161b5463fa33b538d8d5de6dd4e81..b52bd2c0aef06917805eaaf7f8af79175ea034c6 100644 (file)
@@ -443,6 +443,13 @@ strerror_r (int errnum, char *buf, size_t buflen)
 
     if (ret == EINVAL && !*buf)
       {
+        /* gcc 14 produces a
+           "warning: 'Unknown error ' directive output truncated
+            writing 14 bytes into a region of size 2"
+           Thanks for the warning, but here the truncation is intentional.  */
+#if _GL_GNUC_PREREQ (7, 1)
+# pragma GCC diagnostic ignored "-Wformat-truncation"
+#endif
 #if defined __HAIKU__
         /* For consistency with perror().  */
         snprintf (buf, buflen, "Unknown Application Error (%d)", errnum);