]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemumonitorjsontest: GetCPUModelComparison: use g_auto
authorJán Tomko <jtomko@redhat.com>
Fri, 21 Feb 2020 23:55:50 +0000 (00:55 +0100)
committerJán Tomko <jtomko@redhat.com>
Mon, 9 Mar 2020 14:46:43 +0000 (15:46 +0100)
Use g_autoptr for the virCPUDef variables and get rid
of the cleanup label.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
tests/qemumonitorjsontest.c

index 70ebdfd2d43adbe27e9791ba79aecd63751ef1e3..a5d980c8b336b2414fead780759e40bc6ab796ea 100644 (file)
@@ -2981,10 +2981,9 @@ testQemuMonitorJSONqemuMonitorJSONGetCPUModelComparison(const void *opaque)
 {
     const testGenericData *data = opaque;
     g_autoptr(qemuMonitorTest) test = NULL;
-    virCPUDefPtr cpu_a;
-    virCPUDefPtr cpu_b = NULL;
+    g_autoptr(virCPUDef) cpu_a = virCPUDefNew();
+    g_autoptr(virCPUDef) cpu_b = virCPUDefNew();
     g_autofree char *result = NULL;
-    int ret = -1;
 
     if (!(test = qemuMonitorTestNewSchema(data->xmlopt, data->schema)))
         return -1;
@@ -2993,28 +2992,20 @@ testQemuMonitorJSONqemuMonitorJSONGetCPUModelComparison(const void *opaque)
                                "{\"return\":{\"result\":\"test\"}}") < 0)
         return -1;
 
-    cpu_a = virCPUDefNew();
-    cpu_b = virCPUDefNew();
-
     cpu_a->model = g_strdup("cpu_a");
     cpu_b->model = g_strdup("cpu_b");
 
     if (qemuMonitorJSONGetCPUModelComparison(qemuMonitorTestGetMonitor(test),
                                              cpu_a, cpu_b, &result) < 0)
-        goto cleanup;
+        return -1;
 
     if (!result || STRNEQ(result, "test")) {
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                        "Compare result not set");
-        goto cleanup;
+        return -1;
     }
 
-    ret = 0;
-
- cleanup:
-    virCPUDefFree(cpu_a);
-    virCPUDefFree(cpu_b);
-    return ret;
+    return 0;
 }