Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp706267imm; Fri, 3 Aug 2018 10:06:36 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdlsozVVgN6S0+OHP0l9hb9jwQuy90Yocjijt5yKyzz+DD2Agu+mxAL5ucapBKchBVUCaGY X-Received: by 2002:a63:6849:: with SMTP id d70-v6mr4493039pgc.7.1533315996689; Fri, 03 Aug 2018 10:06:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533315996; cv=none; d=google.com; s=arc-20160816; b=knDVqhU946AjYqrXDDsD78zQOUTlK86kMU3D8l6BJ4yn6I/uEtQIvYv2bngfYJjFa/ S7BaaBO8Ck7IGmf5GOs6OfKhpCFQUA2twpaD0WwdvhUQdCKNhFsbjbcgxisJxFGU75S7 hQjjHoRMp2s8vEF25GSEdUzqLy20bnYlZ2ldWs9WYmwmQJsOgVWY2yeOvMO1v0jgFOMW 3fdaGpHNQYfQoLB9LzQt+/FUbtUD7h34AZmlFWMMkRPbxeTP100/VED81hDBDENH9dFA bS6XBBIRu9T7Cbd/eeiniWgOIIeA4YbEyiJqfwrwofkblvTpQFZXkV5yso6bs66PjZYG Mu+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=L6bVP528IBfMdMFmu06YFzeaps3mA6iBQCpvIFusrdE=; b=bTX2GXEAHyxCd7JZ+2psTDHYDZcdWgFSIWDTEQ78WNZIDigwcJJmVdAAqTqrEVzPCm jhEGHvEsoies/Dl27xkqVq2y6vI0GTUbfryN2yXLHiDBZ7IV7rZnypWyB2BNXIQ1zHU7 Z1Xv52vs0AW4Cy88M6So5BPhFkcqBfW/bxs8kNlNRIZ8kC5gu0rihzdIFa02wwK3b1mE KgqzvS6xGAVwZP7CovU1buoxNg+HfokBWj2PAe9xCrTk17jUAUrR6go+Hbe/5eu8IDxW G6gwGNXTPxT82hcYosEaEx86MFCknlfU+chXwR2dVfb4r8oryxaLAxY4xZMpMAPTxo62 16iA== ARC-Authentication-Results: i=1; mx.google.com; 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 b31-v6si5714969pgl.437.2018.08.03.10.06.21; Fri, 03 Aug 2018 10:06:36 -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; 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 S1728246AbeHCTCl (ORCPT + 99 others); Fri, 3 Aug 2018 15:02:41 -0400 Received: from mail2-relais-roc.national.inria.fr ([192.134.164.83]:1577 "EHLO mail2-relais-roc.national.inria.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727171AbeHCTCl (ORCPT ); Fri, 3 Aug 2018 15:02:41 -0400 X-IronPort-AV: E=Sophos;i="5.51,439,1526335200"; d="scan'208";a="341340983" Received: from palace.lip6.fr (HELO localhost.localdomain) ([132.227.105.202]) by mail2-relais-roc.national.inria.fr with ESMTP/TLS/AES128-SHA256; 03 Aug 2018 19:05:30 +0200 From: Julia Lawall To: Masahiro Yamada Cc: kernel-janitors@vger.kernel.org, Gilles Muller , Nicolas Palix , Michal Marek , cocci@systeme.lip6.fr, linux-kernel@vger.kernel.org, Andy Shevchenko , Finn Thain , zhong jiang , Michael Schmitz , "James E . J . Bottomley" , "Martin K . Petersen" , John Garry , linux-scsi Subject: [PATCH] Coccinelle: doubletest: reduce side effect false positives Date: Fri, 3 Aug 2018 18:32:11 +0200 Message-Id: <1533313931-3639-1-git-send-email-Julia.Lawall@lip6.fr> X-Mailer: git-send-email 1.9.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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; @@