Whamcloud - gitweb
lib/et: fix "unused variable" warnings when !HAVE_FCNTL
authorEric Biggers <ebiggers@google.com>
Sat, 21 Jan 2023 20:32:06 +0000 (12:32 -0800)
committerTheodore Ts'o <tytso@mit.edu>
Fri, 27 Jan 2023 17:33:59 +0000 (12:33 -0500)
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@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
lib/et/Android.bp
lib/et/error_message.c

index 07f3c27..565feb5 100644 (file)
@@ -31,9 +31,6 @@ cc_library {
     target: {
         windows: {
             enabled: true,
-            cflags: [
-                "-Wno-unused-variable",
-            ],
         },
     },
 
index cd9f57f..8b9474f 100644 (file)
@@ -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;
-
 }
 
 /*