From: Ondřej Surý Date: Wed, 14 Jan 2026 12:17:30 +0000 (+0100) Subject: Remove useless .expire initialization from rdataslab X-Git-Tag: v9.21.21~3^2~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=08a33a9cc94a241dc48addbd54f5a8f2419e32c5;p=thirdparty%2Fbind9.git Remove useless .expire initialization from rdataslab dns_rdataslab_fromrdataset() set .expire to rdataset->ttl, but the only consumer (qpcache_addrdataset) immediately overwrote it with now + rdataset->ttl. Remove the redundant initialization and set the expire time only once. --- diff --git a/lib/dns/include/dns/rdataslab.h b/lib/dns/include/dns/rdataslab.h index 51a179247b9..5b7e8ffc767 100644 --- a/lib/dns/include/dns/rdataslab.h +++ b/lib/dns/include/dns/rdataslab.h @@ -191,10 +191,8 @@ dns_rdataslab_fromrdataset(dns_rdataset_t *rdataset, isc_mem_t *mctx, * * dns_rdataslab_fromrdataset() allocates space for a dns_slabheader object * and the memory needed for a raw slab, and partially initializes - * it, setting the type, trust, and TTL fields to match rdataset->type, - * rdataset->covers, rdataset->trust, and rdataset->ttl. (Note that the - * last field needs to be overridden when used in the cache database, - * since cache headers use an expire time instead of a TTL.) + * it, setting the type, and trust fields to match rdataset->type, + * rdataset->covers, and rdataset->trust. * * Requires: *\li 'rdataset' is valid. diff --git a/lib/dns/qpcache.c b/lib/dns/qpcache.c index 2b6eaac8c3e..db0d4f99777 100644 --- a/lib/dns/qpcache.c +++ b/lib/dns/qpcache.c @@ -2874,11 +2874,9 @@ qpcache_addrdataset(dns_db_t *db, dns_dbnode_t *node, dns_dbversion_t *version, dns_slabheader_reset(newheader, node); /* - * By default, dns_rdataslab_fromrdataset() sets newheader->ttl - * to the rdataset TTL. In the case of the cache, that's wrong; - * we need it to be set to the expire time instead. + * Set the correct expire time. */ - setttl(newheader, rdataset->ttl + now); + setttl(newheader, now + rdataset->ttl); if (rdataset->ttl == 0U) { DNS_SLABHEADER_SETATTR(newheader, DNS_SLABHEADERATTR_ZEROTTL); } diff --git a/lib/dns/rdataslab.c b/lib/dns/rdataslab.c index 64e955cad4e..e0a43e84347 100644 --- a/lib/dns/rdataslab.c +++ b/lib/dns/rdataslab.c @@ -110,7 +110,6 @@ newslab(dns_rdataset_t *rdataset, isc_mem_t *mctx, isc_region_t *region, *header = (dns_slabheader_t){ .headers_link = CDS_LIST_HEAD_INIT(header->headers_link), .trust = rdataset->trust, - .expire = rdataset->ttl, .dirtylink = ISC_LINK_INITIALIZER, .nitems = nitems, };