86 lines
2.8 KiB
Diff
86 lines
2.8 KiB
Diff
From fe7dd779a9674dc54ffe296247ae6559f2b55b22 Mon Sep 17 00:00:00 2001
|
|
From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= <marcandre.lureau@redhat.com>
|
|
Date: Wed, 16 Dec 2020 16:06:07 -0500
|
|
Subject: [PATCH 06/14] error: Fix examples in error.h's big comment
|
|
MIME-Version: 1.0
|
|
Content-Type: text/plain; charset=UTF-8
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
RH-Author: Marc-André Lureau <marcandre.lureau@redhat.com>
|
|
Message-id: <20201216160615.324213-3-marcandre.lureau@redhat.com>
|
|
Patchwork-id: 100473
|
|
O-Subject: [RHEL-8.4.0 qemu-kvm PATCH v2 02/10] error: Fix examples in error.h's big comment
|
|
Bugzilla: 1859494
|
|
RH-Acked-by: Danilo de Paula <ddepaula@redhat.com>
|
|
RH-Acked-by: Sergio Lopez Pascual <slp@redhat.com>
|
|
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
|
From: Markus Armbruster <armbru@redhat.com>
|
|
|
|
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>
|
|
|
|
(cherry picked from commit 47ff5ac81e8bb3096500de7b132051691d533d36)
|
|
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
|
|
Signed-off-by: Danilo C. L. de Paula <ddepaula@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 3f95141a01a..83c38f9a188 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.27.0
|
|
|