libvirt/SOURCES/libvirt-cpu_x86-Use-g_auto-...

86 lines
2.4 KiB
Diff

From 13d45a3f07d1639250101b037bb65c20aed60763 Mon Sep 17 00:00:00 2001
Message-Id: <13d45a3f07d1639250101b037bb65c20aed60763@dist-git>
From: Jiri Denemark <jdenemar@redhat.com>
Date: Tue, 26 May 2020 10:59:24 +0200
Subject: [PATCH] cpu_x86: Use g_auto* in virCPUx86Translate
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit dff59020187c34e3f814c2aa24f3832d1d5b34f9)
https://bugzilla.redhat.com/show_bug.cgi?id=1840010
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Message-Id: <574920457f9fec4bc1938615016278eddd46ba90.1590483392.git.jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/cpu/cpu_x86.c | 26 ++++++++++----------------
1 file changed, 10 insertions(+), 16 deletions(-)
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
index e3a83061d0..c4654c8d4c 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -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;
}
--
2.26.2