From mboxrd@z Thu Jan 1 00:00:00 1970 From: Julia Lawall Subject: Re: [PATCH] crypto: cavium: zip: Remove unnecessary parentheses Date: Sat, 31 Mar 2018 08:17:34 +0200 (CEST) Message-ID: References: <20180328175736.17360-1-rvarsha016@gmail.com> <1522260676.12357.121.camel@perches.com> <1522441039.2210.50.camel@perches.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: Herbert Xu , Varsha Rao , linux-kernel@vger.kernel.org, cocci , linux-crypto@vger.kernel.org, "David S. Miller" To: Joe Perches Return-path: In-Reply-To: <1522441039.2210.50.camel@perches.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: cocci-bounces@systeme.lip6.fr Errors-To: cocci-bounces@systeme.lip6.fr List-Id: linux-crypto.vger.kernel.org On Fri, 30 Mar 2018, Joe Perches wrote: > On Thu, 2018-03-29 at 21:03 +0530, 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. > hmm > Perhaps you should use something like this? > @@ > identifier i; > constant c; > @@ > > -( > \(i == c\|i <= c\|i < c\|i >= c\|i > c\) > -) This is not safe with respect to !. The following seems to address this problem: @@ identifier i; constant c; expression e; @@ ( !(e) | -( \(i == c\|i <= c\|i < c\|i >= c\|i > c\) -) ) julia