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