Whamcloud - gitweb
libext2fs: improve jbd_debug() implementation
authorEric Biggers <ebiggers@google.com>
Wed, 16 Jun 2021 04:53:29 +0000 (21:53 -0700)
committerTheodore Ts'o <tytso@mit.edu>
Wed, 7 Jul 2021 02:34:03 +0000 (22:34 -0400)
Make jbd_debug() do format string checking (but still get compiled away
to nothing) when --enable-jbd-debug isn't specified, similar to
commit d556435156b7 ("jbd2: avoid -Wempty-body warnings") on the kernel
side.  This should prevent --enable-jbd-debug from getting broken due to
bad jbd_debug() statements.  It also eliminates a -Wunused-variable
warning where a variable was only used in a jbd_debug() statement.

Also remove an alternative definition of jbd_debug() that was
conditional on CONFIG_JBD_DEBUG && !CONFIG_JBD_DEBUG, so was dead code.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
debugfs/journal.c
e2fsck/journal.c
lib/ext2fs/kernel-jbd.h

index e8872f0..686d0eb 100644 (file)
@@ -26,9 +26,7 @@
 #include "uuid/uuid.h"
 #include "journal.h"
 
-#ifdef CONFIG_JBD_DEBUG                /* Enabled by configure --enable-jfs-debug */
 static int bh_count = 0;
-#endif
 
 #if EXT2_FLAT_INCLUDES
 #include "blkid.h"
@@ -135,10 +133,8 @@ struct buffer_head *getblk(kdev_t kdev, unsigned long long blocknr,
        if (retval)
                return NULL;
 
-#ifdef CONFIG_JBD_DEBUG
        if (journal_enable_debug >= 3)
                bh_count++;
-#endif
        jfs_debug(4, "getblk for block %llu (%d bytes)(total %d)\n",
                  blocknr, blocksize, bh_count);
 
index 0128fbd..16d5cf8 100644 (file)
@@ -27,9 +27,7 @@
 #include "problem.h"
 #include "uuid/uuid.h"
 
-#ifdef CONFIG_JBD_DEBUG                /* Enabled by configure --enable-jfs-debug */
 static int bh_count = 0;
-#endif
 
 /*
  * Define USE_INODE_IO to use the inode_io.c / fileio.c codepaths.
@@ -129,10 +127,8 @@ struct buffer_head *getblk(kdev_t kdev, unsigned long long blocknr,
        if (!bh)
                return NULL;
 
-#ifdef CONFIG_JBD_DEBUG
        if (journal_enable_debug >= 3)
                bh_count++;
-#endif
        jfs_debug(4, "getblk for block %llu (%d bytes)(total %d)\n",
                  blocknr, blocksize, bh_count);
 
index 2978ccb..c94de23 100644 (file)
@@ -26,7 +26,6 @@
 
 #define journal_oom_retry 0
 
-#ifdef __STDC__
 #ifdef CONFIG_JBD_DEBUG
 /*
  * Define JBD_EXPENSIVE_CHECKING to enable more expensive internal
  */
 #define JBD_EXPENSIVE_CHECKING
 extern int journal_enable_debug;
+#else
+#define journal_enable_debug (-1)
+#endif /* !CONFIG_JBD_DEBUG */
 
+#ifdef __STDC__
 #define jbd_debug(n, f, a...)                                          \
        do {                                                            \
                if ((n) <= journal_enable_debug) {                      \
@@ -45,27 +48,8 @@ extern int journal_enable_debug;
                }                                                       \
        } while (0)
 #else
-#ifdef __GNUC__
-#if defined(__KERNEL__) || !defined(CONFIG_JBD_DEBUG)
-#define jbd_debug(f, a...)     /**/
-#else
-extern int journal_enable_debug;
-#define jbd_debug(n, f, a...)                                          \
-       do {                                                            \
-               if ((n) <= journal_enable_debug) {                      \
-                       printf("(%s, %d): %s: ",                        \
-                               __FILE__, __LINE__, __func__);          \
-                       printf(f, ## a);                                \
-               }                                                       \
-       } while (0)
-#endif /*__KERNEL__ */
-#else
-#define jbd_debug(f, ...)      /**/
-#endif
-#endif
-#else
 #define jbd_debug(x)           /* AIX doesn't do STDC */
-#endif
+#endif /* !__STDC__ */
 
 extern void * __jbd_kmalloc (char *where, size_t size, int flags, int retry);
 #define jbd_kmalloc(size, flags) \