[libvirt PATCH 1/4] tests: virNumaGetPages: use g_new0 instead of VIR_ALLOC_N

Ján Tomko jtomko at redhat.com
Tue Sep 22 23:04:15 UTC 2020


Signed-off-by: Ján Tomko <jtomko at redhat.com>
---
 tests/virnumamock.c | 16 +++-------------
 1 file changed, 3 insertions(+), 13 deletions(-)

diff --git a/tests/virnumamock.c b/tests/virnumamock.c
index e6282c7f33..40e18e646e 100644
--- a/tests/virnumamock.c
+++ b/tests/virnumamock.c
@@ -133,23 +133,13 @@ virNumaGetPages(int node,
     size_t i = 0;
 
     if (pages_size)
-        *pages_size = NULL;
+        *pages_size = g_new0(unsigned int, npages_def);
 
     if (pages_avail)
-        *pages_avail = NULL;
+        *pages_avail = g_new0(unsigned long long, npages_def);
 
     if (pages_free)
-        *pages_free = NULL;
-
-    *npages = 0;
-
-    if ((pages_size && VIR_ALLOC_N(*pages_size, npages_def) < 0) ||
-        (pages_avail && VIR_ALLOC_N(*pages_avail, npages_def) < 0) ||
-        (pages_free && VIR_ALLOC_N(*pages_free, npages_def) < 0)) {
-        VIR_FREE(*pages_size);
-        VIR_FREE(*pages_avail);
-        return -1;
-    }
+        *pages_free = g_new0(unsigned long long, npages_def);
 
     *npages = npages_def;
     if (pages_size)
-- 
2.26.2




More information about the libvir-list mailing list