Fix unportable usage of printf("%m").

While glibc's version of printf accepts %m, most others do not;
to be portable, we have to do it the hard way with strerror(errno).
pg_verify_checksums evidently did not get that memo.

Noted while fooling around with NetBSD-current, which generates
a compiler warning for this mistake.
This commit is contained in:
Tom Lane 2018-05-20 18:06:00 -04:00
parent c6e846446d
commit a13b47a59f

View File

@ -85,7 +85,8 @@ scan_file(char *fn, int segmentno)
f = open(fn, 0); f = open(fn, 0);
if (f < 0) if (f < 0)
{ {
fprintf(stderr, _("%s: could not open file \"%s\": %m\n"), progname, fn); fprintf(stderr, _("%s: could not open file \"%s\": %s\n"),
progname, fn, strerror(errno));
exit(1); exit(1);
} }
@ -137,8 +138,8 @@ scan_directory(char *basedir, char *subdir)
dir = opendir(path); dir = opendir(path);
if (!dir) if (!dir)
{ {
fprintf(stderr, _("%s: could not open directory \"%s\": %m\n"), fprintf(stderr, _("%s: could not open directory \"%s\": %s\n"),
progname, path); progname, path, strerror(errno));
exit(1); exit(1);
} }
while ((de = readdir(dir)) != NULL) while ((de = readdir(dir)) != NULL)
@ -152,8 +153,8 @@ scan_directory(char *basedir, char *subdir)
snprintf(fn, sizeof(fn), "%s/%s", path, de->d_name); snprintf(fn, sizeof(fn), "%s/%s", path, de->d_name);
if (lstat(fn, &st) < 0) if (lstat(fn, &st) < 0)
{ {
fprintf(stderr, _("%s: could not stat file \"%s\": %m\n"), fprintf(stderr, _("%s: could not stat file \"%s\": %s\n"),
progname, fn); progname, fn, strerror(errno));
exit(1); exit(1);
} }
if (S_ISREG(st.st_mode)) if (S_ISREG(st.st_mode))