From 7af3d91a653ca0b1b09f13e0c90466dc49c87daa Mon Sep 17 00:00:00 2001 From: =?utf8?q?R=C3=A9mi=20Denis-Courmont?= Date: Fri, 20 Jul 2007 14:34:20 +0000 Subject: [PATCH] - Fix a bunch of warnings - Fix a bunch of abuse of strncmp (memcmp rulez) --- modules/demux/Modules.am | 1 + modules/demux/a52.c | 8 ++++---- modules/demux/aiff.c | 11 ++++++----- modules/demux/au.c | 4 ++-- modules/demux/dts.c | 8 ++++---- modules/demux/flac.c | 30 +++++++++++++++++++----------- modules/demux/live555.cpp | 6 +++--- modules/demux/nsv.c | 23 +++++++++++------------ modules/demux/ogg.c | 4 ++-- modules/demux/rawdv.c | 4 ++-- modules/demux/rawvid.c | 2 +- modules/demux/real.c | 10 +++++----- modules/demux/wav.c | 6 +++--- 13 files changed, 63 insertions(+), 54 deletions(-) diff --git a/modules/demux/Modules.am b/modules/demux/Modules.am index 21718dfb22..f6c92a5dae 100644 --- a/modules/demux/Modules.am +++ b/modules/demux/Modules.am @@ -28,3 +28,4 @@ SOURCES_mpc = mpc.c SOURCES_gme = gme.cpp SOURCES_tta = tta.c SOURCES_vc1 = vc1.c +SOURCES_rtp = rtp.c diff --git a/modules/demux/a52.c b/modules/demux/a52.c index 12062db730..c19831d671 100644 --- a/modules/demux/a52.c +++ b/modules/demux/a52.c @@ -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 @@ -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 && diff --git a/modules/demux/aiff.c b/modules/demux/aiff.c index 8a5e80ebae..51ed29b2c3 100644 --- a/modules/demux/aiff.c +++ b/modules/demux/aiff.c @@ -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 @@ -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 ); diff --git a/modules/demux/au.c b/modules/demux/au.c index 9663de597a..eaeca1b42d 100644 --- a/modules/demux/au.c +++ b/modules/demux/au.c @@ -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 @@ -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; diff --git a/modules/demux/dts.c b/modules/demux/dts.c index 437e07db3d..0cdd85afe6 100644 --- a/modules/demux/dts.c +++ b/modules/demux/dts.c @@ -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 @@ -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 && diff --git a/modules/demux/flac.c b/modules/demux/flac.c index 2b3050ea9f..d9dd781a53 100644 --- a/modules/demux/flac.c +++ b/modules/demux/flac.c @@ -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 @@ -31,6 +31,7 @@ #include #include #include +#include /***************************************************************************** * 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 */ diff --git a/modules/demux/live555.cpp b/modules/demux/live555.cpp index 4e1731704a..c04c67670b 100644 --- a/modules/demux/live555.cpp +++ b/modules/demux/live555.cpp @@ -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; diff --git a/modules/demux/nsv.c b/modules/demux/nsv.c index 3e80d2352f..1be161a410 100644 --- a/modules/demux/nsv.c +++ b/modules/demux/nsv.c @@ -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 @@ -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" ); diff --git a/modules/demux/ogg.c b/modules/demux/ogg.c index ab92cec9ec..c499700895 100644 --- a/modules/demux/ogg.c +++ b/modules/demux/ogg.c @@ -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 @@ -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 */ diff --git a/modules/demux/rawdv.c b/modules/demux/rawdv.c index 9a2c0a4cc3..e44b574c8a 100644 --- a/modules/demux/rawdv.c +++ b/modules/demux/rawdv.c @@ -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 @@ -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; diff --git a/modules/demux/rawvid.c b/modules/demux/rawvid.c index 498f9a930e..7c59dc1d91 100644 --- a/modules/demux/rawvid.c +++ b/modules/demux/rawvid.c @@ -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; diff --git a/modules/demux/real.c b/modules/demux/real.c index f055f1ba59..dc145a8eab 100644 --- a/modules/demux/real.c +++ b/modules/demux/real.c @@ -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 @@ -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] ) ); diff --git a/modules/demux/wav.c b/modules/demux/wav.c index c803b8fecf..cc745d3b27 100644 --- a/modules/demux/wav.c +++ b/modules/demux/wav.c @@ -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 @@ -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( ;; ) { -- 2.39.2