public inbox for linux-crypto@vger.kernel.org
 help / color / mirror / Atom feed
From: Julia Lawall <julia.lawall@lip6.fr>
To: Varsha Rao <rvarsha016@gmail.com>
Cc: Joe Perches <joe@perches.com>,
	linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org,
	cocci <cocci@systeme.lip6.fr>,
	Herbert Xu <herbert@gondor.apana.org.au>,
	"David S. Miller" <davem@davemloft.net>
Subject: Re: [Cocci] [PATCH] crypto: cavium: zip: Remove unnecessary parentheses
Date: Sat, 31 Mar 2018 10:55:44 +0200 (CEST)	[thread overview]
Message-ID: <alpine.DEB.2.20.1803311054580.2373@hadrien> (raw)
In-Reply-To: <CAAFX7JTEK5NyvKmYoC6b4tSv9a7Gv1WHONmp4nXxnuz8rqOmxw@mail.gmail.com>



On Sat, 31 Mar 2018, Varsha Rao wrote:

> On Sat, Mar 31, 2018 at 11:48 AM, Julia Lawall  wrote:
> > On Thu, 29 Mar 2018, Varsha Rao wrote:
> >
> >> On Wed, Mar 28, 2018 at 11:41 PM, Joe Perches wrote:
> >> >
> >> > On Wed, 2018-03-28 at 23:27, Varsha Rao wrote:
> >> > > This patch fixes the clang warning of extraneous parentheses, with the
> >> > > following coccinelle script.
> >> > >
> >> > > @@
> >> > > identifier i;
> >> > > constant c;
> >> > > @@
> >> > > (
> >> > > -((i == c))
> >> > > +i == c
> >> > > >
> >> > >
> >> > > -((i <= c))
> >> > > +i <= c
> >> >
> >> > Why just the "==" and "<=" cases?
> >> > Why not "<", ">" and ">=" too?
> >> >
> >> > Why not expression instead of constant?
> >>
> >> Initially I had the other cases too and used expression instead of
> >> constant. But the results included only "==" and "<=" cases with
> >> constant. Along with one false positive case.
> >>
> >> --- a/drivers/crypto/cavium/zip/zip_main.c
> >> +++ b/drivers/crypto/cavium/zip/zip_main.c
> >> @@ -99,7 +99,7 @@ static struct zip_device *zip_alloc_devi
> >>   */
> >>  struct zip_device *zip_get_device(int node)
> >>  {
> >> -    if ((node < MAX_ZIP_DEVICES) && (node >= 0))
> >> +    if (node < MAX_ZIP_DEVICES && node >= 0)
> >
> > Why is it a false positive?
>
> The parentheses around multiple expressions in if statement is not
> considered extra, right?

< and >= should bind tighter than &&.  But perhaps one could fine the
original code to be more readable.

julia

      reply	other threads:[~2018-03-31  8:55 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-28 17:57 [PATCH] crypto: cavium: zip: Remove unnecessary parentheses Varsha Rao
2018-03-28 18:11 ` Joe Perches
2018-03-29 15:33   ` Varsha Rao
2018-03-30 20:17     ` Joe Perches
2018-03-31  6:17       ` Julia Lawall
2018-03-31  6:18     ` Julia Lawall
2018-03-31  8:48       ` [Cocci] " Varsha Rao
2018-03-31  8:55         ` Julia Lawall [this message]

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=alpine.DEB.2.20.1803311054580.2373@hadrien \
    --to=julia.lawall@lip6.fr \
    --cc=cocci@systeme.lip6.fr \
    --cc=davem@davemloft.net \
    --cc=herbert@gondor.apana.org.au \
    --cc=joe@perches.com \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rvarsha016@gmail.com \
    /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