summaryrefslogtreecommitdiff
path: root/lib/lists.c
diff options
context:
space:
mode:
authorMaria Matejka <mq@ucw.cz>2021-08-09 11:51:19 +0200
committerMaria Matejka <mq@ucw.cz>2021-11-22 19:05:43 +0100
commit8d706aedba42f8ace0084c7b983ddaaaf47dff91 (patch)
treec2058491523d63d5d5910a953a578d14a59aecbd /lib/lists.c
parentb5ca6a79d36549fcc5b934b8ffc283f15b8da4a5 (diff)
Fixing expensive list checks. Debug only commit.
Diffstat (limited to 'lib/lists.c')
-rw-r--r--lib/lists.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/lib/lists.c b/lib/lists.c
index fe2b692b..58d51073 100644
--- a/lib/lists.c
+++ b/lib/lists.c
@@ -35,11 +35,12 @@ check_list(list *l, node *n)
if (!l)
{
ASSERT_DIE(n);
- ASSERT_DIE(n->prev);
- do { n = n->prev; } while (n->prev);
+ node *nn = n;
+ while (nn->prev)
+ nn = nn->prev;
- l = SKIP_BACK(list, head_node, n);
+ l = SKIP_BACK(list, head_node, nn);
}
int seen = 0;
@@ -60,7 +61,7 @@ check_list(list *l, node *n)
}
ASSERT_DIE(cur == &(l->tail_node));
- ASSERT_DIE(!n || (seen == 1));
+ ASSERT_DIE(!n || (seen == 1) || (n == &l->head_node) || (n == &l->tail_node));
return 1;
}
@@ -129,7 +130,7 @@ self_link(node *n)
LIST_INLINE void
insert_node(node *n, node *after)
{
- EXPENSIVE_CHECK(check_list(l, after));
+ EXPENSIVE_CHECK(check_list(NULL, after));
ASSUME(n->prev == NULL);
ASSUME(n->next == NULL);
@@ -150,7 +151,7 @@ insert_node(node *n, node *after)
LIST_INLINE void
rem_node(node *n)
{
- EXPENSIVE_CHECK(check_list(NULL, n));
+ EXPENSIVE_CHECK((n == n->prev) && (n == n->next) || check_list(NULL, n));
node *z = n->prev;
node *x = n->next;