render / rpms / libvirt

Forked from rpms/libvirt 10 months ago
Clone
Blob Blame History Raw
From a271a6a71073253a7dde518a63d5ee4965ee53d8 Mon Sep 17 00:00:00 2001
Message-Id: <a271a6a71073253a7dde518a63d5ee4965ee53d8@dist-git>
From: Jiri Denemark <jdenemar@redhat.com>
Date: Tue, 26 May 2020 10:59:05 +0200
Subject: [PATCH] cpu_x86: Use glib allocation in virCPUx86GetModels
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 e43e2ff7f5b629f979e56387c4be46f2be251b75)

https://bugzilla.redhat.com/show_bug.cgi?id=1840010

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Message-Id: <1d1d9c9b60f1ea44a2252cb2fbfbf3886ecd245f.1590483392.git.jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
 src/cpu/cpu_x86.c | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
index 3711e03b3f..48f36c2bfc 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -3121,21 +3121,13 @@ virCPUx86GetModels(char ***models)
         return -1;
 
     if (models) {
-        if (VIR_ALLOC_N(*models, map->nmodels + 1) < 0)
-            goto error;
+        *models = g_new0(char *, map->nmodels + 1);
 
         for (i = 0; i < map->nmodels; i++)
             (*models)[i] = g_strdup(map->models[i]->name);
     }
 
     return map->nmodels;
-
- error:
-    if (models) {
-        virStringListFree(*models);
-        *models = NULL;
-    }
-    return -1;
 }
 
 
-- 
2.26.2