Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp554044pxk; Wed, 2 Sep 2020 08:37:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw+MHgFh0am3TCbP9o4nTzk3UZ0/vpC0bhYIFUqjRJHw7fevMqdTdDItsDezJ+tpGmIs5Ds X-Received: by 2002:a17:906:e50:: with SMTP id q16mr614772eji.544.1599061051030; Wed, 02 Sep 2020 08:37:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599061051; cv=none; d=google.com; s=arc-20160816; b=AJUgRCB/X1hoprhbDsBdXRVc9M4lvlplF/c7O6BKQ7mmgIgcOeEuS+xT0/j0iiBc2X QJD3oU2+GvD9o8vInZIsq9H/ynaeJwUMVHeENRMhSFnpAEPIWE2ksHgV4kQSM8Vki01e 2fwAx44cpsv2DmuACx7YDYWIH505Xq1npdhvDRuYRjlMpwVnhd+S5IEhgr3P7snJnraq L2AfeFabrcWugf+YQWLEF/8gG/o+wYydFViOz5kBkcRXv3k2u5rZ1UYnablCb+zk0Wqf IrZ/9++tjjvY2eZeD1FkhcfK8MtUFFgDWTBeYmZ3i9c4m/w0kGSUMLKF0DU+9txj4wLI PFjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=HsbOuaSUjgAzeexavqDg8BNI1kBauuGj+WofnxN6QNY=; b=Y9mixhg5afLvpVKqwMafASc18CCvlLj84tj2y5JHuXiK20tqYOytuv8dZYaXgWTLXM d8w8PZrr0nILoiciOtnuMX5Wi8+0VOGe8P3roEwiNJcYL2jAcmuZnC6XSx+9Hq5ueOKF MFxcSzCqaUlR9j1KuO1PagTc+iKkP5JcjwuMBhKNEDwWY38XozdIJhNQJKba6WxuyU5D QaWx1f1Kb4PpkEuNKIH/e9o7uP65WRsiJhDrAnGG9INUqAxfRoeRhg9i1VYIA+1J68VG 32ubDRIij8ZnE25kXcNyMWE67AUa2wddm0UHtDTT0BpsE96YAYK2g0f5W0V792j2WALJ ZhpA== 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 c5si2805611ejm.274.2020.09.02.08.37.07; Wed, 02 Sep 2020 08:37:31 -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 S1727842AbgIBPeZ (ORCPT + 99 others); Wed, 2 Sep 2020 11:34:25 -0400 Received: from mail-lj1-f193.google.com ([209.85.208.193]:33210 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727978AbgIBPT5 (ORCPT ); Wed, 2 Sep 2020 11:19:57 -0400 Received: by mail-lj1-f193.google.com with SMTP id r13so6404531ljm.0 for ; Wed, 02 Sep 2020 08:19:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=HsbOuaSUjgAzeexavqDg8BNI1kBauuGj+WofnxN6QNY=; b=cc1AGaoj0OcvL/+WPcH7sDlbjvjHWZdYWW1q94LCOk1uxB5ZaU7zbhqsz7hhXLyUhP pvbozpU142DE3/zGjqQJqreV8zgFTE6wW+X4EqIimePc2UL+c9+QGlJb5GoV8e8YVlWK wFtKD0ZOp3a8EK0gbFPtNczcblx3/vk2MoJ7bSJ6RweAlvZQynpQbrNfPumR4jo/ykXN 1BMu5zoDRM6EC4IUxo3oBjtPSO3ZWMRA0+WNYeS4G0SFoTlTNql73bcNYkf9oPeNR5hr CPtNWVagDNe9DsjdEoIBNzEot5eda77bdGtd5jVmpnss0HlNrhCYWThVvNl/9Acw63Wb prnQ== X-Gm-Message-State: AOAM533BhfnqyxhAKDbs6FOZVTukleSdnLWyZQg6EP8YLZCX3qkPAQlE 2FRkxjlfJpoq8gxC/EX+7Jw= X-Received: by 2002:a05:651c:310:: with SMTP id a16mr3378753ljp.250.1599059947599; Wed, 02 Sep 2020 08:19:07 -0700 (PDT) Received: from localhost.localdomain (broadband-37-110-38-130.ip.moscow.rt.ru. [37.110.38.130]) by smtp.googlemail.com with ESMTPSA id n8sm1036690ljj.69.2020.09.02.08.19.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Sep 2020 08:19:06 -0700 (PDT) From: Denis Efremov To: Julia Lawall Cc: Denis Efremov , cocci@systeme.lip6.fr, linux-kernel@vger.kernel.org Subject: [PATCH] coccinelle: misc: add excluded_middle.cocci script Date: Wed, 2 Sep 2020 18:18:59 +0300 Message-Id: <20200902151859.403354-1-efremov@linux.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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". +/// +// 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 + +@depends on patch@ +expression A, B; +@@ + + !A || +- (A && + B +- ) + +@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") -- 2.26.2