--- a/src/parser/snprintf.c +++ b/src/parser/snprintf.c @@ -403,17 +404,6 @@ * Note: glibc declares this as returning "char *", but that would require * casting away const internally, so we don't follow that detail. */ -#ifndef HAVE_STRCHRNUL - -static inline const char * -strchrnul(const char *s, int c) -{ - while (*s != '\0' && *s != c) - s++; - return s; -} - -#else /* * glibc's declares strchrnul only if _GNU_SOURCE is defined. @@ -425,7 +415,6 @@ extern char *strchrnul(const char *s, int c); #endif -#endif /* HAVE_STRCHRNUL */ /* @@ -767,9 +756,10 @@ break; case 'm': { - char errbuf[PG_STRERROR_R_BUFLEN]; - const char *errm = strerror_r(save_errno, + char errbuf[256]; + int ret = strerror_r(save_errno, errbuf, sizeof(errbuf)); + const char *errm = (ret == 0) ? errbuf : "Unknown error"; dostr(errm, strlen(errm), target); }