Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2054375pxa; Mon, 3 Aug 2020 06:24:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyJyALRgKmnthsHuRuuknx3yXOkw5nSbd6Vu949ksCVsISqTKSFgZS44PJvyQ1AIyMgeacV X-Received: by 2002:a50:cfc6:: with SMTP id i6mr15777707edk.88.1596461047351; Mon, 03 Aug 2020 06:24:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596461047; cv=none; d=google.com; s=arc-20160816; b=HefoXExZV9i/+BpF+3CyPEyoOgxKsHG9a2yMYGjiMQMPWzi2Hxh5/EMbvtI+FjJPRm P27/1fog1O2Y+MQjj6YNqiARt1YCB9CRhHxGLnJlEs7QThoAkbpNrXFJwzLvyFB5YX3B pywVdkkSsF9zT10rMk47//3xI+0sub7VTPKwwlMJKId5SFVYKWWrhstKy5A+E2P5+0yZ CVDUTabQ1UzFDCDu3FV76R65FYiyodcBUFdkE/VkybFHKiJCNKnzPTMsCmsjTycQsSoh PR3tSJDFe3PX04buO+uPbNDgeerJYQDASvWBhdqd0M00QNSv1jraIIDu1+ozd/xqn8I6 R9yQ== 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=lh0Zln3HS2pVD+nOg0dTjTdTU/XKF3LNVaTNjvbrDLM=; b=WTw8MlqHBLfr9AkWe7qTFGdI830gfqe9gDD8W3PpjdJtuLU2zR2y5J00YmyQd0OTic lLYzrPJv+v4XOSkQTmPKBxn7hybYmFSBOzbgEanDbOF4lloxVlF1/P1k0oY2eAshHCae uEtJ7Z2/jmUUIi37NMatMkmra16qzNtB80Z4JRnklRo/s+QVhsSwAXdbO+Vg0pg+oZWD rLDf0/wVG5Id9jgTqFk2qtq6NGNBPiE/WWrnCglwHOqxHYAgBwmkTViejdksof0pGLa8 uGQzV4Ux6RJ/1r98mdnCHr6fSrEMYnQO2h124PROsTPAvUoz4t+Oc6FIq35mrfct4Y+5 MNoQ== 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 g11si10327095edp.245.2020.08.03.06.23.45; Mon, 03 Aug 2020 06:24:07 -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 S1726825AbgHCNVS (ORCPT + 99 others); Mon, 3 Aug 2020 09:21:18 -0400 Received: from mail3-relais-sop.national.inria.fr ([192.134.164.104]:45952 "EHLO mail3-relais-sop.national.inria.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725948AbgHCNVS (ORCPT ); Mon, 3 Aug 2020 09:21:18 -0400 X-IronPort-AV: E=Sophos;i="5.75,430,1589234400"; d="scan'208";a="355862004" Received: from clt-128-93-177-162.vpn.inria.fr ([128.93.177.162]) by mail3-relais-sop.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Aug 2020 15:21:15 +0200 Date: Mon, 3 Aug 2020 15:21:15 +0200 (CEST) From: Julia Lawall X-X-Sender: julia@hadrien To: Markus Elfring cc: Denis Efremov , Gilles Muller , Julia Lawall , Masahiro Yamada , Michal Marek , Nicolas Palix , Coccinelle , linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: Re: [PATCH] coccinelle: api: add kvmalloc script In-Reply-To: Message-ID: References: User-Agent: Alpine 2.22 (DEB 394 2020-01-19) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="8323329-183462625-1596460875=:27678" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --8323329-183462625-1596460875=:27678 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8BIT On Mon, 3 Aug 2020, Markus Elfring wrote: > … > > +++ b/scripts/coccinelle/api/kvmalloc.cocci > … > > +@opportunity depends on !patch@ > > +expression E, E1, size; > > +position p; > > +@@ > > + > > +( > … > > +| > > +* E = \(kmalloc\|kzalloc\|kcalloc\|kmalloc_node\|kzalloc_node\| > > +* kmalloc_array\|kmalloc_array_node\|kcalloc_node\)(..., size, ...) > > + ... when != E = E1 > > + when != size = E1 > > + when any > > +* if (\(!E\|E == NULL\))@p { Actually, you shouldn't need both E == NULL and !E. E == NULL should be sufficient. julia > … > > I suggest to extend the SmPL code exclusion specification so that > pointer dereferences will be filtered out before the shown null pointer detection. > > > > +@depends on patch@ > > +expression E, E1, flags, size, node; > > +identifier x; > > +type T; > > +@@ > > + > > +( > > +- if (\(size <= E1\|size < E1\|size == E1\|size > E1\)) > > This condition check is repeated a few times. > Thus I imagine that the usage of another metavariable with a SmPL constraint > can eventually be helpful. > > +binary operator bo = {<=, <, ==, >}; > … > +-if (size bo E1) > > > > > +- E = kmalloc(size, flags); > > +- else > > +- E = vmalloc(size); > > Will it be interesting to support also the use of conditional operators > by another part of a SmPL disjunction? > > -E = (…) ? kmalloc(size, flags) : vmalloc(size); > > > > ++ E = kvmalloc(size, flags); > > +| > > +- E = kmalloc(size, flags | __GFP_NOWARN); > > +- if (\(!E\|E == NULL\)) > > +- E = vmalloc(size); > > ++ E = kvmalloc(size, flags); > > This source code replacement line is repeated. Thus I imagine > that it would be nice if such SmPL code duplication could be avoided > by the application of another SmPL disjunction. > Unfortunately, the software “Coccinelle 1.0.8-00146-g04f36d53” presents > the error message “15: no available token to attach to” then. > Would you like to adjust anything in this area? > > Regards, > Markus > --8323329-183462625-1596460875=:27678--