From 29da6dcc9d8f0ff0180a23f81183139c99c46ccf Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Tue, 7 Dec 2021 17:16:14 +0100 Subject: [PATCH] virDomainSchedulerParse: Refactor cleanup MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Automatically free the 'ret' temporary bitmap and get rid of the cleanup section. Signed-off-by: Peter Krempa Reviewed-by: Ján Tomko --- src/conf/domain_conf.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 107d2a4f5d..c634e7dd41 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -17977,34 +17977,30 @@ virDomainSchedulerParse(xmlNodePtr node, virProcessSchedPolicy *policy, int *priority) { - virBitmap *ret = NULL; + g_autoptr(virBitmap) ret = NULL; g_autofree char *tmp = NULL; if (!(tmp = virXMLPropString(node, attributeName))) { virReportError(VIR_ERR_XML_ERROR, _("Missing attribute '%s' in element '%s'"), attributeName, elementName); - goto error; + return NULL; } if (virBitmapParse(tmp, &ret, VIR_DOMAIN_CPUMASK_LEN) < 0) - goto error; + return NULL; if (virBitmapIsAllClear(ret)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("'%s' scheduler bitmap '%s' is empty"), attributeName, tmp); - goto error; + return NULL; } if (virDomainSchedulerParseCommonAttrs(node, policy, priority) < 0) - goto error; - - return ret; + return NULL; - error: - virBitmapFree(ret); - return NULL; + return g_steal_pointer(&ret); } -- 2.47.2