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

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