Use the g_auto macros wherever possible to eliminate the cleanup section. Signed-off-by: Ján Tomko <jtomko@xxxxxxxxxx> --- src/qemu/qemu_tpm.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/qemu/qemu_tpm.c b/src/qemu/qemu_tpm.c index 262e6c4f07..c2132250eb 100644 --- a/src/qemu/qemu_tpm.c +++ b/src/qemu/qemu_tpm.c @@ -794,12 +794,12 @@ qemuExtTPMStartEmulator(virQEMUDriverPtr driver, bool incomingMigration) { int ret = -1; - virCommandPtr cmd = NULL; + g_autoptr(virCommand) cmd = NULL; int exitstatus = 0; - char *errbuf = NULL; - virQEMUDriverConfigPtr cfg; + g_autofree char *errbuf = NULL; + g_autoptr(virQEMUDriverConfig) cfg = NULL; virDomainTPMDefPtr tpm = vm->def->tpm; - char *shortName = virDomainDefGetShortName(vm->def); + g_autofree char *shortName = virDomainDefGetShortName(vm->def); int cmdret = 0, timeout, rc; pid_t pid; @@ -855,12 +855,6 @@ qemuExtTPMStartEmulator(virQEMUDriverPtr driver, ret = 0; cleanup: - VIR_FREE(shortName); - VIR_FREE(errbuf); - virCommandFree(cmd); - - virObjectUnref(cfg); - return ret; error: -- 2.21.0