lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Sat, 31 Mar 2018 10:55:44 +0200 (CEST)
From:   Julia Lawall <julia.lawall@...6.fr>
To:     Varsha Rao <rvarsha016@...il.com>
cc:     Joe Perches <joe@...ches.com>, linux-crypto@...r.kernel.org,
        linux-kernel@...r.kernel.org, cocci <cocci@...teme.lip6.fr>,
        Herbert Xu <herbert@...dor.apana.org.au>,
        "David S. Miller" <davem@...emloft.net>
Subject: Re: [Cocci] [PATCH] crypto: cavium: zip: Remove unnecessary
 parentheses



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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ