]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemuMonitorJSONAddDeviceProps: Refactor cleanup
authorPeter Krempa <pkrempa@redhat.com>
Sat, 25 Sep 2021 06:34:48 +0000 (08:34 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 12 Oct 2021 08:26:01 +0000 (10:26 +0200)
Use automatic memory freeing and remove 'ret' variable and 'cleanup'
label.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/qemu/qemu_monitor_json.c

index e5c71f58c2371dde84420e87ed249199bf2cb3ba..f831cfeeb5f3f2f877d3b0d102d0233ffebfef87 100644 (file)
@@ -4557,27 +4557,22 @@ int
 qemuMonitorJSONAddDeviceProps(qemuMonitor *mon,
                               virJSONValue **props)
 {
-    int ret = -1;
-    virJSONValue *cmd = NULL;
-    virJSONValue *reply = NULL;
+    g_autoptr(virJSONValue) cmd = NULL;
+    g_autoptr(virJSONValue) reply = NULL;
 
     if (!(cmd = qemuMonitorJSONMakeCommand("device_add", NULL)))
-        goto cleanup;
+        return -1;
 
     if (virJSONValueObjectAppend(cmd, "arguments", props) < 0)
-        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:
-    virJSONValueFree(cmd);
-    virJSONValueFree(reply);
-    return ret;
+    return 0;
 }