[libvirt] [PATCH v2 2/4] qemu_firmware: Separate machine and arch matching into a function

Pino Toscano ptoscano at redhat.com
Tue Apr 9 15:25:54 UTC 2019


On Tuesday, 9 April 2019 16:52:56 CEST Michal Privoznik wrote:
> This part of the code will be reused later.
> 
> Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
> ---
>  src/qemu/qemu_firmware.c | 47 +++++++++++++++++++++++++---------------
>  1 file changed, 29 insertions(+), 18 deletions(-)
> 
> diff --git a/src/qemu/qemu_firmware.c b/src/qemu/qemu_firmware.c
> index 065e0d11aa..8e9a225982 100644
> --- a/src/qemu/qemu_firmware.c
> +++ b/src/qemu/qemu_firmware.c
> @@ -1054,6 +1054,34 @@ qemuFirmwareFetchConfigs(char ***firmwares,
>  }
>  
>  
> +static bool
> +qemuFirmwareMatchesMachineArch(const qemuFirmware *fw,
> +                               const char *machine,
> +                               virArch arch)
> +{
> +    size_t i;
> +
> +    for (i = 0; i < fw->ntargets; i++) {
> +        size_t j;
> +
> +        if (arch != fw->targets[i]->architecture)
> +            continue;
> +
> +        for (j = 0; j < fw->targets[i]->nmachines; j++) {
> +            if (fnmatch(fw->targets[i]->machines[j], machine, 0) == 0)
> +                break;
> +        }

Considering this is now an own function, this can just return directly,
removing ...

> +
> +        if (j == fw->targets[i]->nmachines)
> +            continue;
> +
> +        break;

... these bits, and ...

> +    }
> +
> +    return i != fw->ntargets;

... return false here.

Just a suggestion though.

-- 
Pino Toscano
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part.
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20190409/a1f7293d/attachment-0001.sig>


More information about the libvir-list mailing list