aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2018-05-20 18:06:00 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2018-05-20 18:06:00 -0400
commita13b47a59ffce6f3c13c8b777738a3aab1db10d3 (patch)
tree6d3b4f4e4338e715b3270d228aab041eb8b6b8ce
parentc6e846446d17db40883eed91fa448e65333a0ae1 (diff)
downloadpostgresql-a13b47a59ffce6f3c13c8b777738a3aab1db10d3.tar.gz
postgresql-a13b47a59ffce6f3c13c8b777738a3aab1db10d3.zip
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.
-rw-r--r--src/bin/pg_verify_checksums/pg_verify_checksums.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/bin/pg_verify_checksums/pg_verify_checksums.c b/src/bin/pg_verify_checksums/pg_verify_checksums.c
index b065d0bb897..845d5aba27e 100644
--- a/src/bin/pg_verify_checksums/pg_verify_checksums.c
+++ b/src/bin/pg_verify_checksums/pg_verify_checksums.c
@@ -85,7 +85,8 @@ scan_file(char *fn, int segmentno)
f = open(fn, 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);
}
@@ -137,8 +138,8 @@ scan_directory(char *basedir, char *subdir)
dir = opendir(path);
if (!dir)
{
- fprintf(stderr, _("%s: could not open directory \"%s\": %m\n"),
- progname, path);
+ fprintf(stderr, _("%s: could not open directory \"%s\": %s\n"),
+ progname, path, strerror(errno));
exit(1);
}
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);
if (lstat(fn, &st) < 0)
{
- fprintf(stderr, _("%s: could not stat file \"%s\": %m\n"),
- progname, fn);
+ fprintf(stderr, _("%s: could not stat file \"%s\": %s\n"),
+ progname, fn, strerror(errno));
exit(1);
}
if (S_ISREG(st.st_mode))