Skip to contentSkip to conversation

ext4: address a benign compiler warning

PATCH In review Patrick Palka 3 participants 5 messages Feb 13, 2014 – Feb 18, 2014 ext4 file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ext4: address a benign compiler warning

When !defined(CONFIG_EXT4_DEBUG), mb_debug() should be defined as an empty do-while statement so as to suppress the following compiler warning:

fs/ext4/mballoc.c: In function ‘ext4_mb_cleanup_pa’:
fs/ext4/mballoc.c:2659:47: warning: suggest braces around empty body in an ‘if’ statement [-Wempty-body]
mb_debug(1, "mballoc: %u PAs left\n", count);

---
 fs/ext4/mballoc.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ext4/mballoc.h +1 -1
index 08481ee..92eeb98 100644
@@ -48,7 +48,7 @@ extern ushort ext4_mballoc_debug;
 		}							\
 	} while (0)
 #else
-#define mb_debug(n, fmt, a...)
+#define mb_debug(n, fmt, a...)		do { } while (0)
 #endif
 
 #define EXT4_MB_HISTORY_ALLOC		1	/* allocation */
Signature · 6 lines
1.9.0.rc3

--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#1 lore raw
Quoted 3 lines · Patrick Palka

When !defined(CONFIG_EXT4_DEBUG), mb_debug() should be defined as an empty do-while statement so as to suppress the following compiler warning:

Hello Patrick.

fs/ext4/mballoc.h

Quoted 5 lines

fs/ext4/mballoc.c: In function ‘ext4_mb_cleanup_pa’:
fs/ext4/mballoc.c:2659:47: warning: suggest braces around empty body in an ‘if’ statement [-Wempty-body]
mb_debug(1, "mballoc: %u PAs left\n", count);
---

fs/ext4/mballoc.h +0 -0

[]

fs/ext4/mballoc.h extern ushort ext4_mballoc_debug; · line 51

Quoted 6 lines
fs/ext4/mballoc.h +1 -1
@@ -48,7 +48,7 @@ extern ushort ext4_mballoc_debug;
 		}							\
 	} while (0)
 #else
-#define mb_debug(n, fmt, a...)
+#define mb_debug(n, fmt, a...)		do { } while (0)

Ideally, this section should be something like below so the !CONFIG_EXT4_DEBUG case still verifies that the format and argument types match.

This can help avoid people adding debug statements but not compiling with the proper CONFIG_<foo> variable set.

---

#ifdef CONFIG_EXT4_DEBUG
extern ushort ext4_mballoc_debug;

#define mb_debug(n, fmt, ...) \

do {								\
	if ((n) <= ext4_mballoc_debug)				\
		pr_debug(fmt, ##__VA_ARGS__);			\
	}							\
} while (0)
#else
#define mb_debug(n, fmt, ...)					\
	no_printk(KERN_DEBUG fmt, ##__VA_ARGS__)

#endif

#2 lore raw
Quoted 41 lines · Joe Perches
Quoted 3 lines · Patrick Palka

When !defined(CONFIG_EXT4_DEBUG), mb_debug() should be defined as an empty do-while statement so as to suppress the following compiler warning:

Hello Patrick.

fs/ext4/mballoc.h

Quoted 5 lines

fs/ext4/mballoc.c: In function 'ext4_mb_cleanup_pa':
fs/ext4/mballoc.c:2659:47: warning: suggest braces around empty body in an 'if' statement [-Wempty-body]
mb_debug(1, "mballoc: %u PAs left\n", count);
---

fs/ext4/mballoc.h +0 -0

[]

fs/ext4/mballoc.h extern ushort ext4_mballoc_debug; · line 51

Quoted 6 lines
fs/ext4/mballoc.h +1 -1
@@ -48,7 +48,7 @@ extern ushort ext4_mballoc_debug;
              }                                                       \
      } while (0)
 #else
-#define mb_debug(n, fmt, a...)
+#define mb_debug(n, fmt, a...)               do { } while (0)

Ideally, this section should be something like below so the !CONFIG_EXT4_DEBUG case still verifies that the format and argument types match.

This can help avoid people adding debug statements but not compiling with the proper CONFIG_<foo> variable set.

---

#ifdef CONFIG_EXT4_DEBUG
extern ushort ext4_mballoc_debug;

#define mb_debug(n, fmt, ...)                                   \
do {                                                            \
        if ((n) <= ext4_mballoc_debug)                          \
                pr_debug(fmt, ##__VA_ARGS__);                   \
        }                                                       \
} while (0)
#else
#define mb_debug(n, fmt, ...)                                   \
        no_printk(KERN_DEBUG fmt, ##__VA_ARGS__)
Quoted 3 lines

#endif

Hi Joe,

Thanks! I was not aware of that idiom. It makes a good amount of sense. I'm going to send a revised version of the patch shortly.

Patrick

#3 lore raw

PATCH 1/1 ext4: address a benign compiler warning

When !defined(CONFIG_EXT4_DEBUG), mb_debug() should be defined as a no_printk() statement instead of an empty statement in order to suppress the following compiler warning:

fs/ext4/mballoc.c: In function ‘ext4_mb_cleanup_pa’:
fs/ext4/mballoc.c:2659:47: warning: suggest braces around empty body in an ‘if’ statement [-Wempty-body]
mb_debug(1, "mballoc: %u PAs left\n", count);

---
 fs/ext4/mballoc.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ext4/mballoc.h +1 -1
index 08481ee..9347328 100644
@@ -48,7 +48,7 @@ extern ushort ext4_mballoc_debug;
 		}							\
 	} while (0)
 #else
-#define mb_debug(n, fmt, a...)
+#define mb_debug(n, fmt, a...)		no_printk(fmt, ## a)
 #endif
 
 #define EXT4_MB_HISTORY_ALLOC		1	/* allocation */
Signature · 6 lines
1.9.0.rc3

--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
maintainer Applied
#4 lore raw
Quoted 9 lines · Patrick Palka

When !defined(CONFIG_EXT4_DEBUG), mb_debug() should be defined as a no_printk() statement instead of an empty statement in order to suppress the following compiler warning:

fs/ext4/mballoc.c: In function ‘ext4_mb_cleanup_pa’:
fs/ext4/mballoc.c:2659:47: warning: suggest braces around empty body in an ‘if’ statement [-Wempty-body]
mb_debug(1, "mballoc: %u PAs left\n", count);

Thanks, applied.

- Ted