2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-23 02:28:55 +00:00

Merge branch 'each-simplify-rbtnodechain' into 'master'

simplify dns_rbtnodechain_init() by removing unnecessary 'mctx' parameter

See merge request isc-projects/bind9!2273
This commit is contained in:
Evan Hunt 2019-08-29 13:29:45 -04:00
commit 8b5aa19ed9
11 changed files with 33 additions and 31 deletions

View File

@ -11488,7 +11488,7 @@ delete_keynames(dns_tsig_keyring_t *ring, char *target,
origin = dns_fixedname_initname(&fixedorigin); origin = dns_fixedname_initname(&fixedorigin);
again: again:
dns_rbtnodechain_init(&chain, ring->mctx); dns_rbtnodechain_init(&chain);
result = dns_rbtnodechain_first(&chain, ring->keys, &foundname, result = dns_rbtnodechain_first(&chain, ring->keys, &foundname,
origin); origin);
if (result == ISC_R_NOTFOUND) { if (result == ISC_R_NOTFOUND) {
@ -11604,7 +11604,7 @@ list_keynames(dns_view_t *view, dns_tsig_keyring_t *ring, isc_buffer_t **text,
dns_name_init(&foundname, NULL); dns_name_init(&foundname, NULL);
origin = dns_fixedname_initname(&fixedorigin); origin = dns_fixedname_initname(&fixedorigin);
dns_rbtnodechain_init(&chain, ring->mctx); dns_rbtnodechain_init(&chain);
result = dns_rbtnodechain_first(&chain, ring->keys, &foundname, result = dns_rbtnodechain_first(&chain, ring->keys, &foundname,
origin); origin);
if (result == ISC_R_NOTFOUND) { if (result == ISC_R_NOTFOUND) {

View File

@ -103,7 +103,7 @@ detail(dns_rbt_t *rbt, dns_name_t *name) {
isc_result_t result; isc_result_t result;
bool nodes_should_match = false; bool nodes_should_match = false;
dns_rbtnodechain_init(&chain, mctx); dns_rbtnodechain_init(&chain);
origin = dns_fixedname_initname(&fixedorigin); origin = dns_fixedname_initname(&fixedorigin);
fullname = dns_fixedname_initname(&fixedfullname); fullname = dns_fixedname_initname(&fixedfullname);
@ -182,7 +182,7 @@ iterate(dns_rbt_t *rbt, bool forward) {
isc_result_t (*move)(dns_rbtnodechain_t *chain, dns_name_t *name, isc_result_t (*move)(dns_rbtnodechain_t *chain, dns_name_t *name,
dns_name_t *origin); dns_name_t *origin);
dns_rbtnodechain_init(&chain, mctx); dns_rbtnodechain_init(&chain);
dns_name_init(&foundname, NULL); dns_name_init(&foundname, NULL);
origin = dns_fixedname_initname(&fixedorigin); origin = dns_fixedname_initname(&fixedorigin);

View File

@ -0,0 +1,7 @@
@@
expression C;
expression M;
@@
- dns_rbtnodechain_init(C, M);
+ dns_rbtnodechain_init(C);

View File

@ -241,7 +241,6 @@ typedef void (*dns_rbtdeleter_t)(void *, void *);
typedef struct dns_rbtnodechain { typedef struct dns_rbtnodechain {
unsigned int magic; unsigned int magic;
isc_mem_t * mctx;
/*% /*%
* The terminal node of the chain. It is not in levels[]. * The terminal node of the chain. It is not in levels[].
* This is ostensibly private ... but in a pinch it could be * This is ostensibly private ... but in a pinch it could be
@ -837,15 +836,13 @@ dns__rbtnode_getdistance(dns_rbtnode_t *node);
*****/ *****/
void void
dns_rbtnodechain_init(dns_rbtnodechain_t *chain, isc_mem_t *mctx); dns_rbtnodechain_init(dns_rbtnodechain_t *chain);
/*%< /*%<
* Initialize 'chain'. * Initialize 'chain'.
* *
* Requires: * Requires:
*\li 'chain' is a valid pointer. *\li 'chain' is a valid pointer.
* *
*\li 'mctx' is a valid memory context.
*
* Ensures: * Ensures:
*\li 'chain' is suitable for use. *\li 'chain' is suitable for use.
*/ */

View File

@ -664,7 +664,7 @@ dns_keytable_totext(dns_keytable_t *keytable, isc_buffer_t **text) {
REQUIRE(text != NULL && *text != NULL); REQUIRE(text != NULL && *text != NULL);
RWLOCK(&keytable->rwlock, isc_rwlocktype_read); RWLOCK(&keytable->rwlock, isc_rwlocktype_read);
dns_rbtnodechain_init(&chain, keytable->mctx); dns_rbtnodechain_init(&chain);
result = dns_rbtnodechain_first(&chain, keytable->table, NULL, NULL); result = dns_rbtnodechain_first(&chain, keytable->table, NULL, NULL);
if (result != ISC_R_SUCCESS && result != DNS_R_NEWORIGIN) { if (result != ISC_R_SUCCESS && result != DNS_R_NEWORIGIN) {
if (result == ISC_R_NOTFOUND) if (result == ISC_R_NOTFOUND)
@ -713,7 +713,7 @@ dns_keytable_forall(dns_keytable_t *keytable,
REQUIRE(VALID_KEYTABLE(keytable)); REQUIRE(VALID_KEYTABLE(keytable));
RWLOCK(&keytable->rwlock, isc_rwlocktype_read); RWLOCK(&keytable->rwlock, isc_rwlocktype_read);
dns_rbtnodechain_init(&chain, keytable->mctx); dns_rbtnodechain_init(&chain);
result = dns_rbtnodechain_first(&chain, keytable->table, NULL, NULL); result = dns_rbtnodechain_first(&chain, keytable->table, NULL, NULL);
if (result != ISC_R_SUCCESS && result != DNS_R_NEWORIGIN) { if (result != ISC_R_SUCCESS && result != DNS_R_NEWORIGIN) {
if (result == ISC_R_NOTFOUND) if (result == ISC_R_NOTFOUND)

View File

@ -504,7 +504,7 @@ dns_ntatable_totext(dns_ntatable_t *ntatable, const char *view,
isc_stdtime_get(&now); isc_stdtime_get(&now);
RWLOCK(&ntatable->rwlock, isc_rwlocktype_read); RWLOCK(&ntatable->rwlock, isc_rwlocktype_read);
dns_rbtnodechain_init(&chain, ntatable->view->mctx); dns_rbtnodechain_init(&chain);
result = dns_rbtnodechain_first(&chain, ntatable->table, NULL, NULL); result = dns_rbtnodechain_first(&chain, ntatable->table, NULL, NULL);
if (result != ISC_R_SUCCESS && result != DNS_R_NEWORIGIN) { if (result != ISC_R_SUCCESS && result != DNS_R_NEWORIGIN) {
if (result == ISC_R_NOTFOUND) if (result == ISC_R_NOTFOUND)
@ -603,7 +603,7 @@ dns_ntatable_save(dns_ntatable_t *ntatable, FILE *fp) {
isc_stdtime_get(&now); isc_stdtime_get(&now);
RWLOCK(&ntatable->rwlock, isc_rwlocktype_read); RWLOCK(&ntatable->rwlock, isc_rwlocktype_read);
dns_rbtnodechain_init(&chain, ntatable->view->mctx); dns_rbtnodechain_init(&chain);
result = dns_rbtnodechain_first(&chain, ntatable->table, NULL, NULL); result = dns_rbtnodechain_first(&chain, ntatable->table, NULL, NULL);
if (result != ISC_R_SUCCESS && result != DNS_R_NEWORIGIN) if (result != ISC_R_SUCCESS && result != DNS_R_NEWORIGIN)
goto cleanup; goto cleanup;

View File

@ -1462,7 +1462,7 @@ dns_rbt_findnode(dns_rbt_t *rbt, const dns_name_t *name, dns_name_t *foundname,
if (chain == NULL) { if (chain == NULL) {
options |= DNS_RBTFIND_NOPREDECESSOR; options |= DNS_RBTFIND_NOPREDECESSOR;
chain = &localchain; chain = &localchain;
dns_rbtnodechain_init(chain, rbt->mctx); dns_rbtnodechain_init(chain);
} else } else
dns_rbtnodechain_reset(chain); dns_rbtnodechain_reset(chain);
@ -3121,14 +3121,12 @@ dns_rbt_printdot(dns_rbt_t *rbt, bool show_pointers, FILE *f) {
*/ */
void void
dns_rbtnodechain_init(dns_rbtnodechain_t *chain, isc_mem_t *mctx) { dns_rbtnodechain_init(dns_rbtnodechain_t *chain) {
REQUIRE(chain != NULL); REQUIRE(chain != NULL);
/* /*
* Initialize 'chain'. * Initialize 'chain'.
*/ */
chain->mctx = mctx;
chain->end = NULL; chain->end = NULL;
chain->level_count = 0; chain->level_count = 0;
chain->level_matches = 0; chain->level_matches = 0;

View File

@ -3410,7 +3410,7 @@ find_wildcard(rbtdb_search_t *search, dns_rbtnode_t **nodep,
break; break;
wnode = NULL; wnode = NULL;
dns_rbtnodechain_init(&wchain, NULL); dns_rbtnodechain_init(&wchain);
result = dns_rbt_findnode(rbtdb->tree, wname, result = dns_rbt_findnode(rbtdb->tree, wname,
NULL, &wnode, &wchain, NULL, &wnode, &wchain,
DNS_RBTFIND_EMPTYDATA, DNS_RBTFIND_EMPTYDATA,
@ -3548,7 +3548,7 @@ previous_closest_nsec(dns_rdatatype_t type, rbtdb_search_t *search,
* It is the first node sought in the NSEC tree. * It is the first node sought in the NSEC tree.
*/ */
*firstp = false; *firstp = false;
dns_rbtnodechain_init(nsecchain, NULL); dns_rbtnodechain_init(nsecchain);
result = dns_name_concatenate(name, origin, result = dns_name_concatenate(name, origin,
target, NULL); target, NULL);
if (result != ISC_R_SUCCESS) if (result != ISC_R_SUCCESS)
@ -3862,7 +3862,7 @@ zone_find(dns_db_t *db, const dns_name_t *name, dns_dbversion_t *version,
search.wild = false; search.wild = false;
search.zonecut = NULL; search.zonecut = NULL;
dns_fixedname_init(&search.zonecut_name); dns_fixedname_init(&search.zonecut_name);
dns_rbtnodechain_init(&search.chain, search.rbtdb->common.mctx); dns_rbtnodechain_init(&search.chain);
search.now = 0; search.now = 0;
/* /*
@ -4739,7 +4739,7 @@ cache_find(dns_db_t *db, const dns_name_t *name, dns_dbversion_t *version,
search.wild = false; search.wild = false;
search.zonecut = NULL; search.zonecut = NULL;
dns_fixedname_init(&search.zonecut_name); dns_fixedname_init(&search.zonecut_name);
dns_rbtnodechain_init(&search.chain, search.rbtdb->common.mctx); dns_rbtnodechain_init(&search.chain);
search.now = now; search.now = now;
update = NULL; update = NULL;
updatesig = NULL; updatesig = NULL;
@ -5079,7 +5079,7 @@ cache_findzonecut(dns_db_t *db, const dns_name_t *name, unsigned int options,
search.wild = false; search.wild = false;
search.zonecut = NULL; search.zonecut = NULL;
dns_fixedname_init(&search.zonecut_name); dns_fixedname_init(&search.zonecut_name);
dns_rbtnodechain_init(&search.chain, search.rbtdb->common.mctx); dns_rbtnodechain_init(&search.chain);
search.now = now; search.now = now;
if (dcnull) { if (dcnull) {
@ -5434,8 +5434,8 @@ createiterator(dns_db_t *db, unsigned int options, dns_dbiterator_t **iteratorp)
rbtdbiter->nsec3only = ((options & DNS_DB_NSEC3ONLY) != 0); rbtdbiter->nsec3only = ((options & DNS_DB_NSEC3ONLY) != 0);
rbtdbiter->nonsec3 = ((options & DNS_DB_NONSEC3) != 0); rbtdbiter->nonsec3 = ((options & DNS_DB_NONSEC3) != 0);
memset(rbtdbiter->deletions, 0, sizeof(rbtdbiter->deletions)); memset(rbtdbiter->deletions, 0, sizeof(rbtdbiter->deletions));
dns_rbtnodechain_init(&rbtdbiter->chain, db->mctx); dns_rbtnodechain_init(&rbtdbiter->chain);
dns_rbtnodechain_init(&rbtdbiter->nsec3chain, db->mctx); dns_rbtnodechain_init(&rbtdbiter->nsec3chain);
if (rbtdbiter->nsec3only) if (rbtdbiter->nsec3only)
rbtdbiter->current = &rbtdbiter->nsec3chain; rbtdbiter->current = &rbtdbiter->nsec3chain;
else else

View File

@ -292,7 +292,7 @@ rbtnode_get_distance(void **state) {
dns_test_namefromstring(name_str, &fname); dns_test_namefromstring(name_str, &fname);
name = dns_fixedname_name(&fname); name = dns_fixedname_name(&fname);
dns_rbtnodechain_init(&chain, dt_mctx); dns_rbtnodechain_init(&chain);
result = dns_rbt_findnode(ctx->rbt_distances, name, NULL, result = dns_rbt_findnode(ctx->rbt_distances, name, NULL,
&node, &chain, 0, NULL, NULL); &node, &chain, 0, NULL, NULL);
@ -730,7 +730,7 @@ rbt_remove(void **state) {
tree_ok = dns__rbt_checkproperties(mytree); tree_ok = dns__rbt_checkproperties(mytree);
assert_true(tree_ok); assert_true(tree_ok);
dns_rbtnodechain_init(&chain, dt_mctx); dns_rbtnodechain_init(&chain);
/* Now, walk through nodes in order. */ /* Now, walk through nodes in order. */
if (j == 0) { if (j == 0) {
@ -1157,7 +1157,7 @@ rbt_nodechain(void **state) {
ctx = test_context_setup(); ctx = test_context_setup();
dns_rbtnodechain_init(&chain, dt_mctx); dns_rbtnodechain_init(&chain);
dns_test_namefromstring("a", &fname); dns_test_namefromstring("a", &fname);
name = dns_fixedname_name(&fname); name = dns_fixedname_name(&fname);

View File

@ -408,7 +408,7 @@ cleanup_ring(dns_tsig_keyring_t *ring)
origin = dns_fixedname_initname(&fixedorigin); origin = dns_fixedname_initname(&fixedorigin);
again: again:
dns_rbtnodechain_init(&chain, ring->mctx); dns_rbtnodechain_init(&chain);
result = dns_rbtnodechain_first(&chain, ring->keys, &foundname, result = dns_rbtnodechain_first(&chain, ring->keys, &foundname,
origin); origin);
if (result != ISC_R_SUCCESS && result != DNS_R_NEWORIGIN) { if (result != ISC_R_SUCCESS && result != DNS_R_NEWORIGIN) {
@ -614,7 +614,7 @@ dns_tsigkeyring_dumpanddetach(dns_tsig_keyring_t **ringp, FILE *fp) {
isc_stdtime_get(&now); isc_stdtime_get(&now);
dns_name_init(&foundname, NULL); dns_name_init(&foundname, NULL);
origin = dns_fixedname_initname(&fixedorigin); origin = dns_fixedname_initname(&fixedorigin);
dns_rbtnodechain_init(&chain, ring->mctx); dns_rbtnodechain_init(&chain);
result = dns_rbtnodechain_first(&chain, ring->keys, &foundname, result = dns_rbtnodechain_first(&chain, ring->keys, &foundname,
origin); origin);
if (result != ISC_R_SUCCESS && result != DNS_R_NEWORIGIN) { if (result != ISC_R_SUCCESS && result != DNS_R_NEWORIGIN) {

View File

@ -433,7 +433,7 @@ dns_zt_setviewcommit(dns_zt_t *zt) {
REQUIRE(VALID_ZT(zt)); REQUIRE(VALID_ZT(zt));
dns_rbtnodechain_init(&chain, zt->mctx); dns_rbtnodechain_init(&chain);
result = dns_rbtnodechain_first(&chain, zt->table, NULL, NULL); result = dns_rbtnodechain_first(&chain, zt->table, NULL, NULL);
while (result == DNS_R_NEWORIGIN || result == ISC_R_SUCCESS) { while (result == DNS_R_NEWORIGIN || result == ISC_R_SUCCESS) {
@ -457,7 +457,7 @@ dns_zt_setviewrevert(dns_zt_t *zt) {
REQUIRE(VALID_ZT(zt)); REQUIRE(VALID_ZT(zt));
dns_rbtnodechain_init(&chain, zt->mctx); dns_rbtnodechain_init(&chain);
result = dns_rbtnodechain_first(&chain, zt->table, NULL, NULL); result = dns_rbtnodechain_first(&chain, zt->table, NULL, NULL);
while (result == DNS_R_NEWORIGIN || result == ISC_R_SUCCESS) { while (result == DNS_R_NEWORIGIN || result == ISC_R_SUCCESS) {
@ -485,7 +485,7 @@ dns_zt_apply(dns_zt_t *zt, bool stop, isc_result_t *sub,
REQUIRE(VALID_ZT(zt)); REQUIRE(VALID_ZT(zt));
REQUIRE(action != NULL); REQUIRE(action != NULL);
dns_rbtnodechain_init(&chain, zt->mctx); dns_rbtnodechain_init(&chain);
result = dns_rbtnodechain_first(&chain, zt->table, NULL, NULL); result = dns_rbtnodechain_first(&chain, zt->table, NULL, NULL);
if (result == ISC_R_NOTFOUND) { if (result == ISC_R_NOTFOUND) {
/* /*