From: Peter Krempa Date: Tue, 7 Dec 2021 16:22:26 +0000 (+0100) Subject: qemuDomainSelectHotplugVcpuEntities: Refactor cleanup X-Git-Tag: v8.0.0-rc1~321 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5b7653a628120cb3cc3292befbe1fa8074a48f67;p=thirdparty%2Flibvirt.git qemuDomainSelectHotplugVcpuEntities: Refactor cleanup Use automatic memory freeing for the 'ret' bitmap and remove the pointless 'cleanup' section. Signed-off-by: Peter Krempa Reviewed-by: Ján Tomko --- diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 2e1d18c633..f307420ac1 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -6473,7 +6473,7 @@ qemuDomainSelectHotplugVcpuEntities(virDomainDef *def, unsigned int nvcpus, bool *enable) { - virBitmap *ret = NULL; + g_autoptr(virBitmap) ret = NULL; virDomainVcpuDef *vcpu; qemuDomainVcpuPrivate *vcpupriv; unsigned int maxvcpus = virDomainDefGetVcpusMax(def); @@ -6501,7 +6501,7 @@ qemuDomainSelectHotplugVcpuEntities(virDomainDef *def, virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("target vm vcpu granularity does not allow the " "desired vcpu count")); - goto error; + return NULL; } ignore_value(virBitmapSetBit(ret, i)); @@ -6528,7 +6528,7 @@ qemuDomainSelectHotplugVcpuEntities(virDomainDef *def, virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("target vm vcpu granularity does not allow the " "desired vcpu count")); - goto error; + return NULL; } ignore_value(virBitmapSetBit(ret, i)); @@ -6539,14 +6539,10 @@ qemuDomainSelectHotplugVcpuEntities(virDomainDef *def, virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("failed to find appropriate hotpluggable vcpus to " "reach the desired target vcpu count")); - goto error; + return NULL; } - return ret; - - error: - virBitmapFree(ret); - return NULL; + return g_steal_pointer(&ret); }