]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemuMonitorJSONGetDeviceProps: Refactor to modern standards
authorPeter Krempa <pkrempa@redhat.com>
Wed, 6 May 2020 15:40:47 +0000 (17:40 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 12 May 2020 04:55:00 +0000 (06:55 +0200)
Use automatic cleanup of variables and current style of header.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/qemu/qemu_monitor_json.c

index 619717eae571714b69d92badf337560a289e54f7..9d1db07ccd5a30cc06de59e3a3a5293e3ce31818 100644 (file)
@@ -6745,13 +6745,13 @@ qemuMonitorJSONParsePropsList(virJSONValuePtr cmd,
 }
 
 
-int qemuMonitorJSONGetDeviceProps(qemuMonitorPtr mon,
-                                  const char *device,
-                                  char ***props)
+int
+qemuMonitorJSONGetDeviceProps(qemuMonitorPtr mon,
+                              const char *device,
+                              char ***props)
 {
-    int ret = -1;
-    virJSONValuePtr cmd;
-    virJSONValuePtr reply = NULL;
+    g_autoptr(virJSONValue) cmd = NULL;
+    g_autoptr(virJSONValue) reply = NULL;
 
     *props = NULL;
 
@@ -6761,18 +6761,12 @@ int qemuMonitorJSONGetDeviceProps(qemuMonitorPtr mon,
         return -1;
 
     if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
-        goto cleanup;
+        return -1;
 
-    if (qemuMonitorJSONHasError(reply, "DeviceNotFound")) {
-        ret = 0;
-        goto cleanup;
-    }
+    if (qemuMonitorJSONHasError(reply, "DeviceNotFound"))
+        return 0;
 
-    ret = qemuMonitorJSONParsePropsList(cmd, reply, NULL, props);
- cleanup:
-    virJSONValueFree(reply);
-    virJSONValueFree(cmd);
-    return ret;
+    return qemuMonitorJSONParsePropsList(cmd, reply, NULL, props);
 }