From f12f4e2658f187943640d287d7dd5e665156c558 Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Fri, 2 Oct 2020 10:36:59 +0200 Subject: [PATCH] virDomainResctrlNew: Refactor allocation to remove 'cleanup' label MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Ján Tomko --- 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..175b632a38 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 resctrl; } -- 2.47.2