[collectd] [PATCH] Added the AC_FUNC_STRERROR_R check.
Sebastian Harl
sh at tokkee.org
Sun Sep 2 16:24:28 CEST 2007
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 at tokkee.org>
---
configure.in | 2 ++
src/common.c | 9 +++++++--
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/configure.in b/configure.in
index 567d542..d02c12f 100644
--- a/configure.in
+++ b/configure.in
@@ -365,6 +365,8 @@ AC_HEADER_TIME
AC_PROG_GCC_TRADITIONAL
AC_CHECK_FUNCS(gettimeofday select strdup strtol getaddrinfo getnameinfo strchr memcpy strstr strcmp strncmp strncpy strlen strncasecmp strcasecmp openlog 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 9ebfe27..f8655a9 100644
--- a/src/common.c
+++ b/src/common.c
@@ -70,12 +70,17 @@ char *sstrdup (const char *s)
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 */
--
1.5.2.1
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://mailman.verplant.org/pipermail/collectd/attachments/20070902/51433c79/attachment.pgp
More information about the collectd
mailing list