Commit 7af3d91a authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

- Fix a bunch of warnings

- Fix a bunch of abuse of strncmp (memcmp rulez)
parent 40785cad
......@@ -28,3 +28,4 @@ SOURCES_mpc = mpc.c
SOURCES_gme = gme.cpp
SOURCES_tta = tta.c
SOURCES_vc1 = vc1.c
SOURCES_rtp = rtp.c
/*****************************************************************************
* 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 &&
......
/*****************************************************************************
* 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 );
......
/*****************************************************************************
* 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;
......
/*****************************************************************************
* 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 &&
......
/*****************************************************************************
* 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 */
......
......@@ -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;
......
/*****************************************************************************
* 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" );
......
/*****************************************************************************
* 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 */
......
/*****************************************************************************
* 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;
......
......@@ -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;
......
/*****************************************************************************
* 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] ) );
......
/*****************************************************************************
* 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( ;; )
{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment