yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

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

a19a21
From fe7dd779a9674dc54ffe296247ae6559f2b55b22 Mon Sep 17 00:00:00 2001
709dde
From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= <marcandre.lureau@redhat.com>
a19a21
Date: Wed, 16 Dec 2020 16:06:07 -0500
a19a21
Subject: [PATCH 06/14] 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>
a19a21
Message-id: <20201216160615.324213-3-marcandre.lureau@redhat.com>
a19a21
Patchwork-id: 100473
a19a21
O-Subject: [RHEL-8.4.0 qemu-kvm PATCH v2 02/10] error: Fix examples in error.h's big comment
a19a21
Bugzilla: 1859494
a19a21
RH-Acked-by: Danilo de Paula <ddepaula@redhat.com>
a19a21
RH-Acked-by: Sergio Lopez Pascual <slp@redhat.com>
a19a21
RH-Acked-by: Stefan Hajnoczi <stefanha@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