error_append_hint and error_prepend will not work, if errp ==
&fatal_error, as program will exit before error_append_hint or
error_prepend call. Fix this by use of special macro
ERRP_AUTO_PROPAGATE.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsement...@virtuozzo.com>
---

CC: kw...@redhat.com
CC: mre...@redhat.com
CC: js...@redhat.com
CC: f...@euphon.net
CC: s...@weilnetz.de
CC: codypr...@gmail.com
CC: marcandre.lur...@redhat.com
CC: pbonz...@redhat.com
CC: gr...@kaod.org
CC: sundeep.l...@gmail.com
CC: peter.mayd...@linaro.org
CC: stefa...@redhat.com
CC: pbur...@wavecomp.com
CC: arik...@wavecomp.com
CC: berra...@redhat.com
CC: ehabk...@redhat.com
CC: da...@gibson.dropbear.id.au
CC: c...@kaod.org
CC: m...@redhat.com
CC: marcel.apfelb...@gmail.com
CC: mark.cave-ayl...@ilande.co.uk
CC: yuval.sh...@oracle.com
CC: coh...@redhat.com
CC: far...@linux.ibm.com
CC: r...@twiddle.net
CC: da...@redhat.com
CC: pa...@linux.ibm.com
CC: borntrae...@de.ibm.com
CC: kra...@redhat.com
CC: alex.william...@redhat.com
CC: and...@aj.id.au
CC: j...@jms.id.au
CC: ebl...@redhat.com
CC: arm...@redhat.com
CC: mdr...@linux.vnet.ibm.com
CC: quint...@redhat.com
CC: dgilb...@redhat.com
CC: jasow...@redhat.com
CC: qemu-bl...@nongnu.org
CC: integrat...@gluster.org
CC: qemu-...@nongnu.org
CC: qemu-...@nongnu.org
CC: qemu-s3...@nongnu.org

 scripts/coccinelle/fix-error-add-info.cocci | 28 +++++++++++++++++++++
 1 file changed, 28 insertions(+)
 create mode 100644 scripts/coccinelle/fix-error-add-info.cocci

diff --git a/scripts/coccinelle/fix-error-add-info.cocci 
b/scripts/coccinelle/fix-error-add-info.cocci
new file mode 100644
index 0000000000..34fa3be720
--- /dev/null
+++ b/scripts/coccinelle/fix-error-add-info.cocci
@@ -0,0 +1,28 @@
+@rule0@
+// Add invocation to errp-functions
+identifier fn;
+@@
+
+ fn(..., Error **errp, ...)
+ {
++   ERRP_AUTO_PROPAGATE();
+    <+...
+(
+    error_append_hint(errp, ...);
+|
+    error_prepend(errp, ...);
+)
+    ...+>
+ }
+
+@@
+// Drop doubled invocation
+identifier rule0.fn;
+@@
+
+ fn(...)
+{
+    ERRP_AUTO_PROPAGATE();
+-   ERRP_AUTO_PROPAGATE();
+    ...
+}
-- 
2.21.0


Reply via email to