libvirt/SOURCES/libvirt-cpu_x86-Use-g_auto-in-virCPUx86DataParse.patch
2021-10-08 13:11:20 +00:00

88 lines
2.6 KiB
Diff

From 45226d208c57719b50152dbec99a75969989208b Mon Sep 17 00:00:00 2001
Message-Id: <45226d208c57719b50152dbec99a75969989208b@dist-git>
From: Jiri Denemark <jdenemar@redhat.com>
Date: Tue, 26 May 2020 10:59:12 +0200
Subject: [PATCH] cpu_x86: Use g_auto* in virCPUx86DataParse
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 c1532711dda6db27c7f6fa7d86ab5ec5d2ab2224)
https://bugzilla.redhat.com/show_bug.cgi?id=1840010
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Message-Id: <e98c6869043aa0b7d0cc3adffe879f5d7d3c39f2.1590483392.git.jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/cpu/cpu_x86.c | 23 ++++++++---------------
1 file changed, 8 insertions(+), 15 deletions(-)
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
index cb5a2f941e..107fd9227d 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -1636,8 +1636,8 @@ virCPUx86DataFormat(const virCPUData *data)
static virCPUDataPtr
virCPUx86DataParse(xmlXPathContextPtr ctxt)
{
- xmlNodePtr *nodes = NULL;
- virCPUDataPtr cpuData = NULL;
+ g_autofree xmlNodePtr *nodes = NULL;
+ g_autoptr(virCPUData) cpuData = NULL;
virCPUx86DataItem item;
size_t i;
int n;
@@ -1646,11 +1646,11 @@ virCPUx86DataParse(xmlXPathContextPtr ctxt)
if (n <= 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("no x86 CPU data found"));
- goto error;
+ return NULL;
}
if (!(cpuData = virCPUDataNew(VIR_ARCH_X86_64)))
- goto error;
+ return NULL;
for (i = 0; i < n; i++) {
ctxt->node = nodes[i];
@@ -1658,28 +1658,21 @@ virCPUx86DataParse(xmlXPathContextPtr ctxt)
if (x86ParseCPUID(ctxt, &item) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("failed to parse cpuid[%zu]"), i);
- goto error;
+ return NULL;
}
} else {
if (x86ParseMSR(ctxt, &item) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("failed to parse msr[%zu]"), i);
- goto error;
+ return NULL;
}
}
if (virCPUx86DataAdd(cpuData, &item) < 0)
- goto error;
+ return NULL;
}
- cleanup:
- VIR_FREE(nodes);
- return cpuData;
-
- error:
- virCPUx86DataFree(cpuData);
- cpuData = NULL;
- goto cleanup;
+ return g_steal_pointer(&cpuData);
}
--
2.26.2