]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
cpu_x86: Use g_auto* in virCPUx86ExpandFeatures
authorJiri Denemark <jdenemar@redhat.com>
Wed, 25 Mar 2020 10:32:57 +0000 (11:32 +0100)
committerJiri Denemark <jdenemar@redhat.com>
Wed, 8 Apr 2020 15:41:46 +0000 (17:41 +0200)
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/cpu/cpu_x86.c

index cf573b6711d687127f92a8c992e97fa466a0baba..c3b8adaea0df9538529a1738daaa4e405975adf0 100644 (file)
@@ -3055,30 +3055,29 @@ static int
 virCPUx86ExpandFeatures(virCPUDefPtr cpu)
 {
     virCPUx86MapPtr map;
-    virCPUDefPtr expanded = NULL;
-    virCPUx86ModelPtr model = NULL;
+    g_autoptr(virCPUDef) expanded = NULL;
+    g_autoptr(virCPUx86Model) model = NULL;
     bool host = cpu->type == VIR_CPU_TYPE_HOST;
     size_t i;
-    int ret = -1;
 
     if (!(map = virCPUx86GetMap()))
-        goto cleanup;
+        return -1;
 
     if (!(expanded = virCPUDefCopy(cpu)))
-        goto cleanup;
+        return -1;
 
     virCPUDefFreeFeatures(expanded);
 
     if (!(model = x86ModelFind(map, cpu->model))) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        _("unknown CPU model %s"), cpu->model);
-        goto cleanup;
+        return -1;
     }
 
     if (!(model = x86ModelCopy(model)) ||
         x86DataToCPUFeatures(expanded, host ? -1 : VIR_CPU_FEATURE_REQUIRE,
                              &model->data, map) < 0)
-        goto cleanup;
+        return -1;
 
     for (i = 0; i < cpu->nfeatures; i++) {
         virCPUFeatureDefPtr f = cpu->features + i;
@@ -3089,17 +3088,12 @@ virCPUx86ExpandFeatures(virCPUDefPtr cpu)
             continue;
 
         if (virCPUDefUpdateFeature(expanded, f->name, f->policy) < 0)
-            goto cleanup;
+            return -1;
     }
 
     virCPUDefFreeModel(cpu);
 
-    ret = virCPUDefCopyModel(cpu, expanded, false);
-
- cleanup:
-    virCPUDefFree(expanded);
-    x86ModelFree(model);
-    return ret;
+    return virCPUDefCopyModel(cpu, expanded, false);
 }