From 06216f4f9003090970e23c7ca8ce659d7e11329a Mon Sep 17 00:00:00 2001 From: Evan Hunt Date: Wed, 5 Apr 2023 00:36:37 -0700 Subject: [PATCH] rename dns_qp_findname_parent() to _findname_ancestor() this function finds the closest matching ancestor, but the function name could be read to imply that it returns the direct parent node; this commit suggests a slightly less misleading name. --- lib/dns/include/dns/qp.h | 14 +++++++------- lib/dns/qp.c | 5 +++-- lib/dns/zt.c | 6 +++--- tests/dns/qp_test.c | 4 ++-- 4 files changed, 15 insertions(+), 14 deletions(-) diff --git a/lib/dns/include/dns/qp.h b/lib/dns/include/dns/qp.h index 786c8f6064..2801c49040 100644 --- a/lib/dns/include/dns/qp.h +++ b/lib/dns/include/dns/qp.h @@ -267,7 +267,7 @@ typedef enum dns_qpgc { } dns_qpgc_t; /*% - * Options for fancy searches such as `dns_qp_findname_parent()` + * Options for fancy searches such as `dns_qp_findname_ancestor()` */ typedef enum dns_qpfind { DNS_QPFIND_NOEXACT = 1 << 0, @@ -468,14 +468,14 @@ dns_qp_getname(dns_qpreadable_t qpr, const dns_name_t *name, void **pval_r, */ isc_result_t -dns_qp_findname_parent(dns_qpreadable_t qpr, const dns_name_t *name, - dns_qpfind_t options, void **pval_r, uint32_t *ival_r); +dns_qp_findname_ancestor(dns_qpreadable_t qpr, const dns_name_t *name, + dns_qpfind_t options, void **pval_r, uint32_t *ival_r); /*%< - * Find a leaf in a qp-trie that is a parent domain of or equal to the + * Find a leaf in a qp-trie that is an ancestor domain of, or equal to, the * given DNS name. * - * If the DNS_QPFIND_NOEXACT option is set, find a strict parent - * domain not equal to the search name. + * If the DNS_QPFIND_NOEXACT option is set, find the closest ancestor + * domain that is not equal to the search name. * * The leaf values are assigned to whichever of `*pval_r` and `*ival_r` * are not null, unless the return value is ISC_R_NOTFOUND. @@ -486,7 +486,7 @@ dns_qp_findname_parent(dns_qpreadable_t qpr, const dns_name_t *name, * * Returns: * \li ISC_R_SUCCESS if an exact match was found - * \li ISC_R_PARTIALMATCH if a parent domain was found + * \li ISC_R_PARTIALMATCH if an ancestor domain was found * \li ISC_R_NOTFOUND if no match was found */ diff --git a/lib/dns/qp.c b/lib/dns/qp.c index 6b56310273..e416bf8085 100644 --- a/lib/dns/qp.c +++ b/lib/dns/qp.c @@ -1810,8 +1810,9 @@ dns_qp_getname(dns_qpreadable_t qpr, const dns_name_t *name, void **pval_r, } isc_result_t -dns_qp_findname_parent(dns_qpreadable_t qpr, const dns_name_t *name, - dns_qpfind_t options, void **pval_r, uint32_t *ival_r) { +dns_qp_findname_ancestor(dns_qpreadable_t qpr, const dns_name_t *name, + dns_qpfind_t options, void **pval_r, + uint32_t *ival_r) { dns_qpreader_t *qp = dns_qpreader(qpr); dns_qpkey_t search, found; size_t searchlen, foundlen; diff --git a/lib/dns/zt.c b/lib/dns/zt.c index 648c49436b..7f2cedadd3 100644 --- a/lib/dns/zt.c +++ b/lib/dns/zt.c @@ -180,10 +180,10 @@ dns_zt_find(dns_zt_t *zt, const dns_name_t *name, dns_ztfind_t options, if (exactopts == DNS_ZTFIND_EXACT) { result = dns_qp_getname(&qpr, name, &pval, NULL); } else if (exactopts == DNS_ZTFIND_NOEXACT) { - result = dns_qp_findname_parent(&qpr, name, DNS_QPFIND_NOEXACT, - &pval, NULL); + result = dns_qp_findname_ancestor( + &qpr, name, DNS_QPFIND_NOEXACT, &pval, NULL); } else { - result = dns_qp_findname_parent(&qpr, name, 0, &pval, NULL); + result = dns_qp_findname_ancestor(&qpr, name, 0, &pval, NULL); } dns_qpread_destroy(zt->multi, &qpr); diff --git a/tests/dns/qp_test.c b/tests/dns/qp_test.c index e2bc50bd9c..4d30f74b52 100644 --- a/tests/dns/qp_test.c +++ b/tests/dns/qp_test.c @@ -268,8 +268,8 @@ check_partialmatch(dns_qp_t *qp, struct check_partialmatch check[]) { check[i].found); #endif dns_test_namefromstring(check[i].query, &fixed); - result = dns_qp_findname_parent(qp, name, check[i].options, - &pval, NULL); + result = dns_qp_findname_ancestor(qp, name, check[i].options, + &pval, NULL); assert_int_equal(result, check[i].result); if (check[i].found == NULL) { assert_null(pval);