Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1598019pxk; Fri, 4 Sep 2020 13:40:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxkq4ANXS6pPi9/76Z9uz8KVx8SGqR4EA3cuOOva/a1KznTFntiNgyG45Ss+eP4H/kqn6g+ X-Received: by 2002:a50:e685:: with SMTP id z5mr9199871edm.305.1599252019999; Fri, 04 Sep 2020 13:40:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599252019; cv=none; d=google.com; s=arc-20160816; b=NXeYvzfapoCOB9IaMsugVd3KfadYK4+aVMkmog9bVdroo7wvBYZ1i4n1RM6GZ93GOB EmBa7B+d9Xzt6CAZbNC+3RCRcS0bmh9oW2kjbi/H2DSvDZhrGHL4XwDVRMDGkXTJ4NnV kln26AIWOqBlnO2jD+1dh9VTz6oam9pp/HIkBv9RFYXzRO9evnLzFOsQ8ZJGQxdTzlVj F3LmlIiQyqayUwo1Q6Cfuf9Qyj74e5HOaSHURdWuse6UjnQYu2x4fTyW3Qtp9NuISgRS WOcmsDtRfUaSatb7K7mcfTf7g5f/Ce7CNuKZIt8FXWb9cmTzGdDUem+ooNaO2d804/OW 4ZGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date; bh=zg2OjMgxwUmzVTRJIJ5fiQdNu/qFCwNqR8hAaqd+dRc=; b=0KYzr308xSrorHqUZ8IG3IbvWQ7gDkiLv6uS2KcPe6CVxXydnhx5DfGQPqYe/ZqaPK J8BWwKsorAz4BfjCawk854OCqCuVOdJY/cglVvVOmYStLNq94F1n3b8c6e5STMQxq4au v6A01Jl8tuCuqNhqnxgXagEab/34AzJHuXoDEpwpai2cCK9ss5+MkzSDM34jiMmi6m4y 4xV18lPVLGMBm5PB4a0/iS4f+Jafqh+WpZB+wA5S3OPPs1bKHR6kjUPA6Ap75iGjwcBz A73TjGzBy6jowPfHwsqIMurRY9tnptWGDLxeOp15RVUjmx/PyCi/lVVxzJKywRqvFgyh YXdg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c11si4920985edw.36.2020.09.04.13.39.56; Fri, 04 Sep 2020 13:40:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728072AbgIDUjS (ORCPT + 99 others); Fri, 4 Sep 2020 16:39:18 -0400 Received: from mail3-relais-sop.national.inria.fr ([192.134.164.104]:6772 "EHLO mail3-relais-sop.national.inria.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726618AbgIDUjR (ORCPT ); Fri, 4 Sep 2020 16:39:17 -0400 X-IronPort-AV: E=Sophos;i="5.76,359,1592863200"; d="scan'208";a="358135169" Received: from abo-173-121-68.mrs.modulonet.fr (HELO hadrien) ([85.68.121.173]) by mail3-relais-sop.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Sep 2020 22:39:16 +0200 Date: Fri, 4 Sep 2020 22:39:16 +0200 (CEST) From: Julia Lawall X-X-Sender: jll@hadrien To: Denis Efremov cc: cocci@systeme.lip6.fr, linux-kernel@vger.kernel.org Subject: Re: [PATCH] coccinelle: misc: add excluded_middle.cocci script In-Reply-To: <20200902151859.403354-1-efremov@linux.com> Message-ID: References: <20200902151859.403354-1-efremov@linux.com> User-Agent: Alpine 2.22 (DEB 394 2020-01-19) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 2 Sep 2020, Denis Efremov wrote: > Check for "!A || A && B" condition. It's equivalent to > "!A || B" condition. > > Signed-off-by: Denis Efremov > --- > scripts/coccinelle/misc/excluded_middle.cocci | 40 +++++++++++++++++++ > 1 file changed, 40 insertions(+) > create mode 100644 scripts/coccinelle/misc/excluded_middle.cocci > > diff --git a/scripts/coccinelle/misc/excluded_middle.cocci b/scripts/coccinelle/misc/excluded_middle.cocci > new file mode 100644 > index 000000000000..1b8c20f13966 > --- /dev/null > +++ b/scripts/coccinelle/misc/excluded_middle.cocci > @@ -0,0 +1,40 @@ > +// SPDX-License-Identifier: GPL-2.0-only > +/// > +/// Condition "!A || A && B" is equalent to "!A || B". As was noted, there is a spelling mistake here. > +/// > +// Confidence: High > +// Copyright: (C) 2020 Denis Efremov ISPRAS > +// Options: --no-includes --include-headers > + > +virtual patch > +virtual context > +virtual org > +virtual report > + > +@r depends on !patch@ > +expression A, B; > +position p; > +@@ > + > +* !A || (A && B)@p In org mode, the token with the position variable gets highlighted in color. It would be more meaningful to put the position variable on the && operator. > + > +@depends on patch@ > +expression A, B; > +@@ > + > + !A || > +- (A && > + B > +- ) I found it better to say - (A && B) + B There are some cases where B should be moved one space to the left and by removing B and adding it back again that will happen. I didn't see any case where the result was less good. > +@script:python depends on report@ > +p << r.p; > +@@ > + > +coccilib.report.print_report(p[0], "WARNING condition !A || A && B is equivalent to !A || B") > + > +@script:python depends on org@ > +p << r.p; > +@@ > + > +coccilib.org.print_todo(p[0], "WARNING condition !A || A && B is equivalent to !A || B") I'm not sure that you need the word condition, but up to you. julia