]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Add more assertions
authorIgor Putovny <igor.putovny@nic.cz>
Tue, 5 Dec 2023 13:30:13 +0000 (14:30 +0100)
committerIgor Putovny <igor.putovny@nic.cz>
Tue, 5 Dec 2023 13:30:13 +0000 (14:30 +0100)
proto/aggregator/aggregator.c

index deeec4012da4175649c8bf7895294b1ef06bce9d..ddb343f3f988a1fd88fed7f6ac89c3e48d8d4b34 100644 (file)
@@ -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 ====");
 }
 
 /*