From: Thomas Klausner <[email protected]>

v2: Move initializing pos into the first clause of the for statement. We
have to keep this macro equivalent to a plain for statement from the
user's perspective, otherwise callers need to {} things to keep control
flow correct. [ajax]

Signed-off-by: Thomas Klausner <[email protected]>
Acked-by: Michel Dänzer <[email protected]>
---
 include/list.h | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/include/list.h b/include/list.h
index 39f1985..3f0574d 100644
--- a/include/list.h
+++ b/include/list.h
@@ -304,8 +304,9 @@ xorg_list_is_empty(struct xorg_list *head)
  * @param member Member name of the struct xorg_list in the list elements.
  *
  */
-#define xorg_list_for_each_entry(pos, head, member)                            
\
-    for (pos = __container_of((head)->next, pos, member);              \
+#define xorg_list_for_each_entry(pos, head, member)                    \
+    for (pos = NULL,                                                    \
+         pos = __container_of((head)->next, pos, member);              \
         &pos->member != (head);                                        \
         pos = __container_of(pos->member.next, pos, member))
 
@@ -317,7 +318,8 @@ xorg_list_is_empty(struct xorg_list *head)
  * See xorg_list_for_each_entry for more details.
  */
 #define xorg_list_for_each_entry_safe(pos, tmp, head, member)          \
-    for (pos = __container_of((head)->next, pos, member),              \
+    for (pos = NULL,                                                    \
+         pos = __container_of((head)->next, pos, member),              \
         tmp = __container_of(pos->member.next, pos, member);           \
         &pos->member != (head);                                        \
         pos = tmp, tmp = __container_of(pos->member.next, tmp, member))
-- 
2.5.0

_______________________________________________
[email protected]: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

Reply via email to