From c60bdbcf5c4b42c151838d79f6540743f4d4758a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Thu, 21 Aug 2025 08:56:29 +0200 Subject: [PATCH] Remove double non-NULL guard around bindrdataset() The bindrdataset() already has a logic to skip the rest of the function if the passed rdataset is NULL. Remove the external guarding for 'addedrdataset' to simplify the code flow both from the zone and cache databases. --- lib/dns/qpcache.c | 43 ++++++++++++++++--------------------------- lib/dns/qpzone.c | 5 +---- 2 files changed, 17 insertions(+), 31 deletions(-) diff --git a/lib/dns/qpcache.c b/lib/dns/qpcache.c index 56682966d2..fa2cfae7ac 100644 --- a/lib/dns/qpcache.c +++ b/lib/dns/qpcache.c @@ -2667,14 +2667,11 @@ add(qpcache_t *qpdb, qpcnode_t *qpnode, dns_slabheader_t *newheader, * The NXDOMAIN/NODATA(QTYPE=ANY) * is more trusted. */ - if (addedrdataset != NULL) { - bindrdataset( - qpdb, qpnode, - top->header, now, - nlocktype, tlocktype, - addedrdataset - DNS__DB_FLARG_PASS); - } + bindrdataset( + qpdb, qpnode, top->header, now, + nlocktype, tlocktype, + addedrdataset + DNS__DB_FLARG_PASS); return DNS_R_UNCHANGED; } /* @@ -2725,11 +2722,9 @@ find_header: if (trust < header->trust && (ACTIVE(header, now) || !EXISTS(header))) { - if (addedrdataset != NULL) { - bindrdataset(qpdb, qpnode, header, now, - nlocktype, tlocktype, - addedrdataset DNS__DB_FLARG_PASS); - } + bindrdataset(qpdb, qpnode, header, now, nlocktype, + tlocktype, + addedrdataset DNS__DB_FLARG_PASS); return DNS_R_UNCHANGED; } @@ -2764,11 +2759,9 @@ find_header: header->closest = newheader->closest; newheader->closest = NULL; } - if (addedrdataset != NULL) { - bindrdataset(qpdb, qpnode, header, now, - nlocktype, tlocktype, - addedrdataset DNS__DB_FLARG_PASS); - } + bindrdataset(qpdb, qpnode, header, now, nlocktype, + tlocktype, + addedrdataset DNS__DB_FLARG_PASS); return DNS_R_UNCHANGED; } @@ -2816,11 +2809,9 @@ find_header: header->closest = newheader->closest; newheader->closest = NULL; } - if (addedrdataset != NULL) { - bindrdataset(qpdb, qpnode, header, now, - nlocktype, tlocktype, - addedrdataset DNS__DB_FLARG_PASS); - } + bindrdataset(qpdb, qpnode, header, now, nlocktype, + tlocktype, + addedrdataset DNS__DB_FLARG_PASS); return DNS_R_UNCHANGED; } @@ -2893,10 +2884,8 @@ find_header: } } - if (addedrdataset != NULL) { - bindrdataset(qpdb, qpnode, newheader, now, nlocktype, tlocktype, - addedrdataset DNS__DB_FLARG_PASS); - } + bindrdataset(qpdb, qpnode, newheader, now, nlocktype, tlocktype, + addedrdataset DNS__DB_FLARG_PASS); return ISC_R_SUCCESS; } diff --git a/lib/dns/qpzone.c b/lib/dns/qpzone.c index 1db535ffbd..247434d3ac 100644 --- a/lib/dns/qpzone.c +++ b/lib/dns/qpzone.c @@ -2053,10 +2053,7 @@ add(qpzonedb_t *qpdb, qpznode_t *node, const dns_name_t *nodename, return DNS_R_CNAMEANDOTHER; } - if (addedrdataset != NULL) { - bindrdataset(qpdb, node, newheader, - addedrdataset DNS__DB_FLARG_PASS); - } + bindrdataset(qpdb, node, newheader, addedrdataset DNS__DB_FLARG_PASS); return ISC_R_SUCCESS; }