[vlc-devel] [PATCH 1/2] mpeg: es: fix -Wsign-compare warning

Steve Lhomme robux4 at ycbcr.xyz
Fri Jan 22 06:49:51 UTC 2021


On 2021-01-21 12:49, Alexandre Janniaux wrote:
> ../../modules/demux/mpeg/es.c: In function 'GenericProbe':
> WARNING : ../../modules/demux/mpeg/es.c:827: 35:  comparison of integer expressions of different signedness: 'uint64_t' {aka 'long unsigned int'} and 'ssize_t' {aka 'const long int'} [-Wsign-compare]
>    827 |         if( i_skip + i_check_size > i_peek )
>        |                                   ^
> ---
>   modules/demux/mpeg/es.c | 5 +++--
>   1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/modules/demux/mpeg/es.c b/modules/demux/mpeg/es.c
> index 73449bf2a2..3ff4c05f98 100644
> --- a/modules/demux/mpeg/es.c
> +++ b/modules/demux/mpeg/es.c
> @@ -824,7 +824,8 @@ static int GenericProbe( demux_t *p_demux, uint64_t *pi_offset,
>   
>       for( ;; )
>       {
> -        if( i_skip + i_check_size > i_peek )
> +        /* i_peek > 0 so we can cast into size_t. */

Not only that, but it's already casted to (size_t) on the same line it's 
tested for < 0.
(LGTM)

> +        if( i_skip + i_check_size > (size_t)i_peek )
>           {
>               if( !b_forced_demux )
>                   return VLC_EGENERIC;
> @@ -852,7 +853,7 @@ static int GenericProbe( demux_t *p_demux, uint64_t *pi_offset,
>                       i_size = i_samples * 2 * 2;
>                   }
>   
> -                if( i_skip + i_check_size + i_size <= i_peek )
> +                if( i_skip + i_check_size + i_size <= (size_t)i_peek )
>                   {
>                       b_ok = pf_check( &p_peek[i_skip+i_size], NULL ) >= 0;
>                       if( b_ok )
> -- 
> 2.30.0
> 
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel
> 


More information about the vlc-devel mailing list