Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp528483pxa; Fri, 21 Aug 2020 13:35:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxn4C3aoMkO1ZMpmW5a9qN2nSbY8p9eVzP6GjFGqalmoA/I4xgj8pZ9tO/t2Jhz1Ztvfirh X-Received: by 2002:a17:906:7f0e:: with SMTP id d14mr4693432ejr.400.1598042137273; Fri, 21 Aug 2020 13:35:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598042137; cv=none; d=google.com; s=arc-20160816; b=eAMn136++3qk3F1Bq0q02VWnpsgvDEvdf+P73q8Hnscl7AhS3yRnFglAAJvno7dXDz AvaamsVfxOF3kUw74iEV22a5M+c+2/O3jsqBde48F6KQIgLqHiCvyjBjl/uhUB0WX7iZ 51vca+aXoRtZ2pDS8D65mrzSA0K1RKoUYwhPHz2zkWeEI1PR6sRKEpa3Z1iuA0zPviVB 1XiO/DitgxcdFEt0G0axDXDKQ++CIgyYKbPCXR25JLAOXR6wBbFt/CDrVbygZqjdChaC bIw7d6VwnHmWy17uQektJZrrOvHT0Pq1QaTtBk2fBfXj7vtkwUV2ilTRz5bA+dETW/W5 cSDA== 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=fPVCJAlsLgCJB+INPwUBsVa/R/Q82ulEo/QzYuNKGPM=; b=QkXpw2DuUxx0A1btfBfTrpQrYevBYcMETu54P1xTPjl4HjhYt6z8nQ/4Xbas7RGawr 607WVwLjNE3iPws6Mqx3/IoTYFlZOAmWxz72tv6STyz1pAYQWRpTZJlsUts/n8xyQEcN FzZklvd2FH0Kv3cl3FVDGgXtPlfXW7eKCMrePZUf3I2qeNYTETZsQswvsUNHozeMMt7r T31umds3mDyCeGFMGpexnDP4qIBB82cW7j4enLfbfKz3omv29pZG8AM+PmWrx0itncis ZGz3mwPvgp6uifLMP/Lr/Sw/7rqYKDIDh5kQRwqJ+IWf4yK0Zrr9AC0fcUZTRfgP/WaA 30gw== 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 v12si1961206ejq.585.2020.08.21.13.35.00; Fri, 21 Aug 2020 13:35:37 -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 S1726588AbgHUUeT (ORCPT + 99 others); Fri, 21 Aug 2020 16:34:19 -0400 Received: from mail2-relais-roc.national.inria.fr ([192.134.164.83]:2759 "EHLO mail2-relais-roc.national.inria.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725831AbgHUUeS (ORCPT ); Fri, 21 Aug 2020 16:34:18 -0400 X-IronPort-AV: E=Sophos;i="5.76,338,1592863200"; d="scan'208";a="464264063" Received: from abo-173-121-68.mrs.modulonet.fr (HELO hadrien) ([85.68.121.173]) by mail2-relais-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 Aug 2020 22:34:17 +0200 Date: Fri, 21 Aug 2020 22:34:16 +0200 (CEST) From: Julia Lawall X-X-Sender: jll@hadrien To: Denis Efremov cc: cocci@systeme.lip6.fr, linux-kernel@vger.kernel.org Subject: Re: [Cocci] [PATCH v2] coccinelle: api: add kobj_to_dev.cocci script In-Reply-To: <20200821201137.446423-1-efremov@linux.com> Message-ID: References: <20200821153100.434332-1-efremov@linux.com> <20200821201137.446423-1-efremov@linux.com> User-Agent: Alpine 2.22 (DEB 394 2020-01-19) 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 Fri, 21 Aug 2020, Denis Efremov wrote: > Use kobj_to_dev() instead of container_of(). > > Signed-off-by: Denis Efremov Applied, thanks. julia > --- > Changes in v2: > - "symbol kobj;" added to the rule r > > scripts/coccinelle/api/kobj_to_dev.cocci | 45 ++++++++++++++++++++++++ > 1 file changed, 45 insertions(+) > create mode 100644 scripts/coccinelle/api/kobj_to_dev.cocci > > diff --git a/scripts/coccinelle/api/kobj_to_dev.cocci b/scripts/coccinelle/api/kobj_to_dev.cocci > new file mode 100644 > index 000000000000..cd5d31c6fe76 > --- /dev/null > +++ b/scripts/coccinelle/api/kobj_to_dev.cocci > @@ -0,0 +1,45 @@ > +// SPDX-License-Identifier: GPL-2.0-only > +/// > +/// Use kobj_to_dev() instead of container_of() > +/// > +// Confidence: High > +// Copyright: (C) 2020 Denis Efremov ISPRAS > +// Options: --no-includes --include-headers > +// > +// Keywords: kobj_to_dev, container_of > +// > + > +virtual context > +virtual report > +virtual org > +virtual patch > + > + > +@r depends on !patch@ > +expression ptr; > +symbol kobj; > +position p; > +@@ > + > +* container_of(ptr, struct device, kobj)@p > + > + > +@depends on patch@ > +expression ptr; > +@@ > + > +- container_of(ptr, struct device, kobj) > ++ kobj_to_dev(ptr) > + > + > +@script:python depends on report@ > +p << r.p; > +@@ > + > +coccilib.report.print_report(p[0], "WARNING opportunity for kobj_to_dev()") > + > +@script:python depends on org@ > +p << r.p; > +@@ > + > +coccilib.org.print_todo(p[0], "WARNING opportunity for kobj_to_dev()") > -- > 2.26.2 > > _______________________________________________ > Cocci mailing list > Cocci@systeme.lip6.fr > https://systeme.lip6.fr/mailman/listinfo/cocci >