diff options
author | Doug Nazar <nazard@nazar.ca> | 2020-07-20 11:31:18 -0400 |
---|---|---|
committer | Steve Dickson <steved@redhat.com> | 2020-07-22 10:39:16 -0400 |
commit | 092e0baa7726a3f215c91e21cc91ab8ab89ef7c7 (patch) | |
tree | 7af9914ed6963c339dcc565b5e95686975ec22b2 | |
parent | f2c9748caa2fa3959f2b62b55e583193ff619e30 (diff) | |
download | nfs-utils-092e0baa7726a3f215c91e21cc91ab8ab89ef7c7.tar.gz |
xlog: Reorganize xlog_backend() to work around -Wmaybe-uninitialized
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>
Signed-off-by: Steve Dickson <steved@redhat.com>
-rw-r--r-- | support/nfs/xlog.c | 41 |
1 files changed, 19 insertions, 22 deletions
diff --git a/support/nfs/xlog.c b/support/nfs/xlog.c index 687d862d..86acd6ac 100644 --- a/support/nfs/xlog.c +++ b/support/nfs/xlog.c @@ -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); } |