Use modern memory handling approach to simplify the code.
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
src/qemu/qemu_migration_cookie.c | 13 +++----------
1 file changed, 3 insertions(+), 10 deletions(-)
diff --git a/src/qemu/qemu_migration_cookie.c b/src/qemu/qemu_migration_cookie.c
index b71ff7bf9d..f63e3d7e12 100644
--- a/src/qemu/qemu_migration_cookie.c
+++ b/src/qemu/qemu_migration_cookie.c
@@ -192,13 +192,10 @@ qemuMigrationCookieGraphicsSpiceAlloc(virQEMUDriverPtr driver,
virDomainGraphicsDefPtr def,
virDomainGraphicsListenDefPtr glisten)
{
- qemuMigrationCookieGraphicsPtr mig = NULL;
+ g_autoptr(qemuMigrationCookieGraphics) mig = g_new0(qemuMigrationCookieGraphics, 1);
const char *listenAddr;
g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver);
- if (VIR_ALLOC(mig) < 0)
- goto error;
-
mig->type = VIR_DOMAIN_GRAPHICS_TYPE_SPICE;
mig->port = def->data.spice.port;
if (cfg->spiceTLS)
@@ -211,15 +208,11 @@ qemuMigrationCookieGraphicsSpiceAlloc(virQEMUDriverPtr driver,
if (cfg->spiceTLS &&
!(mig->tlsSubject =
qemuDomainExtractTLSSubject(cfg->spiceTLSx509certdir)))
- goto error;
+ return NULL;
mig->listen = g_strdup(listenAddr);
- return mig;
-
- error:
- qemuMigrationCookieGraphicsFree(mig);
- return NULL;
+ return g_steal_pointer(&mig);
}
--
2.26.2