summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: e491e45)
raw | patch | inline | side by side (parent: e491e45)
author | Sebastian Harl <sh@tokkee.org> | |
Sun, 2 Sep 2007 14:24:28 +0000 (16:24 +0200) | ||
committer | Florian Forster <octo@huhu.verplant.org> | |
Sun, 2 Sep 2007 15:54:29 +0000 (17:54 +0200) |
Even though Posix requires "strerror_r" to return an "int", some systems
(e.g. the GNU libc) return a "char *" _and_ ignore the second argument.
sstrerror() (in src/common.c) has been changed to be aware of this and
handle both cases correctly.
Signed-off-by: Sebastian Harl <sh@tokkee.org>
Signed-off-by: Florian Forster <octo@huhu.verplant.org>
(e.g. the GNU libc) return a "char *" _and_ ignore the second argument.
sstrerror() (in src/common.c) has been changed to be aware of this and
handle both cases correctly.
Signed-off-by: Sebastian Harl <sh@tokkee.org>
Signed-off-by: Florian Forster <octo@huhu.verplant.org>
configure.in | patch | blob | history | |
src/common.c | patch | blob | history |
diff --git a/configure.in b/configure.in
index 14fcaa7f999f58c5df4ab7e53e1c25afe5d465a6..162acd7472d1be0ef9194f8d15e2bfcc1021cc4b 100644 (file)
--- a/configure.in
+++ b/configure.in
AC_CHECK_FUNCS(strncasecmp strcasecmp)
AC_CHECK_FUNCS(openlog syslog closelog)
+AC_FUNC_STRERROR_R
+
AC_CHECK_FUNCS(getpwnam_r)
AC_CHECK_FUNCS(getgrnam_r)
diff --git a/src/common.c b/src/common.c
index 9ebfe27cb60bc3cb56ae3317f084f69b4f8cf10d..f8655a98ee5e33fd2b0621d884e1073cd193f462 100644 (file)
--- a/src/common.c
+++ b/src/common.c
return (r);
}
-/* Don't use the return value of `strerror_r', because the GNU-people got
- * inventive there.. -octo */
+/* Even though Posix requires "strerror_r" to return an "int",
+ * some systems (e.g. the GNU libc) return a "char *" _and_
+ * ignore the second argument ... -tokkee */
char *sstrerror (int errnum, char *buf, size_t buflen)
{
buf[0] = '\0';
+#ifdef STRERROR_R_CHAR_P
+ buf = strerror_r (errnum, buf, buflen);
+#else
strerror_r (errnum, buf, buflen);
+#endif /* STRERROR_R_CHAR_P */
return (buf);
} /* char *sstrerror */