Skip to content

Commit a13b47a

Browse files
committed
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.
1 parent c6e8464 commit a13b47a

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/bin/pg_verify_checksums/pg_verify_checksums.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,8 @@ scan_file(char *fn, int segmentno)
8585
f = open(fn, 0);
8686
if (f < 0)
8787
{
88-
fprintf(stderr, _("%s: could not open file \"%s\": %m\n"), progname, fn);
88+
fprintf(stderr, _("%s: could not open file \"%s\": %s\n"),
89+
progname, fn, strerror(errno));
8990
exit(1);
9091
}
9192

@@ -137,8 +138,8 @@ scan_directory(char *basedir, char *subdir)
137138
dir = opendir(path);
138139
if (!dir)
139140
{
140-
fprintf(stderr, _("%s: could not open directory \"%s\": %m\n"),
141-
progname, path);
141+
fprintf(stderr, _("%s: could not open directory \"%s\": %s\n"),
142+
progname, path, strerror(errno));
142143
exit(1);
143144
}
144145
while ((de = readdir(dir)) != NULL)
@@ -152,8 +153,8 @@ scan_directory(char *basedir, char *subdir)
152153
snprintf(fn, sizeof(fn), "%s/%s", path, de->d_name);
153154
if (lstat(fn, &st) < 0)
154155
{
155-
fprintf(stderr, _("%s: could not stat file \"%s\": %m\n"),
156-
progname, fn);
156+
fprintf(stderr, _("%s: could not stat file \"%s\": %s\n"),
157+
progname, fn, strerror(errno));
157158
exit(1);
158159
}
159160
if (S_ISREG(st.st_mode))

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy