Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp2260775ybi; Thu, 20 Jun 2019 11:48:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqwk1ox74XXa7MKOmeqvfz2ytg0HYugO7HdbeAPUj073a09vgorN9HD7ToKbj13irGLWbGvW X-Received: by 2002:a63:8b44:: with SMTP id j65mr3016605pge.241.1561056528779; Thu, 20 Jun 2019 11:48:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561056528; cv=none; d=google.com; s=arc-20160816; b=EQfsf8e3OKdxve/EK6rISE7wrX1k7QVy5cDmwyoEdtWykz62HgGS1kIoaZHTgxkCGC wgTDWogFMpmaXJg5mlsi5xQ5qBeFQmCTTgIgeOFmkaIYLah8qG0bqh2Gqj1WUjvxi0JK cJQijrZ/hAsnTHkEE4Z1OuN1XvN1yPMhzU6+tGi3YqP5l4QIPHVvzUd00tdJNBvvQUep iAathyGRUm5QjGBHQJYcpzNyiO4Hm5ATgtXCgyjYf/RbKUvz0MKu1NzmsgMC3MS5Rykx M90QIxXDnp/PQLZw1k6jagZqpsgfVXxCRwXoYWzMWAROa4vYPgtkXAhFsSQSbKvhE6zN FWXg== 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=dZBgADSRVfnlxt1a1krcU8yDOOJaIrpdQ1cPFM7Iw8k=; b=wKHCEiW5bvWIfhRkFbb9Z/PnIPaaQVfnIjjLspaWVcI2XUp2PFIjHyUHwPA3o0pBkR TJocYZCBTx9/GxN5jqxxkwH2bxfA4vKhVBE7dccMzG0etkrhoT0CBhFSupc/j9VNOdxn lsEfrVLNKJvaTrC5pv5K2rDHOrqiIGKn4b0DqTkF7xDa3JwjT71Z/Tme5ec1AQgcjJH9 gP3/fAVO6+8O04TBvCcmzBLAn+4wPY9O9VPntlHSjTnEmyC4JSg/tPOGVf9lVzRaraK8 uNsWV34TZZ5gMVG+vz8uBkC1RsH0fn0kpqaoc1FuoNf/o1V2elRlXq/Sfs/FPsHBPcuT npmA== 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 d11si241201pfn.188.2019.06.20.11.48.33; Thu, 20 Jun 2019 11:48:48 -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 S1726323AbfFTSs0 (ORCPT + 99 others); Thu, 20 Jun 2019 14:48:26 -0400 Received: from mail2-relais-roc.national.inria.fr ([192.134.164.83]:4891 "EHLO mail2-relais-roc.national.inria.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726062AbfFTSs0 (ORCPT ); Thu, 20 Jun 2019 14:48:26 -0400 X-IronPort-AV: E=Sophos;i="5.63,397,1557180000"; d="scan'208";a="388394882" Received: from abo-12-105-68.mrs.modulonet.fr (HELO hadrien) ([85.68.105.12]) by mail2-relais-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Jun 2019 20:48:23 +0200 Date: Thu, 20 Jun 2019 20:48:23 +0200 (CEST) From: Julia Lawall X-X-Sender: jll@hadrien To: Markus Elfring cc: kernel-janitors@vger.kernel.org, Gilles Muller , Masahiro Yamada , Michal Marek , Nicolas Palix , Coccinelle , LKML , Ding Xiang Subject: Re: [PATCH] Coccinelle: Add a SmPL script for the reconsideration of redundant dev_err() calls In-Reply-To: <05d85182-7ec3-8fc1-4bcd-fd2528de3a40@web.de> Message-ID: References: <05d85182-7ec3-8fc1-4bcd-fd2528de3a40@web.de> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="8323329-1240475580-1561056503=:3087" 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-1240475580-1561056503=:3087 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8BIT On Thu, 20 Jun 2019, Markus Elfring wrote: > From: Markus Elfring > Date: Thu, 20 Jun 2019 19:12:53 +0200 > > The function “devm_ioremap_resource” contains appropriate error reporting. > Thus it can be questionable to present another error message > at other places. > > Provide design options for the adjustment of affected source code > by the means of the semantic patch language (Coccinelle software). > > Signed-off-by: Markus Elfring > --- > .../coccinelle/misc/redundant_dev_err.cocci | 53 +++++++++++++++++++ > 1 file changed, 53 insertions(+) > create mode 100644 scripts/coccinelle/misc/redundant_dev_err.cocci > > diff --git a/scripts/coccinelle/misc/redundant_dev_err.cocci b/scripts/coccinelle/misc/redundant_dev_err.cocci > new file mode 100644 > index 000000000000..aeb228280276 > --- /dev/null > +++ b/scripts/coccinelle/misc/redundant_dev_err.cocci > @@ -0,0 +1,53 @@ > +// SPDX-License-Identifier: GPL-2.0 > +/// Reconsider a function call for redundant error reporting. > +// > +// Keywords: dev_err redundant device error messages > +// Confidence: Medium > + > +virtual patch > +virtual context > +virtual org > +virtual report > + > +@display depends on context@ > +expression e; > +@@ > + e = devm_ioremap_resource(...); > + if (IS_ERR(e)) > + { > +* dev_err(...); > + return (...); > + } Why do you assume that there is exactly one dev_err and one return after the test? > + > +@deletion depends on patch@ > +expression e; > +@@ > + e = devm_ioremap_resource(...); > + if (IS_ERR(e)) > +-{ > +- dev_err(...); > + return (...); > +-} > + > +@or depends on org || report@ > +expression e; > +position p; > +@@ > + e = devm_ioremap_resource(...); > + if (IS_ERR(e)) > + { > + dev_err@p(...); > + return (...); > + } > + > +@script:python to_do depends on org@ > +p << or.p; > +@@ > +coccilib.org.print_todo(p[0], > + "WARNING: An error message is probably not needed here because the previously called function contains appropriate error reporting.") "the previously called function" would be better as "devm_ioremap_resource". julia > + > +@script:python reporting depends on report@ > +p << or.p; > +@@ > +coccilib.report.print_report(p[0], > + "WARNING: An error message is probably not needed here because the previously called function contains appropriate error reporting.") > -- > 2.22.0 > > --8323329-1240475580-1561056503=:3087--