Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934700AbcKWJq5 (ORCPT ); Wed, 23 Nov 2016 04:46:57 -0500 Received: from aserp1050.oracle.com ([141.146.126.70]:20732 "EHLO aserp1050.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933823AbcKWJql (ORCPT ); Wed, 23 Nov 2016 04:46:41 -0500 From: Vaishali Thakkar To: mmarek@suse.com Cc: julia.lawall@lip6.fr, gilles.muller@lip6.fr, nicolas.palix@imag.fr, lars@metafoo.de, cocci@systeme.lip6.fr, linux-kernel@vger.kernel.org, Vaishali Thakkar Subject: [PATCH v4 1/3] Coccinelle: misc: Improve the matching of rules Date: Wed, 23 Nov 2016 14:16:39 +0530 Message-Id: X-Mailer: git-send-email 2.1.4 In-Reply-To: References: X-Source-IP: aserp1040.oracle.com [141.146.126.69] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2343 Lines: 102 Currently because of the left associativity of the operators, pattern IRQF_ONESHOT | flags does not match with the pattern when we have more than one flag after the disjunction. This eventually results in giving false positives by the script. This patch eliminates these FPs by improving the rule. Signed-off-by: Vaishali Thakkar --- Changes since v3: - Few more changes in the script to avoid some possible false positives - Moved initialization of all expressions in a single line Changes since v2: - No change in this patch Changes since v1: - Splitted patch in the patchset --- scripts/coccinelle/misc/irqf_oneshot.cocci | 36 +++++++++++++++++++----------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/scripts/coccinelle/misc/irqf_oneshot.cocci b/scripts/coccinelle/misc/irqf_oneshot.cocci index b421150..bd3e140 100644 --- a/scripts/coccinelle/misc/irqf_oneshot.cocci +++ b/scripts/coccinelle/misc/irqf_oneshot.cocci @@ -15,16 +15,13 @@ virtual org virtual report @r1@ -expression dev; -expression irq; -expression thread_fn; -expression flags; +expression dev, irq, thread_fn; position p; @@ ( request_threaded_irq@p(irq, NULL, thread_fn, ( -flags | IRQF_ONESHOT +IRQF_ONESHOT | ... | IRQF_ONESHOT ) @@ -32,21 +29,34 @@ IRQF_ONESHOT | devm_request_threaded_irq@p(dev, irq, NULL, thread_fn, ( -flags | IRQF_ONESHOT +IRQF_ONESHOT | ... | IRQF_ONESHOT ) , ...) ) -@depends on patch@ -expression dev; -expression irq; -expression thread_fn; -expression flags; +@r2@ +expression dev, irq, thread_fn, flags, e; position p != r1.p; @@ ( +flags = IRQF_ONESHOT | ... +| +flags |= IRQF_ONESHOT | ... +) +... when != flags = e +( +request_threaded_irq@p(irq, NULL, thread_fn, flags, ...); +| +devm_request_threaded_irq@p(dev, irq, NULL, thread_fn, flags, ...); +) + +@depends on patch@ +expression dev, irq, thread_fn, flags; +position p != {r1.p,r2.p}; +@@ +( request_threaded_irq@p(irq, NULL, thread_fn, ( -0 @@ -69,13 +79,13 @@ devm_request_threaded_irq@p(dev, irq, NULL, thread_fn, ) @depends on context@ -position p != r1.p; +position p != {r1.p,r2.p}; @@ *request_threaded_irq@p(...) @match depends on report || org@ expression irq; -position p != r1.p; +position p != {r1.p,r2.p}; @@ request_threaded_irq@p(irq, NULL, ...) -- 2.1.4