[vlc-devel] [PATCH] linux/dirs: fix condition checks
Zhao Zhili
quinkblack at foxmail.com
Fri Nov 2 05:50:26 CET 2018
On 2018年11月01日 22:26, Rémi Denis-Courmont wrote:
> Le jeudi 1 novembre 2018, 04:59:55 EET Zhao Zhili a écrit :
>> ---
>> src/linux/dirs.c | 9 +++++----
>> 1 file changed, 5 insertions(+), 4 deletions(-)
>>
>> diff --git a/src/linux/dirs.c b/src/linux/dirs.c
>> index f5dbdaa..b8ad5b9 100644
>> --- a/src/linux/dirs.c
>> +++ b/src/linux/dirs.c
>> @@ -60,10 +60,11 @@ static char *config_GetLibDirRaw(void)
>> if (dir == NULL)
>> continue;
>>
>> - char *file = strrchr (line, '/');
>> - if (end == NULL)
>> - continue;
>> - *file = '\0';
>> + char *file = strrchr (dir, '/');
>> + if (likely(file != dir))
>> + *file = '\0';
>> + else /* install libs at the root directory, unlikely */
>> + *(file + 1) = '\0';
> The existing callers expect the string to terminate without a slash.
> Admittedly, that is bad practice, or arguably even a bug, in the case of root
> directory.
>
> But if we are going to include the final slash in the root case, we should
> include it in all cases. And in any case case, the call sites must be fixed
> accordingly.
>
I'm not clear about the use case, and I'm not bold enough to
install libs under the root directory. It should never happen.
If it's OK, I will just remove the legacy code of checking on
end == NULL and keep other stuff as they are.
More information about the vlc-devel
mailing list