Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1030199AbcJQVIp (ORCPT ); Mon, 17 Oct 2016 17:08:45 -0400 Received: from bear.ext.ti.com ([198.47.19.11]:56140 "EHLO bear.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934103AbcJQVIi (ORCPT ); Mon, 17 Oct 2016 17:08:38 -0400 Subject: Re: [PATCH v2] Coccinelle: Add misc/boolconv.cocci To: Julia Lawall References: <20161017165224.17093-1-afd@ti.com> CC: Gilles Muller , Nicolas Palix , Michal Marek , , From: "Andrew F. Davis" Message-ID: <01267522-ce8d-9fe8-2ec3-e466f24b8492@ti.com> Date: Mon, 17 Oct 2016 16:08:26 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2653 Lines: 123 On 10/17/2016 03:54 PM, Julia Lawall wrote: > On Mon, 17 Oct 2016, Andrew F. Davis wrote: > >> Add a script to check for unneeded conversions to bool. > > What changed since the previous version? > Nothing, just a resend, forgot to label it as such. Andrew > julia > > >> >> 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.10.1 >> >>