linux-xfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: Allison Collins <allison.henderson@oracle.com>
Cc: linux-xfs@vger.kernel.org
Subject: Re: [PATCH v2 1/2] xfs: Fix compiler warning in xfs_attr_node_removename_setup
Date: Mon, 27 Jul 2020 11:50:16 -0700	[thread overview]
Message-ID: <20200727185016.GB3151642@magnolia> (raw)
In-Reply-To: <a641cbc8-6cda-25b2-f6e6-63e52fde572a@oracle.com>

On Mon, Jul 27, 2020 at 09:51:54AM -0700, Allison Collins wrote:
> 
> 
> On 7/27/20 8:46 AM, Darrick J. Wong wrote:
> > On Sun, Jul 26, 2020 at 07:26:07PM -0700, Allison Collins wrote:
> > > Fix compiler warning for variable 'blk' set but not used in
> > > xfs_attr_node_removename_setup.  blk is used only in an ASSERT so only
> > > declare blk when DEBUG is set.
> > > 
> > > Reported-by: kernel test robot <lkp@intel.com>
> > > Signed-off-by: Allison Collins <allison.henderson@oracle.com>
> > > ---
> > >   fs/xfs/libxfs/xfs_attr.c | 2 ++
> > >   1 file changed, 2 insertions(+)
> > > 
> > > diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c
> > > index d4583a0..5168d32 100644
> > > --- a/fs/xfs/libxfs/xfs_attr.c
> > > +++ b/fs/xfs/libxfs/xfs_attr.c
> > > @@ -1174,7 +1174,9 @@ int xfs_attr_node_removename_setup(
> > >   	struct xfs_da_state	**state)
> > >   {
> > >   	int			error;
> > > +#ifdef DEBUG
> > >   	struct xfs_da_state_blk	*blk;
> > > +#endif
> > 
> > But now a non-DEBUG compilation will trip over the assignment to blk:
> > 
> > 	blk = &(*state)->path.blk[(*state)->path.active - 1];
> > 
> > that comes just before the asserts, right?
> > 
> > 	ASSERT((*state)->path.blk[(*state)->path.active - 1].bp != NULL);
> > 	ASSERT((*state)->path.blk[(*state)->path.active - 1].magic ==
> > 		XFS_ATTR_LEAF_MAGIC);
> > 
> > In the end you probably just want to encode the accessor logic in the
> > assert body so the whole thing just disappears entirely.
> Are you sure you'd rather have it that way, then once up in the declaration?
> Like this:
> 
> #ifdef DEBUG
> 	struct xfs_da_state_blk	*blk = &(*state)->path.blk[(*state)->path.active -
> 1];
> #endif

I thought xfs_attr_node_hasname could allocate the da state and set
*state, which means that we can't dereference *state until after that
call?

--D

> > 
> > --D
> > 
> > >   	error = xfs_attr_node_hasname(args, state);
> > >   	if (error != -EEXIST)
> > > -- 
> > > 2.7.4
> > > 

  reply	other threads:[~2020-07-27 18:52 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-27  2:26 [PATCH v2 0/2] xfs: Fix compiler warnings Allison Collins
2020-07-27  2:26 ` [PATCH v2 1/2] xfs: Fix compiler warning in xfs_attr_node_removename_setup Allison Collins
2020-07-27 15:46   ` Darrick J. Wong
2020-07-27 16:42     ` Allison Collins
2020-07-27 16:51     ` Allison Collins
2020-07-27 18:50       ` Darrick J. Wong [this message]
2020-07-27 19:20         ` Allison Collins
2020-07-27  2:26 ` [PATCH v2 2/2] xfs: Fix compiler warning in xfs_attr_shortform_add Allison Collins

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=20200727185016.GB3151642@magnolia \
    --to=darrick.wong@oracle.com \
    --cc=allison.henderson@oracle.com \
    --cc=linux-xfs@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).