lib: Simplify check_log_size
authorVolker Lendecke <vl@samba.org>
Mon, 15 Dec 2014 11:09:11 +0000 (12:09 +0100)
committerJeremy Allison <jra@samba.org>
Sun, 28 Dec 2014 00:57:08 +0000 (01:57 +0100)
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
lib/util/debug.c

index b050205bf10da22575064b7813a025a972e6c15e..a794c5b28deab9c57536479edad71afe308d693e 100644 (file)
@@ -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);
                }
        }