From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F06CAC388F7 for ; Mon, 9 Nov 2020 16:22:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B26EC20897 for ; Mon, 9 Nov 2020 16:22:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730221AbgKIQWo (ORCPT ); Mon, 9 Nov 2020 11:22:44 -0500 Received: from mail2-relais-roc.national.inria.fr ([192.134.164.83]:56239 "EHLO mail2-relais-roc.national.inria.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729791AbgKIQWo (ORCPT ); Mon, 9 Nov 2020 11:22:44 -0500 X-IronPort-AV: E=Sophos;i="5.77,463,1596492000"; d="scan'208";a="476643258" Received: from 173.121.68.85.rev.sfr.net (HELO hadrien) ([85.68.121.173]) by mail2-relais-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Nov 2020 17:22:42 +0100 Date: Mon, 9 Nov 2020 17:22:42 +0100 (CET) From: Julia Lawall X-X-Sender: jll@hadrien To: Peter Zijlstra cc: xiakaixu1987@gmail.com, mingo@redhat.com, acme@kernel.org, mark.rutland@arm.com, alexander.shishkin@linux.intel.com, jolsa@redhat.com, namhyung@kernel.org, adrian.hunter@intel.com, linux-kernel@vger.kernel.org, Kaixu Xia Subject: Re: [PATCH] perf intel-bts: Use true,false for bool variable In-Reply-To: <20201109113912.GH2594@hirez.programming.kicks-ass.net> Message-ID: References: <1604644146-598-1-git-send-email-kaixuxia@tencent.com> <20201109113912.GH2594@hirez.programming.kicks-ass.net> User-Agent: Alpine 2.22 (DEB 394 2020-01-19) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 9 Nov 2020, Peter Zijlstra wrote: > On Fri, Nov 06, 2020 at 02:29:06PM +0800, xiakaixu1987@gmail.com wrote: > > From: Kaixu Xia > > > > Fix the following coccinelle reports: > > > > ./tools/perf/util/intel-bts.c:472:3-13: WARNING: Assignment of 0/1 to bool variable > > ./tools/perf/util/intel-bts.c:515:3-13: WARNING: Assignment of 0/1 to bool variable > > > > Reported-by: Tosk Robot > > Signed-off-by: Kaixu Xia > > Here, I've fixed it differently. I applied this version, but removed the above text from the log message. julia > > --- > Subject: coccinelle: Remove broken check > From: Peter Zijlstra > Date: Mon Nov 9 12:32:00 CET 2020 > > Get rid of the endless stream of patches that complain about: > > "WARNING: Assignment of 0/1 to bool variable" > > Which is perfectly valid C. > > Signed-off-by: Peter Zijlstra (Intel) > --- > scripts/coccinelle/misc/boolinit.cocci | 195 --------------------------------- > 1 file changed, 195 deletions(-) > > --- a/scripts/coccinelle/misc/boolinit.cocci > +++ /dev/null > @@ -1,195 +0,0 @@ > -// SPDX-License-Identifier: GPL-2.0-only > -/// Bool initializations should use true and false. Bool tests don't need > -/// comparisons. Based on contributions from Joe Perches, Rusty Russell > -/// and Bruce W Allan. > -/// > -// Confidence: High > -// Copyright: (C) 2012 Julia Lawall, INRIA/LIP6. > -// Copyright: (C) 2012 Gilles Muller, INRIA/LiP6. > -// URL: http://coccinelle.lip6.fr/ > -// Options: --include-headers > - > -virtual patch > -virtual context > -virtual org > -virtual report > - > -@boolok@ > -symbol true,false; > -@@ > -( > -true > -| > -false > -) > - > -@depends on patch@ > -bool t; > -@@ > - > -( > -- t == true > -+ t > -| > -- true == t > -+ t > -| > -- t != true > -+ !t > -| > -- true != t > -+ !t > -| > -- t == false > -+ !t > -| > -- false == t > -+ !t > -| > -- t != false > -+ t > -| > -- false != t > -+ t > -) > - > -@depends on patch disable is_zero, isnt_zero@ > -bool t; > -@@ > - > -( > -- t == 1 > -+ t > -| > -- t != 1 > -+ !t > -| > -- t == 0 > -+ !t > -| > -- t != 0 > -+ t > -) > - > -@depends on patch && boolok@ > -bool b; > -@@ > -( > - b = > -- 0 > -+ false > -| > - b = > -- 1 > -+ true > -) > - > -// --------------------------------------------------------------------- > - > -@r1 depends on !patch@ > -bool t; > -position p; > -@@ > - > -( > -* t@p == true > -| > -* true == t@p > -| > -* t@p != true > -| > -* true != t@p > -| > -* t@p == false > -| > -* false == t@p > -| > -* t@p != false > -| > -* false != t@p > -) > - > -@r2 depends on !patch disable is_zero, isnt_zero@ > -bool t; > -position p; > -@@ > - > -( > -* t@p == 1 > -| > -* t@p != 1 > -| > -* t@p == 0 > -| > -* t@p != 0 > -) > - > -@r3 depends on !patch && boolok@ > -bool b; > -position p1; > -@@ > -( > -*b@p1 = 0 > -| > -*b@p1 = 1 > -) > - > -@r4 depends on !patch@ > -bool b; > -position p2; > -identifier i; > -constant c != {0,1}; > -@@ > -( > - b = i > -| > -*b@p2 = c > -) > - > -@script:python depends on org@ > -p << r1.p; > -@@ > - > -cocci.print_main("WARNING: Comparison to bool",p) > - > -@script:python depends on org@ > -p << r2.p; > -@@ > - > -cocci.print_main("WARNING: Comparison of 0/1 to bool variable",p) > - > -@script:python depends on org@ > -p1 << r3.p1; > -@@ > - > -cocci.print_main("WARNING: Assignment of 0/1 to bool variable",p1) > - > -@script:python depends on org@ > -p2 << r4.p2; > -@@ > - > -cocci.print_main("ERROR: Assignment of non-0/1 constant to bool variable",p2) > - > -@script:python depends on report@ > -p << r1.p; > -@@ > - > -coccilib.report.print_report(p[0],"WARNING: Comparison to bool") > - > -@script:python depends on report@ > -p << r2.p; > -@@ > - > -coccilib.report.print_report(p[0],"WARNING: Comparison of 0/1 to bool variable") > - > -@script:python depends on report@ > -p1 << r3.p1; > -@@ > - > -coccilib.report.print_report(p1[0],"WARNING: Assignment of 0/1 to bool variable") > - > -@script:python depends on report@ > -p2 << r4.p2; > -@@ > - > -coccilib.report.print_report(p2[0],"ERROR: Assignment of non-0/1 constant to bool variable") >