[PATCH 12/13] qemu_monitor_json: Drop pointless cleanup labels

Michal Privoznik mprivozn at redhat.com
Mon Oct 25 10:57:36 UTC 2021


After previous cleanups, some 'cleanup' labels were rendered
needless - they contain nothing more than a return statement.
Well, those labels can be dropped and 'goto cleanup' can be
replaced with return statement directly.

Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
---
 src/qemu/qemu_monitor_json.c | 1035 ++++++++++++----------------------
 1 file changed, 368 insertions(+), 667 deletions(-)

diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index cd4a37a685..bb76ac7d37 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -216,25 +216,24 @@ qemuMonitorJSONIOProcessLine(qemuMonitor *mon,
                              qemuMonitorMessage *msg)
 {
     g_autoptr(virJSONValue) obj = NULL;
-    int ret = -1;
 
     VIR_DEBUG("Line [%s]", line);
 
     if (!(obj = virJSONValueFromString(line)))
-        goto cleanup;
+        return -1;
 
     if (virJSONValueGetType(obj) != VIR_JSON_TYPE_OBJECT) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        _("Parsed JSON reply '%s' isn't an object"), line);
-        goto cleanup;
+        return -1;
     }
 
     if (virJSONValueObjectHasKey(obj, "QMP") == 1) {
-        ret = 0;
+        return 0;
     } else if (virJSONValueObjectHasKey(obj, "event") == 1) {
         PROBE(QEMU_MONITOR_RECV_EVENT,
               "mon=%p event=%s", mon, line);
-        ret = qemuMonitorJSONIOProcessEvent(mon, obj);
+        return qemuMonitorJSONIOProcessEvent(mon, obj);
     } else if (virJSONValueObjectHasKey(obj, "error") == 1 ||
                virJSONValueObjectHasKey(obj, "return") == 1) {
         PROBE(QEMU_MONITOR_RECV_REPLY,
@@ -242,7 +241,7 @@ qemuMonitorJSONIOProcessLine(qemuMonitor *mon,
         if (msg) {
             msg->rxObject = g_steal_pointer(&obj);
             msg->finished = 1;
-            ret = 0;
+            return 0;
         } else {
             virReportError(VIR_ERR_INTERNAL_ERROR,
                            _("Unexpected JSON reply '%s'"), line);
@@ -252,8 +251,7 @@ qemuMonitorJSONIOProcessLine(qemuMonitor *mon,
                        _("Unknown JSON reply '%s'"), line);
     }
 
- cleanup:
-    return ret;
+    return -1;
 }
 
 int qemuMonitorJSONIOProcess(qemuMonitor *mon,
@@ -307,12 +305,12 @@ qemuMonitorJSONCommandWithFd(qemuMonitor *mon,
         if (virJSONValueObjectAppendString(cmd, "id", id) < 0) {
             virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                            _("Unable to append command 'id' string"));
-            goto cleanup;
+            return -1;
         }
     }
 
     if (virJSONValueToBuffer(cmd, &cmdbuf, false) < 0)
-        goto cleanup;
+        return -1;
     virBufferAddLit(&cmdbuf, "\r\n");
 
     msg.txLength = virBufferUse(&cmdbuf);
@@ -331,7 +329,6 @@ qemuMonitorJSONCommandWithFd(qemuMonitor *mon,
         }
     }
 
- cleanup:
     return ret;
 }
 
@@ -1455,33 +1452,29 @@ qemuMonitorJSONHumanCommand(qemuMonitor *mon,
     g_autoptr(virJSONValue) reply = NULL;
     virJSONValue *obj;
     const char *data;
-    int ret = -1;
 
     cmd = qemuMonitorJSONMakeCommand("human-monitor-command",
                                      "s:command-line", cmd_str,
                                      NULL);
 
     if (!cmd || qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
-        goto cleanup;
+        return -1;
 
     if (qemuMonitorJSONHasError(reply, "CommandNotFound")) {
         virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
                        _("Human monitor command is not available to run %s"),
                        cmd_str);
-        goto cleanup;
+        return -1;
     }
 
     if (qemuMonitorJSONCheckError(cmd, reply))
-        goto cleanup;
+        return -1;
 
     obj = virJSONValueObjectGet(reply, "return");
     data = virJSONValueGetString(obj);
     *reply_str = g_strdup(NULLSTR_EMPTY(data));
 
-    ret = 0;
-
- cleanup:
-    return ret;
+    return 0;
 }
 
 
@@ -1542,7 +1535,6 @@ qemuMonitorJSONStartCPUs(qemuMonitor *mon)
 int
 qemuMonitorJSONStopCPUs(qemuMonitor *mon)
 {
-    int ret = -1;
     g_autoptr(virJSONValue) cmd = qemuMonitorJSONMakeCommand("stop", NULL);
     g_autoptr(virJSONValue) reply = NULL;
 
@@ -1550,14 +1542,12 @@ qemuMonitorJSONStopCPUs(qemuMonitor *mon)
         return -1;
 
     if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
-        goto cleanup;
+        return -1;
 
     if (qemuMonitorJSONCheckError(cmd, reply) < 0)
-        goto cleanup;
+        return -1;
 
-    ret = 0;
- cleanup:
-    return ret;
+    return 0;
 }
 
 
@@ -1604,7 +1594,6 @@ qemuMonitorJSONGetStatus(qemuMonitor *mon,
 
 int qemuMonitorJSONSystemPowerdown(qemuMonitor *mon)
 {
-    int ret = -1;
     g_autoptr(virJSONValue) cmd = qemuMonitorJSONMakeCommand("system_powerdown", NULL);
     g_autoptr(virJSONValue) reply = NULL;
 
@@ -1612,21 +1601,18 @@ int qemuMonitorJSONSystemPowerdown(qemuMonitor *mon)
         return -1;
 
     if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
-        goto cleanup;
+        return -1;
 
     if (qemuMonitorJSONCheckError(cmd, reply) < 0)
-        goto cleanup;
+        return -1;
 
-    ret = 0;
- cleanup:
-    return ret;
+    return 0;
 }
 
 int qemuMonitorJSONSetLink(qemuMonitor *mon,
                            const char *name,
                            virDomainNetInterfaceLinkState state)
 {
-    int ret = -1;
     g_autoptr(virJSONValue) reply = NULL;
     g_autoptr(virJSONValue) cmd = qemuMonitorJSONMakeCommand("set_link",
                                                              "s:name", name,
@@ -1637,19 +1623,16 @@ int qemuMonitorJSONSetLink(qemuMonitor *mon,
         return -1;
 
     if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
-        goto cleanup;
+        return -1;
 
     if (qemuMonitorJSONCheckError(cmd, reply) < 0)
-        goto cleanup;
+        return -1;
 
-    ret = 0;
- cleanup:
-    return ret;
+    return 0;
 }
 
 int qemuMonitorJSONSystemReset(qemuMonitor *mon)
 {
-    int ret = -1;
     g_autoptr(virJSONValue) cmd = qemuMonitorJSONMakeCommand("system_reset", NULL);
     g_autoptr(virJSONValue) reply = NULL;
 
@@ -1657,14 +1640,12 @@ int qemuMonitorJSONSystemReset(qemuMonitor *mon)
         return -1;
 
     if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
-        goto cleanup;
+        return -1;
 
     if (qemuMonitorJSONCheckError(cmd, reply) < 0)
-        goto cleanup;
+        return -1;
 
-    ret = 0;
- cleanup:
-    return ret;
+    return 0;
 }
 
 
@@ -1840,7 +1821,6 @@ qemuMonitorJSONQueryCPUs(qemuMonitor *mon,
                          bool force,
                          bool fast)
 {
-    int ret = -1;
     g_autoptr(virJSONValue) cmd = NULL;
     g_autoptr(virJSONValue) reply = NULL;
     virJSONValue *data;
@@ -1854,20 +1834,15 @@ qemuMonitorJSONQueryCPUs(qemuMonitor *mon,
         return -1;
 
     if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
-        goto cleanup;
+        return -1;
 
     if (force && qemuMonitorJSONCheckError(cmd, reply) < 0)
-        goto cleanup;
+        return -1;
 
-    if (!(data = virJSONValueObjectGetArray(reply, "return"))) {
-        ret = -2;
-        goto cleanup;
-    }
+    if (!(data = virJSONValueObjectGetArray(reply, "return")))
+        return -2;
 
-    ret = qemuMonitorJSONExtractCPUInfo(data, entries, nentries, fast);
-
- cleanup:
-    return ret;
+    return qemuMonitorJSONExtractCPUInfo(data, entries, nentries, fast);
 }
 
 
@@ -1987,7 +1962,6 @@ int
 qemuMonitorJSONGetBalloonInfo(qemuMonitor *mon,
                               unsigned long long *currmem)
 {
-    int ret = -1;
     virJSONValue *data;
     unsigned long long mem;
     g_autoptr(virJSONValue) cmd = qemuMonitorJSONMakeCommand("query-balloon",
@@ -2000,31 +1974,28 @@ qemuMonitorJSONGetBalloonInfo(qemuMonitor *mon,
         return -1;
 
     if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
-        goto cleanup;
+        return -1;
 
     /* See if balloon soft-failed */
     if (qemuMonitorJSONHasError(reply, "DeviceNotActive") ||
         qemuMonitorJSONHasError(reply, "KVMMissingCap")) {
-        ret = 0;
-        goto cleanup;
+        return 0;
     }
 
     /* See if any other fatal error occurred */
     if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_OBJECT) < 0)
-        goto cleanup;
+        return -1;
 
     data = virJSONValueObjectGetObject(reply, "return");
 
     if (virJSONValueObjectGetNumberUlong(data, "actual", &mem) < 0) {
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                        _("info balloon reply was missing balloon data"));
-        goto cleanup;
+        return -1;
     }
 
     *currmem = (mem/1024);
-    ret = 1;
- cleanup:
-    return ret;
+    return 1;
 }
 
 
@@ -2200,19 +2171,15 @@ qemuMonitorJSONQueryBlock(qemuMonitor *mon)
 {
     g_autoptr(virJSONValue) cmd = NULL;
     g_autoptr(virJSONValue) reply = NULL;
-    virJSONValue *devices = NULL;
 
     if (!(cmd = qemuMonitorJSONMakeCommand("query-block", NULL)))
         return NULL;
 
     if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0 ||
         qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_ARRAY) < 0)
-        goto cleanup;
+        return NULL;
 
-    devices = virJSONValueObjectStealArray(reply, "return");
-
- cleanup:
-    return devices;
+    return virJSONValueObjectStealArray(reply, "return");
 }
 
 
@@ -2279,7 +2246,6 @@ qemuMonitorJSONBlockInfoAdd(GHashTable *table,
 int qemuMonitorJSONGetBlockInfo(qemuMonitor *mon,
                                 GHashTable *table)
 {
-    int ret = -1;
     size_t i;
     g_autoptr(virJSONValue) devices = NULL;
 
@@ -2295,10 +2261,10 @@ int qemuMonitorJSONGetBlockInfo(qemuMonitor *mon,
         const char *qdev;
 
         if (!(dev = qemuMonitorJSONGetBlockDev(devices, i)))
-            goto cleanup;
+            return -1;
 
         if (!(thisdev = qemuMonitorJSONGetBlockDevDevice(dev)))
-            goto cleanup;
+            return -1;
 
         thisdev = qemuAliasDiskDriveSkipPrefix(thisdev);
         qdev = virJSONValueObjectGetString(dev, "qdev");
@@ -2309,14 +2275,14 @@ int qemuMonitorJSONGetBlockInfo(qemuMonitor *mon,
         if (!qdev && !thisdev) {
             virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                            _("query-block device entry was not in expected format"));
-            goto cleanup;
+            return -1;
         }
 
         if (virJSONValueObjectGetBoolean(dev, "removable", &info.removable) < 0) {
             virReportError(VIR_ERR_INTERNAL_ERROR,
                            _("cannot read %s value"),
                            "removable");
-            goto cleanup;
+            return -1;
         }
 
         /* 'tray_open' is present only if the device has a tray */
@@ -2334,21 +2300,19 @@ int qemuMonitorJSONGetBlockInfo(qemuMonitor *mon,
         if ((status = virJSONValueObjectGetString(dev, "io-status"))) {
             info.io_status = qemuMonitorBlockIOStatusToError(status);
             if (info.io_status < 0)
-                goto cleanup;
+                return -1;
         }
 
         if (thisdev &&
             qemuMonitorJSONBlockInfoAdd(table, &info, thisdev) < 0)
-            goto cleanup;
+            return -1;
 
         if (qdev && STRNEQ_NULLABLE(thisdev, qdev) &&
             qemuMonitorJSONBlockInfoAdd(table, &info, qdev) < 0)
-            goto cleanup;
+            return -1;
     }
 
-    ret = 0;
- cleanup:
-    return ret;
+    return 0;
 }
 
 
@@ -2661,7 +2625,6 @@ qemuMonitorJSONBlockStatsUpdateCapacityBlockdev(qemuMonitor *mon,
                                                 GHashTable *stats)
 {
     g_autoptr(virJSONValue) nodes = NULL;
-    int ret = -1;
 
     if (!(nodes = qemuMonitorJSONQueryNamedBlockNodes(mon, false)))
         return -1;
@@ -2669,12 +2632,9 @@ qemuMonitorJSONBlockStatsUpdateCapacityBlockdev(qemuMonitor *mon,
     if (virJSONValueArrayForeachSteal(nodes,
                                       qemuMonitorJSONBlockStatsUpdateCapacityBlockdevWorker,
                                       stats) < 0)
-        goto cleanup;
+        return -1;
 
-    ret = 0;
-
- cleanup:
-    return ret;
+    return 0;
 }
 
 
@@ -2845,7 +2805,6 @@ int qemuMonitorJSONBlockResize(qemuMonitor *mon,
                                const char *nodename,
                                unsigned long long size)
 {
-    int ret = -1;
     g_autoptr(virJSONValue) cmd = NULL;
     g_autoptr(virJSONValue) reply = NULL;
 
@@ -2858,14 +2817,12 @@ int qemuMonitorJSONBlockResize(qemuMonitor *mon,
         return -1;
 
     if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
-        goto cleanup;
+        return -1;
 
     if (qemuMonitorJSONCheckError(cmd, reply) < 0)
-        goto cleanup;
+        return -1;
 
-    ret = 0;
- cleanup:
-    return ret;
+    return 0;
 }
 
 
@@ -2874,7 +2831,6 @@ int qemuMonitorJSONSetPassword(qemuMonitor *mon,
                                const char *password,
                                const char *action_if_connected)
 {
-    int ret = -1;
     g_autoptr(virJSONValue) cmd = qemuMonitorJSONMakeCommand("set_password",
                                                              "s:protocol", protocol,
                                                              "s:password", password,
@@ -2886,21 +2842,18 @@ int qemuMonitorJSONSetPassword(qemuMonitor *mon,
         return -1;
 
     if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
-        goto cleanup;
+        return -1;
 
     if (qemuMonitorJSONCheckError(cmd, reply) < 0)
-        goto cleanup;
+        return -1;
 
-    ret = 0;
- cleanup:
-    return ret;
+    return 0;
 }
 
 int qemuMonitorJSONExpirePassword(qemuMonitor *mon,
                                   const char *protocol,
                                   const char *expire_time)
 {
-    int ret = -1;
     g_autoptr(virJSONValue) cmd = qemuMonitorJSONMakeCommand("expire_password",
                                                              "s:protocol", protocol,
                                                              "s:time", expire_time,
@@ -2911,14 +2864,12 @@ int qemuMonitorJSONExpirePassword(qemuMonitor *mon,
         return -1;
 
     if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
-        goto cleanup;
+        return -1;
 
     if (qemuMonitorJSONCheckError(cmd, reply) < 0)
-        goto cleanup;
+        return -1;
 
-    ret = 0;
- cleanup:
-    return ret;
+    return 0;
 }
 
 
@@ -2926,7 +2877,6 @@ int
 qemuMonitorJSONSetBalloon(qemuMonitor *mon,
                           unsigned long long newmem)
 {
-    int ret = -1;
     g_autoptr(virJSONValue) cmd = qemuMonitorJSONMakeCommand("balloon",
                                                              "U:value", newmem * 1024,
                                                              NULL);
@@ -2936,30 +2886,26 @@ qemuMonitorJSONSetBalloon(qemuMonitor *mon,
         return -1;
 
     if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
-        goto cleanup;
+        return -1;
 
     /* See if balloon soft-failed */
     if (qemuMonitorJSONHasError(reply, "DeviceNotActive") ||
         qemuMonitorJSONHasError(reply, "KVMMissingCap")) {
-        ret = 0;
-        goto cleanup;
+        return 0;
     }
 
     /* See if any other fatal error occurred */
     if (qemuMonitorJSONCheckError(cmd, reply) < 0)
-        goto cleanup;
+        return -1;
 
     /* Real success */
-    ret = 1;
- cleanup:
-    return ret;
+    return 1;
 }
 
 
 int qemuMonitorJSONSetCPU(qemuMonitor *mon,
                           int cpu, bool online)
 {
-    int ret = -1;
     g_autoptr(virJSONValue) cmd = NULL;
     g_autoptr(virJSONValue) reply = NULL;
 
@@ -2970,18 +2916,15 @@ int qemuMonitorJSONSetCPU(qemuMonitor *mon,
     } else {
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                        _("vCPU unplug is not supported by this QEMU"));
-        goto cleanup;
+        return -1;
     }
     if (!cmd)
-        goto cleanup;
+        return -1;
 
-    if ((ret = qemuMonitorJSONCommand(mon, cmd, &reply)) < 0)
-        goto cleanup;
+    if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
+        return -1;
 
-    ret = qemuMonitorJSONCheckError(cmd, reply);
-
- cleanup:
-    return ret;
+    return qemuMonitorJSONCheckError(cmd, reply);
 }
 
 
@@ -2996,7 +2939,6 @@ int qemuMonitorJSONEjectMedia(qemuMonitor *mon,
                               const char *dev_name,
                               bool force)
 {
-    int ret = -1;
     g_autoptr(virJSONValue) cmd = qemuMonitorJSONMakeCommand("eject",
                                                              "s:device", dev_name,
                                                              "b:force", force ? 1 : 0,
@@ -3007,14 +2949,12 @@ int qemuMonitorJSONEjectMedia(qemuMonitor *mon,
         return -1;
 
     if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
-        goto cleanup;
+        return -1;
 
     if (qemuMonitorJSONCheckError(cmd, reply) < 0)
-        goto cleanup;
+        return -1;
 
-    ret = 0;
- cleanup:
-    return ret;
+    return 0;
 }
 
 
@@ -3023,7 +2963,6 @@ int qemuMonitorJSONChangeMedia(qemuMonitor *mon,
                                const char *newmedia,
                                const char *format)
 {
-    int ret = -1;
     g_autoptr(virJSONValue) cmd = NULL;
     g_autoptr(virJSONValue) reply = NULL;
 
@@ -3037,14 +2976,12 @@ int qemuMonitorJSONChangeMedia(qemuMonitor *mon,
         return -1;
 
     if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
-        goto cleanup;
+        return -1;
 
     if (qemuMonitorJSONCheckError(cmd, reply) < 0)
-        goto cleanup;
+        return -1;
 
-    ret = 0;
- cleanup:
-    return ret;
+    return 0;
 }
 
 
@@ -3054,7 +2991,6 @@ static int qemuMonitorJSONSaveMemory(qemuMonitor *mon,
                                      unsigned long long length,
                                      const char *path)
 {
-    int ret = -1;
     g_autoptr(virJSONValue) cmd = qemuMonitorJSONMakeCommand(cmdtype,
                                                              "U:val", offset,
                                                              "U:size", length,
@@ -3066,14 +3002,12 @@ static int qemuMonitorJSONSaveMemory(qemuMonitor *mon,
         return -1;
 
     if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
-        goto cleanup;
+        return -1;
 
     if (qemuMonitorJSONCheckError(cmd, reply) < 0)
-        goto cleanup;
+        return -1;
 
-    ret = 0;
- cleanup:
-    return ret;
+    return 0;
 }
 
 
@@ -3097,7 +3031,6 @@ int qemuMonitorJSONSavePhysicalMemory(qemuMonitor *mon,
 int qemuMonitorJSONSetMigrationSpeed(qemuMonitor *mon,
                                      unsigned long bandwidth)
 {
-    int ret = -1;
     g_autoptr(virJSONValue) cmd = NULL;
     g_autoptr(virJSONValue) reply = NULL;
 
@@ -3108,21 +3041,18 @@ int qemuMonitorJSONSetMigrationSpeed(qemuMonitor *mon,
         return -1;
 
     if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
-        goto cleanup;
+        return -1;
 
     if (qemuMonitorJSONCheckError(cmd, reply) < 0)
-        goto cleanup;
+        return -1;
 
-    ret = 0;
- cleanup:
-    return ret;
+    return 0;
 }
 
 
 int qemuMonitorJSONSetMigrationDowntime(qemuMonitor *mon,
                                         unsigned long long downtime)
 {
-    int ret = -1;
     g_autoptr(virJSONValue) cmd = NULL;
     g_autoptr(virJSONValue) reply = NULL;
 
@@ -3133,14 +3063,12 @@ int qemuMonitorJSONSetMigrationDowntime(qemuMonitor *mon,
         return -1;
 
     if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
-        goto cleanup;
+        return -1;
 
     if (qemuMonitorJSONCheckError(cmd, reply) < 0)
-        goto cleanup;
+        return -1;
 
-    ret = 0;
- cleanup:
-    return ret;
+    return 0;
 }
 
 
@@ -3148,7 +3076,6 @@ int
 qemuMonitorJSONGetMigrationCacheSize(qemuMonitor *mon,
                                      unsigned long long *cacheSize)
 {
-    int ret = -1;
     g_autoptr(virJSONValue) cmd = NULL;
     g_autoptr(virJSONValue) reply = NULL;
 
@@ -3159,20 +3086,18 @@ qemuMonitorJSONGetMigrationCacheSize(qemuMonitor *mon,
         return -1;
 
     if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
-        goto cleanup;
+        return -1;
 
     if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_NUMBER) < 0)
-        goto cleanup;
+        return -1;
 
     if (virJSONValueObjectGetNumberUlong(reply, "return", cacheSize) < 0) {
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                        _("invalid cache size in query-migrate-cache-size reply"));
-        goto cleanup;
+        return -1;
     }
 
-    ret = 0;
- cleanup:
-    return ret;
+    return 0;
 }
 
 
@@ -3180,7 +3105,6 @@ int
 qemuMonitorJSONSetMigrationCacheSize(qemuMonitor *mon,
                                      unsigned long long cacheSize)
 {
-    int ret = -1;
     g_autoptr(virJSONValue) cmd = NULL;
     g_autoptr(virJSONValue) reply = NULL;
 
@@ -3191,14 +3115,12 @@ qemuMonitorJSONSetMigrationCacheSize(qemuMonitor *mon,
         return -1;
 
     if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
-        goto cleanup;
+        return -1;
 
     if (qemuMonitorJSONCheckError(cmd, reply) < 0)
-        goto cleanup;
+        return -1;
 
-    ret = 0;
- cleanup:
-    return ret;
+    return 0;
 }
 
 
@@ -3206,7 +3128,6 @@ int
 qemuMonitorJSONGetMigrationParams(qemuMonitor *mon,
                                   virJSONValue **params)
 {
-    int ret = -1;
     g_autoptr(virJSONValue) cmd = NULL;
     g_autoptr(virJSONValue) reply = NULL;
 
@@ -3216,16 +3137,13 @@ qemuMonitorJSONGetMigrationParams(qemuMonitor *mon,
         return -1;
 
     if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
-        goto cleanup;
+        return -1;
 
     if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_OBJECT) < 0)
-        goto cleanup;
+        return -1;
 
     *params = virJSONValueObjectStealObject(reply, "return");
-    ret = 0;
-
- cleanup:
-    return ret;
+    return 0;
 }
 
 int
@@ -3464,7 +3382,6 @@ int qemuMonitorJSONGetMigrationStats(qemuMonitor *mon,
                                      qemuMonitorMigrationStats *stats,
                                      char **error)
 {
-    int ret = -1;
     g_autoptr(virJSONValue) cmd = qemuMonitorJSONMakeCommand("query-migrate",
                                                              NULL);
     g_autoptr(virJSONValue) reply = NULL;
@@ -3475,17 +3392,15 @@ int qemuMonitorJSONGetMigrationStats(qemuMonitor *mon,
         return -1;
 
     if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
-        goto cleanup;
+        return -1;
 
     if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_OBJECT) < 0)
-        goto cleanup;
+        return -1;
 
     if (qemuMonitorJSONGetMigrationStatsReply(reply, stats, error) < 0)
-        goto cleanup;
+        return -1;
 
-    ret = 0;
- cleanup:
-    return ret;
+    return 0;
 }
 
 
@@ -3493,7 +3408,6 @@ int qemuMonitorJSONMigrate(qemuMonitor *mon,
                            unsigned int flags,
                            const char *uri)
 {
-    int ret = -1;
     g_autoptr(virJSONValue) cmd =
       qemuMonitorJSONMakeCommand("migrate",
                                  "b:detach", flags & QEMU_MONITOR_MIGRATE_BACKGROUND ? 1 : 0,
@@ -3507,33 +3421,28 @@ int qemuMonitorJSONMigrate(qemuMonitor *mon,
         return -1;
 
     if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
-        goto cleanup;
+        return -1;
 
     if (qemuMonitorJSONCheckError(cmd, reply) < 0)
-        goto cleanup;
+        return -1;
 
-    ret = 0;
- cleanup:
-    return ret;
+    return 0;
 }
 
 int qemuMonitorJSONMigrateCancel(qemuMonitor *mon)
 {
-    int ret = -1;
     g_autoptr(virJSONValue) cmd = qemuMonitorJSONMakeCommand("migrate_cancel", NULL);
     g_autoptr(virJSONValue) reply = NULL;
     if (!cmd)
         return -1;
 
     if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
-        goto cleanup;
+        return -1;
 
     if (qemuMonitorJSONCheckError(cmd, reply) < 0)
-        goto cleanup;
+        return -1;
 
-    ret = 0;
- cleanup:
-    return ret;
+    return 0;
 }
 
 
@@ -3553,23 +3462,19 @@ qemuMonitorJSONQueryDump(qemuMonitor *mon,
     g_autoptr(virJSONValue) cmd = qemuMonitorJSONMakeCommand("query-dump", NULL);
     g_autoptr(virJSONValue) reply = NULL;
     virJSONValue *result = NULL;
-    int ret = -1;
 
     if (!cmd)
         return -1;
 
     if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
-        goto cleanup;
+        return -1;
 
     if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_OBJECT) < 0)
-        goto cleanup;
+        return -1;
 
     result = virJSONValueObjectGetObject(reply, "return");
 
-    ret = qemuMonitorJSONExtractDumpStats(result, stats);
-
- cleanup:
-    return ret;
+    return qemuMonitorJSONExtractDumpStats(result, stats);
 }
 
 
@@ -3577,7 +3482,6 @@ int
 qemuMonitorJSONGetDumpGuestMemoryCapability(qemuMonitor *mon,
                                             const char *capability)
 {
-    int ret = -1;
     g_autoptr(virJSONValue) cmd = NULL;
     g_autoptr(virJSONValue) reply = NULL;
     virJSONValue *caps;
@@ -3589,17 +3493,17 @@ qemuMonitorJSONGetDumpGuestMemoryCapability(qemuMonitor *mon,
         return -1;
 
     if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
-        goto cleanup;
+        return -1;
 
     if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_OBJECT) < 0)
-        goto cleanup;
+        return -1;
 
     caps = virJSONValueObjectGetObject(reply, "return");
 
     if (!(formats = virJSONValueObjectGetArray(caps, "formats"))) {
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                        _("missing supported dump formats"));
-        goto cleanup;
+        return -1;
     }
 
     for (i = 0; i < virJSONValueArraySize(formats); i++) {
@@ -3608,18 +3512,14 @@ qemuMonitorJSONGetDumpGuestMemoryCapability(qemuMonitor *mon,
         if (!dumpformat || virJSONValueGetType(dumpformat) != VIR_JSON_TYPE_STRING) {
             virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                            _("missing entry in supported dump formats"));
-            goto cleanup;
+            return -1;
         }
 
-        if (STREQ(virJSONValueGetString(dumpformat), capability)) {
-            ret = 1;
-            goto cleanup;
-        }
+        if (STREQ(virJSONValueGetString(dumpformat), capability))
+            return 1;
     }
 
-    ret = 0;
- cleanup:
-    return ret;
+    return 0;
 }
 
 int
@@ -3628,7 +3528,6 @@ qemuMonitorJSONDump(qemuMonitor *mon,
                     const char *dumpformat,
                     bool detach)
 {
-    int ret = -1;
     g_autoptr(virJSONValue) cmd = NULL;
     g_autoptr(virJSONValue) reply = NULL;
 
@@ -3642,14 +3541,12 @@ qemuMonitorJSONDump(qemuMonitor *mon,
         return -1;
 
     if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
-        goto cleanup;
+        return -1;
 
     if (qemuMonitorJSONCheckError(cmd, reply) < 0)
-        goto cleanup;
+        return -1;
 
-    ret = 0;
- cleanup:
-    return ret;
+    return 0;
 }
 
 int qemuMonitorJSONGraphicsRelocate(qemuMonitor *mon,
@@ -3659,7 +3556,6 @@ int qemuMonitorJSONGraphicsRelocate(qemuMonitor *mon,
                                     int tlsPort,
                                     const char *tlsSubject)
 {
-    int ret = -1;
     g_autoptr(virJSONValue) cmd = qemuMonitorJSONMakeCommand("client_migrate_info",
                                                              "s:protocol",
                                                              (type == VIR_DOMAIN_GRAPHICS_TYPE_SPICE ? "spice" : "vnc"),
@@ -3674,14 +3570,12 @@ int qemuMonitorJSONGraphicsRelocate(qemuMonitor *mon,
         return -1;
 
     if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
-        goto cleanup;
+        return -1;
 
     if (qemuMonitorJSONCheckError(cmd, reply) < 0)
-        goto cleanup;
+        return -1;
 
-    ret = 0;
- cleanup:
-    return ret;
+    return 0;
 }
 
 
@@ -3864,7 +3758,6 @@ int qemuMonitorJSONSendFileHandle(qemuMonitor *mon,
                                   const char *fdname,
                                   int fd)
 {
-    int ret = -1;
     g_autoptr(virJSONValue) cmd = qemuMonitorJSONMakeCommand("getfd",
                                                              "s:fdname", fdname,
                                                              NULL);
@@ -3874,21 +3767,18 @@ int qemuMonitorJSONSendFileHandle(qemuMonitor *mon,
         return -1;
 
     if (qemuMonitorJSONCommandWithFd(mon, cmd, fd, &reply) < 0)
-        goto cleanup;
+        return -1;
 
     if (qemuMonitorJSONCheckError(cmd, reply) < 0)
-        goto cleanup;
+        return -1;
 
-    ret = 0;
- cleanup:
-    return ret;
+    return 0;
 }
 
 
 int qemuMonitorJSONCloseFileHandle(qemuMonitor *mon,
                                    const char *fdname)
 {
-    int ret = -1;
     g_autoptr(virJSONValue) cmd = qemuMonitorJSONMakeCommand("closefd",
                                                              "s:fdname", fdname,
                                                              NULL);
@@ -3898,14 +3788,12 @@ int qemuMonitorJSONCloseFileHandle(qemuMonitor *mon,
         return -1;
 
     if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
-        goto cleanup;
+        return -1;
 
     if (qemuMonitorJSONCheckError(cmd, reply) < 0)
-        goto cleanup;
+        return -1;
 
-    ret = 0;
- cleanup:
-    return ret;
+    return 0;
 }
 
 
@@ -3955,7 +3843,6 @@ static int
 qemuMonitorJSONQueryRxFilterParse(virJSONValue *msg,
                                   virNetDevRxFilter **filter)
 {
-    int ret = -1;
     const char *tmp;
     virJSONValue *returnArray;
     virJSONValue *entry;
@@ -3966,21 +3853,21 @@ qemuMonitorJSONQueryRxFilterParse(virJSONValue *msg,
     g_autoptr(virNetDevRxFilter) fil = virNetDevRxFilterNew();
 
     if (!fil)
-        goto cleanup;
+        return -1;
 
     returnArray = virJSONValueObjectGetArray(msg, "return");
 
     if (!(entry = virJSONValueArrayGet(returnArray, 0))) {
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-                       _("query -rx-filter return data missing array element"));
-        goto cleanup;
+                       _("query-rx-filter return data missing array element"));
+        return -1;
     }
 
     if (!(tmp = virJSONValueObjectGetString(entry, "name"))) {
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                        _("Missing or invalid name "
                          "in query-rx-filter response"));
-        goto cleanup;
+        return -1;
     }
     fil->name = g_strdup(tmp);
     if ((!(tmp = virJSONValueObjectGetString(entry, "main-mac"))) ||
@@ -3988,21 +3875,21 @@ qemuMonitorJSONQueryRxFilterParse(virJSONValue *msg,
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                        _("Missing or invalid 'main-mac' "
                          "in query-rx-filter response"));
-        goto cleanup;
+        return -1;
     }
     if (virJSONValueObjectGetBoolean(entry, "promiscuous",
                                      &fil->promiscuous) < 0) {
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                        _("Missing or invalid 'promiscuous' "
                          "in query-rx-filter response"));
-        goto cleanup;
+        return -1;
     }
     if (virJSONValueObjectGetBoolean(entry, "broadcast-allowed",
                                      &fil->broadcastAllowed) < 0) {
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                        _("Missing or invalid 'broadcast-allowed' "
                          "in query-rx-filter response"));
-        goto cleanup;
+        return -1;
     }
 
     if ((!(tmp = virJSONValueObjectGetString(entry, "unicast"))) ||
@@ -4011,21 +3898,21 @@ qemuMonitorJSONQueryRxFilterParse(virJSONValue *msg,
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                        _("Missing or invalid 'unicast' "
                          "in query-rx-filter response"));
-        goto cleanup;
+        return -1;
     }
     if (virJSONValueObjectGetBoolean(entry, "unicast-overflow",
                                      &fil->unicast.overflow) < 0) {
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                        _("Missing or invalid 'unicast-overflow' "
                          "in query-rx-filter response"));
-        goto cleanup;
+        return -1;
     }
     if ((!(table = virJSONValueObjectGet(entry, "unicast-table"))) ||
         (!virJSONValueIsArray(table))) {
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                        _("Missing or invalid 'unicast-table' array "
                          "in query-rx-filter response"));
-        goto cleanup;
+        return -1;
     }
     nTable = virJSONValueArraySize(table);
     fil->unicast.table = g_new0(virMacAddr, nTable);
@@ -4035,13 +3922,13 @@ qemuMonitorJSONQueryRxFilterParse(virJSONValue *msg,
             virReportError(VIR_ERR_INTERNAL_ERROR,
                            _("Missing or invalid element %zu of 'unicast' "
                              "list in query-rx-filter response"), i);
-            goto cleanup;
+            return -1;
         }
         if (virMacAddrParse(tmp, &fil->unicast.table[i]) < 0) {
             virReportError(VIR_ERR_INTERNAL_ERROR,
                            _("invalid mac address '%s' in 'unicast-table' "
                              "array in query-rx-filter response"), tmp);
-            goto cleanup;
+            return -1;
         }
     }
     fil->unicast.nTable = nTable;
@@ -4052,21 +3939,21 @@ qemuMonitorJSONQueryRxFilterParse(virJSONValue *msg,
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                        _("Missing or invalid 'multicast' "
                          "in query-rx-filter response"));
-        goto cleanup;
+        return -1;
     }
     if (virJSONValueObjectGetBoolean(entry, "multicast-overflow",
                                      &fil->multicast.overflow) < 0) {
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                        _("Missing or invalid 'multicast-overflow' "
                          "in query-rx-filter response"));
-        goto cleanup;
+        return -1;
     }
     if ((!(table = virJSONValueObjectGet(entry, "multicast-table"))) ||
         (!virJSONValueIsArray(table))) {
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                        _("Missing or invalid 'multicast-table' array "
                          "in query-rx-filter response"));
-        goto cleanup;
+        return -1;
     }
     nTable = virJSONValueArraySize(table);
     fil->multicast.table = g_new0(virMacAddr, nTable);
@@ -4076,13 +3963,13 @@ qemuMonitorJSONQueryRxFilterParse(virJSONValue *msg,
             virReportError(VIR_ERR_INTERNAL_ERROR,
                            _("Missing or invalid element %zu of 'multicast' "
                              "list in query-rx-filter response"), i);
-            goto cleanup;
+            return -1;
         }
         if (virMacAddrParse(tmp, &fil->multicast.table[i]) < 0) {
             virReportError(VIR_ERR_INTERNAL_ERROR,
                            _("invalid mac address '%s' in 'multicast-table' "
                              "array in query-rx-filter response"), tmp);
-            goto cleanup;
+            return -1;
         }
     }
     fil->multicast.nTable = nTable;
@@ -4093,14 +3980,14 @@ qemuMonitorJSONQueryRxFilterParse(virJSONValue *msg,
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                        _("Missing or invalid 'vlan' "
                          "in query-rx-filter response"));
-        goto cleanup;
+        return -1;
     }
     if ((!(table = virJSONValueObjectGet(entry, "vlan-table"))) ||
         (!virJSONValueIsArray(table))) {
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                        _("Missing or invalid 'vlan-table' array "
                          "in query-rx-filter response"));
-        goto cleanup;
+        return -1;
     }
     nTable = virJSONValueArraySize(table);
     fil->vlan.table = g_new0(unsigned int, nTable);
@@ -4110,15 +3997,13 @@ qemuMonitorJSONQueryRxFilterParse(virJSONValue *msg,
             virReportError(VIR_ERR_INTERNAL_ERROR,
                            _("Missing or invalid element %zu of 'vlan-table' "
                              "array in query-rx-filter response"), i);
-            goto cleanup;
+            return -1;
         }
     }
     fil->vlan.nTable = nTable;
 
     *filter = g_steal_pointer(&fil);
-    ret = 0;
- cleanup:
-    return ret;
+    return 0;
 }
 
 
@@ -4126,27 +4011,24 @@ int
 qemuMonitorJSONQueryRxFilter(qemuMonitor *mon, const char *alias,
                              virNetDevRxFilter **filter)
 {
-    int ret = -1;
     g_autoptr(virJSONValue) cmd = qemuMonitorJSONMakeCommand("query-rx-filter",
                                                              "s:name", alias,
                                                              NULL);
     g_autoptr(virJSONValue) reply = NULL;
 
     if (!cmd)
-        goto cleanup;
+        return -1;
 
     if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
-        goto cleanup;
+        return -1;
 
     if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_ARRAY) < 0)
-        goto cleanup;
+        return -1;
 
     if (qemuMonitorJSONQueryRxFilterParse(reply, filter) < 0)
-        goto cleanup;
+        return -1;
 
-    ret = 0;
- cleanup:
-    return ret;
+    return 0;
 }
 
 
@@ -4233,7 +4115,6 @@ qemuMonitorJSONGetChardevInfo(qemuMonitor *mon,
                               GHashTable *info)
 
 {
-    int ret = -1;
     g_autoptr(virJSONValue) cmd = qemuMonitorJSONMakeCommand("query-chardev",
                                                              NULL);
     g_autoptr(virJSONValue) reply = NULL;
@@ -4242,21 +4123,18 @@ qemuMonitorJSONGetChardevInfo(qemuMonitor *mon,
         return -1;
 
     if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
-        goto cleanup;
+        return -1;
 
     if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_ARRAY) < 0)
-        goto cleanup;
+        return -1;
 
-    ret = qemuMonitorJSONExtractChardevInfo(reply, info);
- cleanup:
-    return ret;
+    return qemuMonitorJSONExtractChardevInfo(reply, info);
 }
 
 
 int qemuMonitorJSONDelDevice(qemuMonitor *mon,
                              const char *devalias)
 {
-    int ret = -1;
     g_autoptr(virJSONValue) cmd = NULL;
     g_autoptr(virJSONValue) reply = NULL;
 
@@ -4267,19 +4145,15 @@ int qemuMonitorJSONDelDevice(qemuMonitor *mon,
         return -1;
 
     if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
-        goto cleanup;
+        return -1;
 
-    if (qemuMonitorJSONHasError(reply, "DeviceNotFound")) {
-        ret = -2;
-        goto cleanup;
-    }
+    if (qemuMonitorJSONHasError(reply, "DeviceNotFound"))
+        return -2;
 
     if (qemuMonitorJSONCheckError(cmd, reply) < 0)
-        goto cleanup;
+        return -1;
 
-    ret = 0;
- cleanup:
-    return ret;
+    return 0;
 }
 
 
@@ -4425,7 +4299,6 @@ qemuMonitorJSONBlockdevMirror(qemuMonitor *mon,
 int
 qemuMonitorJSONTransaction(qemuMonitor *mon, virJSONValue **actions)
 {
-    int ret = -1;
     g_autoptr(virJSONValue) cmd = NULL;
     g_autoptr(virJSONValue) reply = NULL;
 
@@ -4433,17 +4306,15 @@ qemuMonitorJSONTransaction(qemuMonitor *mon, virJSONValue **actions)
                                      "a:actions", actions,
                                      NULL);
     if (!cmd)
-        goto cleanup;
+        return -1;
 
     if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
-        goto cleanup;
+        return -1;
 
     if (qemuMonitorJSONCheckError(cmd, reply) < 0)
-        goto cleanup;
+        return -1;
 
-    ret = 0;
- cleanup:
-    return ret;
+    return 0;
 }
 
 
@@ -4461,7 +4332,6 @@ qemuMonitorJSONBlockCommit(qemuMonitor *mon,
                            const char *backingName,
                            unsigned long long speed)
 {
-    int ret = -1;
     g_autoptr(virJSONValue) cmd = NULL;
     g_autoptr(virJSONValue) reply = NULL;
     virTristateBool autofinalize = VIR_TRISTATE_BOOL_ABSENT;
@@ -4488,14 +4358,12 @@ qemuMonitorJSONBlockCommit(qemuMonitor *mon,
         return -1;
 
     if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
-        goto cleanup;
+        return -1;
 
     if (qemuMonitorJSONCheckError(cmd, reply) < 0)
-        goto cleanup;
+        return -1;
 
-    ret = 0;
- cleanup:
-    return ret;
+    return 0;
 }
 
 
@@ -4538,7 +4406,6 @@ qemuMonitorJSONDiskNameLookup(qemuMonitor *mon,
                               virStorageSource *top,
                               virStorageSource *target)
 {
-    char *ret = NULL;
     g_autoptr(virJSONValue) devices = NULL;
     size_t i;
 
@@ -4552,28 +4419,27 @@ qemuMonitorJSONDiskNameLookup(qemuMonitor *mon,
         const char *thisdev;
 
         if (!(dev = qemuMonitorJSONGetBlockDev(devices, i)))
-            goto cleanup;
+            return NULL;
 
         if (!(thisdev = qemuMonitorJSONGetBlockDevDevice(dev)))
-            goto cleanup;
+            return NULL;
 
         if (STREQ(thisdev, device)) {
             if ((inserted = virJSONValueObjectGetObject(dev, "inserted")) &&
                 (image = virJSONValueObjectGetObject(inserted, "image"))) {
-                ret = qemuMonitorJSONDiskNameLookupOne(image, top, target);
+                return qemuMonitorJSONDiskNameLookupOne(image, top, target);
             }
-            break;
         }
     }
     /* Guarantee an error when returning NULL, but don't override a
      * more specific error if one was already generated.  */
-    if (!ret && virGetLastErrorCode() == VIR_ERR_OK)
+    if (virGetLastErrorCode() == VIR_ERR_OK) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        _("unable to find backing name for device %s"),
                        device);
+    }
 
- cleanup:
-    return ret;
+    return NULL;
 }
 
 
@@ -4583,26 +4449,21 @@ int qemuMonitorJSONArbitraryCommand(qemuMonitor *mon,
 {
     g_autoptr(virJSONValue) cmd = NULL;
     g_autoptr(virJSONValue) reply = NULL;
-    int ret = -1;
 
     if (!(cmd = virJSONValueFromString(cmd_str)))
-        goto cleanup;
+        return -1;
 
     if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
-        goto cleanup;
+        return -1;
 
     if (!(*reply_str = virJSONValueToString(reply, false)))
-        goto cleanup;
+        return -1;
 
-    ret = 0;
-
- cleanup:
-    return ret;
+    return 0;
 }
 
 int qemuMonitorJSONInjectNMI(qemuMonitor *mon)
 {
-    int ret = -1;
     g_autoptr(virJSONValue) cmd = NULL;
     g_autoptr(virJSONValue) reply = NULL;
 
@@ -4611,14 +4472,12 @@ int qemuMonitorJSONInjectNMI(qemuMonitor *mon)
         return -1;
 
     if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
-        goto cleanup;
+        return -1;
 
     if (qemuMonitorJSONCheckError(cmd, reply) < 0)
-        goto cleanup;
+        return -1;
 
-    ret = 0;
- cleanup:
-    return ret;
+    return 0;
 }
 
 int qemuMonitorJSONSendKey(qemuMonitor *mon,
@@ -4626,7 +4485,6 @@ int qemuMonitorJSONSendKey(qemuMonitor *mon,
                            unsigned int *keycodes,
                            unsigned int nkeycodes)
 {
-    int ret = -1;
     g_autoptr(virJSONValue) cmd = NULL;
     g_autoptr(virJSONValue) reply = NULL;
     g_autoptr(virJSONValue) keys = NULL;
@@ -4641,7 +4499,7 @@ int qemuMonitorJSONSendKey(qemuMonitor *mon,
         if (keycodes[i] > 0xffff) {
             virReportError(VIR_ERR_OPERATION_FAILED,
                            _("keycode %zu is invalid: 0x%X"), i, keycodes[i]);
-            goto cleanup;
+            return -1;
         }
 
         /* create single key object */
@@ -4649,14 +4507,14 @@ int qemuMonitorJSONSendKey(qemuMonitor *mon,
 
         /* Union KeyValue has two types, use the generic one */
         if (virJSONValueObjectAppendString(key, "type", "number") < 0)
-            goto cleanup;
+            return -1;
 
         /* with the keycode */
         if (virJSONValueObjectAppendNumberInt(key, "data", keycodes[i]) < 0)
-            goto cleanup;
+            return -1;
 
         if (virJSONValueArrayAppend(keys, &key) < 0)
-            goto cleanup;
+            return -1;
     }
 
     cmd = qemuMonitorJSONMakeCommand("send-key",
@@ -4664,17 +4522,15 @@ int qemuMonitorJSONSendKey(qemuMonitor *mon,
                                      "p:hold-time", holdtime,
                                      NULL);
     if (!cmd)
-        goto cleanup;
+        return -1;
 
     if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
-        goto cleanup;
+        return -1;
 
     if (qemuMonitorJSONCheckError(cmd, reply) < 0)
-        goto cleanup;
+        return -1;
 
-    ret = 0;
- cleanup:
-    return ret;
+    return 0;
 }
 
 int qemuMonitorJSONScreendump(qemuMonitor *mon,
@@ -4682,7 +4538,6 @@ int qemuMonitorJSONScreendump(qemuMonitor *mon,
                               unsigned int head,
                               const char *file)
 {
-    int ret = -1;
     g_autoptr(virJSONValue) cmd = NULL;
     g_autoptr(virJSONValue) reply = NULL;
 
@@ -4696,14 +4551,12 @@ int qemuMonitorJSONScreendump(qemuMonitor *mon,
         return -1;
 
     if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
-        goto cleanup;
+        return -1;
 
     if (qemuMonitorJSONCheckError(cmd, reply) < 0)
-        goto cleanup;
+        return -1;
 
-    ret = 0;
- cleanup:
-    return ret;
+    return 0;
 }
 
 
@@ -4841,7 +4694,6 @@ qemuMonitorJSONBlockStream(qemuMonitor *mon,
                            const char *backingName,
                            unsigned long long speed)
 {
-    int ret = -1;
     g_autoptr(virJSONValue) cmd = NULL;
     g_autoptr(virJSONValue) reply = NULL;
     virTristateBool autofinalize = VIR_TRISTATE_BOOL_ABSENT;
@@ -4865,15 +4717,12 @@ qemuMonitorJSONBlockStream(qemuMonitor *mon,
         return -1;
 
     if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
-        goto cleanup;
+        return -1;
 
     if (qemuMonitorJSONCheckError(cmd, reply) < 0)
-        goto cleanup;
+        return -1;
 
-    ret = 0;
-
- cleanup:
-    return ret;
+    return 0;
 }
 
 
@@ -4906,7 +4755,6 @@ qemuMonitorJSONBlockJobSetSpeed(qemuMonitor *mon,
                                 const char *jobname,
                                 unsigned long long speed)
 {
-    int ret = -1;
     g_autoptr(virJSONValue) cmd = NULL;
     g_autoptr(virJSONValue) reply = NULL;
 
@@ -4917,15 +4765,12 @@ qemuMonitorJSONBlockJobSetSpeed(qemuMonitor *mon,
         return -1;
 
     if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
-        goto cleanup;
+        return -1;
 
     if (qemuMonitorJSONBlockJobError(cmd, reply, jobname) < 0)
-        goto cleanup;
+        return -1;
 
-    ret = 0;
-
- cleanup:
-    return ret;
+    return 0;
 }
 
 
@@ -4933,7 +4778,6 @@ int
 qemuMonitorJSONDrivePivot(qemuMonitor *mon,
                           const char *jobname)
 {
-    int ret = -1;
     g_autoptr(virJSONValue) cmd = NULL;
     g_autoptr(virJSONValue) reply = NULL;
 
@@ -4944,14 +4788,12 @@ qemuMonitorJSONDrivePivot(qemuMonitor *mon,
         return -1;
 
     if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
-        goto cleanup;
+        return -1;
 
     if (qemuMonitorJSONBlockJobError(cmd, reply, jobname) < 0)
-        goto cleanup;
+        return -1;
 
-    ret = 0;
- cleanup:
-    return ret;
+    return 0;
 }
 
 
@@ -5004,7 +4846,6 @@ int qemuMonitorJSONOpenGraphics(qemuMonitor *mon,
                                 const char *fdname,
                                 bool skipauth)
 {
-    int ret = -1;
     g_autoptr(virJSONValue) cmd = NULL;
     g_autoptr(virJSONValue) reply = NULL;
 
@@ -5018,14 +4859,12 @@ int qemuMonitorJSONOpenGraphics(qemuMonitor *mon,
         return -1;
 
     if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
-        goto cleanup;
+        return -1;
 
     if (qemuMonitorJSONCheckError(cmd, reply) < 0)
-        goto cleanup;
+        return -1;
 
-    ret = 0;
- cleanup:
-    return ret;
+    return 0;
 }
 
 
@@ -5174,19 +5013,16 @@ int qemuMonitorJSONGetBlockIoThrottle(qemuMonitor *mon,
                                       const char *qdevid,
                                       virDomainBlockIoTuneInfo *reply)
 {
-    int ret = -1;
     g_autoptr(virJSONValue) devices = NULL;
 
     if (!(devices = qemuMonitorJSONQueryBlock(mon)))
         return -1;
 
-    ret = qemuMonitorJSONBlockIoThrottleInfo(devices, drivealias, qdevid, reply);
-    return ret;
+    return qemuMonitorJSONBlockIoThrottleInfo(devices, drivealias, qdevid, reply);
 }
 
 int qemuMonitorJSONSystemWakeup(qemuMonitor *mon)
 {
-    int ret = -1;
     g_autoptr(virJSONValue) cmd = NULL;
     g_autoptr(virJSONValue) reply = NULL;
 
@@ -5195,14 +5031,12 @@ int qemuMonitorJSONSystemWakeup(qemuMonitor *mon)
         return -1;
 
     if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
-        goto cleanup;
+        return -1;
 
     if (qemuMonitorJSONCheckError(cmd, reply) < 0)
-        goto cleanup;
+        return -1;
 
-    ret = 0;
- cleanup:
-    return ret;
+    return 0;
 }
 
 int qemuMonitorJSONGetVersion(qemuMonitor *mon,
@@ -5211,7 +5045,6 @@ int qemuMonitorJSONGetVersion(qemuMonitor *mon,
                               int *micro,
                               char **package)
 {
-    int ret = -1;
     g_autoptr(virJSONValue) cmd = NULL;
     g_autoptr(virJSONValue) reply = NULL;
     virJSONValue *data;
@@ -5225,33 +5058,33 @@ int qemuMonitorJSONGetVersion(qemuMonitor *mon,
         return -1;
 
     if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
-        goto cleanup;
+        return -1;
 
     if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_OBJECT) < 0)
-        goto cleanup;
+        return -1;
 
     data = virJSONValueObjectGetObject(reply, "return");
 
     if (!(qemu = virJSONValueObjectGetObject(data, "qemu"))) {
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                        _("query-version reply was missing 'qemu' data"));
-        goto cleanup;
+        return -1;
     }
 
     if (virJSONValueObjectGetNumberInt(qemu, "major", major) < 0) {
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                        _("query-version reply was missing 'major' version"));
-        goto cleanup;
+        return -1;
     }
     if (virJSONValueObjectGetNumberInt(qemu, "minor", minor) < 0) {
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                        _("query-version reply was missing 'minor' version"));
-        goto cleanup;
+        return -1;
     }
     if (virJSONValueObjectGetNumberInt(qemu, "micro", micro) < 0) {
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                        _("query-version reply was missing 'micro' version"));
-        goto cleanup;
+        return -1;
     }
 
     if (package) {
@@ -5259,15 +5092,12 @@ int qemuMonitorJSONGetVersion(qemuMonitor *mon,
         if (!(tmp = virJSONValueObjectGetString(data, "package"))) {
             virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                            _("query-version reply was missing 'package' version"));
-            goto cleanup;
+            return -1;
         }
         *package = g_strdup(tmp);
     }
 
-    ret = 0;
-
- cleanup:
-    return ret;
+    return 0;
 }
 
 
@@ -5593,7 +5423,6 @@ qemuMonitorJSONParseCPUModel(const char *cpu_name,
                              qemuMonitorCPUModelInfo **model_info)
 {
     g_autoptr(qemuMonitorCPUModelInfo) machine_model = NULL;
-    int ret = -1;
 
     machine_model = g_new0(qemuMonitorCPUModelInfo, 1);
     machine_model->name = g_strdup(cpu_name);
@@ -5606,14 +5435,11 @@ qemuMonitorJSONParseCPUModel(const char *cpu_name,
         if (virJSONValueObjectForeachKeyValue(cpu_props,
                                               qemuMonitorJSONParseCPUModelProperty,
                                               machine_model) < 0)
-            goto cleanup;
+            return -1;
     }
 
     *model_info = g_steal_pointer(&machine_model);
-    ret = 0;
-
- cleanup:
-    return ret;
+    return 0;
 }
 
 
@@ -5876,7 +5702,6 @@ int qemuMonitorJSONGetKVMState(qemuMonitor *mon,
                                bool *enabled,
                                bool *present)
 {
-    int ret = -1;
     g_autoptr(virJSONValue) cmd = NULL;
     g_autoptr(virJSONValue) reply = NULL;
     virJSONValue *data = NULL;
@@ -5888,10 +5713,10 @@ int qemuMonitorJSONGetKVMState(qemuMonitor *mon,
         return -1;
 
     if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
-        goto cleanup;
+        return -1;
 
     if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_OBJECT) < 0)
-        goto cleanup;
+        return -1;
 
     data = virJSONValueObjectGetObject(reply, "return");
 
@@ -5899,13 +5724,10 @@ int qemuMonitorJSONGetKVMState(qemuMonitor *mon,
         virJSONValueObjectGetBoolean(data, "present", present) < 0) {
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                        _("query-kvm replied unexpected data"));
-        goto cleanup;
+        return -1;
     }
 
-    ret = 0;
-
- cleanup:
-    return ret;
+    return 0;
 }
 
 
@@ -6053,10 +5875,10 @@ int qemuMonitorJSONGetObjectProperty(qemuMonitor *mon,
         return -1;
 
     if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
-        goto cleanup;
+        return -1;
 
     if (qemuMonitorJSONCheckError(cmd, reply) < 0)
-        goto cleanup;
+        return -1;
 
     data = virJSONValueObjectGet(reply, "return");
 
@@ -6093,19 +5915,17 @@ int qemuMonitorJSONGetObjectProperty(qemuMonitor *mon,
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        _("qom-get invalid object property type %d"),
                        prop->type);
-        goto cleanup;
+        return -1;
         break;
     }
 
     if (ret == -1) {
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                        _("qom-get reply was missing return data"));
-        goto cleanup;
+        return -1;
     }
 
-    ret = 0;
- cleanup:
-    return ret;
+    return 0;
 }
 
 
@@ -6150,7 +5970,6 @@ int qemuMonitorJSONSetObjectProperty(qemuMonitor *mon,
                                      const char *property,
                                      qemuMonitorJSONObjectProperty *prop)
 {
-    int ret = -1;
     g_autoptr(virJSONValue) cmd = NULL;
     g_autoptr(virJSONValue) reply = NULL;
 
@@ -6183,21 +6002,19 @@ int qemuMonitorJSONSetObjectProperty(qemuMonitor *mon,
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        _("qom-set invalid object property type %d"),
                        prop->type);
-        goto cleanup;
+        return -1;
 
     }
     if (!cmd)
         return -1;
 
     if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
-        goto cleanup;
+        return -1;
 
     if (qemuMonitorJSONCheckError(cmd, reply) < 0)
-        goto cleanup;
+        return -1;
 
-    ret = 0;
- cleanup:
-    return ret;
+    return 0;
 }
 #undef MAKE_SET_CMD
 
@@ -6326,7 +6143,6 @@ qemuMonitorJSONGetObjectProps(qemuMonitor *mon,
 char *
 qemuMonitorJSONGetTargetArch(qemuMonitor *mon)
 {
-    char *ret = NULL;
     const char *arch;
     g_autoptr(virJSONValue) cmd = NULL;
     g_autoptr(virJSONValue) reply = NULL;
@@ -6336,23 +6152,20 @@ qemuMonitorJSONGetTargetArch(qemuMonitor *mon)
         return NULL;
 
     if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
-        goto cleanup;
+        return NULL;
 
     if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_OBJECT) < 0)
-        goto cleanup;
+        return NULL;
 
     data = virJSONValueObjectGetObject(reply, "return");
 
     if (!(arch = virJSONValueObjectGetString(data, "arch"))) {
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                        _("query-target reply was missing arch data"));
-        goto cleanup;
+        return NULL;
     }
 
-    ret = g_strdup(arch);
-
- cleanup:
-    return ret;
+    return g_strdup(arch);
 }
 
 
@@ -6449,7 +6262,6 @@ int
 qemuMonitorJSONGetGICCapabilities(qemuMonitor *mon,
                                   virGICCapability **capabilities)
 {
-    int ret = -1;
     g_autoptr(virJSONValue) cmd = NULL;
     g_autoptr(virJSONValue) reply = NULL;
     virJSONValue *caps;
@@ -6464,27 +6276,23 @@ qemuMonitorJSONGetGICCapabilities(qemuMonitor *mon,
         return -1;
 
     if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
-        goto cleanup;
+        return -1;
 
     /* If the 'query-gic-capabilities' QMP command was not available
      * we simply successfully return zero capabilities.
      * This is the case for QEMU <2.6 and all non-ARM architectures */
-    if (qemuMonitorJSONHasError(reply, "CommandNotFound")) {
-        ret = 0;
-        goto cleanup;
-    }
+    if (qemuMonitorJSONHasError(reply, "CommandNotFound"))
+        return 0;
 
     if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_ARRAY) < 0)
-        goto cleanup;
+        return -1;
 
     caps = virJSONValueObjectGetArray(reply, "return");
     n = virJSONValueArraySize(caps);
 
     /* If the returned array was empty we have to return successfully */
-    if (n == 0) {
-        ret = 0;
-        goto cleanup;
-    }
+    if (n == 0)
+        return 0;
 
     list = g_new0(virGICCapability, n);
 
@@ -6497,25 +6305,25 @@ qemuMonitorJSONGetGICCapabilities(qemuMonitor *mon,
         if (!cap || virJSONValueGetType(cap) != VIR_JSON_TYPE_OBJECT) {
             virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                            _("missing entry in GIC capabilities list"));
-            goto cleanup;
+            return -1;
         }
 
         if (virJSONValueObjectGetNumberInt(cap, "version", &version) < 0) {
             virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                            _("missing GIC version"));
-            goto cleanup;
+            return -1;
         }
 
         if (virJSONValueObjectGetBoolean(cap, "kernel", &kernel) < 0) {
             virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                            _("missing in-kernel GIC information"));
-            goto cleanup;
+            return -1;
         }
 
         if (virJSONValueObjectGetBoolean(cap, "emulated", &emulated) < 0) {
             virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                            _("missing emulated GIC information"));
-            goto cleanup;
+            return -1;
         }
 
         list[i].version = version;
@@ -6525,11 +6333,8 @@ qemuMonitorJSONGetGICCapabilities(qemuMonitor *mon,
             list[i].implementation |= VIR_GIC_IMPLEMENTATION_EMULATED;
     }
 
-    ret = n;
     *capabilities = g_steal_pointer(&list);
-
- cleanup:
-    return ret;
+    return n;
 }
 
 
@@ -6551,7 +6356,6 @@ int
 qemuMonitorJSONGetSEVCapabilities(qemuMonitor *mon,
                                   virSEVCapability **capabilities)
 {
-    int ret = -1;
     g_autoptr(virJSONValue) cmd = NULL;
     g_autoptr(virJSONValue) reply = NULL;
     virJSONValue *caps;
@@ -6568,16 +6372,14 @@ qemuMonitorJSONGetSEVCapabilities(qemuMonitor *mon,
         return -1;
 
     if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
-        goto cleanup;
+        return -1;
 
     /* QEMU has only compiled-in support of SEV */
-    if (qemuMonitorJSONHasError(reply, "GenericError")) {
-        ret = 0;
-        goto cleanup;
-    }
+    if (qemuMonitorJSONHasError(reply, "GenericError"))
+        return 0;
 
     if (qemuMonitorJSONCheckError(cmd, reply) < 0)
-        goto cleanup;
+        return -1;
 
     caps = virJSONValueObjectGetObject(reply, "return");
 
@@ -6585,7 +6387,7 @@ qemuMonitorJSONGetSEVCapabilities(qemuMonitor *mon,
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                        _("query-sev-capabilities reply was missing"
                          " 'cbitpos' field"));
-        goto cleanup;
+        return -1;
     }
 
     if (virJSONValueObjectGetNumberUint(caps, "reduced-phys-bits",
@@ -6593,21 +6395,21 @@ qemuMonitorJSONGetSEVCapabilities(qemuMonitor *mon,
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                        _("query-sev-capabilities reply was missing"
                          " 'reduced-phys-bits' field"));
-        goto cleanup;
+        return -1;
     }
 
     if (!(pdh = virJSONValueObjectGetString(caps, "pdh"))) {
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                        _("query-sev-capabilities reply was missing"
                          " 'pdh' field"));
-        goto cleanup;
+        return -1;
     }
 
     if (!(cert_chain = virJSONValueObjectGetString(caps, "cert-chain"))) {
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                        _("query-sev-capabilities reply was missing"
                          " 'cert-chain' field"));
-        goto cleanup;
+        return -1;
     }
 
     capability = g_new0(virSEVCapability, 1);
@@ -6619,9 +6421,7 @@ qemuMonitorJSONGetSEVCapabilities(qemuMonitor *mon,
     capability->cbitpos = cbitpos;
     capability->reduced_phys_bits = reduced_phys_bits;
     *capabilities = g_steal_pointer(&capability);
-    ret = 1;
- cleanup:
-    return ret;
+    return 1;
 }
 
 static virJSONValue *
@@ -6663,7 +6463,6 @@ qemuMonitorJSONNBDServerStart(qemuMonitor *mon,
                               const virStorageNetHostDef *server,
                               const char *tls_alias)
 {
-    int ret = -1;
     g_autoptr(virJSONValue) cmd = NULL;
     g_autoptr(virJSONValue) reply = NULL;
     g_autoptr(virJSONValue) addr = NULL;
@@ -6681,27 +6480,24 @@ qemuMonitorJSONNBDServerStart(qemuMonitor *mon,
     case VIR_STORAGE_NET_HOST_TRANS_LAST:
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                        _("invalid server address"));
-        goto cleanup;
+        return -1;
     }
     if (!addr)
-        goto cleanup;
+        return -1;
 
     if (!(cmd = qemuMonitorJSONMakeCommand("nbd-server-start",
                                            "a:addr", &addr,
                                            "S:tls-creds", tls_alias,
                                            NULL)))
-        goto cleanup;
+        return -1;
 
     if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
-        goto cleanup;
+        return -1;
 
     if (qemuMonitorJSONCheckError(cmd, reply) < 0)
-        goto cleanup;
+        return -1;
 
-    ret = 0;
-
- cleanup:
-    return ret;
+    return 0;
 }
 
 int
@@ -6711,7 +6507,6 @@ qemuMonitorJSONNBDServerAdd(qemuMonitor *mon,
                             bool writable,
                             const char *bitmap)
 {
-    int ret = -1;
     g_autoptr(virJSONValue) cmd = NULL;
     g_autoptr(virJSONValue) reply = NULL;
 
@@ -6722,39 +6517,34 @@ qemuMonitorJSONNBDServerAdd(qemuMonitor *mon,
                                            "b:writable", writable,
                                            "S:bitmap", bitmap,
                                            NULL)))
-        return ret;
+        return -1;
 
     if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
-        goto cleanup;
+        return -1;
 
     if (qemuMonitorJSONCheckError(cmd, reply) < 0)
-        goto cleanup;
+        return -1;
 
-    ret = 0;
- cleanup:
-    return ret;
+    return 0;
 }
 
 int
 qemuMonitorJSONNBDServerStop(qemuMonitor *mon)
 {
-    int ret = -1;
     g_autoptr(virJSONValue) cmd = NULL;
     g_autoptr(virJSONValue) reply = NULL;
 
     if (!(cmd = qemuMonitorJSONMakeCommand("nbd-server-stop",
                                            NULL)))
-        return ret;
+        return -1;
 
     if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
-        goto cleanup;
+        return -1;
 
     if (qemuMonitorJSONCheckError(cmd, reply) < 0)
-        goto cleanup;
+        return -1;
 
-    ret = 0;
- cleanup:
-    return ret;
+    return 0;
 }
 
 
@@ -6833,7 +6623,6 @@ static virJSONValue *
 qemuMonitorJSONAttachCharDevCommand(const char *chrID,
                                     const virDomainChrSourceDef *chr)
 {
-    virJSONValue *ret = NULL;
     g_autoptr(virJSONValue) backend = virJSONValueNewObject();
     g_autoptr(virJSONValue) data = virJSONValueNewObject();
     g_autoptr(virJSONValue) addr = NULL;
@@ -6859,18 +6648,18 @@ qemuMonitorJSONAttachCharDevCommand(const char *chrID,
     case VIR_DOMAIN_CHR_TYPE_FILE:
         backend_type = "file";
         if (virJSONValueObjectAppendString(data, "out", chr->data.file.path) < 0)
-            goto cleanup;
+            return NULL;
         if (virJSONValueObjectAdd(data,
                                   "T:append", chr->data.file.append,
                                   NULL) < 0)
-            goto cleanup;
+            return NULL;
         break;
 
     case VIR_DOMAIN_CHR_TYPE_DEV:
         backend_type = STRPREFIX(chrID, "parallel") ? "parallel" : "serial";
         if (virJSONValueObjectAppendString(data, "device",
                                            chr->data.file.path) < 0)
-            goto cleanup;
+            return NULL;
         break;
 
     case VIR_DOMAIN_CHR_TYPE_TCP:
@@ -6879,27 +6668,27 @@ qemuMonitorJSONAttachCharDevCommand(const char *chrID,
                                                      chr->data.tcp.service);
         if (!addr ||
             virJSONValueObjectAppend(data, "addr", &addr) < 0)
-            goto cleanup;
+            return NULL;
 
         telnet = chr->data.tcp.protocol == VIR_DOMAIN_CHR_TCP_PROTOCOL_TELNET;
 
         if (chr->data.tcp.listen &&
             virJSONValueObjectAppendBoolean(data, "wait", false) < 0)
-            goto cleanup;
+            return NULL;
 
         if (virJSONValueObjectAppendBoolean(data, "telnet", telnet) < 0 ||
             virJSONValueObjectAppendBoolean(data, "server", chr->data.tcp.listen) < 0)
-            goto cleanup;
+            return NULL;
         if (chr->data.tcp.tlscreds) {
             if (!(tlsalias = qemuAliasTLSObjFromSrcAlias(chrID)))
-                goto cleanup;
+                return NULL;
 
             if (virJSONValueObjectAppendString(data, "tls-creds", tlsalias) < 0)
-                goto cleanup;
+                return NULL;
         }
 
         if (qemuMonitorJSONBuildChrChardevReconnect(data, &chr->data.tcp.reconnect) < 0)
-            goto cleanup;
+            return NULL;
         break;
 
     case VIR_DOMAIN_CHR_TYPE_UDP:
@@ -6911,7 +6700,7 @@ qemuMonitorJSONAttachCharDevCommand(const char *chrID,
                                                      chr->data.udp.connectService);
         if (!addr ||
             virJSONValueObjectAppend(data, "remote", &addr) < 0)
-            goto cleanup;
+            return NULL;
 
         host = chr->data.udp.bindHost;
         port = chr->data.udp.bindService;
@@ -6923,7 +6712,7 @@ qemuMonitorJSONAttachCharDevCommand(const char *chrID,
             addr = qemuMonitorJSONBuildInetSocketAddress(host, port);
             if (!addr ||
                 virJSONValueObjectAppend(data, "local", &addr) < 0)
-                goto cleanup;
+                return NULL;
         }
         break;
 
@@ -6933,17 +6722,17 @@ qemuMonitorJSONAttachCharDevCommand(const char *chrID,
 
         if (!addr ||
             virJSONValueObjectAppend(data, "addr", &addr) < 0)
-            goto cleanup;
+            return NULL;
 
         if (chr->data.nix.listen &&
             virJSONValueObjectAppendBoolean(data, "wait", false) < 0)
-            goto cleanup;
+            return NULL;
 
         if (virJSONValueObjectAppendBoolean(data, "server", chr->data.nix.listen) < 0)
-            goto cleanup;
+            return NULL;
 
         if (qemuMonitorJSONBuildChrChardevReconnect(data, &chr->data.nix.reconnect) < 0)
-            goto cleanup;
+            return NULL;
         break;
 
     case VIR_DOMAIN_CHR_TYPE_SPICEVMC:
@@ -6951,7 +6740,7 @@ qemuMonitorJSONAttachCharDevCommand(const char *chrID,
 
         if (virJSONValueObjectAppendString(data, "type",
                                            virDomainChrSpicevmcTypeToString(chr->data.spicevmc)) < 0)
-            goto cleanup;
+            return NULL;
         break;
 
     case VIR_DOMAIN_CHR_TYPE_SPICEPORT:
@@ -6968,7 +6757,7 @@ qemuMonitorJSONAttachCharDevCommand(const char *chrID,
                            _("Hotplug unsupported for char device type '%d'"),
                            chr->type);
         }
-        goto cleanup;
+        return NULL;
     }
 
     if (chr->logfile &&
@@ -6976,20 +6765,16 @@ qemuMonitorJSONAttachCharDevCommand(const char *chrID,
                               "s:logfile", chr->logfile,
                               "T:logappend", chr->logappend,
                               NULL) < 0)
-        goto cleanup;
+        return NULL;
 
     if (virJSONValueObjectAppendString(backend, "type", backend_type) < 0 ||
         virJSONValueObjectAppend(backend, "data", &data) < 0)
-        goto cleanup;
+        return NULL;
 
-    if (!(ret = qemuMonitorJSONMakeCommand("chardev-add",
-                                           "s:id", chrID,
-                                           "a:backend", &backend,
-                                           NULL)))
-        goto cleanup;
-
- cleanup:
-    return ret;
+    return qemuMonitorJSONMakeCommand("chardev-add",
+                                      "s:id", chrID,
+                                      "a:backend", &backend,
+                                      NULL);
 }
 
 
@@ -6998,22 +6783,21 @@ qemuMonitorJSONAttachCharDev(qemuMonitor *mon,
                              const char *chrID,
                              virDomainChrSourceDef *chr)
 {
-    int ret = -1;
     g_autoptr(virJSONValue) cmd = NULL;
     g_autoptr(virJSONValue) reply = NULL;
 
     if (!(cmd = qemuMonitorJSONAttachCharDevCommand(chrID, chr)))
-        return ret;
+        return -1;
 
     if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
-        goto cleanup;
+        return -1;
 
     if (chr->type == VIR_DOMAIN_CHR_TYPE_PTY) {
         if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_OBJECT) < 0)
-            goto cleanup;
+            return -1;
     } else {
         if (qemuMonitorJSONCheckError(cmd, reply) < 0)
-            goto cleanup;
+            return -1;
     }
 
     if (chr->type == VIR_DOMAIN_CHR_TYPE_PTY) {
@@ -7023,40 +6807,34 @@ qemuMonitorJSONAttachCharDev(qemuMonitor *mon,
         if (!(path = virJSONValueObjectGetString(data, "pty"))) {
             virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                            _("chardev-add reply was missing pty path"));
-            goto cleanup;
+            return -1;
         }
 
         chr->data.file.path = g_strdup(path);
     }
 
-    ret = 0;
-
- cleanup:
-    return ret;
+    return 0;
 }
 
 int
 qemuMonitorJSONDetachCharDev(qemuMonitor *mon,
                              const char *chrID)
 {
-    int ret = -1;
     g_autoptr(virJSONValue) cmd = NULL;
     g_autoptr(virJSONValue) reply = NULL;
 
     if (!(cmd = qemuMonitorJSONMakeCommand("chardev-remove",
                                            "s:id", chrID,
                                            NULL)))
-        return ret;
+        return -1;
 
     if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
-        goto cleanup;
+        return -1;
 
     if (qemuMonitorJSONCheckError(cmd, reply) < 0)
-        goto cleanup;
+        return -1;
 
-    ret = 0;
- cleanup:
-    return ret;
+    return 0;
 }
 
 
@@ -7177,28 +6955,24 @@ qemuMonitorJSONGetCPUx86Data(qemuMonitor *mon,
     g_autoptr(virJSONValue) cmd = NULL;
     g_autoptr(virJSONValue) reply = NULL;
     virJSONValue *data;
-    int ret = -1;
 
     if (!(cmd = qemuMonitorJSONMakeCommand("qom-get",
                                            "s:path", QOM_CPU_PATH,
                                            "s:property", property,
                                            NULL)))
-        goto cleanup;
+        return -1;
 
     if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
-        goto cleanup;
+        return -1;
 
     if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_ARRAY) < 0)
-        goto cleanup;
+        return -1;
 
     data = virJSONValueObjectGetArray(reply, "return");
     if (!(*cpudata = qemuMonitorJSONParseCPUx86Features(data)))
-        goto cleanup;
+        return -1;
 
-    ret = 0;
-
- cleanup:
-    return ret;
+    return 0;
 }
 
 
@@ -7214,27 +6988,25 @@ qemuMonitorJSONCheckCPUx86(qemuMonitor *mon)
     virJSONValue *data;
     size_t i;
     size_t n;
-    int ret = -1;
 
     if (!(cmd = qemuMonitorJSONMakeCommand("qom-list",
                                            "s:path", QOM_CPU_PATH,
                                            NULL)))
-        goto cleanup;
+        return -1;
 
     if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
-        goto cleanup;
+        return -1;
 
     if ((data = virJSONValueObjectGet(reply, "error"))) {
         const char *klass = virJSONValueObjectGetString(data, "class");
         if (STREQ_NULLABLE(klass, "DeviceNotFound") ||
             STREQ_NULLABLE(klass, "CommandNotFound")) {
-            ret = 0;
-            goto cleanup;
+            return 0;
         }
     }
 
     if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_ARRAY) < 0)
-        goto cleanup;
+        return -1;
 
     data = virJSONValueObjectGetArray(reply, "return");
     n = virJSONValueArraySize(data);
@@ -7243,16 +7015,10 @@ qemuMonitorJSONCheckCPUx86(qemuMonitor *mon)
         virJSONValue *element = virJSONValueArrayGet(data, i);
         if (STREQ_NULLABLE(virJSONValueObjectGetString(element, "name"),
                            "feature-words"))
-            break;
+            return 1;
     }
 
-    if (i == n)
-        ret = 0;
-    else
-        ret = 1;
-
- cleanup:
-    return ret;
+    return 0;
 }
 
 
@@ -7408,50 +7174,43 @@ qemuMonitorJSONGetGuestCPU(qemuMonitor *mon,
 {
     g_autoptr(virCPUData) cpuEnabled = NULL;
     g_autoptr(virCPUData) cpuDisabled = NULL;
-    int ret = -1;
 
     if (!(cpuEnabled = virCPUDataNew(arch)) ||
         !(cpuDisabled = virCPUDataNew(arch)))
-        goto cleanup;
+        return -1;
 
     if (qemuMonitorJSONGetCPUData(mon, translate, opaque, cpuEnabled) < 0)
-        goto cleanup;
+        return -1;
 
     if (disabled &&
         qemuMonitorJSONGetCPUDataDisabled(mon, translate, opaque, cpuDisabled) < 0)
-        goto cleanup;
+        return -1;
 
     *enabled = g_steal_pointer(&cpuEnabled);
     if (disabled)
         *disabled = g_steal_pointer(&cpuDisabled);
 
-    ret = 0;
-
- cleanup:
-    return ret;
+    return 0;
 }
 
 
 int
 qemuMonitorJSONRTCResetReinjection(qemuMonitor *mon)
 {
-    int ret = -1;
     g_autoptr(virJSONValue) cmd = NULL;
     g_autoptr(virJSONValue) reply = NULL;
 
     if (!(cmd = qemuMonitorJSONMakeCommand("rtc-reset-reinjection",
                                            NULL)))
-        return ret;
+        return -1;
 
     if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
-        goto cleanup;
+        return -1;
 
     if (qemuMonitorJSONCheckError(cmd, reply) < 0)
-        goto cleanup;
+        return -1;
 
-    ret = 0;
- cleanup:
-    return ret;
+    return 0;
 }
 
 /**
@@ -7558,7 +7317,6 @@ int
 qemuMonitorJSONSetIOThread(qemuMonitor *mon,
                            qemuMonitorIOThreadInfo *iothreadInfo)
 {
-    int ret = -1;
     g_autofree char *path = NULL;
     qemuMonitorJSONObjectProperty prop;
 
@@ -7570,7 +7328,7 @@ qemuMonitorJSONSetIOThread(qemuMonitor *mon,
         prop.type = QEMU_MONITOR_OBJECT_PROPERTY_INT; \
         prop.val.iv = iothreadInfo->propVal; \
         if (qemuMonitorJSONSetObjectProperty(mon, path, propName, &prop) < 0) \
-            goto cleanup; \
+            return -1; \
     }
 
     VIR_IOTHREAD_SET_PROP("poll-max-ns", poll_max_ns);
@@ -7579,10 +7337,7 @@ qemuMonitorJSONSetIOThread(qemuMonitor *mon,
 
 #undef VIR_IOTHREAD_SET_PROP
 
-    ret = 0;
-
- cleanup:
-    return ret;
+    return 0;
 }
 
 
@@ -7590,7 +7345,6 @@ int
 qemuMonitorJSONGetMemoryDeviceInfo(qemuMonitor *mon,
                                    GHashTable *info)
 {
-    int ret = -1;
     g_autoptr(virJSONValue) cmd = NULL;
     g_autoptr(virJSONValue) reply = NULL;
     virJSONValue *data = NULL;
@@ -7600,10 +7354,10 @@ qemuMonitorJSONGetMemoryDeviceInfo(qemuMonitor *mon,
         return -1;
 
     if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
-        goto cleanup;
+        return -1;
 
     if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_ARRAY) < 0)
-        goto cleanup;
+        return -1;
 
     data = virJSONValueObjectGetArray(reply, "return");
 
@@ -7618,14 +7372,14 @@ qemuMonitorJSONGetMemoryDeviceInfo(qemuMonitor *mon,
             virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                            _("query-memory-devices reply data doesn't contain "
                              "enum type discriminator"));
-            goto cleanup;
+            return -1;
         }
 
         if (!(dimminfo = virJSONValueObjectGetObject(elem, "data"))) {
             virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                            _("query-memory-devices reply data doesn't "
                              "contain enum data"));
-            goto cleanup;
+            return -1;
         }
 
         /* While 'id' attribute is marked as optional in QEMU's QAPI
@@ -7634,7 +7388,7 @@ qemuMonitorJSONGetMemoryDeviceInfo(qemuMonitor *mon,
         if (!(devalias = virJSONValueObjectGetString(dimminfo, "id"))) {
             virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                            _("dimm memory info data is missing 'id'"));
-            goto cleanup;
+            return -1;
         }
 
         meminfo = g_new0(qemuMonitorMemoryDeviceInfo, 1);
@@ -7645,21 +7399,21 @@ qemuMonitorJSONGetMemoryDeviceInfo(qemuMonitor *mon,
                                                  &meminfo->address) < 0) {
                 virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                                _("malformed/missing addr in dimm memory info"));
-                goto cleanup;
+                return -1;
             }
 
             if (virJSONValueObjectGetNumberUint(dimminfo, "slot",
                                                 &meminfo->slot) < 0) {
                 virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                                _("malformed/missing slot in dimm memory info"));
-                goto cleanup;
+                return -1;
             }
 
             if (virJSONValueObjectGetBoolean(dimminfo, "hotplugged",
                                              &meminfo->hotplugged) < 0) {
                 virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                                _("malformed/missing hotplugged in dimm memory info"));
-                goto cleanup;
+                return -1;
 
             }
 
@@ -7667,7 +7421,7 @@ qemuMonitorJSONGetMemoryDeviceInfo(qemuMonitor *mon,
                                              &meminfo->hotpluggable) < 0) {
                 virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                                _("malformed/missing hotpluggable in dimm memory info"));
-                goto cleanup;
+                return -1;
 
             }
 
@@ -7676,7 +7430,7 @@ qemuMonitorJSONGetMemoryDeviceInfo(qemuMonitor *mon,
                                                  &meminfo->size) < 0) {
                 virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                                _("malformed/missing size in virtio memory info"));
-                goto cleanup;
+                return -1;
             }
         } else {
             /* type not handled yet */
@@ -7684,15 +7438,12 @@ qemuMonitorJSONGetMemoryDeviceInfo(qemuMonitor *mon,
         }
 
         if (virHashAddEntry(info, devalias, meminfo) < 0)
-            goto cleanup;
+            return -1;
 
         meminfo = NULL;
     }
 
-    ret = 0;
-
- cleanup:
-    return ret;
+    return 0;
 }
 
 
@@ -7855,7 +7606,6 @@ qemuMonitorJSONMigrateIncoming(qemuMonitor *mon,
 int
 qemuMonitorJSONMigrateStartPostCopy(qemuMonitor *mon)
 {
-    int ret = -1;
     g_autoptr(virJSONValue) cmd = NULL;
     g_autoptr(virJSONValue) reply = NULL;
 
@@ -7863,12 +7613,9 @@ qemuMonitorJSONMigrateStartPostCopy(qemuMonitor *mon)
         return -1;
 
     if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
-        goto cleanup;
+        return -1;
 
-    ret = qemuMonitorJSONCheckError(cmd, reply);
-
- cleanup:
-    return ret;
+    return qemuMonitorJSONCheckError(cmd, reply);
 }
 
 
@@ -7877,7 +7624,6 @@ qemuMonitorJSONMigrateContinue(qemuMonitor *mon,
                                qemuMonitorMigrationStatus status)
 {
     const char *statusStr = qemuMonitorMigrationStatusTypeToString(status);
-    int ret = -1;
     g_autoptr(virJSONValue) cmd = NULL;
     g_autoptr(virJSONValue) reply = NULL;
 
@@ -7887,12 +7633,9 @@ qemuMonitorJSONMigrateContinue(qemuMonitor *mon,
         return -1;
 
     if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
-        goto cleanup;
+        return -1;
 
-    ret = qemuMonitorJSONCheckError(cmd, reply);
-
- cleanup:
-    return ret;
+    return qemuMonitorJSONCheckError(cmd, reply);
 }
 
 
@@ -7900,7 +7643,6 @@ int
 qemuMonitorJSONGetRTCTime(qemuMonitor *mon,
                           struct tm *tm)
 {
-    int ret = -1;
     g_autoptr(virJSONValue) cmd = NULL;
     g_autoptr(virJSONValue) reply = NULL;
     virJSONValue *data;
@@ -7912,10 +7654,10 @@ qemuMonitorJSONGetRTCTime(qemuMonitor *mon,
         return -1;
 
     if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
-        goto cleanup;
+        return -1;
 
     if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_OBJECT) < 0)
-        goto cleanup;
+        return -1;
 
     data = virJSONValueObjectGet(reply, "return");
 
@@ -7927,12 +7669,10 @@ qemuMonitorJSONGetRTCTime(qemuMonitor *mon,
         virJSONValueObjectGetNumberInt(data, "tm_sec", &tm->tm_sec) < 0) {
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                        _("qemu returned malformed time"));
-        goto cleanup;
+        return -1;
     }
 
-    ret = 0;
- cleanup:
-    return ret;
+    return 0;
 }
 
 
@@ -8108,21 +7848,17 @@ qemuMonitorJSONQueryQMPSchema(qemuMonitor *mon)
 {
     g_autoptr(virJSONValue) cmd = NULL;
     g_autoptr(virJSONValue) reply = NULL;
-    virJSONValue *ret = NULL;
 
     if (!(cmd = qemuMonitorJSONMakeCommand("query-qmp-schema", NULL)))
         return NULL;
 
     if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
-        goto cleanup;
+        return NULL;
 
     if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_ARRAY) < 0)
-        goto cleanup;
+        return NULL;
 
-    ret = virJSONValueObjectStealArray(reply, "return");
-
- cleanup:
-    return ret;
+    return virJSONValueObjectStealArray(reply, "return");
 }
 
 
@@ -8133,7 +7869,6 @@ qemuMonitorJSONSetBlockThreshold(qemuMonitor *mon,
 {
     g_autoptr(virJSONValue) cmd = NULL;
     g_autoptr(virJSONValue) reply = NULL;
-    int ret = -1;
 
     if (!(cmd = qemuMonitorJSONMakeCommand("block-set-write-threshold",
                                            "s:node-name", nodename,
@@ -8142,15 +7877,12 @@ qemuMonitorJSONSetBlockThreshold(qemuMonitor *mon,
         return -1;
 
     if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
-        goto cleanup;
+        return -1;
 
     if (qemuMonitorJSONCheckError(cmd, reply) < 0)
-        goto cleanup;
+        return -1;
 
-    ret = 0;
-
- cleanup:
-    return ret;
+    return 0;
 }
 
 
@@ -8293,7 +8025,6 @@ qemuMonitorJSONBlockdevTrayOpen(qemuMonitor *mon,
 {
     g_autoptr(virJSONValue) cmd = NULL;
     g_autoptr(virJSONValue) reply = NULL;
-    int ret = -1;
 
     if (!(cmd = qemuMonitorJSONMakeCommand("blockdev-open-tray",
                                            "s:id", id,
@@ -8301,15 +8032,12 @@ qemuMonitorJSONBlockdevTrayOpen(qemuMonitor *mon,
         return -1;
 
     if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
-        goto cleanup;
+        return -1;
 
     if (qemuMonitorJSONCheckError(cmd, reply) < 0)
-        goto cleanup;
+        return -1;
 
-    ret = 0;
-
- cleanup:
-    return ret;
+    return 0;
 }
 
 
@@ -8319,22 +8047,18 @@ qemuMonitorJSONBlockdevTrayClose(qemuMonitor *mon,
 {
     g_autoptr(virJSONValue) cmd = NULL;
     g_autoptr(virJSONValue) reply = NULL;
-    int ret = -1;
 
     if (!(cmd = qemuMonitorJSONMakeCommand("blockdev-close-tray",
                                            "s:id", id, NULL)))
         return -1;
 
     if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
-        goto cleanup;
+        return -1;
 
     if (qemuMonitorJSONCheckError(cmd, reply) < 0)
-        goto cleanup;
+        return -1;
 
-    ret = 0;
-
- cleanup:
-    return ret;
+    return 0;
 }
 
 
@@ -8344,22 +8068,18 @@ qemuMonitorJSONBlockdevMediumRemove(qemuMonitor *mon,
 {
     g_autoptr(virJSONValue) cmd = NULL;
     g_autoptr(virJSONValue) reply = NULL;
-    int ret = -1;
 
     if (!(cmd = qemuMonitorJSONMakeCommand("blockdev-remove-medium",
                                            "s:id", id, NULL)))
         return -1;
 
     if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
-        goto cleanup;
+        return -1;
 
     if (qemuMonitorJSONCheckError(cmd, reply) < 0)
-        goto cleanup;
+        return -1;
 
-    ret = 0;
-
- cleanup:
-    return ret;
+    return 0;
 }
 
 
@@ -8370,7 +8090,6 @@ qemuMonitorJSONBlockdevMediumInsert(qemuMonitor *mon,
 {
     g_autoptr(virJSONValue) cmd = NULL;
     g_autoptr(virJSONValue) reply = NULL;
-    int ret = -1;
 
     if (!(cmd = qemuMonitorJSONMakeCommand("blockdev-insert-medium",
                                            "s:id", id,
@@ -8379,15 +8098,12 @@ qemuMonitorJSONBlockdevMediumInsert(qemuMonitor *mon,
         return -1;
 
     if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
-        goto cleanup;
+        return -1;
 
     if (qemuMonitorJSONCheckError(cmd, reply) < 0)
-        goto cleanup;
+        return -1;
 
-    ret = 0;
-
- cleanup:
-    return ret;
+    return 0;
 }
 
 
@@ -8405,7 +8121,6 @@ char *
 qemuMonitorJSONGetSEVMeasurement(qemuMonitor *mon)
 {
     const char *tmp;
-    char *measurement = NULL;
     g_autoptr(virJSONValue) cmd = NULL;
     g_autoptr(virJSONValue) reply = NULL;
     virJSONValue *data;
@@ -8414,20 +8129,17 @@ qemuMonitorJSONGetSEVMeasurement(qemuMonitor *mon)
          return NULL;
 
     if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
-        goto cleanup;
+        return NULL;
 
     if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_OBJECT) < 0)
-        goto cleanup;
+        return NULL;
 
     data = virJSONValueObjectGetObject(reply, "return");
 
     if (!(tmp = virJSONValueObjectGetString(data, "data")))
-        goto cleanup;
+        return NULL;
 
-    measurement = g_strdup(tmp);
-
- cleanup:
-    return measurement;
+    return g_strdup(tmp);
 }
 
 
@@ -8443,7 +8155,6 @@ qemuMonitorJSONExtractPRManagerInfo(virJSONValue *reply,
                                     GHashTable *info)
 {
     virJSONValue *data;
-    int ret = -1;
     size_t i;
 
     data = virJSONValueObjectGetArray(reply, "return");
@@ -8465,19 +8176,17 @@ qemuMonitorJSONExtractPRManagerInfo(virJSONValue *reply,
         }
 
         if (virHashAddEntry(info, alias, entry) < 0)
-            goto cleanup;
+            return -1;
 
         entry = NULL;
     }
 
-    ret = 0;
- cleanup:
-    return ret;
+    return 0;
 
  malformed:
     virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                    _("malformed prManager reply"));
-    goto cleanup;
+    return -1;
 }
 
 
@@ -8485,7 +8194,6 @@ int
 qemuMonitorJSONGetPRManagerInfo(qemuMonitor *mon,
                                 GHashTable *info)
 {
-    int ret = -1;
     g_autoptr(virJSONValue) cmd = NULL;
     g_autoptr(virJSONValue) reply = NULL;
 
@@ -8494,15 +8202,12 @@ qemuMonitorJSONGetPRManagerInfo(qemuMonitor *mon,
         return -1;
 
     if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
-        goto cleanup;
+        return -1;
 
     if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_ARRAY) < 0)
-        goto cleanup;
-
-    ret = qemuMonitorJSONExtractPRManagerInfo(reply, info);
- cleanup:
-    return ret;
+        return -1;
 
+    return qemuMonitorJSONExtractPRManagerInfo(reply, info);
 }
 
 
@@ -8533,7 +8238,6 @@ int
 qemuMonitorJSONGetCurrentMachineInfo(qemuMonitor *mon,
                                      qemuMonitorCurrentMachineInfo *info)
 {
-    int ret = -1;
     g_autoptr(virJSONValue) cmd = NULL;
     g_autoptr(virJSONValue) reply = NULL;
 
@@ -8542,15 +8246,12 @@ qemuMonitorJSONGetCurrentMachineInfo(qemuMonitor *mon,
         return -1;
 
     if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
-        goto cleanup;
+        return -1;
 
     if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_OBJECT) < 0)
-        goto cleanup;
+        return -1;
 
-    ret = qemuMonitorJSONExtractCurrentMachineInfo(reply, info);
-
- cleanup:
-    return ret;
+    return qemuMonitorJSONExtractCurrentMachineInfo(reply, info);
 }
 
 
-- 
2.32.0




More information about the libvir-list mailing list