From 74c48ab08816aa3fd80c8f8cddf51146fafdc4cf Mon Sep 17 00:00:00 2001 From: Igor Putovny Date: Tue, 5 Dec 2023 14:30:13 +0100 Subject: [PATCH] Add more assertions --- proto/aggregator/aggregator.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/proto/aggregator/aggregator.c b/proto/aggregator/aggregator.c index deeec401..ddb343f3 100644 --- a/proto/aggregator/aggregator.c +++ b/proto/aggregator/aggregator.c @@ -81,6 +81,7 @@ new_node(slab *trie_slab) struct trie_node *new = sl_alloc(trie_slab); assert(new != NULL); *new = (struct trie_node) { 0 }; + assert(new->bucket == NULL); return new; } @@ -189,6 +190,9 @@ first_pass(struct trie_node *node, slab *trie_slab) assert(node != NULL); assert(trie_slab != NULL); + if (node->parent == NULL) + assert(node->bucket != NULL); + if (is_leaf(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->potential_buckets_count <= MAX_POTENTIAL_BUCKETS_COUNT); + if (node->parent == NULL) + assert(node->bucket != NULL); + if (is_leaf(node)) { assert(node->potential_buckets_count > 0); @@ -468,6 +475,9 @@ third_pass(struct trie_node *node) if (node == NULL) return; + if (node->parent == NULL) + assert(node->bucket != NULL); + assert(node->potential_buckets_count <= MAX_POTENTIAL_BUCKETS_COUNT); /* 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); struct net_addr_ip4 addr = { 0 }; print_prefixes_helper(node, addr, 0); - log("==== END PREFIXES ===="); } /*