lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230121203230.27624-15-ebiggers@kernel.org>
Date:   Sat, 21 Jan 2023 12:32:06 -0800
From:   Eric Biggers <ebiggers@...nel.org>
To:     linux-ext4@...r.kernel.org
Subject: [PATCH 14/38] lib/et: fix "unused variable" warnings when !HAVE_FCNTL

From: Eric Biggers <ebiggers@...gle.com>

In init_debug(), avoid -Wunused-variable and -Wunused-but-set-variable
warnings when HAVE_FCNTL is not defined by only declaring 'fd' and
'flags' when HAVE_FCNTL is defined.  This affected Windows builds.

Signed-off-by: Eric Biggers <ebiggers@...gle.com>
---
 lib/et/Android.bp      |  3 ---
 lib/et/error_message.c | 10 +++++-----
 2 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/lib/et/Android.bp b/lib/et/Android.bp
index 07f3c277e..565feb594 100644
--- a/lib/et/Android.bp
+++ b/lib/et/Android.bp
@@ -31,9 +31,6 @@ cc_library {
     target: {
         windows: {
             enabled: true,
-            cflags: [
-                "-Wno-unused-variable",
-            ],
         },
     },
 
diff --git a/lib/et/error_message.c b/lib/et/error_message.c
index cd9f57f56..8b9474ffa 100644
--- a/lib/et/error_message.c
+++ b/lib/et/error_message.c
@@ -235,7 +235,6 @@ static FILE *debug_f = 0;
 static void init_debug(void)
 {
 	char	*dstr, *fn, *tmp;
-	int	fd, flags;
 
 	if (debug_mask & DEBUG_INIT)
 		return;
@@ -257,10 +256,12 @@ static void init_debug(void)
 	if (!debug_f)
 		debug_f = fopen("/dev/tty", "a");
 	if (debug_f) {
-		fd = fileno(debug_f);
-#if defined(HAVE_FCNTL)
+#ifdef HAVE_FCNTL
+		int fd = fileno(debug_f);
+
 		if (fd >= 0) {
-			flags = fcntl(fd, F_GETFD);
+			int flags = fcntl(fd, F_GETFD);
+
 			if (flags >= 0)
 				flags = fcntl(fd, F_SETFD, flags | FD_CLOEXEC);
 			if (flags < 0) {
@@ -274,7 +275,6 @@ static void init_debug(void)
 #endif
 	} else
 		debug_mask = DEBUG_INIT;
-
 }
 
 /*
-- 
2.39.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ