libvirt/SOURCES/libvirt-cpu_x86-Use-glib-allocation-for-virCPUx86Model.patch
2021-09-10 11:57:33 +00:00

104 lines
2.7 KiB
Diff

From 18b41d5bb489080b8be3c78d7f8436c9fb13087a Mon Sep 17 00:00:00 2001
Message-Id: <18b41d5bb489080b8be3c78d7f8436c9fb13087a@dist-git>
From: Jiri Denemark <jdenemar@redhat.com>
Date: Tue, 26 May 2020 10:59:03 +0200
Subject: [PATCH] cpu_x86: Use glib allocation for virCPUx86Model
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 ccc0c2e4de58d62308e224076a7aa979ae97b520)
https://bugzilla.redhat.com/show_bug.cgi?id=1840010
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Message-Id: <db624beaa5c879842c45b90269fb58a8f2fcfff2.1590483392.git.jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/cpu/cpu_x86.c | 31 ++++++++-----------------------
1 file changed, 8 insertions(+), 23 deletions(-)
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
index 3a598e35d2..373c34a834 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -1111,29 +1111,18 @@ x86FeatureParse(xmlXPathContextPtr ctxt,
}
-static virCPUx86ModelPtr
-x86ModelNew(void)
-{
- virCPUx86ModelPtr model;
-
- if (VIR_ALLOC(model) < 0)
- return NULL;
-
- return model;
-}
-
-
static void
x86ModelFree(virCPUx86ModelPtr model)
{
if (!model)
return;
- VIR_FREE(model->name);
- VIR_FREE(model->signatures);
+ g_free(model->name);
+ g_free(model->signatures);
virCPUx86DataClear(&model->data);
- VIR_FREE(model);
+ g_free(model);
}
+G_DEFINE_AUTOPTR_CLEANUP_FUNC(virCPUx86Model, x86ModelFree);
static int
@@ -1161,9 +1150,7 @@ x86ModelCopy(virCPUx86ModelPtr model)
{
virCPUx86ModelPtr copy;
- if (VIR_ALLOC(copy) < 0)
- return NULL;
-
+ copy = g_new0(virCPUx86Model, 1);
copy->name = g_strdup(model->name);
if (x86ModelCopySignatures(copy, model) < 0) {
@@ -1216,7 +1203,7 @@ x86ModelFromCPU(const virCPUDef *cpu,
if (cpu->type == VIR_CPU_TYPE_HOST &&
policy != VIR_CPU_FEATURE_REQUIRE &&
policy != -1)
- return x86ModelNew();
+ return g_new0(virCPUx86Model, 1);
if (cpu->model &&
(policy == VIR_CPU_FEATURE_REQUIRE || policy == -1)) {
@@ -1228,7 +1215,7 @@ x86ModelFromCPU(const virCPUDef *cpu,
model = x86ModelCopy(model);
} else {
- model = x86ModelNew();
+ model = g_new0(virCPUx86Model, 1);
}
if (!model)
@@ -1540,9 +1527,7 @@ x86ModelParse(xmlXPathContextPtr ctxt,
goto cleanup;
}
- if (!(model = x86ModelNew()))
- goto cleanup;
-
+ model = g_new0(virCPUx86Model, 1);
model->name = g_strdup(name);
if (x86ModelParseDecode(model, ctxt) < 0)
--
2.26.2