[PATCH 01/22] qemuMonitorJSONSetWatchdogAction: Use automatic memory clearing

Peter Krempa pkrempa at redhat.com
Tue Aug 24 14:44:22 UTC 2021


Signed-off-by: Peter Krempa <pkrempa at redhat.com>
---
 src/qemu/qemu_monitor_json.c | 16 +++++-----------
 1 file changed, 5 insertions(+), 11 deletions(-)

diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index 8e5af9f79a..8fb2bf4dc3 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -8560,9 +8560,8 @@ int
 qemuMonitorJSONSetWatchdogAction(qemuMonitor *mon,
                                  const char *action)
 {
-    virJSONValue *cmd;
-    virJSONValue *reply = NULL;
-    int ret = -1;
+    g_autoptr(virJSONValue) cmd = NULL;
+    g_autoptr(virJSONValue) reply = NULL;

     if (!(cmd = qemuMonitorJSONMakeCommand("watchdog-set-action",
                                            "s:action", action,
@@ -8570,17 +8569,12 @@ qemuMonitorJSONSetWatchdogAction(qemuMonitor *mon,
         return -1;

     if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
-        goto cleanup;
+        return -1;

     if (qemuMonitorJSONCheckError(cmd, reply) < 0)
-        goto cleanup;
-
-    ret = 0;
+        return -1;

- cleanup:
-    virJSONValueFree(cmd);
-    virJSONValueFree(reply);
-    return ret;
+    return 0;
 }


-- 
2.31.1




More information about the libvir-list mailing list