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:
@@ -49,6 +49,10 @@ list_add_link_to_head(struct list *list, void *_link)
|
|||||||
|
|
||||||
list->link.next->prev = link;
|
list->link.next->prev = link;
|
||||||
list->link.next = 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->next = link;
|
||||||
list->link.prev = link;
|
list->link.prev = link;
|
||||||
|
|
||||||
|
#if DEBUG_DOUBLY_LINKED_LIST
|
||||||
|
ASSERT(link->prev != link);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user