0
0
mirror of https://gitlab.nic.cz/labs/bird.git synced 2024-11-10 05:08:42 +00:00

Lists: fixed bugs in expensive checks in quirky usecases

This commit is contained in:
Maria Matejka 2023-02-02 13:26:49 +01:00
parent c354e8f4c1
commit 226839c977

View File

@ -37,9 +37,10 @@ check_list(list *l, node *n)
ASSERT_DIE(n); ASSERT_DIE(n);
ASSERT_DIE(n->prev); ASSERT_DIE(n->prev);
do { n = n->prev; } while (n->prev); node *nn = n;
do { nn = nn->prev; } while (nn->prev);
l = SKIP_BACK(list, head_node, n); l = SKIP_BACK(list, head_node, nn);
} }
int seen = 0; int seen = 0;
@ -120,7 +121,7 @@ add_head(list *l, node *n)
LIST_INLINE void LIST_INLINE void
insert_node(node *n, node *after) insert_node(node *n, node *after)
{ {
EXPENSIVE_CHECK(check_list(l, after)); EXPENSIVE_CHECK((after->prev == NULL) || check_list(NULL, after));
ASSUME(n->prev == NULL); ASSUME(n->prev == NULL);
ASSUME(n->next == NULL); ASSUME(n->next == NULL);
@ -141,7 +142,7 @@ insert_node(node *n, node *after)
LIST_INLINE void LIST_INLINE void
rem_node(node *n) rem_node(node *n)
{ {
EXPENSIVE_CHECK(check_list(NULL, n)); EXPENSIVE_CHECK((n->prev == n) && (n->next == n) || check_list(NULL, n));
node *z = n->prev; node *z = n->prev;
node *x = n->next; node *x = n->next;