From: Peter Eisentraut Date: Mon, 13 Apr 2026 08:52:19 +0000 (+0200) Subject: pg_createsubscriber: Remove separate logfile_open() function X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f5528b90b411e0ba365f9cf42e97aa9b1c47cffa;p=thirdparty%2Fpostgresql.git pg_createsubscriber: Remove separate logfile_open() function This seems like an excessive indirection. Discussion: https://www.postgresql.org/message-id/flat/CAEqnbaUthOQARV1dscGvB_EsqC-YfxiM6rWkVDHc%2BG%2Bf4oSUHw%40mail.gmail.com --- diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c index 5c5fa2a7633..e90fce0302e 100644 --- a/src/bin/pg_basebackup/pg_createsubscriber.c +++ b/src/bin/pg_basebackup/pg_createsubscriber.c @@ -975,22 +975,6 @@ server_is_in_recovery(PGconn *conn) return ret == 0; } -/* - * Open a new logfile with proper permissions. - */ -static FILE * -logfile_open(const char *filename, const char *mode) -{ - FILE *fh; - - fh = fopen(filename, mode); - - if (!fh) - pg_fatal("could not open log file \"%s\": %m", filename); - - return fh; -} - static void make_output_dirs(const char *log_basedir) { @@ -2530,8 +2514,10 @@ main(int argc, char **argv) make_output_dirs(opt.log_dir); internal_log_file = psprintf("%s/%s", logdir, INTERNAL_LOG_FILE_NAME); - /* logfile_open() will exit if there is an error */ - internal_log_file_fp = logfile_open(internal_log_file, "a"); + internal_log_file_fp = fopen(internal_log_file, "a"); + if (!internal_log_file_fp) + pg_fatal("could not open log file \"%s\": %m", internal_log_file); + pg_free(internal_log_file); pg_logging_set_logfile(internal_log_file_fp);