summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2017-10-18 15:24:03 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2017-10-30 09:42:28 +1000
commit5521837aafd42126ffd4720f24a7bdb30e0a2371 (patch)
tree2f7030ef644e8dc45b1c24776a0436d35f11697e
parent520789925cc5885670ea23e56abf6374893b3797 (diff)
util: add an extra assert for list_insert()
If we're adding an element that's not null or not a freshly initialized list, chances are we haven't removed it from a previous list. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Jonas Ã…dahl <jadahl@gmail.com> (cherry picked from commit 28ef7456d3f219f6e4a7e655c78b9c547b8e16d1)
-rw-r--r--src/libinput-util.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/libinput-util.c b/src/libinput-util.c
index eeeeca07..3cef33e6 100644
--- a/src/libinput-util.c
+++ b/src/libinput-util.c
@@ -52,6 +52,8 @@ list_insert(struct list *list, struct list *elm)
{
assert((list->next != NULL && list->prev != NULL) ||
!"list->next|prev is NULL, possibly missing list_init()");
+ assert(((elm->next == NULL && elm->prev == NULL) || list_empty(elm)) ||
+ !"elm->next|prev is not NULL, list node used twice?");
elm->prev = list;
elm->next = list->next;