]> git.sesse.net Git - vlc/commitdiff
- Fix a bunch of warnings
authorRémi Denis-Courmont <rem@videolan.org>
Fri, 20 Jul 2007 14:34:20 +0000 (14:34 +0000)
committerRémi Denis-Courmont <rem@videolan.org>
Fri, 20 Jul 2007 14:34:20 +0000 (14:34 +0000)
- Fix a bunch of abuse of strncmp (memcmp rulez)

13 files changed:
modules/demux/Modules.am
modules/demux/a52.c
modules/demux/aiff.c
modules/demux/au.c
modules/demux/dts.c
modules/demux/flac.c
modules/demux/live555.cpp
modules/demux/nsv.c
modules/demux/ogg.c
modules/demux/rawdv.c
modules/demux/rawvid.c
modules/demux/real.c
modules/demux/wav.c

index 21718dfb223e21a372f86e7931d623ee0c21ac70..f6c92a5daed3a8bb53fc82b60e2f100ec4c104ca 100644 (file)
@@ -28,3 +28,4 @@ SOURCES_mpc = mpc.c
 SOURCES_gme = gme.cpp
 SOURCES_tta = tta.c
 SOURCES_vc1 = vc1.c
+SOURCES_rtp = rtp.c
index 12062db730d139188a5e1288192c270f08f2890c..c19831d671daf8018df936a95ae8cc13cf358005 100644 (file)
@@ -1,7 +1,7 @@
 /*****************************************************************************
  * a52.c : raw A/52 stream input module for vlc
  *****************************************************************************
- * Copyright (C) 2001 the VideoLAN team
+ * Copyright (C) 2001-2007 the VideoLAN team
  * $Id$
  *
  * Authors: Gildas Bazin <gbazin@netcourrier.com>
@@ -65,7 +65,7 @@ struct demux_sys_t
     vlc_bool_t b_big_endian;
 };
 
-static int CheckSync( uint8_t *p_peek, vlc_bool_t *p_big_endian );
+static int CheckSync( const uint8_t *p_peek, vlc_bool_t *p_big_endian );
 
 #define PCM_FRAME_SIZE (1536 * 4)
 #define A52_PACKET_SIZE (4 * PCM_FRAME_SIZE)
@@ -79,7 +79,7 @@ static int Open( vlc_object_t * p_this )
 {
     demux_t     *p_demux = (demux_t*)p_this;
     demux_sys_t *p_sys;
-    byte_t      *p_peek;
+    const byte_t*p_peek;
     int         i_peek = 0;
     vlc_bool_t  b_big_endian = 0; /* Arbitrary initialisation */
 
@@ -257,7 +257,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
 /*****************************************************************************
  * CheckSync: Check if buffer starts with an A52 sync code
  *****************************************************************************/
-static int CheckSync( uint8_t *p_peek, vlc_bool_t *p_big_endian )
+static int CheckSync( const uint8_t *p_peek, vlc_bool_t *p_big_endian )
 {
     /* Little endian version of the bitstream */
     if( p_peek[0] == 0x77 && p_peek[1] == 0x0b &&
index 8a5e80ebaeab51c26173d3c14321ed121d2e522e..51ed29b2c3f7b3a591717dd5bd4875056ee8fa69 100644 (file)
@@ -1,7 +1,7 @@
 /*****************************************************************************
  * aiff.c: Audio Interchange File Format demuxer
  *****************************************************************************
- * Copyright (C) 2004 the VideoLAN team
+ * Copyright (C) 2004-2007 the VideoLAN team
  * $Id$
  *
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
@@ -101,11 +101,12 @@ static int Open( vlc_object_t *p_this )
     demux_t     *p_demux = (demux_t*)p_this;
     demux_sys_t *p_sys;
 
-    uint8_t     *p_peek;
+    const uint8_t *p_peek;
 
     if( stream_Peek( p_demux->s, &p_peek, 12 ) < 12 )
         return VLC_EGENERIC;
-    if( strncmp( (char *)&p_peek[0], "FORM", 4 ) || strncmp( (char *)&p_peek[8], "AIFF", 4 ) )
+    if( memcmp( p_peek, "FORM", 4 )
+     || memcmp( &p_peek[8], "AIFF", 4 ) )
         return VLC_EGENERIC;
 
     /* skip aiff header */
@@ -126,7 +127,7 @@ static int Open( vlc_object_t *p_this )
 
         msg_Dbg( p_demux, "chunk fcc=%4.4s size=%d", p_peek, i_size );
 
-        if( !strncmp( (char *)&p_peek[0], "COMM", 4 ) )
+        if( !memcmp( p_peek, "COMM", 4 ) )
         {
             CHECK_PEEK_GOTO( p_peek, 18+8 );
             es_format_Init( &p_sys->fmt, AUDIO_ES, VLC_FOURCC( 't', 'w', 'o', 's' ) );
@@ -137,7 +138,7 @@ static int Open( vlc_object_t *p_this )
             msg_Dbg( p_demux, "COMM: channels=%d samples_frames=%d bits=%d rate=%d",
                      GetWBE( &p_peek[8] ), GetDWBE( &p_peek[10] ), GetWBE( &p_peek[14] ), GetF80BE( &p_peek[16] ) );
         }
-        else if( !strncmp( (char *)&p_peek[0], "SSND", 4 ) )
+        else if( !memcmp( p_peek, "SSND", 4 ) )
         {
             CHECK_PEEK_GOTO( p_peek, 8+8 );
             p_sys->i_ssnd_pos = stream_Tell( p_demux->s );
index 9663de597a0cff6ce908e60fcfb467858d6ff948..eaeca1b42d4345c30de54b91df2ce24a111cc554 100644 (file)
@@ -1,7 +1,7 @@
 /*****************************************************************************
  * au.c : au file input module for vlc
  *****************************************************************************
- * Copyright (C) 2001-2003 the VideoLAN team
+ * Copyright (C) 2001-2007 the VideoLAN team
  * $Id$
  *
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
@@ -101,7 +101,7 @@ static int Open( vlc_object_t *p_this )
     demux_sys_t *p_sys;
 
     uint8_t      hdr[20];
-    uint8_t     *p_peek;
+    const uint8_t *p_peek;
     int          i_cat;
     int          i_samples, i_modulo;
 
index 437e07db3ddce8e34f14ba113357c617e0eca583..0cdd85afe6a77fb2b69a636a3516e2e617660945 100644 (file)
@@ -1,7 +1,7 @@
 /*****************************************************************************
  * dts.c : raw DTS stream input module for vlc
  *****************************************************************************
- * Copyright (C) 2001 the VideoLAN team
+ * Copyright (C) 2001-2007 the VideoLAN team
  * $Id$
  *
  * Authors: Gildas Bazin <gbazin@netcourrier.com>
@@ -60,7 +60,7 @@ struct demux_sys_t
     int i_mux_rate;
 };
 
-static int CheckSync( uint8_t *p_peek );
+static int CheckSync( const uint8_t *p_peek );
 
 #define DTS_PACKET_SIZE 16384
 #define DTS_PROBE_SIZE (DTS_PACKET_SIZE * 4)
@@ -73,7 +73,7 @@ static int Open( vlc_object_t * p_this )
 {
     demux_t     *p_demux = (demux_t*)p_this;
     demux_sys_t *p_sys;
-    byte_t *     p_peek;
+    const byte_t *p_peek;
     int          i_peek = 0;
 
     /* Check if we are dealing with a WAV file */
@@ -237,7 +237,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
 /*****************************************************************************
  * CheckSync: Check if buffer starts with a DTS sync code
  *****************************************************************************/
-static int CheckSync( uint8_t *p_peek )
+static int CheckSync( const uint8_t *p_peek )
 {
     /* 14 bits, little endian version of the bitstream */
     if( p_peek[0] == 0xff && p_peek[1] == 0x1f &&
index 2b3050ea9ff854df1bf1d17647c78748acba443b..d9dd781a5389b1512d1f48f08d14f51c0a2f5f4c 100644 (file)
@@ -1,7 +1,7 @@
 /*****************************************************************************
  * flac.c : FLAC demux module for vlc
  *****************************************************************************
- * Copyright (C) 2001-2003 the VideoLAN team
+ * Copyright (C) 2001-2007 the VideoLAN team
  * $Id$
  *
  * Authors: Gildas Bazin <gbazin@netcourrier.com>
@@ -31,6 +31,7 @@
 #include <vlc_input.h>
 #include <vlc_codec.h>
 #include <assert.h>
+#include <vlc_charset.h>
 
 /*****************************************************************************
  * Module descriptor
@@ -94,7 +95,7 @@ static int Open( vlc_object_t * p_this )
     demux_t     *p_demux = (demux_t*)p_this;
     module_t    *p_id3;
     demux_sys_t *p_sys;
-    byte_t      *p_peek;
+    const byte_t *p_peek;
     uint8_t     *p_streaminfo;
     int         i_streaminfo;
 
@@ -280,11 +281,13 @@ static int64_t ControlGetLength( demux_t *p_demux )
     }
     return i_length;
 }
+
 static int64_t ControlGetTime( demux_t *p_demux )
 {
     demux_sys_t *p_sys = p_demux->p_sys;
     return __MAX(p_sys->i_pts, p_sys->i_pts_start) + p_sys->i_time_offset;
 }
+
 static int ControlSetTime( demux_t *p_demux, int64_t i_time )
 {
     demux_sys_t *p_sys = p_demux->p_sys;
@@ -413,21 +416,22 @@ enum
     META_PICTURE = 6,
 };
 
-static inline int Get24bBE( uint8_t *p )
+static inline int Get24bBE( const uint8_t *p )
 {
     return (p[0] << 16)|(p[1] << 8)|(p[2]);
 }
 
 static void ParseStreamInfo( demux_t *p_demux, int *pi_rate, int64_t *pi_count, uint8_t *p_data, int i_data );
-static void ParseSeekTable( demux_t *p_demux, uint8_t *p_data, int i_data, int i_sample_rate );
-static void ParseComment( demux_t *, uint8_t *p_data, int i_data );
-static void ParsePicture( demux_t *, uint8_t *p_data, int i_data );
+static void ParseSeekTable( demux_t *p_demux, const uint8_t *p_data, int i_data,
+                            int i_sample_rate );
+static void ParseComment( demux_t *, const uint8_t *p_data, int i_data );
+static void ParsePicture( demux_t *, const uint8_t *p_data, int i_data );
 
 static int  ReadMeta( demux_t *p_demux, uint8_t **pp_streaminfo, int *pi_streaminfo )
 {
     demux_sys_t *p_sys = p_demux->p_sys;
     int     i_peek;
-    uint8_t *p_peek;
+    const uint8_t *p_peek;
     vlc_bool_t b_last;
     int i_sample_rate;
     int64_t i_sample_count;
@@ -519,7 +523,9 @@ static void ParseStreamInfo( demux_t *p_demux, int *pi_rate, int64_t *pi_count,
     *pi_rate = GetDWBE(&p_data[i_skip+4+6]) >> 12;
     *pi_count = GetQWBE(&p_data[i_skip+4+6]) &  ((I64C(1)<<36)-1);
 }
-static void ParseSeekTable( demux_t *p_demux, uint8_t *p_data, int i_data, int i_sample_rate )
+
+static void ParseSeekTable( demux_t *p_demux, const uint8_t *p_data, int i_data,
+                            int i_sample_rate )
 {
     demux_sys_t *p_sys = p_demux->p_sys;
     seekpoint_t *s;
@@ -559,6 +565,7 @@ static void ParseSeekTable( demux_t *p_demux, uint8_t *p_data, int i_data, int i
     }
     /* TODO sort it by size and remove wrong seek entry (time not increasing) */
 }
+
 static inline void astrcat( char **ppsz_dst, const char *psz_src )
 {
     char *psz_old = *ppsz_dst;
@@ -568,7 +575,8 @@ static inline void astrcat( char **ppsz_dst, const char *psz_src )
 
     if( psz_old )
     {
-        asprintf( ppsz_dst, "%s,%s", psz_old, psz_src );
+        if( asprintf( ppsz_dst, "%s,%s", psz_old, psz_src ) == -1 )
+            *ppsz_dst = NULL;
         free( psz_old );
     }
     else
@@ -578,7 +586,7 @@ static inline void astrcat( char **ppsz_dst, const char *psz_src )
 }
 
 #define RM(x) do { i_data -= (x); p_data += (x); } while(0)
-static void ParseComment( demux_t *p_demux, uint8_t *p_data, int i_data )
+static void ParseComment( demux_t *p_demux, const uint8_t *p_data, int i_data )
 {
     demux_sys_t *p_sys = p_demux->p_sys;
     int n;
@@ -652,7 +660,7 @@ static void ParseComment( demux_t *p_demux, uint8_t *p_data, int i_data )
 #undef RM
 }
 
-static void ParsePicture( demux_t *p_demux, uint8_t *p_data, int i_data )
+static void ParsePicture( demux_t *p_demux, const uint8_t *p_data, int i_data )
 {
     static const int pi_cover_score[] = {
         0,      /* other */
index 4e1731704a4b5b9f5df886fce491b3b7f4d7fc98..c04c67670b8578ed166201395e24c6a7df8c3705 100644 (file)
@@ -222,11 +222,11 @@ static int  Open ( vlc_object_t *p_this )
     {
         /* See if it looks like a SDP
            v, o, s fields are mandatory and in this order */
-        uint8_t *p_peek;
+        const uint8_t *p_peek;
         if( stream_Peek( p_demux->s, &p_peek, 7 ) < 7 ) return VLC_EGENERIC;
 
-        if( memcmp( (char*)p_peek, "v=0\r\n", 5 ) &&
-            memcmp( (char*)p_peek, "v=0\n", 4 ) &&
+        if( memcmp( p_peek, "v=0\r\n", 5 ) &&
+            memcmp( p_peek, "v=0\n", 4 ) &&
             ( p_peek[0] < 'a' || p_peek[0] > 'z' || p_peek[1] != '=' ) )
         {
             return VLC_EGENERIC;
index 3e80d2352fca57b7072c08f1d8eee6cc535348a2..1be161a410dd702d7a910d643987d9bb2869cead 100644 (file)
@@ -1,7 +1,7 @@
 /*****************************************************************************
  * nsv.c: NullSoft Video demuxer.
  *****************************************************************************
- * Copyright (C) 2004 the VideoLAN team
+ * Copyright (C) 2004-2007 the VideoLAN team
  * $Id$
  *
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
@@ -86,13 +86,12 @@ static int Open( vlc_object_t *p_this )
     demux_t     *p_demux = (demux_t*)p_this;
     demux_sys_t *p_sys;
 
-    uint8_t     *p_peek;
+    const uint8_t *p_peek;
 
     if( stream_Peek( p_demux->s, &p_peek, 8 ) < 8 )
         return VLC_EGENERIC;
 
-    if( strncmp( (char *)p_peek, "NSVf", 4 )
-            && strncmp( (char *)p_peek, "NSVs", 4 ))
+    if( memcmp( p_peek, "NSVf", 4 ) && memcmp( p_peek, "NSVs", 4 ) )
     {
        /* In case we had force this demuxer we try to resynch */
         if( strcmp( p_demux->psz_demux, "nsv" ) || ReSynch( p_demux ) )
@@ -142,7 +141,7 @@ static int Demux( demux_t *p_demux )
     demux_sys_t *p_sys = p_demux->p_sys;
 
     uint8_t     header[5];
-    uint8_t     *p_peek;
+    const uint8_t *p_peek;
 
     int         i_size;
     block_t     *p_frame;
@@ -155,14 +154,14 @@ static int Demux( demux_t *p_demux )
             return 0;
         }
 
-        if( !strncmp( (char *)p_peek, "NSVf", 4 ) )
+        if( !memcmp( p_peek, "NSVf", 4 ) )
         {
             if( ReadNSVf( p_demux ) )
             {
                 return -1;
             }
         }
-        else if( !strncmp( (char *)p_peek, "NSVs", 4 ) )
+        else if( !memcmp( p_peek, "NSVs", 4 ) )
         {
             if( ReadNSVs( p_demux ) )
             {
@@ -182,7 +181,7 @@ static int Demux( demux_t *p_demux )
         }
         else
         {
-            msg_Err( p_demux, "invalid signature 0x%x (%4.4s)", *(uint32_t*)p_peek, (char*)p_peek );
+            msg_Err( p_demux, "invalid signature 0x%x (%4.4s)", GetDWLE( p_peek ), (const char*)p_peek );
             if( ReSynch( p_demux ) )
             {
                 return -1;
@@ -382,7 +381,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
  *****************************************************************************/
 static int ReSynch( demux_t *p_demux )
 {
-    uint8_t  *p_peek;
+    const uint8_t *p_peek;
     int      i_skip;
     int      i_peek;
 
@@ -396,8 +395,8 @@ static int ReSynch( demux_t *p_demux )
 
         while( i_skip < i_peek - 4 )
         {
-            if( !strncmp( (char *)p_peek, "NSVf", 4 )
-                    || !strncmp( (char *)p_peek, "NSVs", 4 ) )
+            if( !memcmp( p_peek, "NSVf", 4 )
+             || !memcmp( p_peek, "NSVs", 4 ) )
             {
                 if( i_skip > 0 )
                 {
@@ -420,7 +419,7 @@ static int ReSynch( demux_t *p_demux )
 static int ReadNSVf( demux_t *p_demux )
 {
     /* demux_sys_t *p_sys = p_demux->p_sys; */
-    uint8_t     *p;
+    const uint8_t     *p;
     int         i_size;
 
     msg_Dbg( p_demux, "new NSVf chunk" );
index ab92cec9ec5fd56fb964f775e556b66b64f80863..c499700895d0ebfeab9b174f46793d96278a0033 100644 (file)
@@ -1,7 +1,7 @@
 /*****************************************************************************
  * ogg.c : ogg stream demux module for vlc
  *****************************************************************************
- * Copyright (C) 2001-2003 the VideoLAN team
+ * Copyright (C) 2001-2007 the VideoLAN team
  * $Id$
  *
  * Authors: Gildas Bazin <gbazin@netcourrier.com>
@@ -181,7 +181,7 @@ static int Open( vlc_object_t * p_this )
     demux_t *p_demux = (demux_t *)p_this;
     input_thread_t *p_input;
     demux_sys_t    *p_sys;
-    uint8_t        *p_peek;
+    const uint8_t  *p_peek;
 
 
     /* Check if we are dealing with an ogg stream */
index 9a2c0a4cc3b63f2fcc88d0641b6dd3bba74d9ec2..e44b574c8aa75fcca27efacabfd5dc24a78d5856 100644 (file)
@@ -1,7 +1,7 @@
 /*****************************************************************************
  * rawdv.c : raw DV input module for vlc
  *****************************************************************************
- * Copyright (C) 2001-2004 the VideoLAN team
+ * Copyright (C) 2001-2007 the VideoLAN team
  * $Id$
  *
  * Authors: Gildas Bazin <gbazin@netcourrier.com>
@@ -130,7 +130,7 @@ static int Open( vlc_object_t * p_this )
     demux_t     *p_demux = (demux_t*)p_this;
     demux_sys_t *p_sys;
 
-    byte_t      *p_peek, *p_peek_backup;
+    const byte_t *p_peek, *p_peek_backup;
 
     uint32_t    i_dword;
     dv_header_t dv_header;
index 498f9a930ea7246db0531efa00b2a1f8887e26ce..7c59dc1d9197bf806b228ab235b84835dc4d0b25 100644 (file)
@@ -130,7 +130,7 @@ static int Open( vlc_object_t * p_this )
     char *psz_aspect_ratio;
     unsigned int i_aspect = 0;
     struct preset_t *p_preset = NULL;
-    uint8_t *p_peek;
+    const uint8_t *p_peek;
     vlc_bool_t b_valid = VLC_FALSE;
     vlc_bool_t b_y4m = VLC_FALSE;
 
index f055f1ba59b08d6915bbac32803ffdafb21a0cb6..dc145a8eabe586bcaf28484dbde55a735345a646 100644 (file)
@@ -1,7 +1,7 @@
 /*****************************************************************************
  * real.c: Real demuxer.
  *****************************************************************************
- * Copyright (C) 2004, 2006 the VideoLAN team
+ * Copyright (C) 2004, 2006-2007 the VideoLAN team
  * $Id$
  *
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
@@ -113,10 +113,10 @@ static int Open( vlc_object_t *p_this )
     demux_t     *p_demux = (demux_t*)p_this;
     demux_sys_t *p_sys;
 
-    uint8_t     *p_peek;
+    const uint8_t *p_peek;
 
     if( stream_Peek( p_demux->s, &p_peek, 10 ) < 10 ) return VLC_EGENERIC;
-    if( strncmp( (char *)p_peek, ".RMF", 4 ) ) return VLC_EGENERIC;
+    if( memcmp( p_peek, ".RMF", 4 ) ) return VLC_EGENERIC;
 
     /* Fill p_demux field */
     p_demux->pf_demux = Demux;
@@ -927,12 +927,12 @@ static int ReadCodecSpecificData( demux_t *p_demux, int i_len, int i_num )
     demux_sys_t *p_sys = p_demux->p_sys;
     es_format_t fmt;
     real_track_t *tk;
-    uint8_t *p_peek;
+    const uint8_t *p_peek;
 
     msg_Dbg( p_demux, "    - specific data len=%d", i_len );
     if( stream_Peek(p_demux->s, &p_peek, i_len) < i_len ) return VLC_EGENERIC;
 
-    if( !strncmp( (char *)&p_peek[4], "VIDO", 4 ) )
+    if( ( i_len >= 8 ) && !memcmp( &p_peek[4], "VIDO", 4 ) )
     {
         es_format_Init( &fmt, VIDEO_ES, VLC_FOURCC( p_peek[8], p_peek[9],
                         p_peek[10], p_peek[11] ) );
index c803b8fecfe306d5705359d59b8dbd6706244e05..cc745d3b279cd99b5149ac908b3ee7391738c30e 100644 (file)
@@ -1,7 +1,7 @@
 /*****************************************************************************
  * wav.c : wav file input module for vlc
  *****************************************************************************
- * Copyright (C) 2001-2003 the VideoLAN team
+ * Copyright (C) 2001-2007 the VideoLAN team
  * $Id$
  *
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
@@ -101,7 +101,7 @@ static int Open( vlc_object_t * p_this )
     demux_t     *p_demux = (demux_t*)p_this;
     demux_sys_t *p_sys;
 
-    uint8_t     *p_peek;
+    const uint8_t *p_peek;
     unsigned int i_size, i_extended;
     const char        *psz_name;
 
@@ -375,7 +375,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
  *****************************************************************************/
 static int ChunkFind( demux_t *p_demux, const char *fcc, unsigned int *pi_size )
 {
-    uint8_t *p_peek;
+    const uint8_t *p_peek;
 
     for( ;; )
     {