render / rpms / libvirt

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