@@ -156,13 +156,29 @@ xlog_enabled(int fac)
void
xlog_backend(int kind, const char *fmt, va_list args)
{
- va_list args2;
-
if (!(kind & (L_ALL)) && !(logging && (kind & logmask)))
return;
- if (log_stderr)
+ if (log_stderr) {
+ va_list args2;
+#ifdef VERBOSE_PRINTF
+ time_t now;
+ struct tm *tm;
+
+ time(&now);
+ tm = localtime(&now);
+ fprintf(stderr, "%s[%d] %04d-%02d-%02d %02d:%02d:%02d ",
+ log_name, log_pid,
+ tm->tm_year+1900, tm->tm_mon + 1, tm->tm_mday,
+ tm->tm_hour, tm->tm_min, tm->tm_sec);
+#else
+ fprintf(stderr, "%s: ", log_name);
+#endif
va_copy(args2, args);
+ vfprintf(stderr, fmt, args2);
+ fprintf(stderr, "\n");
+ va_end(args2);
+ }
if (log_syslog) {
switch (kind) {
@@ -185,25 +201,6 @@ xlog_backend(int kind, const char *fmt, va_list args)
}
}
- if (log_stderr) {
-#ifdef VERBOSE_PRINTF
- time_t now;
- struct tm *tm;
-
- time(&now);
- tm = localtime(&now);
- fprintf(stderr, "%s[%d] %04d-%02d-%02d %02d:%02d:%02d ",
- log_name, log_pid,
- tm->tm_year+1900, tm->tm_mon + 1, tm->tm_mday,
- tm->tm_hour, tm->tm_min, tm->tm_sec);
-#else
- fprintf(stderr, "%s: ", log_name);
-#endif
- vfprintf(stderr, fmt, args2);
- fprintf(stderr, "\n");
- va_end(args2);
- }
-
if (kind == L_FATAL)
exit(1);
}
xlog.c: In function ‘xlog_backend’: xlog.c:202:3: warning: ‘args2’ may be used uninitialized in this function [-Wmaybe-uninitialized] 202 | vfprintf(stderr, fmt, args2); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ Signed-off-by: Doug Nazar <nazard@nazar.ca> --- support/nfs/xlog.c | 41 +++++++++++++++++++---------------------- 1 file changed, 19 insertions(+), 22 deletions(-)