libvirt/SOURCES/libvirt-cpu_x86-Use-g_auto-in-x86VendorParse.patch
2021-09-10 11:57:33 +00:00

77 lines
2.3 KiB
Diff

From 6a7bb46df53af5c1213e3a53a530c8745eb1aa0e Mon Sep 17 00:00:00 2001
Message-Id: <6a7bb46df53af5c1213e3a53a530c8745eb1aa0e@dist-git>
From: Jiri Denemark <jdenemar@redhat.com>
Date: Tue, 26 May 2020 10:59:07 +0200
Subject: [PATCH] cpu_x86: Use g_auto* in x86VendorParse
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 6a0a7db9041cb1d8d92919bb4adf0d19bdd5dd68)
https://bugzilla.redhat.com/show_bug.cgi?id=1840010
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Message-Id: <3d21717ab7a594e301afc7f33ddbb32b57a8c56e.1590483392.git.jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/cpu/cpu_x86.c | 20 +++++++-------------
1 file changed, 7 insertions(+), 13 deletions(-)
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
index 310dfcbcb3..3ffddf0342 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -849,9 +849,8 @@ x86VendorParse(xmlXPathContextPtr ctxt,
void *data)
{
virCPUx86MapPtr map = data;
- virCPUx86VendorPtr vendor = NULL;
- char *string = NULL;
- int ret = -1;
+ g_autoptr(virCPUx86Vendor) vendor = NULL;
+ g_autofree char *string = NULL;
vendor = g_new0(virCPUx86Vendor, 1);
vendor->name = g_strdup(name);
@@ -859,7 +858,7 @@ x86VendorParse(xmlXPathContextPtr ctxt,
if (x86VendorFind(map, vendor->name)) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("CPU vendor %s already defined"), vendor->name);
- goto cleanup;
+ return -1;
}
string = virXPathString("string(@string)", ctxt);
@@ -867,21 +866,16 @@ x86VendorParse(xmlXPathContextPtr ctxt,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Missing vendor string for CPU vendor %s"),
vendor->name);
- goto cleanup;
+ return -1;
}
if (virCPUx86VendorToData(string, &vendor->data) < 0)
- goto cleanup;
+ return -1;
if (VIR_APPEND_ELEMENT(map->vendors, map->nvendors, vendor) < 0)
- goto cleanup;
-
- ret = 0;
+ return -1;
- cleanup:
- x86VendorFree(vendor);
- VIR_FREE(string);
- return ret;
+ return 0;
}
--
2.26.2