git » nmdb » commit 0f2ab7e

Simplify log_init() and log_reopen()

author Alberto Bertogli
2008-06-01 04:07:15 UTC
committer Alberto Bertogli
2008-06-01 04:07:15 UTC
parent ef3c2b1b2a91904b630573417e88946993c82e06

Simplify log_init() and log_reopen()

Signed-off-by: Alberto Bertogli <albertito@gmail.com>

nmdb/log.c +8 -16

diff --git a/nmdb/log.c b/nmdb/log.c
index 8162493..b20b9f0 100644
--- a/nmdb/log.c
+++ b/nmdb/log.c
@@ -25,23 +25,8 @@ int log_init(void)
 
 	if (strcmp(settings.logfname, "-") == 0) {
 		logfd = 1;
-	} else {
-		logfd = open(settings.logfname, O_WRONLY | O_APPEND | O_CREAT,
-				0660);
-		if (logfd < 0)
-			return 0;
-	}
-
-	return 1;
-}
-
-int log_reopen(void)
-{
-	if (settings.logfname == NULL)
-		return 1;
-
-	if (strcmp(settings.logfname, "-") == 0)
 		return 1;
+	}
 
 	logfd = open(settings.logfname, O_WRONLY | O_APPEND | O_CREAT, 0660);
 	if (logfd < 0)
@@ -50,6 +35,13 @@ int log_reopen(void)
 	return 1;
 }
 
+int log_reopen(void)
+{
+	/* Just call log_init(), it will do just fine as we don't need any
+	 * special considerations for reopens */
+	return log_init();
+}
+
 void wlog(const char *fmt, ...)
 {
 	int r, tr;