[PATCH libinput 2/2] util: add an extra assert for list_insert()

Peter Hutterer peter.hutterer at who-t.net
Wed Oct 18 22:39:03 UTC 2017


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 at who-t.net>
---
 src/libinput-util.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/libinput-util.c b/src/libinput-util.c
index 48cb7181..93d73827 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;
-- 
2.13.6



More information about the wayland-devel mailing list