summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/list/list.h11
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/list/list.h b/lib/list/list.h
index 6000320..0174b90 100644
--- a/lib/list/list.h
+++ b/lib/list/list.h
@@ -41,11 +41,12 @@ struct list {
for (; _pos; _pos = list_next_entry(_list, _pos, _member))
#define list_for_each_entry_safe(_list, _pos, _tmp, _member) \
- for (_pos = list_entry((_list)->head.next, typeof(*_pos), _member, _list), \
- _tmp = list_entry(_pos->_member.next, typeof(*_pos), _member, _list); \
- _pos; \
- _pos = _tmp, \
- _tmp = _tmp ? list_entry(_tmp->_member.next, typeof(*_pos), _member, _list) : NULL)
+ for (_pos = container_of((_list)->head.next, typeof(*_pos), _member), \
+ _tmp = container_of(_pos->_member.next, typeof(*_pos), \
+ _member); \
+ &_pos->_member != &(_list)->head; \
+ _pos = _tmp, \
+ _tmp = container_of(_tmp->_member.next, typeof(*_pos), _member))
#define DEFINE_LIST(_list) struct list _list = { \
.head = { \
OpenPOWER on IntegriCloud