The clang compiler treats the memory address of a structure field as
tautologically true when compared to non-NULL. This breaks the macros
in llist.h when compiled using clang. Fix this by not comparing the
address of a structure field to NULL when determining the end of the
llist. Refer to -Wtautological-pointer-compare in clang for more
information.
Signed-off-by: Hans Petter Selasky <hps@xxxxxxxxxxx>
---
include/linux/llist.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/linux/llist.h b/include/linux/llist.h
index 171baa90f6f6..76a6d618de75 100644
--- a/include/linux/llist.h
+++ b/include/linux/llist.h
@@ -126,7 +126,7 @@ static inline void init_llist_head(struct llist_head
*list)
*/
#define llist_for_each_entry(pos, node, member) \
for ((pos) = llist_entry((node), typeof(*(pos)), member); \
- &(pos)->member != NULL; \
+ (pos) != llist_entry(NULL, typeof(*(pos)), member); \
(pos) = llist_entry((pos)->member.next, typeof(*(pos)), member))
/**
@@ -148,7 +148,7 @@ static inline void init_llist_head(struct llist_head
*list)
*/
#define llist_for_each_entry_safe(pos, n, node, member) \
for (pos = llist_entry((node), typeof(*pos), member); \
- &pos->member != NULL && \
+ (pos) != llist_entry(NULL, typeof(*(pos)), member) && \
(n = llist_entry(pos->member.next, typeof(*n), member), true); \
pos = n)
--
2.11.1
>From 14e1f86ad297cc3c2b575135699b8c08849d1c6a Mon Sep 17 00:00:00 2001
From: Hans Petter Selasky <hps@xxxxxxxxxxx>
Date: Tue, 25 Apr 2017 09:30:47 +0200
Subject: [PATCH] Fix for compilation with clang
The clang compiler treats the memory address of a structure field as
tautologically true when compared to non-NULL. This breaks the macros
in llist.h when compiled using clang. Fix this by not comparing the
address of a structure field to NULL when determining the end of the
llist. Refer to -Wtautological-pointer-compare in clang for more
information.
Signed-off-by: Hans Petter Selasky <hps@xxxxxxxxxxx>
---
include/linux/llist.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/linux/llist.h b/include/linux/llist.h
index 171baa90f6f6..76a6d618de75 100644
--- a/include/linux/llist.h
+++ b/include/linux/llist.h
@@ -126,7 +126,7 @@ static inline void init_llist_head(struct llist_head *list)
*/
#define llist_for_each_entry(pos, node, member) \
for ((pos) = llist_entry((node), typeof(*(pos)), member); \
- &(pos)->member != NULL; \
+ (pos) != llist_entry(NULL, typeof(*(pos)), member); \
(pos) = llist_entry((pos)->member.next, typeof(*(pos)), member))
/**
@@ -148,7 +148,7 @@ static inline void init_llist_head(struct llist_head *list)
*/
#define llist_for_each_entry_safe(pos, n, node, member) \
for (pos = llist_entry((node), typeof(*pos), member); \
- &pos->member != NULL && \
+ (pos) != llist_entry(NULL, typeof(*(pos)), member) && \
(n = llist_entry(pos->member.next, typeof(*n), member), true); \
pos = n)
--
2.11.1