[PATCH libinput 1/5] util: allow list_remove() on a NULL node

Peter Hutterer peter.hutterer at who-t.net
Sun Jun 28 20:49:21 PDT 2015


Don't require a list_init() on a node before we can call list_remove on it, it
clutters up the code for little benefit.

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 src/libinput-util.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/libinput-util.c b/src/libinput-util.c
index 3a9c8db..f19695c 100644
--- a/src/libinput-util.c
+++ b/src/libinput-util.c
@@ -59,6 +59,9 @@ list_insert(struct list *list, struct list *elm)
 void
 list_remove(struct list *elm)
 {
+	if (elm->next == NULL && elm->prev == NULL)
+		return;
+
 	elm->prev->next = elm->next;
 	elm->next->prev = elm->prev;
 	elm->next = NULL;
-- 
2.4.3



More information about the wayland-devel mailing list