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