Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp4998992yba; Mon, 13 May 2019 03:41:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqwT2lOi+YAlCtWYwilavCyXXvGjgzkM29k4i5t3Rmshi6gM7v0qNcbkuyBEJfd+aIAmXg9K X-Received: by 2002:aa7:9e9a:: with SMTP id p26mr631444pfq.176.1557744088413; Mon, 13 May 2019 03:41:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557744088; cv=none; d=google.com; s=arc-20160816; b=ADz/vdBsSKuIkDOiRWUj/7XFWIKvEB4WvF1bflVwYDKhO0j4h7nFhW4s92OdoTjCgc JprC3SZbOT7S3ptQp+Ihx/0w/LpV5zV1aGJXcoVxF2zyVj9HeEEVmFVfYXGnAeSYFAIw bJm6gUQjD4L0uWEUEHQa3Ee9csQoMZ8bla2V2VDJp5dHN+rSrXKF9rcksRZxQ+Pm+m+q ulqLkNB+9wmH5qJ7HlXdZHUeillpwTYVEsU8m6vY/wSUxftZ02t1HVpja716IHUJu7Rd hrZnDcH5EW414iWnn3WNsJStUuIElw6ZFvZq5Qh/xVBo1FyXZ/KE618MsFwvF8GV090k 2+wA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date; bh=UIN7MYTs2MaUQ4mwPyKl9yo/gxpkFcrKoCDpCsfD6A0=; b=xtXiOVpLmneyp/bE/AjSEdFbScDzYFbdTp6MyUCaezumXeMv17XldNSQHpf9iipTsI bInGfqI5huI/72aotfwRSLUbf5BFaJwgZXP2OmMntdZwmmwKGIYU6ONGNczTKYOBzOgp huOOZLWuioy+Y0s9qElmfxt1MB+eoW4JpeEtFENGlfD3tULX/xOfoH/j6y2I4X0rhvHL P2GYwEPTyT013qrsBgzxDlsHZho8oHqhAJy/kqR3e0RqPuu2WIy9IVvUfFbocLjcFwS/ 2IWG2IblSJAFkZY08TwiW6qsdfzJeyv9j6a3SxYWLyHGoZsdf2eoIwvJHwihRhO7tLc0 QzJg== 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 f17si5796770pgn.99.2019.05.13.03.41.09; Mon, 13 May 2019 03:41:28 -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 S1727849AbfEMJbt (ORCPT + 99 others); Mon, 13 May 2019 05:31:49 -0400 Received: from mail3-relais-sop.national.inria.fr ([192.134.164.104]:41124 "EHLO mail3-relais-sop.national.inria.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726218AbfEMJbs (ORCPT ); Mon, 13 May 2019 05:31:48 -0400 X-IronPort-AV: E=Sophos;i="5.60,465,1549926000"; d="scan'208";a="305790425" Received: from vaio-julia.rsr.lip6.fr ([132.227.76.33]) by mail3-relais-sop.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 May 2019 11:31:46 +0200 Date: Mon, 13 May 2019 11:31:42 +0200 (CEST) From: Julia Lawall X-X-Sender: jll@hadrien To: Markus Elfring cc: Gilles Muller , Masahiro Yamada , Michal Marek , Nicolas Palix , Wen Yang , cocci@systeme.lip6.fr, linux-kernel@vger.kernel.org, Yi Wang Subject: Re: [PATCH 4/5] Coccinelle: put_device: Extend when constraints for two SmPL ellipses In-Reply-To: <6f08d4d7-5ffc-11c0-8200-cade7d294de6@web.de> Message-ID: References: <1553321671-27749-1-git-send-email-wen.yang99@zte.com.cn> <6f08d4d7-5ffc-11c0-8200-cade7d294de6@web.de> User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 13 May 2019, Markus Elfring wrote: > From: Markus Elfring > Date: Mon, 13 May 2019 09:47:17 +0200 > > A SmPL ellipsis was specified for a search approach so that additional > source code would be tolerated between an assignment to a local variable > and the corresponding null pointer check. > > But such code should be restricted. > * The local variable must not be reassigned there. > * It must also not be forwarded to an other assignment target. > > Take additional casts for these code exclusion specifications into account > together with optional parentheses. NACK. You don't need so many type metavariables. Type metavariables in the same ... can be the same. julia > > Link: https://lore.kernel.org/cocci/201902191014156680299@zte.com.cn/ > Link: https://systeme.lip6.fr/pipermail/cocci/2019-February/005620.html > Fixes: da9cfb87a44da61f2403c4312916befcb6b6d7e8 ("coccinelle: semantic code search for missing put_device()") > Signed-off-by: Markus Elfring > --- > scripts/coccinelle/free/put_device.cocci | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > > diff --git a/scripts/coccinelle/free/put_device.cocci b/scripts/coccinelle/free/put_device.cocci > index aae79c02c1e0..28b0be53fb3f 100644 > --- a/scripts/coccinelle/free/put_device.cocci > +++ b/scripts/coccinelle/free/put_device.cocci > @@ -13,13 +13,15 @@ virtual org > local idexpression id; > expression x,e,e1; > position p1,p2; > -type T,T1,T2,T3; > +type T,T1,T2,T3,T4,T5,T6; > @@ > > id = of_find_device_by_node@p1(x) > -... when != e = id > + ... when != e = (T4)(id) > + when != id = (T5)(e) > if (id == NULL || ...) { ... return ...; } > ... when != put_device(&id->dev) > + when != id = (T6)(e) > when != platform_device_put(id) > when != of_dev_put(id) > when != if (id) { ... put_device(&id->dev) ... } > -- > 2.21.0 > >