[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 01/53] error: Fix examples in error.h's big comment
From: |
Markus Armbruster |
Subject: |
[PULL 01/53] error: Fix examples in error.h's big comment |
Date: |
Tue, 7 Jul 2020 23:24:11 +0200 |
Mark a bad example more clearly. Fix the error_propagate_prepend()
example. Add a missing declaration and a second error pileup example.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Reviewed-by: Greg Kurz <groug@kaod.org>
Message-Id: <20200707160613.848843-2-armbru@redhat.com>
---
include/qapi/error.h | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/include/qapi/error.h b/include/qapi/error.h
index ad5b6e896d..e8960eaad5 100644
--- a/include/qapi/error.h
+++ b/include/qapi/error.h
@@ -24,7 +24,7 @@
* "charm, top, bottom.\n");
*
* Do *not* contract this to
- * error_setg(&err, "invalid quark\n"
+ * error_setg(&err, "invalid quark\n" // WRONG!
* "Valid quarks are up, down, strange, charm, top, bottom.");
*
* Report an error to the current monitor if we have one, else stderr:
@@ -52,7 +52,8 @@
* where Error **errp is a parameter, by convention the last one.
*
* Pass an existing error to the caller with the message modified:
- * error_propagate_prepend(errp, err);
+ * error_propagate_prepend(errp, err,
+ * "Could not frobnicate '%s': ", name);
*
* Avoid
* error_propagate(errp, err);
@@ -108,12 +109,23 @@
* }
*
* Do *not* "optimize" this to
+ * Error *err = NULL;
* foo(arg, &err);
* bar(arg, &err); // WRONG!
* if (err) {
* handle the error...
* }
* because this may pass a non-null err to bar().
+ *
+ * Likewise, do *not*
+ * Error *err = NULL;
+ * if (cond1) {
+ * error_setg(&err, ...);
+ * }
+ * if (cond2) {
+ * error_setg(&err, ...); // WRONG!
+ * }
+ * because this may pass a non-null err to error_setg().
*/
#ifndef ERROR_H
--
2.26.2
- [PULL 33/53] error: Avoid unnecessary error_propagate() after error_setg(), (continued)
- [PULL 33/53] error: Avoid unnecessary error_propagate() after error_setg(), Markus Armbruster, 2020/07/08
- [PULL 43/53] qemu-img: Ignore Error objects where the return value suffices, Markus Armbruster, 2020/07/08
- [PULL 31/53] qdev: Make functions taking Error ** return bool, not void, Markus Armbruster, 2020/07/08
- [PULL 23/53] qom: Crash more nicely on object_property_get_link() failure, Markus Armbruster, 2020/07/08
- [PULL 53/53] xen: Use ERRP_GUARD(), Markus Armbruster, 2020/07/08
- [PULL 26/53] qom: Put name parameter before value / visitor parameter, Markus Armbruster, 2020/07/08
- [PULL 40/53] qapi: Smooth visitor error checking in generated code, Markus Armbruster, 2020/07/08
- [PULL 39/53] qapi: Smooth another visitor error checking pattern, Markus Armbruster, 2020/07/08
- [PULL 18/53] qapi: Use returned bool to check for failure, Coccinelle part, Markus Armbruster, 2020/07/08
- [PULL 12/53] qemu-option: Replace opt_set() by cleaner opt_validate(), Markus Armbruster, 2020/07/08
- [PULL 01/53] error: Fix examples in error.h's big comment,
Markus Armbruster <=
- [PULL 10/53] qemu-option: Simplify around find_default_by_name(), Markus Armbruster, 2020/07/08
- [PULL 17/53] qapi: Make visitor functions taking Error ** return bool, not void, Markus Armbruster, 2020/07/08
- [PULL 37/53] error: Reduce unnecessary error propagation, Markus Armbruster, 2020/07/08
- [PULL 15/53] block: Avoid error accumulation in bdrv_img_create(), Markus Armbruster, 2020/07/08
- [PULL 48/53] sd: Use ERRP_GUARD(), Markus Armbruster, 2020/07/08
- [PULL 14/53] qemu-option: Use returned bool to check for failure, Markus Armbruster, 2020/07/08
- [PULL 21/53] qom: Use error_reportf_err() instead of g_printerr() in examples, Markus Armbruster, 2020/07/08
- [PULL 20/53] s390x/pci: Fix harmless mistake in zpci's property fid's setter, Markus Armbruster, 2020/07/08
- [PULL 29/53] qom: Use returned bool to check for failure, manual part, Markus Armbruster, 2020/07/08
- [PULL 03/53] error: Document Error API usage rules, Markus Armbruster, 2020/07/08