All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] error: Document how to accumulate multiple errors
@ 2015-11-17 16:05 Markus Armbruster
  2015-11-25  9:16 ` Stefan Hajnoczi
  2015-11-26  4:02 ` Fam Zheng
  0 siblings, 2 replies; 4+ messages in thread
From: Markus Armbruster @ 2015-11-17 16:05 UTC (permalink / raw)
  To: qemu-devel; +Cc: mdroth

Suggested-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
---
 include/qapi/error.h | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/include/qapi/error.h b/include/qapi/error.h
index 4d42cdc..b2362a5 100644
--- a/include/qapi/error.h
+++ b/include/qapi/error.h
@@ -76,6 +76,23 @@
  * But when all you do with the error is pass it on, please use
  *     foo(arg, errp);
  * for readability.
+ *
+ * Receive and accumulate multiple errors (first one wins):
+ *     Error *err = NULL, *local_err = NULL;
+ *     foo(arg, &err);
+ *     bar(arg, &local_err);
+ *     error_propagate(&err, local_err);
+ *     if (err) {
+ *         handle the error...
+ *     }
+ *
+ * Do *not* "optimize" this to
+ *     foo(arg, &err);
+ *     bar(arg, &err); // WRONG!
+ *     if (err) {
+ *         handle the error...
+ *     }
+ * because this may pass a non-null err to bar().
  */
 
 #ifndef ERROR_H
-- 
2.4.3

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

end of thread, other threads:[~2015-11-26  7:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-17 16:05 [Qemu-devel] [PATCH] error: Document how to accumulate multiple errors Markus Armbruster
2015-11-25  9:16 ` Stefan Hajnoczi
2015-11-26  4:02 ` Fam Zheng
2015-11-26  7:19   ` Markus Armbruster

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.