From 262f1d7e471bacca6b985ec3f2cd5cb76d6e2584 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Thu, 18 Oct 2018 02:06:58 +0300 Subject: [PATCH] Fix build failures The freopen return value caused warnings. --- server/core/log_manager.cc | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/server/core/log_manager.cc b/server/core/log_manager.cc index d625235a4..3d2194b87 100644 --- a/server/core/log_manager.cc +++ b/server/core/log_manager.cc @@ -576,8 +576,11 @@ static bool logmanager_init_nomutex(const char* ident, if (redirect_stdout) { // Redirect stdout and stderr to the log file - freopen(lm->lm_logfile.lf_full_file_name, "a", stdout); - freopen(lm->lm_logfile.lf_full_file_name, "a", stderr); + if (!freopen(lm->lm_logfile.lf_full_file_name, "a", stdout) || + !freopen(lm->lm_logfile.lf_full_file_name, "a", stderr)) + { + fprintf(stderr, "Error: Failed to redirect stdout/stderr to log file.\n"); + } } return_succ: @@ -2166,8 +2169,12 @@ static bool thr_flush_file(logmanager_t *lm, filewriter_t *fwr) else if (redirect_stdout) { // Redirect stdout and stderr to the new log file - freopen(lf->lf_full_file_name, "a", stdout); - freopen(lf->lf_full_file_name, "a", stderr); + if (!freopen(lf->lf_full_file_name, "a", stdout) || + !freopen(lf->lf_full_file_name, "a", stderr)) + { + LOG_ERROR("MaxScale Log: Error, could not redirect stdout/stderr to log file %s.\n", + lf->lf_full_file_name); + } } }