qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [RFC PATCH 32/34] loader: allow arbitrary basename for


From: Paolo Bonzini
Subject: Re: [Qemu-devel] [RFC PATCH 32/34] loader: allow arbitrary basename for fw_cfg file roms
Date: Wed, 7 Feb 2018 12:22:58 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2

On 06/02/2018 21:30, Roman Kagan wrote:
> +        basename = strrchr(fw_path, '/');
> +        if (basename && basename[1] == '\0') {
> +            /* given path terminates with '/', append basename(file) */
> +            basename = strrchr(file, '/');
> +            if (basename) {
> +                basename++;
> +            } else {
> +                basename = file;
> +            }
> +
> +            rom->fw_file = g_strdup_printf("%s%s", fw_path, basename);
>          } else {
> -            basename = rom->fw_file;
> +            rom->fw_file = g_strdup(fw_path);
>          }

Reusing basename is a bit unclear.  Maybe:

        assert(*fw_path);
        if (fw_path[strlen(fw_path) - 1] == '/') {
            /* given path terminates with '/', append basename(file) */
            const char *basename = strrchr(file, '/');
            if (basename) {
                basename++;
            } else {
                basename = file;
            }
            rom->fw_file = g_strdup_printf("%s%s", fw_path, basename);
        } else {
            rom->fw_file = g_strdup(fw_path);
        }

Thanks,

Paolo



reply via email to

[Prev in Thread] Current Thread [Next in Thread]