From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752235AbcFZWBR (ORCPT ); Sun, 26 Jun 2016 18:01:17 -0400 Received: from mail3-relais-sop.national.inria.fr ([192.134.164.104]:63739 "EHLO mail3-relais-sop.national.inria.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751673AbcFZWBP (ORCPT ); Sun, 26 Jun 2016 18:01:15 -0400 X-IronPort-AV: E=Sophos;i="5.26,533,1459807200"; d="scan'208";a="182790776" Date: Mon, 27 Jun 2016 00:01:09 +0200 (CEST) From: Julia Lawall X-X-Sender: jll@localhost6.localdomain6 To: "Andrew F. Davis" cc: Julia Lawall , Gilles Muller , Nicolas Palix , Michal Marek , cocci@systeme.lip6.fr, linux-kernel@vger.kernel.org Subject: Re: [PATCH] Coccinelle: Add misc/boolconv.cocci In-Reply-To: <20160623185352.25818-1-afd@ti.com> Message-ID: References: <20160623185352.25818-1-afd@ti.com> User-Agent: Alpine 2.02 (DEB 1266 2009-07-14) 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 Thu, 23 Jun 2016, Andrew F. Davis wrote: > Add a script to check for unneeded conversions to bool. > > Signed-off-by: Andrew F. Davis Acked-by: Julia Lawall > --- > scripts/coccinelle/misc/boolconv.cocci | 90 ++++++++++++++++++++++++++++++++++ > 1 file changed, 90 insertions(+) > create mode 100644 scripts/coccinelle/misc/boolconv.cocci > > diff --git a/scripts/coccinelle/misc/boolconv.cocci b/scripts/coccinelle/misc/boolconv.cocci > new file mode 100644 > index 0000000..33c464d > --- /dev/null > +++ b/scripts/coccinelle/misc/boolconv.cocci > @@ -0,0 +1,90 @@ > +/// Remove unneeded conversion to bool > +/// > +//# Relational and logical operators evaluate to bool, > +//# explicit conversion is overly verbose and unneeded. > +// > +// Copyright: (C) 2016 Andrew F. Davis GPLv2. > + > +virtual patch > +virtual context > +virtual org > +virtual report > + > +//---------------------------------------------------------- > +// For patch mode > +//---------------------------------------------------------- > + > +@depends on patch@ > +expression A, B; > +symbol true, false; > +@@ > + > +( > + A == B > +| > + A != B > +| > + A > B > +| > + A < B > +| > + A >= B > +| > + A <= B > +| > + A && B > +| > + A || B > +) > +- ? true : false > + > +//---------------------------------------------------------- > +// For context mode > +//---------------------------------------------------------- > + > +@r depends on !patch@ > +expression A, B; > +symbol true, false; > +position p; > +@@ > + > +( > + A == B > +| > + A != B > +| > + A > B > +| > + A < B > +| > + A >= B > +| > + A <= B > +| > + A && B > +| > + A || B > +) > +* ? true : false@p > + > +//---------------------------------------------------------- > +// For org mode > +//---------------------------------------------------------- > + > +@script:python depends on r&&org@ > +p << r.p; > +@@ > + > +msg = "WARNING: conversion to bool not needed here" > +coccilib.org.print_todo(p[0], msg) > + > +//---------------------------------------------------------- > +// For report mode > +//---------------------------------------------------------- > + > +@script:python depends on r&&report@ > +p << r.p; > +@@ > + > +msg = "WARNING: conversion to bool not needed here" > +coccilib.report.print_report(p[0], msg) > -- > 2.9.0 > >