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>
This commit is contained in:
Andrea Bolognani 2022-03-31 10:56:55 +02:00
parent f3248cca90
commit c890c4962f

View File

@ -919,7 +919,7 @@ static char *
virQEMUCapsFindBinaryForArch(virArch hostarch,
virArch guestarch)
{
char *ret = NULL;
char *binary;
const char *archstr;
virArch target;
@ -928,24 +928,24 @@ virQEMUCapsFindBinaryForArch(virArch hostarch,
* 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;
}