mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-24 13:35:17 +00:00
conf: capabilities: 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:
parent
9b0c71a39b
commit
9225b4f116
@ -382,14 +382,10 @@ virCapabilitiesAllocMachines(const char *const *names, int nnames)
|
|||||||
virCapsGuestMachinePtr *machines;
|
virCapsGuestMachinePtr *machines;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
if (VIR_ALLOC_N(machines, nnames) < 0)
|
machines = g_new0(virCapsGuestMachinePtr, nnames);
|
||||||
return NULL;
|
|
||||||
|
|
||||||
for (i = 0; i < nnames; i++) {
|
for (i = 0; i < nnames; i++) {
|
||||||
if (VIR_ALLOC(machines[i]) < 0) {
|
machines[i] = g_new0(virCapsGuestMachine, 1);
|
||||||
virCapabilitiesFreeMachines(machines, nnames);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
machines[i]->name = g_strdup(names[i]);
|
machines[i]->name = g_strdup(names[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -442,8 +438,7 @@ virCapabilitiesAddGuest(virCapsPtr caps,
|
|||||||
{
|
{
|
||||||
virCapsGuestPtr guest;
|
virCapsGuestPtr guest;
|
||||||
|
|
||||||
if (VIR_ALLOC(guest) < 0)
|
guest = g_new0(virCapsGuest, 1);
|
||||||
goto error;
|
|
||||||
|
|
||||||
guest->ostype = ostype;
|
guest->ostype = ostype;
|
||||||
guest->arch.id = arch;
|
guest->arch.id = arch;
|
||||||
@ -492,8 +487,7 @@ virCapabilitiesAddGuestDomain(virCapsGuestPtr guest,
|
|||||||
{
|
{
|
||||||
virCapsGuestDomainPtr dom;
|
virCapsGuestDomainPtr dom;
|
||||||
|
|
||||||
if (VIR_ALLOC(dom) < 0)
|
dom = g_new0(virCapsGuestDomain, 1);
|
||||||
goto error;
|
|
||||||
|
|
||||||
dom->type = hvtype;
|
dom->type = hvtype;
|
||||||
dom->info.emulator = g_strdup(emulator);
|
dom->info.emulator = g_strdup(emulator);
|
||||||
@ -728,8 +722,7 @@ virCapabilitiesDomainDataLookupInternal(virCapsPtr caps,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (VIR_ALLOC(ret) < 0)
|
ret = g_new0(virCapsDomainData, 1);
|
||||||
return ret;
|
|
||||||
|
|
||||||
ret->ostype = foundguest->ostype;
|
ret->ostype = foundguest->ostype;
|
||||||
ret->arch = foundguest->arch.id;
|
ret->arch = foundguest->arch.id;
|
||||||
@ -806,8 +799,7 @@ virCapabilitiesAddStoragePool(virCapsPtr caps,
|
|||||||
{
|
{
|
||||||
virCapsStoragePoolPtr pool;
|
virCapsStoragePoolPtr pool;
|
||||||
|
|
||||||
if (VIR_ALLOC(pool) < 0)
|
pool = g_new0(virCapsStoragePool, 1);
|
||||||
goto error;
|
|
||||||
|
|
||||||
pool->type = poolType;
|
pool->type = poolType;
|
||||||
|
|
||||||
@ -1493,8 +1485,7 @@ virCapabilitiesGetNUMASiblingInfo(int node,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (VIR_ALLOC_N(tmp, ndistances) < 0)
|
tmp = g_new0(virCapsHostNUMACellSiblingInfo, ndistances);
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
for (i = 0; i < ndistances; i++) {
|
for (i = 0; i < ndistances; i++) {
|
||||||
if (!distances[i])
|
if (!distances[i])
|
||||||
@ -1532,8 +1523,7 @@ virCapabilitiesGetNUMAPagesInfo(int node,
|
|||||||
if (virNumaGetPages(node, &pages_size, &pages_avail, NULL, &npages) < 0)
|
if (virNumaGetPages(node, &pages_size, &pages_avail, NULL, &npages) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (VIR_ALLOC_N(*pageinfo, npages) < 0)
|
*pageinfo = g_new0(virCapsHostNUMACellPageInfo, npages);
|
||||||
goto cleanup;
|
|
||||||
*npageinfo = npages;
|
*npageinfo = npages;
|
||||||
|
|
||||||
for (i = 0; i < npages; i++) {
|
for (i = 0; i < npages; i++) {
|
||||||
@ -1572,8 +1562,7 @@ virCapabilitiesHostNUMAInitFake(virCapsHostNUMAPtr caps)
|
|||||||
int nodecpus = nodeinfo.sockets * nodeinfo.cores * nodeinfo.threads;
|
int nodecpus = nodeinfo.sockets * nodeinfo.cores * nodeinfo.threads;
|
||||||
cid = 0;
|
cid = 0;
|
||||||
|
|
||||||
if (VIR_ALLOC_N(cpus, nodecpus) < 0)
|
cpus = g_new0(virCapsHostNUMACellCPU, nodecpus);
|
||||||
return -1;
|
|
||||||
|
|
||||||
for (s = 0; s < nodeinfo.sockets; s++) {
|
for (s = 0; s < nodeinfo.sockets; s++) {
|
||||||
for (c = 0; c < nodeinfo.cores; c++) {
|
for (c = 0; c < nodeinfo.cores; c++) {
|
||||||
@ -1644,8 +1633,7 @@ virCapabilitiesHostNUMAInitReal(virCapsHostNUMAPtr caps)
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (VIR_ALLOC_N(cpus, ncpus) < 0)
|
cpus = g_new0(virCapsHostNUMACellCPU, ncpus);
|
||||||
goto cleanup;
|
|
||||||
cpu = 0;
|
cpu = 0;
|
||||||
|
|
||||||
for (i = 0; i < virBitmapSize(cpumap); i++) {
|
for (i = 0; i < virBitmapSize(cpumap); i++) {
|
||||||
@ -1816,8 +1804,7 @@ virCapabilitiesInitResctrlMemory(virCapsPtr caps)
|
|||||||
|
|
||||||
for (i = 0; i < caps->host.cache.nbanks; i++) {
|
for (i = 0; i < caps->host.cache.nbanks; i++) {
|
||||||
virCapsHostCacheBankPtr bank = caps->host.cache.banks[i];
|
virCapsHostCacheBankPtr bank = caps->host.cache.banks[i];
|
||||||
if (VIR_ALLOC(node) < 0)
|
node = g_new0(virCapsHostMemBWNode, 1);
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
if (virResctrlInfoGetMemoryBandwidth(caps->host.resctrl,
|
if (virResctrlInfoGetMemoryBandwidth(caps->host.resctrl,
|
||||||
bank->level, &node->control) > 0) {
|
bank->level, &node->control) > 0) {
|
||||||
@ -1901,9 +1888,7 @@ virCapabilitiesInitCaches(virCapsPtr caps)
|
|||||||
if (level < cache_min_level)
|
if (level < cache_min_level)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (VIR_ALLOC(bank) < 0)
|
bank = g_new0(virCapsHostCacheBank, 1);
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
bank->level = level;
|
bank->level = level;
|
||||||
|
|
||||||
if (virFileReadValueUint(&bank->id,
|
if (virFileReadValueUint(&bank->id,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user