]> granicus.if.org Git - postgresql/commitdiff
Fix portability failure introduced in commits d2b0b60e7 et al.
authorTom Lane <tgl@sss.pgh.pa.us>
Wed, 26 Dec 2018 20:30:10 +0000 (15:30 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Wed, 26 Dec 2018 20:30:30 +0000 (15:30 -0500)
I made a frontend fprintf() format use %m, forgetting that that's only
safe in HEAD not the back branches; prior to 96bf88d52 and d6c55de1f,
it would work on glibc platforms but not elsewhere.  Revert to using
%s ... strerror(errno) as the code did before.

We could have left HEAD as-is, but for code consistency across branches,
I chose to apply this patch there too.

Per Coverity and a few buildfarm members.

src/common/psprintf.c

index 53cee23fa9f2f82932d77c8b676fe13e6fb4613b..93daeda5526f48b90640d1f7e32cf94640e268e1 100644 (file)
@@ -131,7 +131,8 @@ pvsnprintf(char *buf, size_t len, const char *fmt, va_list args)
 #ifndef FRONTEND
                elog(ERROR, "vsnprintf failed: %m with format string \"%s\"", fmt);
 #else
-               fprintf(stderr, "vsnprintf failed: %m with format string \"%s\"\n", fmt);
+               fprintf(stderr, "vsnprintf failed: %s with format string \"%s\"\n",
+                               strerror(errno), fmt);
                exit(EXIT_FAILURE);
 #endif
        }