a41c76
From 13d45a3f07d1639250101b037bb65c20aed60763 Mon Sep 17 00:00:00 2001
a41c76
Message-Id: <13d45a3f07d1639250101b037bb65c20aed60763@dist-git>
a41c76
From: Jiri Denemark <jdenemar@redhat.com>
a41c76
Date: Tue, 26 May 2020 10:59:24 +0200
a41c76
Subject: [PATCH] cpu_x86: Use g_auto* in virCPUx86Translate
a41c76
MIME-Version: 1.0
a41c76
Content-Type: text/plain; charset=UTF-8
a41c76
Content-Transfer-Encoding: 8bit
a41c76
a41c76
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
a41c76
Reviewed-by: Ján Tomko <jtomko@redhat.com>
a41c76
(cherry picked from commit dff59020187c34e3f814c2aa24f3832d1d5b34f9)
a41c76
a41c76
https://bugzilla.redhat.com/show_bug.cgi?id=1840010
a41c76
a41c76
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
a41c76
Message-Id: <574920457f9fec4bc1938615016278eddd46ba90.1590483392.git.jdenemar@redhat.com>
a41c76
Reviewed-by: Ján Tomko <jtomko@redhat.com>
a41c76
---
a41c76
 src/cpu/cpu_x86.c | 26 ++++++++++----------------
a41c76
 1 file changed, 10 insertions(+), 16 deletions(-)
a41c76
a41c76
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
a41c76
index e3a83061d0..c4654c8d4c 100644
a41c76
--- a/src/cpu/cpu_x86.c
a41c76
+++ b/src/cpu/cpu_x86.c
a41c76
@@ -3015,45 +3015,39 @@ static int
a41c76
 virCPUx86Translate(virCPUDefPtr cpu,
a41c76
                    virDomainCapsCPUModelsPtr models)
a41c76
 {
a41c76
-    virCPUDefPtr translated = NULL;
a41c76
+    g_autoptr(virCPUDef) translated = NULL;
a41c76
     virCPUx86MapPtr map;
a41c76
-    virCPUx86ModelPtr model = NULL;
a41c76
+    g_autoptr(virCPUx86Model) model = NULL;
a41c76
     size_t i;
a41c76
-    int ret = -1;
a41c76
 
a41c76
     if (!(map = virCPUx86GetMap()))
a41c76
-        goto cleanup;
a41c76
+        return -1;
a41c76
 
a41c76
     if (!(model = x86ModelFromCPU(cpu, map, -1)))
a41c76
-        goto cleanup;
a41c76
+        return -1;
a41c76
 
a41c76
     if (model->vendor &&
a41c76
         virCPUx86DataAddItem(&model->data, &model->vendor->data) < 0)
a41c76
-        goto cleanup;
a41c76
+        return -1;
a41c76
 
a41c76
     if (model->signatures &&
a41c76
         x86DataAddSignature(&model->data, model->signatures[0]) < 0)
a41c76
-        goto cleanup;
a41c76
+        return -1;
a41c76
 
a41c76
     if (!(translated = virCPUDefCopyWithoutModel(cpu)))
a41c76
-        goto cleanup;
a41c76
+        return -1;
a41c76
 
a41c76
     if (x86Decode(translated, &model->data, models, NULL, false) < 0)
a41c76
-        goto cleanup;
a41c76
+        return -1;
a41c76
 
a41c76
     for (i = 0; i < cpu->nfeatures; i++) {
a41c76
         virCPUFeatureDefPtr f = cpu->features + i;
a41c76
         if (virCPUDefUpdateFeature(translated, f->name, f->policy) < 0)
a41c76
-            goto cleanup;
a41c76
+            return -1;
a41c76
     }
a41c76
 
a41c76
     virCPUDefStealModel(cpu, translated, true);
a41c76
-    ret = 0;
a41c76
-
a41c76
- cleanup:
a41c76
-    virCPUDefFree(translated);
a41c76
-    x86ModelFree(model);
a41c76
-    return ret;
a41c76
+    return 0;
a41c76
 }
a41c76
 
a41c76
 
a41c76
-- 
a41c76
2.26.2
a41c76