This is just a very minor issue.

gnulib contains some calls to strerror where the result is assigned
to a char *. However, according to the strerror specification, the
string returned by strerror should never be changed, so it would be
better to use const char * instead.
Most assignments of strerror return values in gnulib actually already
use a const char *.

For the 4 others,see the attached small patch.

Philipp
diff --git a/m4/perror.m4 b/m4/perror.m4
index 6a36408e7..81c20321a 100644
--- a/m4/perror.m4
+++ b/m4/perror.m4
@@ -31,7 +31,7 @@ AC_DEFUN([gl_FUNC_PERROR],
                 #include <stdlib.h>
                 #include <string.h>
               ]],
-              [[char *str = strerror (-1);
+              [[const char *str = strerror (-1);
                 if (!getenv("CONFTEST_OUTPUT")) return 0;
                 if (!str) str = "";
                 puts (str);
diff --git a/m4/strerror.m4 b/m4/strerror.m4
index fd84ce871..d44b3c738 100644
--- a/m4/strerror.m4
+++ b/m4/strerror.m4
@@ -69,7 +69,7 @@ AC_DEFUN([gl_FUNC_STRERROR_0],
            #include <errno.h>
          ]],
          [[int result = 0;
-           char *str;
+           const char *str;
            errno = 0;
            str = strerror (0);
            if (!*str) result |= 1;
diff --git a/m4/strerror_r.m4 b/m4/strerror_r.m4
index d431f2360..51a121b1a 100644
--- a/m4/strerror_r.m4
+++ b/m4/strerror_r.m4
@@ -148,7 +148,7 @@ changequote([,])dnl
                   [[int result = 0;
                     char buf[256] = "^";
                     char copy[256];
-                    char *str = strerror (-1);
+                    const char *str = strerror (-1);
                     strcpy (copy, str);
                     if (__xpg_strerror_r (-2, buf, 1) == 0)
                       result |= 1;
diff --git a/tests/test-perror2.c b/tests/test-perror2.c
index c6214dd25..8467b4806 100644
--- a/tests/test-perror2.c
+++ b/tests/test-perror2.c
@@ -94,7 +94,7 @@ main (void)
     for (i = 0; i < SIZEOF (errs); i++)
       {
         char buf[256];
-        char *err = strerror (errs[i]);
+        const char *err = strerror (errs[i]);
 
         ASSERT (err);
         ASSERT (strlen (err) < sizeof buf);

Reply via email to