linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Neil Brown <neilb@suse.de>
To: Julia Lawall <julia.lawall@lip6.fr>
Cc: walter harms <wharms@bfs.de>, Firo Yang <firogm@gmail.com>,
	linux-raid@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] md: fix a build warning
Date: Thu, 11 Jun 2015 06:38:26 +1000	[thread overview]
Message-ID: <20150611063826.78ea7931@home.neil.brown.name> (raw)
In-Reply-To: <alpine.DEB.2.10.1506101935390.5463@hadrien>

On Wed, 10 Jun 2015 19:36:43 +0200 (CEST)
Julia Lawall <julia.lawall@lip6.fr> wrote:

> 
> 
> On Wed, 10 Jun 2015, walter harms wrote:
> 
> >
> >
> > Am 10.06.2015 17:20, schrieb Firo Yang:
> > > Warning like this:
> > >
> > > drivers/md/md.c: In function ‘update_array_info’:
> > > drivers/md/md.c:6394:26: warning: logical not is only applied
> > > to the left hand side of comparison [-Wlogical-not-parentheses]
> > >       !mddev->persistent  != info->not_persistent||
> > >
> > > I fix it by enclosing !mddev->persistent with parentheses
> > >
> > > By the way, I also fixed a line over 80 characters warning outputed
> > > by ./scripts/checkpatch.pl
> > >
> > > Signed-off-by: Firo Yang <firogm@gmail.com>
> > > ---
> > >  drivers/md/md.c | 5 +++--
> > >  1 file changed, 3 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/drivers/md/md.c b/drivers/md/md.c
> > > index dd85be9..b420d82 100644
> > > --- a/drivers/md/md.c
> > > +++ b/drivers/md/md.c
> > > @@ -6391,9 +6391,10 @@ static int update_array_info(struct mddev *mddev, mdu_array_info_t *info)
> > >  	    mddev->ctime         != info->ctime         ||
> > >  	    mddev->level         != info->level         ||
> > >  /*	    mddev->layout        != info->layout        || */
> > > -	    !mddev->persistent	 != info->not_persistent||
> > > +	    (!mddev->persistent) != info->not_persistent ||
> >
> >
> > this looks odd,
> > would it be possible the check for == instead (and drop the !) ?
> > and it someone care for readability: It would be helpful to
> > make some more ifs here.
> 
> The original issue looks like a false positive.  If all of the other cases
> have no parentheses on the left and use !=, isn't it better to leave the
> code as is?
> 

Leaving the code as it is would leave at least one compiler generating warnings.
I don't like warnings.
So if the compiler can be "fixed" that would be good.  But it seems unlikely.

May we could do:

> > > +	    mddev->persistent != !info->not_persistent ||

That would keep the two "not"s together, avoid the need for parentheses, and
probably avoid the compiler warning.
(I think I had it the way it is because it almost reads 
   " not ...peristent != ... not_persistent"
but that isn't a strong reason)

Firo: Can you confirm that this version doesn't upset the compiler?
If if doesn't I'd definitely prefer this one. (and definitely leave out the
comment change - just change the code)

Thanks,
NeilBrown


> julia
> 
> >
> > re,
> >  wh
> >
> > >  	    mddev->chunk_sectors != info->chunk_size >> 9 ||
> > > -	    /* ignore bottom 8 bits of state, and allow SB_BITMAP_PRESENT to change */
> > > +	    /* ignore bottom 8 bits of state, and allow SB_BITMAP_PRESENT
> > > +		to change */
> > >  	    ((state^info->state) & 0xfffffe00)
> > >  		)
> > >  		return -EINVAL;
> > --
> > To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html
> >
--
To unsubscribe from this list: send the line "unsubscribe linux-raid" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2015-06-10 20:38 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-10 15:20 [PATCH] md: fix a build warning Firo Yang
2015-06-10 16:07 ` Dan Carpenter
2015-06-10 17:32 ` walter harms
2015-06-10 17:36   ` Julia Lawall
2015-06-10 18:04     ` walter harms
2015-06-10 20:38     ` Neil Brown [this message]
2015-06-10 20:34   ` Neil Brown
2015-06-11 11:48 ` Dan Carpenter

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=20150611063826.78ea7931@home.neil.brown.name \
    --to=neilb@suse.de \
    --cc=firogm@gmail.com \
    --cc=julia.lawall@lip6.fr \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-raid@vger.kernel.org \
    --cc=wharms@bfs.de \
    /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).