[GEDI] [RFC v2 6/9] scripts: add coccinelle script to use auto propagated errp
Vladimir Sementsov-Ogievskiy
vsementsov at virtuozzo.com
Mon Sep 23 16:12:28 UTC 2019
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov at virtuozzo.com>
---
scripts/coccinelle/auto-propagated-errp.cocci | 82 +++++++++++++++++++
1 file changed, 82 insertions(+)
create mode 100644 scripts/coccinelle/auto-propagated-errp.cocci
diff --git a/scripts/coccinelle/auto-propagated-errp.cocci b/scripts/coccinelle/auto-propagated-errp.cocci
new file mode 100644
index 0000000000..1a3f006f0b
--- /dev/null
+++ b/scripts/coccinelle/auto-propagated-errp.cocci
@@ -0,0 +1,82 @@
+@@
+identifier fn;
+identifier local_err;
+@@
+
+ fn(..., Error **errp)
+ {
++ ERRP_FUNCTION_BEGIN();
+ }
+
+ at rule1@
+identifier fn;
+identifier local_err;
+@@
+
+ fn(..., Error **errp)
+ {
+ <...
+- Error *local_err = NULL;
+ ...>
+ }
+
+@@
+identifier rule1.fn;
+identifier rule1.local_err;
+identifier out;
+@@
+
+ fn(...)
+ {
+ <...
+- goto out;
++ return;
+ ...>
+- out:
+- error_propagate(errp, local_err);
+ }
+
+@@
+identifier rule1.fn;
+identifier rule1.local_err;
+@@
+
+ fn(...)
+ {
+ <...
+(
+- error_free(local_err);
+- local_err = NULL;
++ error_free_errp(errp);
+|
+- error_free(local_err);
++ error_free_errp(errp);
+|
+- error_report_err(local_err);
++ error_report_errp(errp);
+|
+- warn_report_err(local_err);
++ warn_report_errp(errp);
+|
+- error_propagate(errp, local_err);
+)
+ ...>
+ }
+
+@@
+identifier rule1.fn;
+identifier rule1.local_err;
+@@
+
+ fn(...)
+ {
+ <...
+(
+- &local_err
++ errp
+|
+- local_err
++ *errp
+)
+ ...>
+ }
--
2.21.0
More information about the integration
mailing list