mirror of
https://gitlab.nic.cz/labs/bird.git
synced 2025-01-03 07:31:54 +00:00
Add more assertions
This commit is contained in:
parent
49ee481280
commit
74c48ab088
@ -81,6 +81,7 @@ new_node(slab *trie_slab)
|
|||||||
struct trie_node *new = sl_alloc(trie_slab);
|
struct trie_node *new = sl_alloc(trie_slab);
|
||||||
assert(new != NULL);
|
assert(new != NULL);
|
||||||
*new = (struct trie_node) { 0 };
|
*new = (struct trie_node) { 0 };
|
||||||
|
assert(new->bucket == NULL);
|
||||||
|
|
||||||
return new;
|
return new;
|
||||||
}
|
}
|
||||||
@ -189,6 +190,9 @@ first_pass(struct trie_node *node, slab *trie_slab)
|
|||||||
assert(node != NULL);
|
assert(node != NULL);
|
||||||
assert(trie_slab != NULL);
|
assert(trie_slab != NULL);
|
||||||
|
|
||||||
|
if (node->parent == NULL)
|
||||||
|
assert(node->bucket != NULL);
|
||||||
|
|
||||||
if (is_leaf(node))
|
if (is_leaf(node))
|
||||||
{
|
{
|
||||||
//node->potential_buckets[node->potential_buckets_count++] = get_ancestor_bucket(node);
|
//node->potential_buckets[node->potential_buckets_count++] = get_ancestor_bucket(node);
|
||||||
@ -402,6 +406,9 @@ second_pass(struct trie_node *node)
|
|||||||
assert(node != NULL);
|
assert(node != NULL);
|
||||||
assert(node->potential_buckets_count <= MAX_POTENTIAL_BUCKETS_COUNT);
|
assert(node->potential_buckets_count <= MAX_POTENTIAL_BUCKETS_COUNT);
|
||||||
|
|
||||||
|
if (node->parent == NULL)
|
||||||
|
assert(node->bucket != NULL);
|
||||||
|
|
||||||
if (is_leaf(node))
|
if (is_leaf(node))
|
||||||
{
|
{
|
||||||
assert(node->potential_buckets_count > 0);
|
assert(node->potential_buckets_count > 0);
|
||||||
@ -468,6 +475,9 @@ third_pass(struct trie_node *node)
|
|||||||
if (node == NULL)
|
if (node == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (node->parent == NULL)
|
||||||
|
assert(node->bucket != NULL);
|
||||||
|
|
||||||
assert(node->potential_buckets_count <= MAX_POTENTIAL_BUCKETS_COUNT);
|
assert(node->potential_buckets_count <= MAX_POTENTIAL_BUCKETS_COUNT);
|
||||||
|
|
||||||
/* Root is assigned any of its potential buckets */
|
/* Root is assigned any of its potential buckets */
|
||||||
@ -603,7 +613,6 @@ print_prefixes(const struct trie_node *node)
|
|||||||
//print_prefixes_helper(node, _MI4(0), 0);
|
//print_prefixes_helper(node, _MI4(0), 0);
|
||||||
struct net_addr_ip4 addr = { 0 };
|
struct net_addr_ip4 addr = { 0 };
|
||||||
print_prefixes_helper(node, addr, 0);
|
print_prefixes_helper(node, addr, 0);
|
||||||
log("==== END PREFIXES ====");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user