render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
Blob Blame History Raw
From fd3758c438af5b2c4b571916bbe6bc4bf6e0bf4e Mon Sep 17 00:00:00 2001
Message-Id: <fd3758c438af5b2c4b571916bbe6bc4bf6e0bf4e@dist-git>
From: Peter Krempa <pkrempa@redhat.com>
Date: Wed, 24 Aug 2016 16:11:04 -0400
Subject: [PATCH] qemu: monitor: Add do-while block to QEMU_CHECK_MONITOR_FULL

https://bugzilla.redhat.com/show_bug.cgi?id=1097930
https://bugzilla.redhat.com/show_bug.cgi?id=1224341

Assure that it's just one statement to avoid problems when used with
conditions.

(cherry picked from commit 0f889e725e2e132e1eed62de38995677abc5da41)
---
 src/qemu/qemu_monitor.c | 25 ++++++++++++++-----------
 1 file changed, 14 insertions(+), 11 deletions(-)

diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index 2931f82..65e7a11 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -112,17 +112,20 @@ struct _qemuMonitor {
  * monitor.
  */
 #define QEMU_CHECK_MONITOR_FULL(mon, force_json, exit)                         \
-    if (!mon) {                                                                \
-        virReportError(VIR_ERR_INVALID_ARG, "%s",                              \
-                       _("monitor must not be NULL"));                         \
-        exit;                                                                  \
-    }                                                                          \
-    VIR_DEBUG("mon:%p vm:%p json:%d fd:%d", mon, mon->vm, mon->json, mon->fd); \
-    if (force_json && !mon->json) {                                            \
-        virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",                    \
-                       _("JSON monitor is required"));                         \
-        exit;                                                                  \
-    }
+    do {                                                                       \
+        if (!mon) {                                                            \
+            virReportError(VIR_ERR_INVALID_ARG, "%s",                          \
+                           _("monitor must not be NULL"));                     \
+            exit;                                                              \
+        }                                                                      \
+        VIR_DEBUG("mon:%p vm:%p json:%d fd:%d",                                \
+                  mon, mon->vm, mon->json, mon->fd);                           \
+        if (force_json && !mon->json) {                                        \
+            virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",                \
+                           _("JSON monitor is required"));                     \
+            exit;                                                              \
+        }                                                                      \
+    } while (0)
 
 /* Check monitor and return NULL on error */
 #define QEMU_CHECK_MONITOR_NULL(mon) \
-- 
2.10.0