tests: cpuTestLoadMultiXML: use g_new0 instead of VIR_ALLOC_N

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
Ján Tomko 2020-09-23 00:59:59 +02:00
parent bff6aee4ca
commit cc9674c318
1 changed files with 3 additions and 1 deletions

View 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)