virDomainSchedulerParse: Refactor cleanup

Automatically free the 'ret' temporary bitmap and get rid of the cleanup
section.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Peter Krempa 2021-12-07 17:16:14 +01:00
parent 473df98ad8
commit 29da6dcc9d

View File

@ -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 NULL;
return ret;
error:
virBitmapFree(ret);
return NULL;
return g_steal_pointer(&ret);
}