From: Sebastian Harl Date: Sun, 2 Sep 2007 14:24:28 +0000 (+0200) Subject: Added the AC_FUNC_STRERROR_R check. X-Git-Tag: collectd-4.0.8~17 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=fa7db5e964775dc39e71661884de9f4f8bde7ef6;p=collectd.git Added the AC_FUNC_STRERROR_R check. 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 Signed-off-by: Florian Forster --- diff --git a/configure.in b/configure.in index 14fcaa7f..162acd74 100644 --- a/configure.in +++ b/configure.in @@ -424,6 +424,8 @@ AC_CHECK_FUNCS(strchr memcpy strstr strcmp strncmp strncpy strlen) 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 9ebfe27c..f8655a98 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 */