From 74998ed6627f72ddb86476603cd3546af2d872c3 Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Fri, 17 Mar 2023 14:38:20 +0100 Subject: [PATCH] virQEMUCapsInitGuest: Refactor cleanup and remove return value MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use automatic pointer freeing, remove 'ret' variable and also remove return value completely. Signed-off-by: Peter Krempa Reviewed-by: Ján Tomko --- src/qemu/qemu_capabilities.c | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 28cc92a7fe..0b02c9e6d9 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -984,15 +984,14 @@ virQEMUCapsGetDefaultEmulator(virArch hostarch, } -static int +static void virQEMUCapsInitGuest(virCaps *caps, virFileCache *cache, virArch hostarch, virArch guestarch) { - char *binary = NULL; - virQEMUCaps *qemuCaps = NULL; - int ret = -1; + g_autofree char *binary = NULL; + g_autoptr(virQEMUCaps) qemuCaps = NULL; binary = virQEMUCapsGetDefaultEmulator(hostarch, guestarch); @@ -1000,17 +999,11 @@ virQEMUCapsInitGuest(virCaps *caps, if (binary) { if (!(qemuCaps = virQEMUCapsCacheLookup(cache, binary))) { virResetLastError(); - VIR_FREE(binary); + return; } } virQEMUCapsInitGuestFromBinary(caps, binary, qemuCaps, guestarch); - ret = 0; - - VIR_FREE(binary); - virObjectUnref(qemuCaps); - - return ret; } @@ -1194,10 +1187,7 @@ virQEMUCapsInit(virFileCache *cache) * if a qemu-system-$ARCH binary can't be found */ for (i = 0; i < VIR_ARCH_LAST; i++) - if (virQEMUCapsInitGuest(caps, cache, - hostarch, - i) < 0) - return NULL; + virQEMUCapsInitGuest(caps, cache, hostarch, i); return g_steal_pointer(&caps); }