From: Igor Putovny Date: Wed, 3 Jul 2024 13:44:36 +0000 (+0200) Subject: Small changes, add assert X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d9c54c329267419c6ab256d3736b24dcb78d708f;p=thirdparty%2Fbird.git Small changes, add assert --- diff --git a/proto/aggregator/aggregator.c b/proto/aggregator/aggregator.c index 0eddf84a9..7801704c0 100644 --- a/proto/aggregator/aggregator.c +++ b/proto/aggregator/aggregator.c @@ -497,9 +497,7 @@ remove_potential_buckets(struct trie_node *node) static void third_pass(struct trie_node *node) { - if (!node) - return; - + assert(node != NULL); assert(node->potential_buckets_count <= MAX_POTENTIAL_BUCKETS_COUNT); /* Root is assigned any of its potential buckets */ @@ -511,6 +509,10 @@ third_pass(struct trie_node *node) } else { + // Internal nodes should not have a bucket since it was deleted during first pass + if (!is_leaf(node)) + assert(node->bucket == NULL); + const struct aggregator_bucket *inherited_bucket = get_ancestor_bucket(node); /* @@ -530,8 +532,11 @@ third_pass(struct trie_node *node) } /* Preorder traversal */ - third_pass(node->child[0]); - third_pass(node->child[1]); + if (node->child[0]) + third_pass(node->child[0]); + + if (node->child[1]) + third_pass(node->child[1]); /* Leaves with no assigned bucket are removed */ if (!node->bucket && is_leaf(node))