debug: Always store short version of prog_name in debug state
authorChristof Schmitt <cs@samba.org>
Tue, 24 Feb 2015 21:09:18 +0000 (14:09 -0700)
committerChristof Schmitt <cs@samba.org>
Mon, 23 Mar 2015 20:22:11 +0000 (21:22 +0100)
Storing the prog_name in the debug state is not necessary at this point,
but it will be used later.

Signed-off-by: Christof Schmitt <cs@samba.org>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
lib/util/debug.c

index c502d27d35a4ec00d04f2923c5be2871229fcb38..9a4e5718112a53e044141759878cf23f5f07617e 100644 (file)
@@ -479,20 +479,23 @@ void setup_logging(const char *prog_name, enum debug_logtype new_logtype)
                state.logtype = new_logtype;
        }
        if (prog_name) {
+               const char *p = strrchr(prog_name, '/');
+
+               if (p) {
+                       prog_name = p + 1;
+               }
+
                state.prog_name = prog_name;
        }
        reopen_logs_internal();
 
        if (state.logtype == DEBUG_FILE) {
 #ifdef WITH_SYSLOG
-               const char *p = strrchr(prog_name, '/');
-               if (p)
-                       prog_name = p + 1;
 #ifdef LOG_DAEMON
-               openlog( prog_name, LOG_PID, SYSLOG_FACILITY );
+               openlog(state.prog_name, LOG_PID, SYSLOG_FACILITY );
 #else
                /* for old systems that have no facility codes. */
-               openlog( prog_name, LOG_PID );
+               openlog(state.prog_name, LOG_PID );
 #endif
 #endif
        }