commit f0678b77c63a9dc8aa32c781cc38bab77932669d from: Thomas Adam via: Thomas Adam date: Tue Sep 21 20:55:42 2021 UTC sterror: use XPG version on GLIBC It looks like autoconf 2.69 will not provide XPG strerror_r even if the appropriate macros are set which request the XPG version. Until this is fixed in autoconf and that version is more widely-adopted, this approach will provide what's required. Originally from Stefan Sperling, tweaked by me. commit - 7293142804d9e432cda75b24e7987b55640bcaab commit + f0678b77c63a9dc8aa32c781cc38bab77932669d blob - 4ad6d22aa77f19cf6105fcd6bc22a98e92d55ef7 blob + 3173307f2ab8682ed6c74f18e1dcce9c02344d9d --- lib/error.c +++ lib/error.c @@ -37,6 +37,14 @@ #ifndef nitems #define nitems(_a) (sizeof(_a) / sizeof((_a)[0])) +#endif + +#if defined(__GLIBC__) + /* + * The autoconf test for strerror_r is broken in current versions + * of autoconf: https://savannah.gnu.org/support/?110367 + */ +#define strerror_r __xpg_strerror_r #endif static struct got_custom_error { @@ -144,7 +152,15 @@ got_error_from_errno_fmt(const char *fmt, ...) vsnprintf(buf, sizeof(buf), fmt, ap); va_end(ap); +#ifdef __GLIBC__ + /* + * The autoconf test for strerror_r is broken in current versions + * of autoconf: https://savannah.gnu.org/support/?110367 + */ + __xpg_strerror_r(errno, strerr, sizeof(strerr)); +#else strerror_r(errno, strerr, sizeof(strerr)); +#endif snprintf(cerr->msg, sizeof(cerr->msg), "%s: %s", buf, strerr); err->code = GOT_ERR_ERRNO;