cocci.inria.fr archive mirror
 help / color / mirror / Atom feed
* [Cocci] [PATCH] Coccinelle: Add a SmPL script for the reconsideration of redundant dev_err() calls
@ 2019-06-20 17:30 Markus Elfring
  2019-06-20 18:48 ` Julia Lawall
  2019-07-01  8:10 ` [Cocci] [PATCH v2] " Markus Elfring
  0 siblings, 2 replies; 15+ messages in thread
From: Markus Elfring @ 2019-06-20 17:30 UTC (permalink / raw)
  To: kernel-janitors, Gilles Muller, Julia Lawall, Masahiro Yamada,
	Michal Marek, Nicolas Palix
  Cc: Ding Xiang, Coccinelle, LKML

From: Markus Elfring <elfring@users.sourceforge.net>
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 <elfring@users.sourceforge.net>
---
 .../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 (...);
+ }
+
+@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.")
+
+@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

_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

^ permalink raw reply related	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2019-07-01 12:47 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-20 17:30 [Cocci] [PATCH] Coccinelle: Add a SmPL script for the reconsideration of redundant dev_err() calls Markus Elfring
2019-06-20 18:48 ` Julia Lawall
2019-06-20 19:02   ` [Cocci] " Markus Elfring
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-07-01  8:10 ` [Cocci] [PATCH v2] " Markus Elfring
2019-07-01 10:48   ` Enrico Weigelt, metux IT consult
2019-07-01 12:40     ` [Cocci] [v2] Coccinelle: Suppression of warnings? Markus Elfring
2019-07-01 12:47     ` [Cocci] [PATCH v2] Coccinelle: Add a SmPL script for the reconsideration of redundant dev_err() calls Julia Lawall

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).