Browse Source

vlc_arrays: avoid variable shadowing warnings

Make the variable name depend on "item" to avoid variable shadowing
warnings for nested loops (even if this specific shadowing is harmless).

Signed-off-by: Jean-Baptiste Kempf <jb@videolan.org>
pull/71/head
Romain Vimont 8 years ago
committed by Jean-Baptiste Kempf
parent
commit
0393082816
  1. 9
      include/vlc_arrays.h
  2. 8
      src/misc/events.c

9
include/vlc_arrays.h

@ -243,10 +243,13 @@ static inline void *realloc_or_free( void *p, size_t sz )
#define ARRAY_BSEARCH(array, elem, zetype, key, answer) \
BSEARCH( (array).p_elems, (array).i_size, elem, zetype, key, answer)
/* append ##item to index variable name to avoid variable shadowing warnings for
* nested loops */
#define ARRAY_FOREACH(item, array) \
for (int fe_idx = 0; \
fe_idx < (array).i_size && ((item) = (array).p_elems[fe_idx], 1); \
++fe_idx)
for (int array_index_##item = 0; \
array_index_##item < (array).i_size && \
((item) = (array).p_elems[array_index_##item], 1); \
++array_index_##item)
/************************************************************************

8
src/misc/events.c

@ -149,19 +149,17 @@ void vlc_event_detach( vlc_event_manager_t *p_em,
void *p_user_data )
{
vlc_event_listeners_group_t *slot = &p_em->events[event_type];
struct vlc_event_listener_t * listener;
vlc_mutex_lock( &p_em->lock );
ARRAY_FOREACH( listener, slot->listeners )
for (int i = 0; i < slot->listeners.i_size; ++i)
{
struct vlc_event_listener_t *listener = slot->listeners.p_elems[i];
if( listener->pf_callback == pf_callback &&
listener->p_user_data == p_user_data )
{
/* that's our listener */
ARRAY_REMOVE( slot->listeners,
fe_idx /* This comes from the macro (and that's why
I hate macro) */ );
ARRAY_REMOVE( slot->listeners, i );
vlc_mutex_unlock( &p_em->lock );
free( listener );
return;

Loading…
Cancel
Save