]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
tests: cpuTestLoadMultiXML: use g_new0 instead of VIR_ALLOC_N
authorJán Tomko <jtomko@redhat.com>
Tue, 22 Sep 2020 22:59:59 +0000 (00:59 +0200)
committerJán Tomko <jtomko@redhat.com>
Wed, 23 Sep 2020 12:54:38 +0000 (14:54 +0200)
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
tests/cputest.c

index 83d63bf495faab0bbd4ec6bf61ae1774327506af..383da949387e05363dbf01bda49b145a5bc1673d 100644 (file)
@@ -111,11 +111,13 @@ cpuTestLoadMultiXML(virArch arch,
         goto cleanup;
 
     n = virXPathNodeSet("/cpuTest/cpu", ctxt, &nodes);
-    if (n <= 0 || (VIR_ALLOC_N(cpus, n) < 0)) {
+    if (n <= 0) {
         fprintf(stderr, "\nNo /cpuTest/cpu elements found in %s\n", xml);
         goto cleanup;
     }
 
+    cpus = g_new0(virCPUDefPtr, n);
+
     for (i = 0; i < n; i++) {
         ctxt->node = nodes[i];
         if (virCPUDefParseXML(ctxt, NULL, VIR_CPU_TYPE_HOST, &cpus[i]) < 0)