summaryrefslogtreecommitdiff
path: root/src/bin/pg_upgrade/parallel.c
diff options
context:
space:
mode:
authorMichael Paquier <michael@paquier.xyz>2024-03-12 10:02:54 +0900
committerMichael Paquier <michael@paquier.xyz>2024-03-12 10:02:54 +0900
commit2c8118ee5d980e11f73683fcda2329c323aa381e (patch)
tree7527eb2a94bc9cc8821ff9afba62e03918dff351 /src/bin/pg_upgrade/parallel.c
parent3045324214467dd3f0bef31f6f33562b9eb93aa3 (diff)
Use printf's %m format instead of strerror(errno) in more places
Most callers of strerror() are removed from the backend code. The remaining callers require special handling with a saved errno from a previous system call. The frontend code still needs strerror() where error states need to be handled outside of fprintf. Note that pg_regress is not changed to use %m as the TAP output may clobber errno, since those functions call fprintf() and friends before evaluating the format string. Support for %m in src/port/snprintf.c has been added in d6c55de1f99a, hence all the stable branches currently supported include it. Author: Dagfinn Ilmari Mannsåker Discussion: https://postgr.es/m/87sf13jhuw.fsf@wibble.ilmari.org
Diffstat (limited to 'src/bin/pg_upgrade/parallel.c')
-rw-r--r--src/bin/pg_upgrade/parallel.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/bin/pg_upgrade/parallel.c b/src/bin/pg_upgrade/parallel.c
index ae15457a9d6..05313a9b156 100644
--- a/src/bin/pg_upgrade/parallel.c
+++ b/src/bin/pg_upgrade/parallel.c
@@ -124,7 +124,7 @@ parallel_exec_prog(const char *log_file, const char *opt_log_file,
_exit(!exec_prog(log_file, opt_log_file, true, true, "%s", cmd));
else if (child < 0)
/* fork failed */
- pg_fatal("could not create worker process: %s", strerror(errno));
+ pg_fatal("could not create worker process: %m");
#else
/* empty array element are always at the end */
new_arg = exec_thread_args[parallel_jobs - 1];
@@ -140,7 +140,7 @@ parallel_exec_prog(const char *log_file, const char *opt_log_file,
child = (HANDLE) _beginthreadex(NULL, 0, (void *) win32_exec_prog,
new_arg, 0, NULL);
if (child == 0)
- pg_fatal("could not create worker thread: %s", strerror(errno));
+ pg_fatal("could not create worker thread: %m");
thread_handles[parallel_jobs - 1] = child;
#endif
@@ -232,7 +232,7 @@ parallel_transfer_all_new_dbs(DbInfoArr *old_db_arr, DbInfoArr *new_db_arr,
}
else if (child < 0)
/* fork failed */
- pg_fatal("could not create worker process: %s", strerror(errno));
+ pg_fatal("could not create worker process: %m");
#else
/* empty array element are always at the end */
new_arg = transfer_thread_args[parallel_jobs - 1];
@@ -250,7 +250,7 @@ parallel_transfer_all_new_dbs(DbInfoArr *old_db_arr, DbInfoArr *new_db_arr,
child = (HANDLE) _beginthreadex(NULL, 0, (void *) win32_transfer_all_new_dbs,
new_arg, 0, NULL);
if (child == 0)
- pg_fatal("could not create worker thread: %s", strerror(errno));
+ pg_fatal("could not create worker thread: %m");
thread_handles[parallel_jobs - 1] = child;
#endif
@@ -291,7 +291,7 @@ reap_child(bool wait_for_child)
#ifndef WIN32
child = waitpid(-1, &work_status, wait_for_child ? 0 : WNOHANG);
if (child == (pid_t) -1)
- pg_fatal("%s() failed: %s", "waitpid", strerror(errno));
+ pg_fatal("%s() failed: %m", "waitpid");
if (child == 0)
return false; /* no children, or no dead children */
if (work_status != 0)
@@ -310,7 +310,7 @@ reap_child(bool wait_for_child)
/* get the result */
GetExitCodeThread(thread_handles[thread_num], &res);
if (res != 0)
- pg_fatal("child worker exited abnormally: %s", strerror(errno));
+ pg_fatal("child worker exited abnormally: %m");
/* dispose of handle to stop leaks */
CloseHandle(thread_handles[thread_num]);