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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
> ---
>  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

Attachment: signature.asc
Description: This is a digitally signed message part.

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux