Use g_autoptr() and remove the 'cleanup' label. Signed-off-by: Daniel Henrique Barboza <danielhb413@xxxxxxxxx> --- src/qemu/qemu_migration.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index d8f2aeb9f0..c8bb0a6060 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -4926,13 +4926,12 @@ qemuMigrationDstPersist(virQEMUDriverPtr driver, qemuMigrationCookiePtr mig, bool ignoreSaveError) { - virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver); + g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver); qemuDomainObjPrivatePtr priv = vm->privateData; virDomainDefPtr vmdef; - virDomainDefPtr oldDef = NULL; + g_autoptr(virDomainDef) oldDef = NULL; unsigned int oldPersist = vm->persistent; virObjectEventPtr event; - int ret = -1; vm->persistent = 1; oldDef = vm->newDef; @@ -4953,19 +4952,14 @@ qemuMigrationDstPersist(virQEMUDriverPtr driver, VIR_DOMAIN_EVENT_DEFINED_ADDED); virObjectEventStateQueue(driver->domainEventState, event); - ret = 0; - - cleanup: - virDomainDefFree(oldDef); - virObjectUnref(cfg); - return ret; + return 0; error: virDomainDefFree(vm->newDef); vm->persistent = oldPersist; vm->newDef = oldDef; oldDef = NULL; - goto cleanup; + return -1; } -- 2.26.2