--- a/src/parser/snprintf.c.orig +++ b/src/parser/snprintf.c @@ -400,18 +400,7 @@ * 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. * While we typically use that on glibc platforms, configure will set @@ -422,9 +411,7 @@ extern char *strchrnul(const char *s, int c); #endif -#endif /* HAVE_STRCHRNUL */ - /* * dopr(): the guts of *printf for all cases. */ @@ -764,10 +751,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); } break;