From: Alessio Podda Date: Wed, 3 Sep 2025 23:18:47 +0000 (+0200) Subject: Torvalds style X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5760f0de223bb2170c09070b09ff4fb73d7aea2d;p=thirdparty%2Fbind9.git Torvalds style --- diff --git a/lib/dns/qpzone.c b/lib/dns/qpzone.c index 9ae93e5ad34..b011a0227e6 100644 --- a/lib/dns/qpzone.c +++ b/lib/dns/qpzone.c @@ -825,40 +825,22 @@ clean_zone_node(qpznode_t *node, uint32_t least_serial) { DNS_SLABTOP_FOREACH(top, node->data) { INSIST(top->header != NULL); - /* - * First, we clean up any instances of multiple rdatasets - * with the same serial number, or that have the IGNORE - * attribute. - */ - dns_slabheader_t *dcurrent = NULL; - dns_slabheader_t *dcurrent_down = NULL, *dparent = NULL; - - dparent = top->header; - for (dcurrent = dparent->down; dcurrent != NULL; - dcurrent = dcurrent_down) - { - dcurrent_down = dcurrent->down; - INSIST(dcurrent->serial <= dparent->serial); - if (dcurrent->serial == dparent->serial || - IGNORE(dcurrent)) - { - dparent->down = dcurrent_down; - dns_slabheader_destroy(&dcurrent); + /* Torvalds style */ + uint32_t parent_serial = -1; /* Maybe should be bigger than uint32 max? */ + dns_slabheader_t **parent_p = &top->header; + + while (*parent_p != NULL) { + dns_slabheader_t *child = *parent_p; + + if (child->serial == parent_serial || IGNORE(child)) { + *parent_p = child->down; + dns_slabheader_destroy(&child); } else { - dparent = dcurrent; + parent_p = &(child->down); + parent_serial = child->serial; } } - /* - * We've now eliminated all IGNORE datasets with the possible - * exception of current, which we now check. - */ - dcurrent = top->header; - if (IGNORE(dcurrent)) { - top->header = dcurrent->down; - dns_slabheader_destroy(&dcurrent); - } - if (top->header == NULL) { goto empty; } @@ -868,6 +850,9 @@ clean_zone_node(qpznode_t *node, uint32_t least_serial) { * serial, and if there are such rdatasets, delete it and any * older versions. */ + dns_slabheader_t *dcurrent = NULL; + dns_slabheader_t *dcurrent_down = NULL, *dparent = NULL; + dparent = top->header; for (dcurrent = dparent->down; dcurrent != NULL; dcurrent = dcurrent_down)