Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2819469imm; Mon, 13 Aug 2018 00:38:43 -0700 (PDT) X-Google-Smtp-Source: AA+uWPyXD/otJ2XzgGUnpeFoknMphHJqYuXV2epyD9atObmzIa4eyGTLkHLbBGl65xkSAVryX61j X-Received: by 2002:a62:225d:: with SMTP id i90-v6mr17590977pfi.246.1534145923902; Mon, 13 Aug 2018 00:38:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534145923; cv=none; d=google.com; s=arc-20160816; b=MdNMJbMQ5+wxZG6HCSpvQhRdTgGDj/GEfLtWHFG4Ka45abtMeRSymwSeePVhyEE2dG nLOPQfTTzocPorIGbXGi9AhMlfIC9RiVSvEmAd9JVPPfV8H0MBdY0QQdTbsDCj0D6xMF oNo0e8ajGeYzdA31msQpeAVpUhiTBQgPztXDdjaNUuOuWFmk6x3LM2xfrp3GVV76ln86 NyLSKAeTDDhabIjij329HUmg5A5EDIdUqDaDjgcGxvvJjEKbVeHp0FA90GQ8tilzCmw5 ZjZCxAXEOm7I2IWOHOORhDIZu/t7xN9IVTh7RRV/cRUG/f1oLqbINeFwPjB0o4QAp35z VXTw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature:dkim-filter :arc-authentication-results; bh=ZAp12j8ZgQtNVs6MYDWVimf4wurxQMqOv09T+vgnvbE=; b=tAZuYcJKxeHdoKGijjJwoQ8wLddDb450CX2Zw+odXMQtYvSuJoCYCjyc8IpWL3A5bl j+WktBlaAOMIwnAOj7Q8YK82ZQlPPRy/rjTqc73YNuLQjAuTTkAmGLRHHJpKSqHIRbnr INhjzFA30O+FoaP0g9NzqAnSNnPCQor16MIPXfFGqraRQdgAis7vXG8vv/PKTANW4h/4 PmIuNoA6fWcZUCsX1LLgN/z9/njH6iWxHuSBioCjh1D2/J+jkO4/J1Vfa1vKk2MoSmOU R91HwwLRYpHDbdD5JZLZBhLZzH/LwBTvJsqccaNkxkByIuLp/C7sT+eJtu/UURwYa3d3 hjSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=mB1QkDMv; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 15-v6si16479340pld.157.2018.08.13.00.38.29; Mon, 13 Aug 2018 00:38:43 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=mB1QkDMv; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728589AbeHMKLm (ORCPT + 99 others); Mon, 13 Aug 2018 06:11:42 -0400 Received: from conssluserg-01.nifty.com ([210.131.2.80]:44276 "EHLO conssluserg-01.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728443AbeHMKLm (ORCPT ); Mon, 13 Aug 2018 06:11:42 -0400 Received: from mail-ua1-f43.google.com (mail-ua1-f43.google.com [209.85.222.43]) (authenticated) by conssluserg-01.nifty.com with ESMTP id w7D7UN0F026091; Mon, 13 Aug 2018 16:30:24 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conssluserg-01.nifty.com w7D7UN0F026091 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1534145424; bh=ZAp12j8ZgQtNVs6MYDWVimf4wurxQMqOv09T+vgnvbE=; h=In-Reply-To:References:From:Date:Subject:To:Cc:From; b=mB1QkDMvnRAg3ODQPPaQEZWmp0gxXbMhxULqg8IGyyQYs62mZ2ez+w8eexL3FNsyT 6wiSefwz0dKaJ/bov8sMtiSFGP7AHkVOiFOi7urVy5bCZOiJMoU8lrVYC1oQWTUqxe Pqa3AcBUSeoyQz4b0mnJ82xLbHXqaeKpQCIq/mahVtHKLFIh6LU9RhAsdzT7zwMEe0 f6Uz4wA7ZXhccolWtDEyZSv8WLIEjFgfb+HOB41hcJ+LL8PP8cT43OFG+I9f+VMxlM CaxrOXPFR1KAv+RwT+zFGx3w+jR/ohe552LCoZx0kBok5yrlYRY2X4ePZ/Hlcujbfh 4dliNXp+xuEEA== X-Nifty-SrcIP: [209.85.222.43] Received: by mail-ua1-f43.google.com with SMTP id m13-v6so8140518uaq.7; Mon, 13 Aug 2018 00:30:24 -0700 (PDT) X-Gm-Message-State: AOUpUlEyZmmtqSP8dkwjyE4GIwH5gJu5cM0sYDcT28io3ZQvbKMbweH4 y3d4mnmbubspwCvWfoCBADle3r+c1m/krzHKJXk= X-Received: by 2002:ab0:4c24:: with SMTP id l36-v6mr10622859uaf.199.1534145423409; Mon, 13 Aug 2018 00:30:23 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:ab0:2642:0:0:0:0:0 with HTTP; Mon, 13 Aug 2018 00:29:42 -0700 (PDT) In-Reply-To: <1533313931-3639-1-git-send-email-Julia.Lawall@lip6.fr> References: <1533313931-3639-1-git-send-email-Julia.Lawall@lip6.fr> From: Masahiro Yamada Date: Mon, 13 Aug 2018 16:29:42 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] Coccinelle: doubletest: reduce side effect false positives To: Julia Lawall Cc: kernel-janitors@vger.kernel.org, Gilles Muller , Nicolas Palix , Michal Marek , cocci@systeme.lip6.fr, Linux Kernel Mailing List , Andy Shevchenko , Finn Thain , zhong jiang , Michael Schmitz , "James E . J . Bottomley" , "Martin K . Petersen" , John Garry , linux-scsi Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 2018-08-04 1:32 GMT+09:00 Julia Lawall : > Ensure that the cited expression is not a function call or an > assignment to reduce the chance of false positives. > > Slightly modify the warning message to indicate another source > of false positves. > > Signed-off-by: Julia Lawall > Applied to linux-kbuild. Thanks! (Please send a reminder if there are more coccinelle patches I missed.) > --- > scripts/coccinelle/tests/doubletest.cocci | 34 ++++++++++++++++++++++-------- > 1 file changed, 26 insertions(+), 8 deletions(-) > > diff --git a/scripts/coccinelle/tests/doubletest.cocci b/scripts/coccinelle/tests/doubletest.cocci > index 78d74c2..7af2ce7 100644 > --- a/scripts/coccinelle/tests/doubletest.cocci > +++ b/scripts/coccinelle/tests/doubletest.cocci > @@ -1,6 +1,7 @@ > /// Find &&/|| operations that include the same argument more than once > -//# A common source of false positives is when the argument performs a side > -//# effect. > +//# A common source of false positives is when the expression, or > +//# another expresssion in the same && or || operation, performs a > +//# side effect. > /// > // Confidence: Moderate > // Copyright: (C) 2010 Nicolas Palix, DIKU. GPLv2. > @@ -20,20 +21,37 @@ position p; > @@ > > ( > -* E@p > - || ... || E > + E@p || ... || E > | > -* E@p > - && ... && E > + E@p && ... && E > ) > > -@script:python depends on org@ > +@bad@ > +expression r.E,e1,e2,fn; > +position r.p; > +assignment operator op; > +@@ > + > +( > +E@p > +& > + <+... \(fn(...)\|e1 op e2\|e1++\|e1--\|++e1\|--e1\) ...+> > +) > + > +@depends on context && !bad@ > +expression r.E; > +position r.p; > +@@ > + > +*E@p > + > +@script:python depends on org && !bad@ > p << r.p; > @@ > > cocci.print_main("duplicated argument to && or ||",p) > > -@script:python depends on report@ > +@script:python depends on report && !bad@ > p << r.p; > @@ > > -- Best Regards Masahiro Yamada