summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Klausner <wiz@NetBSD.org>2016-01-05 12:51:41 -0500
committerAdam Jackson <ajax@redhat.com>2016-01-06 09:42:59 -0500
commit63f83d1b7f496d05b409352749cdb6674d71cf80 (patch)
treea08eb9592a17749709e27bec1581c2773066f8fd
parentba71b69f94f00a6f6910597185610668e79c10be (diff)
Fix uninitialized variable warnings reported by clang
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 <wiz@NetBSD.org> Acked-by: Michel Dänzer <michel.daenzer@amd.com>
-rw-r--r--include/list.h8
1 files changed, 5 insertions, 3 deletions
diff --git a/include/list.h b/include/list.h
index 39f198590..3f0574d43 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))