]> xenbits.xensource.com Git - libvirt.git/commitdiff
cpu_x86: Use g_auto* in virCPUx86Translate
authorJiri Denemark <jdenemar@redhat.com>
Wed, 25 Mar 2020 10:32:44 +0000 (11:32 +0100)
committerJiri Denemark <jdenemar@redhat.com>
Wed, 8 Apr 2020 15:41:43 +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 70aadfaa99ce17f281fab027db42306c4b9ddc90..cf573b6711d687127f92a8c992e97fa466a0baba 100644 (file)
@@ -3015,45 +3015,39 @@ static int
 virCPUx86Translate(virCPUDefPtr cpu,
                    virDomainCapsCPUModelsPtr models)
 {
-    virCPUDefPtr translated = NULL;
+    g_autoptr(virCPUDef) translated = NULL;
     virCPUx86MapPtr map;
-    virCPUx86ModelPtr model = NULL;
+    g_autoptr(virCPUx86Model) model = NULL;
     size_t i;
-    int ret = -1;
 
     if (!(map = virCPUx86GetMap()))
-        goto cleanup;
+        return -1;
 
     if (!(model = x86ModelFromCPU(cpu, map, -1)))
-        goto cleanup;
+        return -1;
 
     if (model->vendor &&
         virCPUx86DataAddItem(&model->data, &model->vendor->data) < 0)
-        goto cleanup;
+        return -1;
 
     if (model->signatures &&
         x86DataAddSignature(&model->data, model->signatures[0]) < 0)
-        goto cleanup;
+        return -1;
 
     if (!(translated = virCPUDefCopyWithoutModel(cpu)))
-        goto cleanup;
+        return -1;
 
     if (x86Decode(translated, &model->data, models, NULL, false) < 0)
-        goto cleanup;
+        return -1;
 
     for (i = 0; i < cpu->nfeatures; i++) {
         virCPUFeatureDefPtr f = cpu->features + i;
         if (virCPUDefUpdateFeature(translated, f->name, f->policy) < 0)
-            goto cleanup;
+            return -1;
     }
 
     virCPUDefStealModel(cpu, translated, true);
-    ret = 0;
-
- cleanup:
-    virCPUDefFree(translated);
-    x86ModelFree(model);
-    return ret;
+    return 0;
 }