mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2026-05-09 04:48:02 +02:00
util: add asserts with useful error messages to catch uninitialized lists
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
parent
96fa4266d0
commit
87b04a0cb2
1 changed files with 9 additions and 0 deletions
|
|
@ -50,6 +50,9 @@ list_init(struct list *list)
|
|||
void
|
||||
list_insert(struct list *list, struct list *elm)
|
||||
{
|
||||
assert((list->next != NULL && list->prev != NULL) ||
|
||||
!"list->next|prev is NULL, possibly missing list_init()");
|
||||
|
||||
elm->prev = list;
|
||||
elm->next = list->next;
|
||||
list->next = elm;
|
||||
|
|
@ -59,6 +62,9 @@ list_insert(struct list *list, struct list *elm)
|
|||
void
|
||||
list_remove(struct list *elm)
|
||||
{
|
||||
assert((elm->next != NULL && elm->prev != NULL) ||
|
||||
!"list->next|prev is NULL, possibly missing list_init()");
|
||||
|
||||
elm->prev->next = elm->next;
|
||||
elm->next->prev = elm->prev;
|
||||
elm->next = NULL;
|
||||
|
|
@ -68,6 +74,9 @@ list_remove(struct list *elm)
|
|||
bool
|
||||
list_empty(const struct list *list)
|
||||
{
|
||||
assert((list->next != NULL && list->prev != NULL) ||
|
||||
!"list->next|prev is NULL, possibly missing list_init()");
|
||||
|
||||
return list->next == list;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue