Linux-NFS Archive on lore.kernel.org
 help / color / Atom feed
From: Doug Nazar <nazard@nazar.ca>
To: linux-nfs@vger.kernel.org
Subject: [PATCH 05/11] xlog: Reorganize xlog_backend() to work around -Wmaybe-uninitialized
Date: Sat, 18 Jul 2020 05:24:15 -0400
Message-ID: <20200718092421.31691-6-nazard@nazar.ca> (raw)
In-Reply-To: <20200718092421.31691-1-nazard@nazar.ca>

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(-)

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);
 }
-- 
2.26.2


  parent reply index

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-18  9:24 [PATCH 00/11] nfs-utils: Misc cleanups & fixes Doug Nazar
2020-07-18  9:24 ` [PATCH 01/11] Add error handling to libevent allocations Doug Nazar
2020-07-18  9:24 ` [PATCH 02/11] gssd: Fix cccache buffer size Doug Nazar
2020-07-20 14:43   ` Steve Dickson
2020-07-20 15:41     ` Doug Nazar
2020-07-18  9:24 ` [PATCH 03/11] gssd: Fix handling of failed allocations Doug Nazar
2020-07-18  9:24 ` [PATCH 04/11] gssd: srchost should never be * Doug Nazar
2020-07-18  9:24 ` Doug Nazar [this message]
2020-07-18  9:24 ` [PATCH 06/11] nfsdcld: Add graceful exit handling and resource cleanup Doug Nazar
2020-07-18  9:24 ` [PATCH 07/11] nfsdcld: Don't copy more data than exists in column Doug Nazar
2020-07-18  9:24 ` [PATCH 08/11] svcgssd: Convert to using libevent Doug Nazar
2020-07-18  9:24 ` [PATCH 09/11] nfsidmap: Add support to cleanup resources on exit Doug Nazar
2020-07-20 15:49   ` Steve Dickson
2020-07-20 15:58     ` Doug Nazar
2020-07-20 17:31       ` Steve Dickson
2020-07-18  9:24 ` [PATCH 10/11] svcgssd: Cleanup global " Doug Nazar
2020-07-18  9:24 ` [PATCH 11/11] svcgssd: Wait for nullrpc channel if not available Doug Nazar
2020-07-18 15:55   ` J. Bruce Fields
2020-07-18 18:07     ` Doug Nazar
2020-07-27 14:42 ` [PATCH 00/11] nfs-utils: Misc cleanups & fixes Steve Dickson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200718092421.31691-6-nazard@nazar.ca \
    --to=nazard@nazar.ca \
    --cc=linux-nfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Linux-NFS Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-nfs/0 linux-nfs/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-nfs linux-nfs/ https://lore.kernel.org/linux-nfs \
		linux-nfs@vger.kernel.org
	public-inbox-index linux-nfs

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-nfs


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git