mirror of
https://github.com/CTCaer/hekate.git
synced 2024-11-26 19:52:11 +00:00
lists: Fix list member iteration with no entries
This commit is contained in:
parent
bc7a7bcfa0
commit
f3802ec464
2 changed files with 6 additions and 4 deletions
|
@ -33,9 +33,10 @@
|
||||||
#define LIST_FOREACH_SAFE(iter, list) \
|
#define LIST_FOREACH_SAFE(iter, list) \
|
||||||
for(link_t *iter = (list)->next, *safe = iter->next; iter != (list); iter = safe, safe = iter->next)
|
for(link_t *iter = (list)->next, *safe = iter->next; iter != (list); iter = safe, safe = iter->next)
|
||||||
|
|
||||||
/*! Iterate over all list members. */
|
/*! Iterate over all list members and make sure that the list has at least one entry. */
|
||||||
#define LIST_FOREACH_ENTRY(etype, iter, list, mn) \
|
#define LIST_FOREACH_ENTRY(etype, iter, list, mn) \
|
||||||
for(etype *iter = CONTAINER_OF((list)->next, etype, mn); &iter->mn != (list); iter = CONTAINER_OF(iter->mn.next, etype, mn))
|
if ((list)->next != (list)) \
|
||||||
|
for(etype *iter = CONTAINER_OF((list)->next, etype, mn); &iter->mn != (list); iter = CONTAINER_OF(iter->mn.next, etype, mn))
|
||||||
|
|
||||||
typedef struct _link_t
|
typedef struct _link_t
|
||||||
{
|
{
|
||||||
|
|
|
@ -33,9 +33,10 @@
|
||||||
#define LIST_FOREACH_SAFE(iter, list) \
|
#define LIST_FOREACH_SAFE(iter, list) \
|
||||||
for(link_t *iter = (list)->next, *safe = iter->next; iter != (list); iter = safe, safe = iter->next)
|
for(link_t *iter = (list)->next, *safe = iter->next; iter != (list); iter = safe, safe = iter->next)
|
||||||
|
|
||||||
/*! Iterate over all list members. */
|
/*! Iterate over all list members and make sure that the list has at least one entry. */
|
||||||
#define LIST_FOREACH_ENTRY(etype, iter, list, mn) \
|
#define LIST_FOREACH_ENTRY(etype, iter, list, mn) \
|
||||||
for(etype *iter = CONTAINER_OF((list)->next, etype, mn); &iter->mn != (list); iter = CONTAINER_OF(iter->mn.next, etype, mn))
|
if ((list)->next != (list)) \
|
||||||
|
for(etype *iter = CONTAINER_OF((list)->next, etype, mn); &iter->mn != (list); iter = CONTAINER_OF(iter->mn.next, etype, mn))
|
||||||
|
|
||||||
typedef struct _link_t
|
typedef struct _link_t
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue