[vlc-devel] [PATCH] vlc_list: prevent name conflict

Romain Vimont rom1v at videolabs.io
Wed Sep 16 15:54:32 CEST 2020


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



More information about the vlc-devel mailing list