]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
fixup! fixup! fixup! fixup! Add slabheader foreach macro
authorAlessio Podda <alessio@isc.org>
Wed, 3 Sep 2025 22:15:38 +0000 (00:15 +0200)
committerAlessio Podda <alessio@isc.org>
Wed, 3 Sep 2025 22:17:11 +0000 (00:17 +0200)
lib/dns/qpzone.c

index c6da3563be18331531d5a4ecf56571928b519adb..45c0b2e548567e59ef5d920dc1ebfdddb2ea9030 100644 (file)
@@ -2662,19 +2662,22 @@ step(qpz_search_t *search, dns_qpiter_t *it, direction_t direction,
        while (result == ISC_R_SUCCESS) {
                isc_rwlock_t *nlock = qpzone_get_lock(node);
                isc_rwlocktype_t nlocktype = isc_rwlocktype_none;
-               dns_slabheader_t *found = NULL;
 
                NODE_RDLOCK(nlock, &nlocktype);
+
+               dns_slabheader_t *found = NULL;
                DNS_SLABTOP_FOREACH(top, node->data) {
-                       dns_slabheader_t *header = top->header;
-                       while (header != NULL &&
-                              (IGNORE(header) ||
-                               header->serial > search->serial))
-                       {
-                               header = header->down;
+                       SLABHEADER_FOREACH_SAFE(top->header, inner, down) {
+                               if (inner->serial <= search->serial &&
+                                   !IGNORE(inner))
+                               {
+                                       if (EXISTS(inner)) {
+                                               found = inner;
+                                       }
+                                       break;
+                               }
                        }
-                       if (header != NULL && EXISTS(header)) {
-                               found = header;
+                       if (found != NULL) {
                                break;
                        }
                }
@@ -3046,35 +3049,34 @@ again:
                NODE_RDLOCK(nlock, &nlocktype);
                empty_node = true;
                DNS_SLABTOP_FOREACH(top, node->data) {
-                       dns_slabheader_t *header = top->header;
+
                        /*
                         * Look for an active, extant NSEC or RRSIG NSEC.
                         */
-                       do {
-                               if (header->serial <= search->serial &&
-                                   !IGNORE(header))
+                       dns_slabheader_t *candidate = NULL;
+                       SLABHEADER_FOREACH_SAFE(top->header, inner, down) {
+                               if (inner->serial <= search->serial &&
+                                   !IGNORE(inner))
                                {
-                                       if (!EXISTS(header)) {
-                                               header = NULL;
+                                       if (EXISTS(inner)) {
+                                               candidate = inner;
                                        }
                                        break;
-                               } else {
-                                       header = header->down;
                                }
-                       } while (header != NULL);
-                       if (header != NULL) {
+                       }
+                       if (candidate != NULL) {
                                /*
                                 * We now know that there is at least one
                                 * active rdataset at this node.
                                 */
                                empty_node = false;
                                if (top->typepair == typepair) {
-                                       found = header;
+                                       found = candidate;
                                        if (foundsig != NULL) {
                                                break;
                                        }
                                } else if (top->typepair == sigpair) {
-                                       foundsig = header;
+                                       foundsig = candidate;
                                        if (found != NULL) {
                                                break;
                                        }