No need for the cleanup section once we switch to g_autoptr. Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx> --- src/qemu/qemu_driver.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 4e680bc0a7..5330a1d3b7 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -9975,24 +9975,23 @@ qemuDomainBlocksStatsGather(virQEMUDriver *driver, qemuDomainObjPrivate *priv = vm->privateData; bool blockdev = virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV); virDomainDiskDef *disk = NULL; - GHashTable *blockstats = NULL; + g_autoptr(GHashTable) blockstats = NULL; qemuBlockStats *stats; size_t i; int nstats; int rc = 0; const char *entryname = NULL; - int ret = -1; if (*path) { if (!(disk = virDomainDiskByName(vm->def, path, false))) { virReportError(VIR_ERR_INVALID_ARG, _("invalid path: %s"), path); - goto cleanup; + return -1; } if (virStorageSourceGetActualType(disk->src) == VIR_STORAGE_TYPE_VHOST_USER) { virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", _("block stats are not supported for vhostuser disk")); - goto cleanup; + return -1; } if (blockdev && QEMU_DOMAIN_DISK_PRIVATE(disk)->qomName) { @@ -10001,7 +10000,7 @@ qemuDomainBlocksStatsGather(virQEMUDriver *driver, if (!disk->info.alias) { virReportError(VIR_ERR_INTERNAL_ERROR, _("missing disk device alias name for %s"), disk->dst); - goto cleanup; + return -1; } entryname = disk->info.alias; @@ -10019,7 +10018,7 @@ qemuDomainBlocksStatsGather(virQEMUDriver *driver, } if (qemuDomainObjExitMonitor(driver, vm) < 0 || nstats < 0 || rc < 0) - goto cleanup; + return -1; *retstats = g_new0(qemuBlockStats, 1); @@ -10027,7 +10026,7 @@ qemuDomainBlocksStatsGather(virQEMUDriver *driver, if (!(stats = virHashLookup(blockstats, entryname))) { virReportError(VIR_ERR_INTERNAL_ERROR, _("cannot find statistics for device '%s'"), entryname); - goto cleanup; + return -1; } **retstats = *stats; @@ -10063,18 +10062,14 @@ qemuDomainBlocksStatsGather(virQEMUDriver *driver, if (!(stats = virHashLookup(blockstats, entryname))) { virReportError(VIR_ERR_INTERNAL_ERROR, _("cannot find statistics for device '%s'"), entryname); - goto cleanup; + return -1; } qemuDomainBlockStatsGatherTotals(stats, *retstats); } } - ret = nstats; - - cleanup: - virHashFree(blockstats); - return ret; + return nstats; } -- 2.31.1