Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita13b47a

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 generatesa compiler warning for this mistake.
1 parentc6e8464 commita13b47a

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)

[8]ページ先頭

©2009-2025 Movatter.jp