[vlc-devel] control: size_t is an unsigned integer

Rémi Denis-Courmont remi at remlab.net
Fri Mar 2 21:59:16 CET 2018


Le perjantaina 2. maaliskuuta 2018, 17.28.51 EET Matthew Whitworth a écrit :
> cppcheck 1.82 picked this up.
> 
> ---
> diff --git a/src/input/control.c b/src/input/control.c
> index 1ecf8529e1..80f86e3a75 100644
> --- a/src/input/control.c
> +++ b/src/input/control.c
> @@ -542,7 +542,7 @@ int input_vaControl( input_thread_t *p_input, int
> i_query, va_list args )
>              size_t *pi_vout = va_arg( args, size_t * );
> 
>              input_resource_HoldVouts( priv->p_resource, ppp_vout, pi_vout
> ); -            if( *pi_vout <= 0 )
> +            if( *pi_vout == 0 )

Sorry but I just don't see what this fixes?

Insofar as the pi_vout is a pointer to unsigned, the code is exactly the same. 
This is guaranteed by the ISO C specification. If pi_vout is ever changed to 
be signed with, say, negative values indicating error, the original code is 
correct and the patch code is wrong.

So this really only makes the code actually identically good, and potentially 
worse. That is not an improvement, if you ask me.

-- 
雷米‧德尼-库尔蒙
https://www.remlab.net/



More information about the vlc-devel mailing list