1
0

conf: cpu: use g_new0

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
This commit is contained in:
Ján Tomko 2020-10-07 21:15:39 +02:00
parent 1eb1413410
commit 7ff9f76a2e

View File

@ -153,9 +153,7 @@ virCPUDefCopyModelFilter(virCPUDefPtr dst,
size_t i; size_t i;
size_t n; size_t n;
if (VIR_ALLOC_N(dst->features, src->nfeatures) < 0) dst->features = g_new0(virCPUFeatureDef, src->nfeatures);
return -1;
dst->model = g_strdup(src->model); dst->model = g_strdup(src->model);
dst->vendor = g_strdup(src->vendor); dst->vendor = g_strdup(src->vendor);
dst->vendor_id = g_strdup(src->vendor_id); dst->vendor_id = g_strdup(src->vendor_id);
@ -248,16 +246,12 @@ virCPUDefCopyWithoutModel(const virCPUDef *cpu)
copy->migratable = cpu->migratable; copy->migratable = cpu->migratable;
if (cpu->cache) { if (cpu->cache) {
if (VIR_ALLOC(copy->cache) < 0) copy->cache = g_new0(virCPUCacheDef, 1);
return NULL;
*copy->cache = *cpu->cache; *copy->cache = *cpu->cache;
} }
if (cpu->tsc) { if (cpu->tsc) {
if (VIR_ALLOC(copy->tsc) < 0) copy->tsc = g_new0(virHostCPUTscInfo, 1);
return NULL;
*copy->tsc = *cpu->tsc; *copy->tsc = *cpu->tsc;
} }
@ -1156,8 +1150,7 @@ virCPUDefListParse(const char **xmlCPUs,
goto error; goto error;
} }
if (VIR_ALLOC_N(cpus, ncpus + 1)) cpus = g_new0(virCPUDefPtr, ncpus + 1);
goto error;
for (i = 0; i < ncpus; i++) { for (i = 0; i < ncpus; i++) {
if (!(doc = virXMLParseStringCtxt(xmlCPUs[i], _("(CPU_definition)"), &ctxt))) if (!(doc = virXMLParseStringCtxt(xmlCPUs[i], _("(CPU_definition)"), &ctxt)))