kernel/util: Add self-link assertions to list_add_link_to_{head|tail}.

These caught the problem fixed in prior commits, and would have saved
me an awful lot of debugging time had they existed from the start.

They cannot catch all double-list-insertions, of course, but it's
relatively cheap to add these, and more than nothing.
This commit is contained in:
Augustin Cavalier
2023-04-01 00:53:01 -04:00
parent 70b4d59f18
commit 6ec600d29b
+8
View File
@@ -49,6 +49,10 @@ list_add_link_to_head(struct list *list, void *_link)
list->link.next->prev = link;
list->link.next = link;
#if DEBUG_DOUBLY_LINKED_LIST
ASSERT(link->next != link);
#endif
}
@@ -65,6 +69,10 @@ list_add_link_to_tail(struct list *list, void *_link)
list->link.prev->next = link;
list->link.prev = link;
#if DEBUG_DOUBLY_LINKED_LIST
ASSERT(link->prev != link);
#endif
}