File c890c496-qemu-cleanup-virQEMUCapsFindBinaryForArch.patch of Package libvirt.26629
commit c890c4962f89b71fdfb7f06207e116e3ce16ba80
Author: Andrea Bolognani <abologna@redhat.com>
Date: Thu Mar 31 10:56:55 2022 +0200
qemu: Clean up virQEMUCapsFindBinaryForArch()
If we get to the bottom of the function we know that none of the
attempts to locate a QEMU binary has been successful, so we can
simply return NULL directly.
This makes it unnecessary variable used to store the path, for
which we can use a more descriptive name.
Lastly, comparing with NULL explicitly is somewhat uncommon in
libvirt and more verbose than the equivalent implicit comparison,
so get rid of it.
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Tested-by: Jim Fehlig <jfehlig@suse.com>
Index: libvirt-8.0.0/src/qemu/qemu_capabilities.c
===================================================================
--- libvirt-8.0.0.orig/src/qemu/qemu_capabilities.c
+++ libvirt-8.0.0/src/qemu/qemu_capabilities.c
@@ -877,7 +877,7 @@ static char *
virQEMUCapsFindBinaryForArch(virArch hostarch,
virArch guestarch)
{
- char *ret = NULL;
+ char *binary;
const char *archstr;
virArch target;
@@ -886,24 +886,24 @@ virQEMUCapsFindBinaryForArch(virArch hos
* to avoid using qemu-system-arm (and thus TCG) instead */
if (hostarch == VIR_ARCH_AARCH64 && guestarch == VIR_ARCH_ARMV7L) {
archstr = virQEMUCapsArchToString(hostarch);
- if ((ret = virQEMUCapsFindBinary("qemu-system-%s", archstr)) != NULL)
- return ret;
+ if ((binary = virQEMUCapsFindBinary("qemu-system-%s", archstr)))
+ return binary;
}
/* First attempt: try the guest architecture as it is */
archstr = virQEMUCapsArchToString(guestarch);
- if ((ret = virQEMUCapsFindBinary("qemu-system-%s", archstr)) != NULL)
- return ret;
+ if ((binary = virQEMUCapsFindBinary("qemu-system-%s", archstr)))
+ return binary;
/* Second attempt: try looking up by target instead */
target = virQEMUCapsFindTarget(hostarch, guestarch);
if (target != guestarch) {
archstr = virQEMUCapsArchToString(target);
- if ((ret = virQEMUCapsFindBinary("qemu-system-%s", archstr)) != NULL)
- return ret;
+ if ((binary = virQEMUCapsFindBinary("qemu-system-%s", archstr)))
+ return binary;
}
- return ret;
+ return NULL;
}