Linux-BTRFS Archive on lore.kernel.org
 help / color / Atom feed
From: David Sterba <dsterba@suse.cz>
To: dsterba@suse.cz, Anders Roxell <anders.roxell@linaro.org>,
	clm@fb.com, josef@toxicpanda.com, dsterba@suse.com,
	linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] btrfs: relocation: fix unused variable
Date: Tue, 29 Jan 2019 16:42:13 +0100
Message-ID: <20190129154212.GO2900@twin.jikos.cz> (raw)
In-Reply-To: <20190129152127.GN2900@twin.jikos.cz>

On Tue, Jan 29, 2019 at 04:21:27PM +0100, David Sterba wrote:
> On Tue, Jan 29, 2019 at 02:01:46PM +0100, Anders Roxell wrote:
> > When CONFIG_BRTFS_ASSERT isn't enabled, variable root_objectid isn't used.
> > 
> > fs/btrfs/relocation.c: In function ‘insert_dirty_subv’:
> > fs/btrfs/relocation.c:2138:6: warning: unused variable ‘root_objectid’ [-Wunused-variable]
> >   u64 root_objectid = root->root_key.objectid;
> >       ^~~~~~~~~~~~~
> > 
> > Reworked by adding a runtime check in the assfail function instead of
> > the '#ifdef CONFIG_BTRFS_ASSERT #else ...", so the compiler sees the
> > condition being passed into an inline function after preprocessing.
> 
> I've fixed the warning by avoiding the local variable but I like your
> fix in general, thanks.

Committed with this changelog:

"btrfs: let the assertion expression compile in all configs

 A compiler warning (in a patch in development) pointed to a variable
 that was used only inside and ASSERT:

   u64 root_objectid = root->root_key.objectid;
   ASSERT(root_objectid == ...);

   fs/btrfs/relocation.c: In function ‘insert_dirty_subv’:
   fs/btrfs/relocation.c:2138:6: warning: unused variable ‘root_objectid’ [-Wunused-variable]
     u64 root_objectid = root->root_key.objectid;
	 ^~~~~~~~~~~~~

 When CONFIG_BRTFS_ASSERT isn't enabled, variable root_objectid isn't used.

 Rework the assertion helper by adding a runtime check instead of the
 '#ifdef CONFIG_BTRFS_ASSERT #else ...", so the compiler sees the
 condition being passed into an inline function after preprocessing."

      reply index

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-29 13:01 Anders Roxell
2019-01-29 15:21 ` David Sterba
2019-01-29 15:42   ` David Sterba [this message]

Reply instructions:

You may reply publically 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=20190129154212.GO2900@twin.jikos.cz \
    --to=dsterba@suse.cz \
    --cc=anders.roxell@linaro.org \
    --cc=clm@fb.com \
    --cc=dsterba@suse.com \
    --cc=josef@toxicpanda.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-kernel@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

Linux-BTRFS Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-btrfs/0 linux-btrfs/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-btrfs linux-btrfs/ https://lore.kernel.org/linux-btrfs \
		linux-btrfs@vger.kernel.org linux-btrfs@archiver.kernel.org
	public-inbox-index linux-btrfs


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-btrfs


AGPL code for this site: git clone https://public-inbox.org/ public-inbox