diff mbox

btrfs: btrfs_debug should consume fs_info when DEBUG is not defined

Message ID 44bec1b2-b961-ff13-374d-57b7adf5e3fd@suse.com (mailing list archive)
State Accepted
Headers show

Commit Message

Jeff Mahoney Sept. 21, 2016, 4:17 p.m. UTC
We can hit unused variable warnings when btrfs_debug and friends are
just aliases for no_printk.  This is due to the fs_info not getting
consumed by the function call, which can happen if convenenience
variables are used.  This patch adds a new btrfs_no_printk static inline
that consumes the convenience variable and does nothing else.  It
silences the unused variable warning and has no impact on the generated
code:

$ size fs/btrfs/extent_io.o*
   text	   data	    bss	    dec	    hex	filename
  44072	    152	     32	  44256	   ace0	fs/btrfs/extent_io.o.btrfs_no_printk
  44072	    152	     32	  44256	   ace0	fs/btrfs/extent_io.o.no_printk

Fixes: 27a0dd61a5 (Btrfs: make btrfs_debug match pr_debug handling related to DEBUG)
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
---
 fs/btrfs/ctree.h | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

Comments

David Sterba Sept. 22, 2016, 2:43 p.m. UTC | #1
On Wed, Sep 21, 2016 at 12:17:37PM -0400, Jeff Mahoney wrote:
> We can hit unused variable warnings when btrfs_debug and friends are
> just aliases for no_printk.  This is due to the fs_info not getting
> consumed by the function call, which can happen if convenenience
> variables are used.  This patch adds a new btrfs_no_printk static inline
> that consumes the convenience variable and does nothing else.  It
> silences the unused variable warning and has no impact on the generated
> code:
> 
> $ size fs/btrfs/extent_io.o*
>    text	   data	    bss	    dec	    hex	filename
>   44072	    152	     32	  44256	   ace0	fs/btrfs/extent_io.o.btrfs_no_printk
>   44072	    152	     32	  44256	   ace0	fs/btrfs/extent_io.o.no_printk
> 
> Fixes: 27a0dd61a5 (Btrfs: make btrfs_debug match pr_debug handling related to DEBUG)
> Signed-off-by: Jeff Mahoney <jeffm@suse.com>

Looks good, aded to the queue.
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index b967af5..e51ee72 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -3241,6 +3241,12 @@  int btrfs_sync_fs(struct super_block *sb, int wait);
 #ifdef CONFIG_PRINTK
 __printf(2, 3)
 void btrfs_printk(const struct btrfs_fs_info *fs_info, const char *fmt, ...);
+__printf(2, 3)
+static inline int btrfs_no_printk(const struct btrfs_fs_info *fs_info,
+				   const char *fmt, ...)
+{
+	return 0;
+}
 #else
 static inline __printf(2, 3)
 void btrfs_printk(const struct btrfs_fs_info *fs_info, const char *fmt, ...)
@@ -3355,13 +3361,13 @@  do {									\
 	btrfs_printk_ratelimited(fs_info, KERN_DEBUG fmt, ##args)
 #else
 #define btrfs_debug(fs_info, fmt, args...) \
-	no_printk(KERN_DEBUG fmt, ##args)
+	btrfs_no_printk(fs_info, KERN_DEBUG fmt, ##args)
 #define btrfs_debug_in_rcu(fs_info, fmt, args...) \
-	no_printk(KERN_DEBUG fmt, ##args)
+	btrfs_no_printk(fs_info, KERN_DEBUG fmt, ##args)
 #define btrfs_debug_rl_in_rcu(fs_info, fmt, args...) \
-	no_printk(KERN_DEBUG fmt, ##args)
+	btrfs_no_printk(fs_info, KERN_DEBUG fmt, ##args)
 #define btrfs_debug_rl(fs_info, fmt, args...) \
-	no_printk(KERN_DEBUG fmt, ##args)
+	btrfs_no_printk(fs_info, KERN_DEBUG fmt, ##args)
 #endif
 
 #define btrfs_printk_in_rcu(fs_info, fmt, args...)	\