From 7954e9405fab8c90a083a301a657342d5125c3d8 Mon Sep 17 00:00:00 2001 From: Andrea Mazzoleni Date: Tue, 3 Feb 2015 18:30:32 +0100 Subject: [PATCH] Disable stdlog if log file is not specified --- cmdline/snapraid.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/cmdline/snapraid.c b/cmdline/snapraid.c index 1f333c52..c9b73f29 100644 --- a/cmdline/snapraid.c +++ b/cmdline/snapraid.c @@ -92,14 +92,9 @@ void log_open(const char* log) time_t t; struct tm* tm; - /* if no log file is specified, don't output */ - if (log == 0) { -#ifdef _WIN32 - log = "NUL"; -#else - log = "/dev/null"; -#endif - } + /* leave stdlog at 0 if not specified */ + if (log == 0) + return; t = time(0); tm = localtime(&t); @@ -174,7 +169,7 @@ void log_open(const char* log) void log_close(const char* log) { - if (stdlog != stdout && stdlog != stderr) { + if (stdlog != stdout && stdlog != stderr && stdlog != 0) { if (fclose(stdlog) != 0) { /* LCOV_EXCL_START */ ferr("Error closing the log file '%s'. %s.\n", log, strerror(errno)); @@ -182,6 +177,8 @@ void log_close(const char* log) /* LCOV_EXCL_STOP */ } } + + stdlog = 0; } /****************************************************************************/