Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3331326pxk; Mon, 21 Sep 2020 10:49:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz8XhsJeqcyXT7sm6PuA4iLHvfVeGM4IIb9KU42G/G/4kVXd9sy32CtoPItShh9AJEQLQeS X-Received: by 2002:a50:cdd1:: with SMTP id h17mr105424edj.94.1600710557321; Mon, 21 Sep 2020 10:49:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600710557; cv=none; d=google.com; s=arc-20160816; b=GfaQe72QR62VbUWFCy7Yeu5OA/EKAaZ65xUuCtlUX1x5AsIn+hYzpzWsj76Z8Rgdj9 zH6pD4F2IbrGVSujf+FsDiGfonYpdpUaT7aM5vyigDrw3rC7iPGzSc/eTgDJSTnHEeuF zM575Q+HTC9xA3Xp0QgcObxzwTGm1JGpejIpDWHlUPDM40QIyIJ33VjrWT0me+9z9nOO VWlHLcKGqVSutauVUFRo3D7ZLAyqOsiNnTpgs4ZpAjBCrFaYFd4LfVTdcV7k9q+EP816 JPFWfYWBKQabcvt4IbLWOusS6WzzZRAak+aMm2srIKamIhZo4APAOb9OkITarAHgQbNu EA6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:message-id :in-reply-to:subject:cc:to:from:date; bh=g34xaziLjS4XOrP2A8i4gUhIN8Xc3JtJYFLsAmXdLLc=; b=R3g2slJC/WryyFF5QCB6zngBqUJfm663tsEuC8ET37wvXhFy0/mqw0yl5J33YNQSg3 6kQkHW2V6St9rO1li8KEOE3KE5+fIxHpTEqeSejImFXB5zEnrUePrXbchvPNeRPjORIP 80ewLHEgYYdv16DfrRcagX5AL809YX3sIJpuSBCFMPzNs2+WSmNadQqzbb9sBhGFoKeN nmlcndKFQqiJ5c32XftT8Es/vAokQalW8pOkq2oKV53pvT7WEx7YhgSzdOZN2XsLCsyV AtxCZs7Nj0lkcb8fH7dZxXTp9XajpEDkN565ZamKLZr15glCxIiFzDUSZJ8KUAU+9HMi eYFQ== 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 b11si10587061ejz.631.2020.09.21.10.48.54; Mon, 21 Sep 2020 10:49:17 -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 S1728213AbgIURrF (ORCPT + 99 others); Mon, 21 Sep 2020 13:47:05 -0400 Received: from mail2-relais-roc.national.inria.fr ([192.134.164.83]:15944 "EHLO mail2-relais-roc.national.inria.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726537AbgIURrE (ORCPT ); Mon, 21 Sep 2020 13:47:04 -0400 X-IronPort-AV: E=Sophos;i="5.77,287,1596492000"; d="scan'208";a="468823752" Received: from abo-173-121-68.mrs.modulonet.fr (HELO hadrien) ([85.68.121.173]) by mail2-relais-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 Sep 2020 19:47:02 +0200 Date: Mon, 21 Sep 2020 19:47:02 +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 v2] coccinelle: misc: add excluded_middle.cocci script In-Reply-To: <20200921152850.59194-1-efremov@linux.com> Message-ID: References: <20200902151859.403354-1-efremov@linux.com> <20200921152850.59194-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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 21 Sep 2020, Denis Efremov wrote: > Check for !A || A && B condition. It's equivalent to !A || B. > > Signed-off-by: Denis Efremov Applied, thanks. > --- > Changes in v2: > - spelling mistake fixed > - position variable moved on the && operator > - patch pattern changed to - (A && B) > - word "condition" removed from warning message > > scripts/coccinelle/misc/excluded_middle.cocci | 39 +++++++++++++++++++ > 1 file changed, 39 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..ab28393e4843 > --- /dev/null > +++ b/scripts/coccinelle/misc/excluded_middle.cocci > @@ -0,0 +1,39 @@ > +// SPDX-License-Identifier: GPL-2.0-only > +/// > +/// Condition !A || A && B is equivalent to !A || B. > +/// > +// 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 &&@p B) > + > +@depends on patch@ > +expression A, B; > +@@ > + > + !A || > +- (A && B) > ++ B > + > +@script:python depends on report@ > +p << r.p; > +@@ > + > +coccilib.report.print_report(p[0], "WARNING !A || A && B is equivalent to !A || B") > + > +@script:python depends on org@ > +p << r.p; > +@@ > + > +coccilib.org.print_todo(p[0], "WARNING !A || A && B is equivalent to !A || B") > -- > 2.26.2 > >