From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752967AbeCaIzs (ORCPT ); Sat, 31 Mar 2018 04:55:48 -0400 Received: from mail2-relais-roc.national.inria.fr ([192.134.164.83]:61753 "EHLO mail2-relais-roc.national.inria.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752068AbeCaIzq (ORCPT ); Sat, 31 Mar 2018 04:55:46 -0400 X-IronPort-AV: E=Sophos;i="5.48,383,1517871600"; d="scan'208";a="320806109" Date: Sat, 31 Mar 2018 10:55:44 +0200 (CEST) From: Julia Lawall X-X-Sender: jll@hadrien To: Varsha Rao cc: Joe Perches , linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, cocci , Herbert Xu , "David S. Miller" Subject: Re: [Cocci] [PATCH] crypto: cavium: zip: Remove unnecessary parentheses In-Reply-To: Message-ID: References: <20180328175736.17360-1-rvarsha016@gmail.com> <1522260676.12357.121.camel@perches.com> User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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