Re: [PATCH] ext4: address a benign compiler warning

From: Joe Perches
Date: Wed Feb 12 2014 - 22:00:00 EST


On Wed, 2014-02-12 at 21:13 -0500, Patrick Palka wrote:
> 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.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);
> ---
> diff --git a/fs/ext4/mballoc.h b/fs/ext4/mballoc.h
[]
> @@ -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


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/