diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2013-06-13 21:24:14 -0400 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2013-06-13 21:24:14 -0400 |
commit | 030a58a05e595694dccfa958563103d2f0644231 (patch) | |
tree | 3cb4e135ded7235f2edbbfc12db8764bd47221e7 /src/list.h | |
parent | 7507ce28f436fe8b37bcd09a85c7289bf4c4284f (diff) | |
download | seabios-030a58a05e595694dccfa958563103d2f0644231.tar.gz |
Another fix for hlist_for_each_entry_safe.
Although the previous patch does fix hlist_for_each_entry_safe for the
common case, it doesn't work correctly when deleting the current
node. To fix this, introduce two macros - hlist_for_each_entry_safe
for iterating through a list that can be modified, and
hlist_for_each_entry_pprev for those users that only need access to
the "pprev" pointer.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'src/list.h')
-rw-r--r-- | src/list.h | 8 |
1 files changed, 7 insertions, 1 deletions
@@ -66,7 +66,13 @@ hlist_add_after(struct hlist_node *n, struct hlist_node *prev) ; pos != container_of(NULL, typeof(*pos), member) \ ; pos = container_of(pos->member.next, typeof(*pos), member)) -#define hlist_for_each_entry_safe(pos, pprev, head, member) \ +#define hlist_for_each_entry_safe(pos, n, head, member) \ + for (pos = container_of((head)->first, typeof(*pos), member) \ + ; pos != container_of(NULL, typeof(*pos), member) \ + && ({ n = pos->member.next; 1; }) \ + ; pos = container_of(n, typeof(*pos), member)) + +#define hlist_for_each_entry_pprev(pos, pprev, head, member) \ for (pprev = &(head)->first \ ; *pprev && ({ pos=container_of(*pprev, typeof(*pos), member); 1; }) \ ; pprev = &(*pprev)->next) |