qemuProcessRefreshDisks: Automatically free GHashTable and refactor cleanup

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
This commit is contained in:
Peter Krempa 2021-11-30 11:49:24 +01:00
parent 7ef8e9af6f
commit 2e93441697
1 changed files with 3 additions and 8 deletions

View File

@ -8310,8 +8310,7 @@ qemuProcessRefreshDisks(virQEMUDriver *driver,
{ {
qemuDomainObjPrivate *priv = vm->privateData; qemuDomainObjPrivate *priv = vm->privateData;
bool blockdev = virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV); bool blockdev = virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV);
GHashTable *table = NULL; g_autoptr(GHashTable) table = NULL;
int ret = -1;
size_t i; size_t i;
if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) == 0) { if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) == 0) {
@ -8320,7 +8319,7 @@ qemuProcessRefreshDisks(virQEMUDriver *driver,
} }
if (!table) if (!table)
goto cleanup; return -1;
for (i = 0; i < vm->def->ndisks; i++) { for (i = 0; i < vm->def->ndisks; i++) {
virDomainDiskDef *disk = vm->def->disks[i]; virDomainDiskDef *disk = vm->def->disks[i];
@ -8351,11 +8350,7 @@ qemuProcessRefreshDisks(virQEMUDriver *driver,
diskpriv->tray = info->tray; diskpriv->tray = info->tray;
} }
ret = 0; return 0;
cleanup:
virHashFree(table);
return ret;
} }