]> 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>
Wed, 25 Dec 2024 14:30:40 +0000 (15:30 +0100)
* lib/strerror_r.c (strerror_r): Silence -Wformat-truncation warning.

ChangeLog
lib/strerror_r.c

index fbdd30a36de31049ca4ae739f2c72a41ccc1775e..c1390e5a19aa44bc7629573134dabe0ebe4a8ff7 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-01  Bruno Haible  <bruno@clisp.org>
 
        announce-gen: Fix bug when accessing symlinks.
index 0cd28ade6e60e741f92636478698f05a8d0ad866..9d6bb5a53470ca0c1a9893a592e5452702c69c5e 100644 (file)
@@ -440,6 +440,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);