Commit cce64a51 authored by Michael Paquier's avatar Michael Paquier

Replace use of strerror() with %s by %m in pg_waldump

Since d6c55de1, src/port/snprintf.c is able to use %m instead of
strerror().  A couple of utilities in src/bin/ have already done the
switch, and do it now for pg_waldump as this reduces the workload for
translators.

Note that more could be done, particularly with pgbench.  Thanks to
Kyotaro Horiguchi for the discussion.

Discussion: https://postgr.es/m/20191129065115.GM2505@paquier.xyz
parent e69d6445
...@@ -142,8 +142,7 @@ open_file_in_directory(const char *directory, const char *fname) ...@@ -142,8 +142,7 @@ open_file_in_directory(const char *directory, const char *fname)
fd = open(fpath, O_RDONLY | PG_BINARY, 0); fd = open(fpath, O_RDONLY | PG_BINARY, 0);
if (fd < 0 && errno != ENOENT) if (fd < 0 && errno != ENOENT)
fatal_error("could not open file \"%s\": %s", fatal_error("could not open file \"%s\": %m", fname);
fname, strerror(errno));
return fd; return fd;
} }
...@@ -207,8 +206,8 @@ search_directory(const char *directory, const char *fname) ...@@ -207,8 +206,8 @@ search_directory(const char *directory, const char *fname)
else else
{ {
if (errno != 0) if (errno != 0)
fatal_error("could not read file \"%s\": %s", fatal_error("could not read file \"%s\": %m",
fname, strerror(errno)); fname);
else else
fatal_error("could not read file \"%s\": read %d of %zu", fatal_error("could not read file \"%s\": read %d of %zu",
fname, r, (Size) XLOG_BLCKSZ); fname, r, (Size) XLOG_BLCKSZ);
...@@ -316,7 +315,7 @@ WALDumpOpenSegment(XLogSegNo nextSegNo, WALSegmentContext *segcxt, ...@@ -316,7 +315,7 @@ WALDumpOpenSegment(XLogSegNo nextSegNo, WALSegmentContext *segcxt,
break; break;
} }
fatal_error("could not find file \"%s\": %s", fname, strerror(errno)); fatal_error("could not find file \"%s\": %m", fname);
return -1; /* keep compiler quiet */ return -1; /* keep compiler quiet */
} }
...@@ -925,8 +924,7 @@ main(int argc, char **argv) ...@@ -925,8 +924,7 @@ main(int argc, char **argv)
/* validate path points to directory */ /* validate path points to directory */
if (!verify_directory(waldir)) if (!verify_directory(waldir))
{ {
pg_log_error("path \"%s\" could not be opened: %s", pg_log_error("could not open directory \"%s\": %m", waldir);
waldir, strerror(errno));
goto bad_argument; goto bad_argument;
} }
} }
...@@ -946,8 +944,7 @@ main(int argc, char **argv) ...@@ -946,8 +944,7 @@ main(int argc, char **argv)
waldir = directory; waldir = directory;
if (!verify_directory(waldir)) if (!verify_directory(waldir))
fatal_error("could not open directory \"%s\": %s", fatal_error("could not open directory \"%s\": %m", waldir);
waldir, strerror(errno));
} }
waldir = identify_target_directory(waldir, fname); waldir = identify_target_directory(waldir, fname);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment