[vlc-commits] mpeg: es: fix -Wsign-compare warning

Alexandre Janniaux git at videolan.org
Mon Jan 25 11:37:25 UTC 2021


vlc | branch: master | Alexandre Janniaux <ajanni at videolabs.io> | Thu Jan 21 10:47:51 2021 +0100| [4a1ea13002f76cc6ee33273baf506910904038bf] | committer: Alexandre Janniaux

mpeg: es: fix -Wsign-compare warning

../../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 )
      |                                   ^

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=4a1ea13002f76cc6ee33273baf506910904038bf
---

 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. */
+        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 )



More information about the vlc-commits mailing list