[PATCH 5/6] virDomainResctrlNew: Refactor allocation to remove 'cleanup' label
Ján Tomko
jtomko at redhat.com
Fri Oct 2 12:31:43 UTC 2020
On a Friday in 2020, Peter Krempa wrote:
>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 at redhat.com>
>---
> src/conf/domain_conf.c | 12 +++---------
> 1 file changed, 3 insertions(+), 9 deletions(-)
>
>diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
>index f716338efd..0d93ae3341 100644
>--- a/src/conf/domain_conf.c
>+++ b/src/conf/domain_conf.c
>@@ -20900,7 +20900,6 @@ virDomainResctrlNew(xmlNodePtr node,
> unsigned int flags)
> {
> virDomainResctrlDefPtr resctrl = NULL;
>- virDomainResctrlDefPtr ret = NULL;
> g_autofree char *vcpus_str = NULL;
> g_autofree char *alloc_id = NULL;
>
>@@ -20923,18 +20922,13 @@ virDomainResctrlNew(xmlNodePtr node,
> }
>
> if (virResctrlAllocSetID(alloc, alloc_id) < 0)
>- goto cleanup;
>-
>- if (VIR_ALLOC(resctrl) < 0)
>- goto cleanup;
>+ return NULL;
>
>+ resctrl = g_new0(virDomainResctrlDef, 1);
> resctrl->vcpus = virBitmapNewCopy(vcpus);
> resctrl->alloc = virObjectRef(alloc);
>
>- ret = g_steal_pointer(&resctrl);
>- cleanup:
>- virDomainResctrlDefFree(resctrl);
>- return ret;
>+ return g_steal_pointer(&resctrl);
> }
There is no need to steal the pointer.
Reviewed-by: Ján Tomko <jtomko at redhat.com>
Jano
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20201002/5f74c0a5/attachment-0001.sig>
More information about the libvir-list
mailing list