Blame SOURCES/kvm-error-Fix-examples-in-error.h-s-big-comment.patch

709dde
From 393a5e9b24947f90cd116c4fb1b2ff4ee200f0df Mon Sep 17 00:00:00 2001
709dde
From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= <marcandre.lureau@redhat.com>
709dde
Date: Fri, 8 Jan 2021 07:40:53 -0500
709dde
Subject: [PATCH 02/10] error: Fix examples in error.h's big comment
709dde
MIME-Version: 1.0
709dde
Content-Type: text/plain; charset=UTF-8
709dde
Content-Transfer-Encoding: 8bit
709dde
709dde
RH-Author: Marc-André Lureau <marcandre.lureau@redhat.com>
709dde
Message-id: <20210108074101.290008-3-marcandre.lureau@redhat.com>
709dde
Patchwork-id: 100521
709dde
O-Subject: [RHEL-8.3.0.z qemu-kvm PATCH 02/10] error: Fix examples in error.h's big comment
709dde
Bugzilla: 1913818
709dde
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
709dde
RH-Acked-by: Philippe Mathieu-Daudé <philmd@redhat.com>
709dde
RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
709dde
709dde
From: Marc-André Lureau <marcandre.lureau@redhat.com>
709dde
709dde
From: Markus Armbruster <armbru@redhat.com>
709dde
709dde
Mark a bad example more clearly.  Fix the error_propagate_prepend()
709dde
example.  Add a missing declaration and a second error pileup example.
709dde
709dde
Signed-off-by: Markus Armbruster <armbru@redhat.com>
709dde
Reviewed-by: Eric Blake <eblake@redhat.com>
709dde
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
709dde
Reviewed-by: Greg Kurz <groug@kaod.org>
709dde
Message-Id: <20200707160613.848843-2-armbru@redhat.com>
709dde
709dde
(cherry picked from commit 47ff5ac81e8bb3096500de7b132051691d533d36)
709dde
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
709dde
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
709dde
---
709dde
 include/qapi/error.h | 16 ++++++++++++++--
709dde
 1 file changed, 14 insertions(+), 2 deletions(-)
709dde
709dde
diff --git a/include/qapi/error.h b/include/qapi/error.h
709dde
index 3f95141a01a..83c38f9a188 100644
709dde
--- a/include/qapi/error.h
709dde
+++ b/include/qapi/error.h
709dde
@@ -24,7 +24,7 @@
709dde
  *                       "charm, top, bottom.\n");
709dde
  *
709dde
  * Do *not* contract this to
709dde
- *     error_setg(&err, "invalid quark\n"
709dde
+ *     error_setg(&err, "invalid quark\n" // WRONG!
709dde
  *                "Valid quarks are up, down, strange, charm, top, bottom.");
709dde
  *
709dde
  * Report an error to the current monitor if we have one, else stderr:
709dde
@@ -52,7 +52,8 @@
709dde
  * where Error **errp is a parameter, by convention the last one.
709dde
  *
709dde
  * Pass an existing error to the caller with the message modified:
709dde
- *     error_propagate_prepend(errp, err);
709dde
+ *     error_propagate_prepend(errp, err,
709dde
+ *                             "Could not frobnicate '%s': ", name);
709dde
  *
709dde
  * Avoid
709dde
  *     error_propagate(errp, err);
709dde
@@ -108,12 +109,23 @@
709dde
  *     }
709dde
  *
709dde
  * Do *not* "optimize" this to
709dde
+ *     Error *err = NULL;
709dde
  *     foo(arg, &err);
709dde
  *     bar(arg, &err); // WRONG!
709dde
  *     if (err) {
709dde
  *         handle the error...
709dde
  *     }
709dde
  * because this may pass a non-null err to bar().
709dde
+ *
709dde
+ * Likewise, do *not*
709dde
+ *     Error *err = NULL;
709dde
+ *     if (cond1) {
709dde
+ *         error_setg(&err, ...);
709dde
+ *     }
709dde
+ *     if (cond2) {
709dde
+ *         error_setg(&err, ...); // WRONG!
709dde
+ *     }
709dde
+ * because this may pass a non-null err to error_setg().
709dde
  */
709dde
 
709dde
 #ifndef ERROR_H
709dde
-- 
709dde
2.27.0
709dde