]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Torvalds style
authorAlessio Podda <alessio@isc.org>
Wed, 3 Sep 2025 23:18:47 +0000 (01:18 +0200)
committerAlessio Podda <alessio@isc.org>
Wed, 3 Sep 2025 23:18:47 +0000 (01:18 +0200)
lib/dns/qpzone.c

index 9ae93e5ad3410aedf8c42d4ec2abdf01d42d7a8d..b011a0227e61659c62bc6b85b1c8c373cce1c808 100644 (file)
@@ -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)