[PATCH] Fix potentially undefined behavior

Joel Teichroeb joel at teichroeb.net
Tue Nov 23 14:56:26 PST 2010


---
 wayland/wayland-util.h |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/wayland/wayland-util.h b/wayland/wayland-util.h
index 575e657..dcda75b 100644
--- a/wayland/wayland-util.h
+++ b/wayland/wayland-util.h
@@ -94,11 +94,13 @@ int wl_list_empty(struct wl_list *list);
          ((char *)&(sample)->member - (char *)(sample)))

 #define wl_list_for_each(pos, head, member)                \
+    pos = 0;                            \
     for (pos = __container_of((head)->next, pos, member);        \
          &pos->member != (head);                    \
          pos = __container_of(pos->member.next, pos, member))

 #define wl_list_for_each_safe(pos, tmp, head, member)            \
+    pos = 0;                            \
     for (pos = __container_of((head)->next, pos, member),        \
          tmp = __container_of((pos)->member.next, tmp, member);    \
          &pos->member != (head);                    \
@@ -106,6 +108,7 @@ int wl_list_empty(struct wl_list *list);
          tmp = __container_of(pos->member.next, tmp, member))

 #define wl_list_for_each_reverse(pos, head, member)            \
+    pos = 0;                            \
     for (pos = __container_of((head)->prev, pos, member);        \
          &pos->member != (head);                    \
          pos = __container_of(pos->member.prev, pos, member))
-- 
1.7.3.2
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/wayland-devel/attachments/20101123/429fb208/attachment.htm>


More information about the wayland-devel mailing list