From: Markus Elfring <Markus.Elfring@web.de>
To: kernel-janitors@vger.kernel.org,
Gilles Muller <Gilles.Muller@lip6.fr>,
Julia Lawall <Julia.Lawall@lip6.fr>,
Masahiro Yamada <yamada.masahiro@socionext.com>,
Michal Marek <michal.lkml@markovi.net>,
Nicolas Palix <nicolas.palix@imag.fr>
Cc: Coccinelle <cocci@systeme.lip6.fr>,
LKML <linux-kernel@vger.kernel.org>,
Ding Xiang <dingxiang@cmss.chinamobile.com>
Subject: [PATCH v2] Coccinelle: Add a SmPL script for the reconsideration of redundant dev_err() calls
Date: Mon, 1 Jul 2019 10:10:52 +0200 [thread overview]
Message-ID: <2744a3fc-9e67-8113-1dd9-43669e06386a@web.de> (raw)
In-Reply-To: <05d85182-7ec3-8fc1-4bcd-fd2528de3a40@web.de>
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 1 Jul 2019 10:00:39 +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 <elfring@users.sourceforge.net>
---
v2:
Suggestions from Julia Lawall were integrated.
* Application of the SmPL construct “<+... … ...+>”
* Replacement of a return specification by a statement metavariable.
* Different coding style for a branch of a SmPL disjunction.
* Usage of a specific function name in two messages.
.../coccinelle/misc/redundant_dev_err.cocci | 62 +++++++++++++++++++
1 file changed, 62 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..7998defb04f3
--- /dev/null
+++ b/scripts/coccinelle/misc/redundant_dev_err.cocci
@@ -0,0 +1,62 @@
+// 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(...);
+ ...+>
+ }
+
+@deletion depends on patch@
+expression e;
+statement s;
+@@
+ e = devm_ioremap_resource(...);
+ if (IS_ERR(e))
+(
+-{
+- dev_err(...);
+ s
+-}
+|
+ {
+ <+...
+- dev_err(...);
+ ...+>
+ }
+)
+
+@or depends on org || report@
+expression e;
+position p;
+@@
+ e = devm_ioremap_resource(...);
+ if (IS_ERR(e))
+ {
+ <+... dev_err@p(...); ...+>
+ }
+
+@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 devm_ioremap_resource() function contains appropriate error reporting.")
+
+@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 devm_ioremap_resource() function contains appropriate error reporting.")
--
2.22.0
next prev parent reply other threads:[~2019-07-01 8:11 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-20 17:30 [PATCH] " Markus Elfring
2019-06-20 18:48 ` Julia Lawall
2019-06-20 19:02 ` Markus Elfring
2019-06-20 19:12 ` Julia Lawall
2019-06-20 19:34 ` Markus Elfring
2019-06-21 9:15 ` Markus Elfring
2019-06-21 9:21 ` Julia Lawall
2019-06-21 9:37 ` Markus Elfring
2019-06-21 9:37 ` Markus Elfring
2019-06-21 14:52 ` Julia Lawall
2019-06-20 19:02 ` Markus Elfring
2019-07-01 8:10 ` Markus Elfring [this message]
2019-07-01 10:48 ` [PATCH v2] " Enrico Weigelt, metux IT consult
2019-07-01 12:40 ` [v2] Coccinelle: Suppression of warnings? Markus Elfring
2019-07-01 12:47 ` [PATCH v2] Coccinelle: Add a SmPL script for the reconsideration of redundant dev_err() calls Julia Lawall
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2744a3fc-9e67-8113-1dd9-43669e06386a@web.de \
--to=markus.elfring@web.de \
--cc=Gilles.Muller@lip6.fr \
--cc=Julia.Lawall@lip6.fr \
--cc=cocci@systeme.lip6.fr \
--cc=dingxiang@cmss.chinamobile.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=michal.lkml@markovi.net \
--cc=nicolas.palix@imag.fr \
--cc=yamada.masahiro@socionext.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®