From 08a33a9cc94a241dc48addbd54f5a8f2419e32c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Wed, 14 Jan 2026 13:17:30 +0100 Subject: [PATCH] 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. --- lib/dns/include/dns/rdataslab.h | 6 ++---- lib/dns/qpcache.c | 6 ++---- lib/dns/rdataslab.c | 1 - 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/lib/dns/include/dns/rdataslab.h b/lib/dns/include/dns/rdataslab.h index 51a179247b..5b7e8ffc76 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 2b6eaac8c3..db0d4f9977 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 64e955cad4..e0a43e8434 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, };