mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-25 10:03:49 +03:00
virQEMUCapsInitGuest: Refactor cleanup and remove return value
Use automatic pointer freeing, remove 'ret' variable and also remove return value completely. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
a4c03bdd59
commit
74998ed662
@ -984,15 +984,14 @@ virQEMUCapsGetDefaultEmulator(virArch hostarch,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int
|
static void
|
||||||
virQEMUCapsInitGuest(virCaps *caps,
|
virQEMUCapsInitGuest(virCaps *caps,
|
||||||
virFileCache *cache,
|
virFileCache *cache,
|
||||||
virArch hostarch,
|
virArch hostarch,
|
||||||
virArch guestarch)
|
virArch guestarch)
|
||||||
{
|
{
|
||||||
char *binary = NULL;
|
g_autofree char *binary = NULL;
|
||||||
virQEMUCaps *qemuCaps = NULL;
|
g_autoptr(virQEMUCaps) qemuCaps = NULL;
|
||||||
int ret = -1;
|
|
||||||
|
|
||||||
binary = virQEMUCapsGetDefaultEmulator(hostarch, guestarch);
|
binary = virQEMUCapsGetDefaultEmulator(hostarch, guestarch);
|
||||||
|
|
||||||
@ -1000,17 +999,11 @@ virQEMUCapsInitGuest(virCaps *caps,
|
|||||||
if (binary) {
|
if (binary) {
|
||||||
if (!(qemuCaps = virQEMUCapsCacheLookup(cache, binary))) {
|
if (!(qemuCaps = virQEMUCapsCacheLookup(cache, binary))) {
|
||||||
virResetLastError();
|
virResetLastError();
|
||||||
VIR_FREE(binary);
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
virQEMUCapsInitGuestFromBinary(caps, binary, qemuCaps, guestarch);
|
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
|
* if a qemu-system-$ARCH binary can't be found
|
||||||
*/
|
*/
|
||||||
for (i = 0; i < VIR_ARCH_LAST; i++)
|
for (i = 0; i < VIR_ARCH_LAST; i++)
|
||||||
if (virQEMUCapsInitGuest(caps, cache,
|
virQEMUCapsInitGuest(caps, cache, hostarch, i);
|
||||||
hostarch,
|
|
||||||
i) < 0)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
return g_steal_pointer(&caps);
|
return g_steal_pointer(&caps);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user