Commit 728ef39d authored by Rafaël Carré's avatar 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.
parent 22188d37
...@@ -4054,16 +4054,17 @@ static void PATCallBack( void *data, dvbpsi_pat_t *p_pat ) ...@@ -4054,16 +4054,17 @@ static void PATCallBack( void *data, dvbpsi_pat_t *p_pat )
/* Delete PMT pid */ /* Delete PMT pid */
for( int i = 0; i < i_pmt_rm; i++ ) 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 ); es_out_Control( p_demux->out, ES_OUT_DEL_GROUP, i_number );
} }
PIDClean( p_demux, &p_sys->pid[pmt_rm[i]->i_pid] ); PIDClean( p_demux, &p_sys->pid[pid->i_pid] );
TAB_REMOVE( p_sys->i_pmt, p_sys->pmt, pmt_rm[i] ); TAB_REMOVE( p_sys->i_pmt, p_sys->pmt, pid );
} }
free( pmt_rm ); free( pmt_rm );
......
...@@ -1439,9 +1439,10 @@ static int RtspCallbackES( httpd_callback_sys_t *p_args, httpd_client_t *cl, ...@@ -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++ ) 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; break;
} }
} }
......
...@@ -702,13 +702,11 @@ static int ExecuteMediaProperty( vlm_t *p_vlm, int64_t id, bool b_new, ...@@ -702,13 +702,11 @@ static int ExecuteMediaProperty( vlm_t *p_vlm, int64_t id, bool b_new,
} }
else if( !strcmp( psz_option, "inputdeln" ) ) else if( !strcmp( psz_option, "inputdeln" ) )
{ {
int i_index;
MISSING( "inputdeln" ); MISSING( "inputdeln" );
i_index = atoi( psz_value ); int idx = atoi( psz_value );
if( i_index > 0 && i_index <= p_cfg->i_input ) if( idx > 0 && idx <= p_cfg->i_input )
TAB_REMOVE( p_cfg->i_input, p_cfg->ppsz_input, p_cfg->ppsz_input[i_index-1] ); TAB_REMOVE( p_cfg->i_input, p_cfg->ppsz_input, p_cfg->ppsz_input[idx-1] );
i++; i++;
} }
else if( !strcmp( psz_option, "output" ) ) else if( !strcmp( psz_option, "output" ) )
......
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