[vlc-devel] [PATCH] vlc_list: prevent name conflict
Alexandre Janniaux
ajanni at videolabs.io
Wed Sep 16 16:27:22 CEST 2020
LGTM for anaconda case, probably nobody sane would use that
in normal condition and it doesn't break POSIX requirements,
or at least we won't use that in the core.
Regards,
--
Alexandre Janniaux
Videolabs
On Wed, Sep 16, 2020 at 03:54:32PM +0200, Romain Vimont wrote:
> The macro vlc_list_foreach() declares an internal variable
> vlc_list_it_XXX variable for looping, where XXX is the variable provided
> by the user to receive the item.
>
> If this name is "next", the resulting internal variable name is
> "vlc_list_it_next", which conflicts with the function
> vlc_list_it_next().
>
> Add an _ to the internal variable name to prevent it.
> ---
> include/vlc_list.h | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/include/vlc_list.h b/include/vlc_list.h
> index 45263cc789..bea20bfd9f 100644
> --- a/include/vlc_list.h
> +++ b/include/vlc_list.h
> @@ -257,11 +257,11 @@ static inline void vlc_list_it_next(struct vlc_list_it *restrict it)
> * It is however <b>not</b> safe to delete another item.
> */
> #define vlc_list_foreach(pos, head, member) \
> - for (struct vlc_list_it vlc_list_it_##pos = vlc_list_it_start(head); \
> - vlc_list_it_continue(&(vlc_list_it_##pos)) \
> - && ((pos) = vlc_list_entry_p((vlc_list_it_##pos).current, \
> + for (struct vlc_list_it vlc_list_it__##pos = vlc_list_it_start(head); \
> + vlc_list_it_continue(&(vlc_list_it__##pos)) \
> + && ((pos) = vlc_list_entry_p((vlc_list_it__##pos).current, \
> pos, member), true); \
> - vlc_list_it_next(&(vlc_list_it_##pos)))
> + vlc_list_it_next(&(vlc_list_it__##pos)))
>
> /**
> * Converts a list node pointer to an element pointer.
> --
> 2.28.0
>
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel
More information about the vlc-devel
mailing list