[PATCH] Fix potentially undefined behavior
Kristian Høgsberg
krh at bitplanet.net
Wed Nov 24 05:53:16 PST 2010
On Tue, Nov 23, 2010 at 9:01 PM, Joel Teichroeb <joel at teichroeb.net> wrote:
> Really this time.
> ---
> wayland/wayland-util.h | 7 ++++---
> 1 files changed, 4 insertions(+), 3 deletions(-)
Thanks committed. I added a reference to the llvm bug in the commit message.
Kristian
> diff --git a/wayland/wayland-util.h b/wayland/wayland-util.h
> index 575e657..ebac305 100644
> --- a/wayland/wayland-util.h
> +++ b/wayland/wayland-util.h
> @@ -94,19 +94,20 @@ int wl_list_empty(struct wl_list *list);
> ((char *)&(sample)->member - (char *)(sample)))
>
> #define wl_list_for_each(pos, head, member) \
> - for (pos = __container_of((head)->next, pos, member); \
> + for (pos = 0, 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) \
> - for (pos = __container_of((head)->next, pos, member), \
> + for (pos = 0, tmp = 0, \
> + pos = __container_of((head)->next, pos, member), \
> tmp = __container_of((pos)->member.next, tmp, member); \
> &pos->member != (head); \
> pos = tmp, \
> tmp = __container_of(pos->member.next, tmp, member))
>
> #define wl_list_for_each_reverse(pos, head, member) \
> - for (pos = __container_of((head)->prev, pos, member); \
> + for (pos = 0, pos = __container_of((head)->prev, pos, member); \
> &pos->member != (head); \
> pos = __container_of(pos->member.prev, pos, member))
>
> --
> 1.7.3.2
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/wayland-devel
>
More information about the wayland-devel
mailing list