linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff Mahoney <jeffm@suse.com>
To: David Sterba <dsterba@suse.com>, linux-btrfs@vger.kernel.org
Subject: Re: [PATCH] btrfs: silence compiler warning when fs_info is not used
Date: Wed, 21 Sep 2016 12:16:41 -0400	[thread overview]
Message-ID: <46b76b10-7199-4938-bb78-15eee39e17da@suse.com> (raw)
In-Reply-To: <7a1f023d-d9c4-82ac-88d7-d123118f524a@suse.com>

On 9/21/16 11:47 AM, Jeff Mahoney wrote:
> On 9/21/16 11:43 AM, David Sterba wrote:
>> Some functions introduced a local fs_info pointer for the message
>> helpers. If btrfs_debug results to an empty macro, the fs_info pointer
>> is reported to be unused. Splitting the variable declaration and setting
>> will silence the warning, without any functional change.
> 
> I'm investigating fixing this differently.  I'd like the no-call version
> to silence the warning and let gcc optimize it out behind the seems if
> possible.

The following works for me.  It looks like this problem has existed since
commit 27a0dd61a5 (Btrfs: make btrfs_debug match pr_debug handling related to DEBUG)
but we just haven't hit it.

I'll post it separately for inclusion.

$ 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

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...)	\



-- 
Jeff Mahoney
SUSE Labs

  reply	other threads:[~2016-09-21 16:16 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-20 14:04 [PATCH 0/5] btrfs: printing cleanup patchset jeffm
2016-09-20 14:04 ` [PATCH 1/5] btrfs: add dynamic debug support jeffm
2016-09-20 14:05 ` [PATCH 2/5] btrfs: unsplit printed strings jeffm
2016-09-20 14:05 ` [PATCH 3/5] btrfs: convert printk(KERN_* to use pr_* calls jeffm
2016-09-20 14:05 ` [PATCH 4/5] btrfs: convert pr_* to btrfs_* where possible jeffm
2016-09-21 15:36   ` David Sterba
2016-09-23 12:37   ` David Sterba
2016-09-20 14:05 ` [PATCH 5/5] btrfs: convert send's verbose_printk to btrfs_debug jeffm
2016-09-21 15:43 ` [PATCH] btrfs: silence compiler warning when fs_info is not used David Sterba
2016-09-21 15:47   ` Jeff Mahoney
2016-09-21 16:16     ` Jeff Mahoney [this message]
2016-09-21 15:46 ` [PATCH 0/5] btrfs: printing cleanup patchset David Sterba
2016-09-21 16:17 ` [PATCH] btrfs: btrfs_debug should consume fs_info when DEBUG is not defined Jeff Mahoney
2016-09-22 14:43   ` David Sterba

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=46b76b10-7199-4938-bb78-15eee39e17da@suse.com \
    --to=jeffm@suse.com \
    --cc=dsterba@suse.com \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).