1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-03-07 17:28:15 +00:00

qemuDomainSelectHotplugVcpuEntities: Refactor cleanup

Use automatic memory freeing for the 'ret' bitmap and remove the
pointless '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:22:26 +01:00
parent 4ab26d3e3e
commit 5b7653a628

View File

@ -6473,7 +6473,7 @@ qemuDomainSelectHotplugVcpuEntities(virDomainDef *def,
unsigned int nvcpus, unsigned int nvcpus,
bool *enable) bool *enable)
{ {
virBitmap *ret = NULL; g_autoptr(virBitmap) ret = NULL;
virDomainVcpuDef *vcpu; virDomainVcpuDef *vcpu;
qemuDomainVcpuPrivate *vcpupriv; qemuDomainVcpuPrivate *vcpupriv;
unsigned int maxvcpus = virDomainDefGetVcpusMax(def); unsigned int maxvcpus = virDomainDefGetVcpusMax(def);
@ -6501,7 +6501,7 @@ qemuDomainSelectHotplugVcpuEntities(virDomainDef *def,
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("target vm vcpu granularity does not allow the " _("target vm vcpu granularity does not allow the "
"desired vcpu count")); "desired vcpu count"));
goto error; return NULL;
} }
ignore_value(virBitmapSetBit(ret, i)); ignore_value(virBitmapSetBit(ret, i));
@ -6528,7 +6528,7 @@ qemuDomainSelectHotplugVcpuEntities(virDomainDef *def,
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("target vm vcpu granularity does not allow the " _("target vm vcpu granularity does not allow the "
"desired vcpu count")); "desired vcpu count"));
goto error; return NULL;
} }
ignore_value(virBitmapSetBit(ret, i)); ignore_value(virBitmapSetBit(ret, i));
@ -6539,14 +6539,10 @@ qemuDomainSelectHotplugVcpuEntities(virDomainDef *def,
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("failed to find appropriate hotpluggable vcpus to " _("failed to find appropriate hotpluggable vcpus to "
"reach the desired target vcpu count")); "reach the desired target vcpu count"));
goto error; return NULL;
} }
return ret; return g_steal_pointer(&ret);
error:
virBitmapFree(ret);
return NULL;
} }