[PATCH] lib: Simplify check_log_size
Volker Lendecke
Volker.Lendecke at SerNet.DE
Sat Dec 27 03:47:30 MST 2014
Hi!
Review&push appreciated!
Thanks,
Volker
--
SerNet GmbH, Bahnhofsallee 1b, 37081 Göttingen
phone: +49-551-370000-0, fax: +49-551-370000-9
AG Göttingen, HRB 2816, GF: Dr. Johannes Loxen
http://www.sernet.de, mailto:kontakt at sernet.de
-------------- next part --------------
From 6672886a5c5225d4fb6778ed1bc90552d0389417 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Mon, 15 Dec 2014 12:09:11 +0100
Subject: [PATCH] lib: Simplify check_log_size
Signed-off-by: Volker Lendecke <vl at samba.org>
---
lib/util/debug.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/lib/util/debug.c b/lib/util/debug.c
index b050205..a794c5b 100644
--- a/lib/util/debug.c
+++ b/lib/util/debug.c
@@ -708,18 +708,16 @@ void check_log_size( void )
(void)reopen_logs_internal();
if (state.fd > 2 && (fstat(state.fd, &st) == 0
&& st.st_size > maxlog)) {
- char *name = NULL;
+ char name[strlen(state.debugf) + 5];
+
+ snprintf(name, sizeof(name), "%s.old", state.debugf);
- if (asprintf(&name, "%s.old", state.debugf ) < 0) {
- return;
- }
(void)rename(state.debugf, name);
if (!reopen_logs_internal()) {
/* We failed to reopen a log - continue using the old name. */
(void)rename(name, state.debugf);
}
- SAFE_FREE(name);
}
}
--
1.9.1
More information about the samba-technical
mailing list