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