|
|
fbe740 |
From 39dea7f80de53e9f7fb8f298d1f9f7f32f20fc29 Mon Sep 17 00:00:00 2001
|
|
|
fbe740 |
Message-Id: <39dea7f80de53e9f7fb8f298d1f9f7f32f20fc29@dist-git>
|
|
|
fbe740 |
From: Jiri Denemark <jdenemar@redhat.com>
|
|
|
fbe740 |
Date: Tue, 26 May 2020 10:59:08 +0200
|
|
|
fbe740 |
Subject: [PATCH] cpu_x86: Use g_auto* in x86FeatureParse
|
|
|
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 3125688f78f6289e51bfdaa196addb230b0de4e1)
|
|
|
fbe740 |
|
|
|
fbe740 |
https://bugzilla.redhat.com/show_bug.cgi?id=1840010
|
|
|
fbe740 |
|
|
|
fbe740 |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
fbe740 |
Message-Id: <14cf6ca6816ee8bda3e195aa5218162b280715b5.1590483392.git.jdenemar@redhat.com>
|
|
|
fbe740 |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
fbe740 |
---
|
|
|
fbe740 |
src/cpu/cpu_x86.c | 31 ++++++++++++-------------------
|
|
|
fbe740 |
1 file changed, 12 insertions(+), 19 deletions(-)
|
|
|
fbe740 |
|
|
|
fbe740 |
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
|
|
|
fbe740 |
index 3ffddf0342..10c5fbacf7 100644
|
|
|
fbe740 |
--- a/src/cpu/cpu_x86.c
|
|
|
fbe740 |
+++ b/src/cpu/cpu_x86.c
|
|
|
fbe740 |
@@ -1023,13 +1023,12 @@ x86FeatureParse(xmlXPathContextPtr ctxt,
|
|
|
fbe740 |
void *data)
|
|
|
fbe740 |
{
|
|
|
fbe740 |
virCPUx86MapPtr map = data;
|
|
|
fbe740 |
- xmlNodePtr *nodes = NULL;
|
|
|
fbe740 |
- virCPUx86FeaturePtr feature;
|
|
|
fbe740 |
+ g_autofree xmlNodePtr *nodes = NULL;
|
|
|
fbe740 |
+ g_autoptr(virCPUx86Feature) feature = NULL;
|
|
|
fbe740 |
virCPUx86DataItem item;
|
|
|
fbe740 |
size_t i;
|
|
|
fbe740 |
int n;
|
|
|
fbe740 |
- char *str = NULL;
|
|
|
fbe740 |
- int ret = -1;
|
|
|
fbe740 |
+ g_autofree char *str = NULL;
|
|
|
fbe740 |
|
|
|
fbe740 |
feature = g_new0(virCPUx86Feature, 1);
|
|
|
fbe740 |
feature->migratable = true;
|
|
|
fbe740 |
@@ -1038,7 +1037,7 @@ x86FeatureParse(xmlXPathContextPtr ctxt,
|
|
|
fbe740 |
if (x86FeatureFind(map, feature->name)) {
|
|
|
fbe740 |
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
fbe740 |
_("CPU feature %s already defined"), feature->name);
|
|
|
fbe740 |
- goto cleanup;
|
|
|
fbe740 |
+ return -1;
|
|
|
fbe740 |
}
|
|
|
fbe740 |
|
|
|
fbe740 |
str = virXPathString("string(@migratable)", ctxt);
|
|
|
fbe740 |
@@ -1047,13 +1046,13 @@ x86FeatureParse(xmlXPathContextPtr ctxt,
|
|
|
fbe740 |
|
|
|
fbe740 |
n = virXPathNodeSet("./cpuid|./msr", ctxt, &nodes);
|
|
|
fbe740 |
if (n < 0)
|
|
|
fbe740 |
- goto cleanup;
|
|
|
fbe740 |
+ return -1;
|
|
|
fbe740 |
|
|
|
fbe740 |
if (n == 0) {
|
|
|
fbe740 |
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
fbe740 |
_("Missing cpuid or msr element in feature %s"),
|
|
|
fbe740 |
feature->name);
|
|
|
fbe740 |
- goto cleanup;
|
|
|
fbe740 |
+ return -1;
|
|
|
fbe740 |
}
|
|
|
fbe740 |
|
|
|
fbe740 |
for (i = 0; i < n; i++) {
|
|
|
fbe740 |
@@ -1063,37 +1062,31 @@ x86FeatureParse(xmlXPathContextPtr ctxt,
|
|
|
fbe740 |
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
fbe740 |
_("Invalid cpuid[%zu] in %s feature"),
|
|
|
fbe740 |
i, feature->name);
|
|
|
fbe740 |
- goto cleanup;
|
|
|
fbe740 |
+ return -1;
|
|
|
fbe740 |
}
|
|
|
fbe740 |
} else {
|
|
|
fbe740 |
if (x86ParseMSR(ctxt, &item) < 0) {
|
|
|
fbe740 |
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
fbe740 |
_("Invalid msr[%zu] in %s feature"),
|
|
|
fbe740 |
i, feature->name);
|
|
|
fbe740 |
- goto cleanup;
|
|
|
fbe740 |
+ return -1;
|
|
|
fbe740 |
}
|
|
|
fbe740 |
}
|
|
|
fbe740 |
|
|
|
fbe740 |
if (virCPUx86DataAddItem(&feature->data, &item))
|
|
|
fbe740 |
- goto cleanup;
|
|
|
fbe740 |
+ return -1;
|
|
|
fbe740 |
}
|
|
|
fbe740 |
|
|
|
fbe740 |
if (!feature->migratable &&
|
|
|
fbe740 |
VIR_APPEND_ELEMENT_COPY(map->migrate_blockers,
|
|
|
fbe740 |
map->nblockers,
|
|
|
fbe740 |
feature) < 0)
|
|
|
fbe740 |
- goto cleanup;
|
|
|
fbe740 |
+ return -1;
|
|
|
fbe740 |
|
|
|
fbe740 |
if (VIR_APPEND_ELEMENT(map->features, map->nfeatures, feature) < 0)
|
|
|
fbe740 |
- goto cleanup;
|
|
|
fbe740 |
-
|
|
|
fbe740 |
- ret = 0;
|
|
|
fbe740 |
+ return -1;
|
|
|
fbe740 |
|
|
|
fbe740 |
- cleanup:
|
|
|
fbe740 |
- x86FeatureFree(feature);
|
|
|
fbe740 |
- VIR_FREE(nodes);
|
|
|
fbe740 |
- VIR_FREE(str);
|
|
|
fbe740 |
- return ret;
|
|
|
fbe740 |
+ return 0;
|
|
|
fbe740 |
}
|
|
|
fbe740 |
|
|
|
fbe740 |
|
|
|
fbe740 |
--
|
|
|
fbe740 |
2.26.2
|
|
|
fbe740 |
|