mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-07-31 22:17:17 +00:00
virDomainResctrlNew: Refactor allocation to remove 'cleanup' label
If we use g_new0 there's no need for the 'cleanup' label as there's nothing to fail after the allocation. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
30ff783a80
commit
f12f4e2658
@ -20900,7 +20900,6 @@ virDomainResctrlNew(xmlNodePtr node,
|
|||||||
unsigned int flags)
|
unsigned int flags)
|
||||||
{
|
{
|
||||||
virDomainResctrlDefPtr resctrl = NULL;
|
virDomainResctrlDefPtr resctrl = NULL;
|
||||||
virDomainResctrlDefPtr ret = NULL;
|
|
||||||
g_autofree char *vcpus_str = NULL;
|
g_autofree char *vcpus_str = NULL;
|
||||||
g_autofree char *alloc_id = NULL;
|
g_autofree char *alloc_id = NULL;
|
||||||
|
|
||||||
@ -20923,18 +20922,13 @@ virDomainResctrlNew(xmlNodePtr node,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (virResctrlAllocSetID(alloc, alloc_id) < 0)
|
if (virResctrlAllocSetID(alloc, alloc_id) < 0)
|
||||||
goto cleanup;
|
return NULL;
|
||||||
|
|
||||||
if (VIR_ALLOC(resctrl) < 0)
|
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
|
resctrl = g_new0(virDomainResctrlDef, 1);
|
||||||
resctrl->vcpus = virBitmapNewCopy(vcpus);
|
resctrl->vcpus = virBitmapNewCopy(vcpus);
|
||||||
resctrl->alloc = virObjectRef(alloc);
|
resctrl->alloc = virObjectRef(alloc);
|
||||||
|
|
||||||
ret = g_steal_pointer(&resctrl);
|
return resctrl;
|
||||||
cleanup:
|
|
||||||
virDomainResctrlDefFree(resctrl);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user