[vlc-commits] Remove variable name clashes in TAB_REMOVE
Rafaël Carré
git at videolan.org
Mon Dec 17 01:06:20 CET 2012
vlc | branch: master | Rafaël Carré <funman at videolan.org> | Mon Dec 17 01:00:29 2012 +0100| [728ef39d15cdbfc5b1bc9beba8a97493ef6c08fc] | committer: Rafaël Carré
Remove variable name clashes in TAB_REMOVE
If foo[i] or bar[i_index] are used in TAB_REMOVE / TAB_FIND, they will
use another variable with local scope declared inside the macro.
for (int i = 0; i < 1; i++) {
TAB_REMOVE( count, array, foo[i] );
}
will expand to:
for (int i = 0; i < 1; i++) {
int i_index;
.....
for (int i = 0; i < count; i++)
if (array[i] == foo[i])
{
index = i;
break;
}
.....
}
And inner scope i is used to index foo, instead of the outer scope i
which we would expect without knowing the content of the macro.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=728ef39d15cdbfc5b1bc9beba8a97493ef6c08fc
---
modules/demux/ts.c | 11 ++++++-----
modules/misc/rtsp.c | 5 +++--
src/input/vlmshell.c | 8 +++-----
3 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/modules/demux/ts.c b/modules/demux/ts.c
index 87b8a00..1374791 100644
--- a/modules/demux/ts.c
+++ b/modules/demux/ts.c
@@ -4054,16 +4054,17 @@ static void PATCallBack( void *data, dvbpsi_pat_t *p_pat )
/* Delete PMT pid */
for( int i = 0; i < i_pmt_rm; i++ )
{
- SetPIDFilter( p_demux, pmt_rm[i]->i_pid, false );
+ ts_pid_t *pid = pmt_rm[i];
+ SetPIDFilter( p_demux, pid->i_pid, false );
- for( int i_prg = 0; i_prg < pmt_rm[i]->psi->i_prg; i_prg++ )
+ for( int i_prg = 0; i_prg < pid->psi->i_prg; i_prg++ )
{
- const int i_number = pmt_rm[i]->psi->prg[i_prg]->i_number;
+ const int i_number = pid->psi->prg[i_prg]->i_number;
es_out_Control( p_demux->out, ES_OUT_DEL_GROUP, i_number );
}
- PIDClean( p_demux, &p_sys->pid[pmt_rm[i]->i_pid] );
- TAB_REMOVE( p_sys->i_pmt, p_sys->pmt, pmt_rm[i] );
+ PIDClean( p_demux, &p_sys->pid[pid->i_pid] );
+ TAB_REMOVE( p_sys->i_pmt, p_sys->pmt, pid );
}
free( pmt_rm );
diff --git a/modules/misc/rtsp.c b/modules/misc/rtsp.c
index 784f8b0..061ca15 100644
--- a/modules/misc/rtsp.c
+++ b/modules/misc/rtsp.c
@@ -1439,9 +1439,10 @@ static int RtspCallbackES( httpd_callback_sys_t *p_args, httpd_client_t *cl,
for( int i = 0; i < p_rtsp->i_es; i++ )
{
- if( p_rtsp->es[i]->p_media_es == p_es )
+ rtsp_client_es_t *es = p_rtsp->es[i];
+ if( es->p_media_es == p_es )
{
- TAB_REMOVE( p_rtsp->i_es, p_rtsp->es, p_rtsp->es[i] );
+ TAB_REMOVE( p_rtsp->i_es, p_rtsp->es, es );
break;
}
}
diff --git a/src/input/vlmshell.c b/src/input/vlmshell.c
index 8f1dbb2..97edd90 100644
--- a/src/input/vlmshell.c
+++ b/src/input/vlmshell.c
@@ -702,13 +702,11 @@ static int ExecuteMediaProperty( vlm_t *p_vlm, int64_t id, bool b_new,
}
else if( !strcmp( psz_option, "inputdeln" ) )
{
- int i_index;
-
MISSING( "inputdeln" );
- i_index = atoi( psz_value );
- if( i_index > 0 && i_index <= p_cfg->i_input )
- TAB_REMOVE( p_cfg->i_input, p_cfg->ppsz_input, p_cfg->ppsz_input[i_index-1] );
+ int idx = atoi( psz_value );
+ if( idx > 0 && idx <= p_cfg->i_input )
+ TAB_REMOVE( p_cfg->i_input, p_cfg->ppsz_input, p_cfg->ppsz_input[idx-1] );
i++;
}
else if( !strcmp( psz_option, "output" ) )
More information about the vlc-commits
mailing list