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

fix: dev: Enforce type checking for dns_dbnode_t

Originally, the dns_dbnode_t was typedef'ed to void type.  This allowed
some flexibility, but using (void *) just removes any type-checking that
C might have.  Instead of using:

    typedef void dns_dbnode_t;

use a trick to define the type to non-existing structure:

    typedef struct dns_dbnode dns_dbnode_t;

This allows the C compilers to employ the type-checking while the
structure itself doesn't have to be ever defined because the actual
'storage' is never accessed using dns_dbnode_t type.

Merge branch 'ondrej/non-void-dns_dbnode_t' into 'main'

See merge request isc-projects/bind9!9719
This commit is contained in:
Ondřej Surý 2024-11-06 17:05:03 +00:00
commit 4b47c4f628
9 changed files with 101 additions and 84 deletions

View File

@ -859,7 +859,7 @@ getoriginnode(dns_db_t *db, dns_dbnode_t **nodep DNS__DB_FLARG) {
return (result);
}
*nodep = node;
*nodep = (dns_dbnode_t *)node;
return (ISC_R_SUCCESS);
}
@ -905,7 +905,7 @@ findnode(dns_db_t *db, const dns_name_t *name, bool create,
}
}
*nodep = node;
*nodep = (dns_dbnode_t *)node;
return (ISC_R_SUCCESS);
}
@ -1015,7 +1015,7 @@ find(dns_db_t *db, const dns_name_t *name, dns_dbversion_t *version,
* and try again.
*/
if (i < nlabels) {
destroynode(node);
destroynode((bdbnode_t *)node);
node = NULL;
continue;
}

View File

@ -61,11 +61,12 @@ typedef struct dns_db dns_db_t;
typedef struct dns_dbimplementation dns_dbimplementation_t;
typedef struct dns_dbiterator dns_dbiterator_t;
typedef void dns_dbload_t;
typedef void dns_dbnode_t;
typedef struct dns_dbonupdatelistener dns_dbonupdatelistener_t;
typedef void dns_dbversion_t;
typedef struct dns_dlzimplementation dns_dlzimplementation_t;
typedef struct dns_dlzdb dns_dlzdb_t;
typedef struct dns_dbnode dns_dbnode_t; /* this is dummy struct for proper type
checking */
typedef struct dns_dbonupdatelistener dns_dbonupdatelistener_t;
typedef void dns_dbversion_t;
typedef struct dns_dlzimplementation dns_dlzimplementation_t;
typedef struct dns_dlzdb dns_dlzdb_t;
typedef ISC_LIST(dns_dlzdb_t) dns_dlzdblist_t;
typedef struct dns_dyndbctx dns_dyndbctx_t;
typedef struct dns_sdlzimplementation dns_sdlzimplementation_t;

View File

@ -1113,7 +1113,7 @@ setup_delegation(qpc_search_t *search, dns_dbnode_t **nodep,
* count here because we're going to use the reference we
* already have in the search block.
*/
*nodep = node;
*nodep = (dns_dbnode_t *)node;
search->need_cleanup = false;
}
if (rdataset != NULL) {
@ -1380,7 +1380,7 @@ find_deepest_zonecut(qpc_search_t *search, qpcnode_t *node,
if (nodep != NULL) {
newref(search->qpdb, node, nlocktype,
isc_rwlocktype_none DNS__DB_FLARG_PASS);
*nodep = node;
*nodep = (dns_dbnode_t *)node;
}
bindrdataset(search->qpdb, node, found, search->now,
nlocktype, isc_rwlocktype_none,
@ -1519,7 +1519,7 @@ find_coveringnsec(qpc_search_t *search, const dns_name_t *name,
dns_name_copy(fname, foundname);
*nodep = node;
*nodep = (dns_dbnode_t *)node;
result = DNS_R_COVERINGNSEC;
} else {
result = ISC_R_NOTFOUND;
@ -1810,7 +1810,7 @@ find(dns_db_t *db, const dns_name_t *name, dns_dbversion_t *version,
if (nodep != NULL) {
newref(search.qpdb, node, nlocktype,
tlocktype DNS__DB_FLARG_PASS);
*nodep = node;
*nodep = (dns_dbnode_t *)node;
}
bindrdataset(search.qpdb, node, nsecheader, search.now,
nlocktype, tlocktype,
@ -1854,7 +1854,7 @@ find(dns_db_t *db, const dns_name_t *name, dns_dbversion_t *version,
if (nodep != NULL) {
newref(search.qpdb, node, nlocktype,
tlocktype DNS__DB_FLARG_PASS);
*nodep = node;
*nodep = (dns_dbnode_t *)node;
}
bindrdataset(search.qpdb, node, nsheader, search.now,
nlocktype, tlocktype,
@ -1888,7 +1888,7 @@ find(dns_db_t *db, const dns_name_t *name, dns_dbversion_t *version,
if (nodep != NULL) {
newref(search.qpdb, node, nlocktype,
tlocktype DNS__DB_FLARG_PASS);
*nodep = node;
*nodep = (dns_dbnode_t *)node;
}
if (NEGATIVE(found)) {
@ -2108,7 +2108,7 @@ findzonecut(dns_db_t *db, const dns_name_t *name, unsigned int options,
if (nodep != NULL) {
newref(search.qpdb, node, nlocktype,
tlocktype DNS__DB_FLARG_PASS);
*nodep = node;
*nodep = (dns_dbnode_t *)node;
}
bindrdataset(search.qpdb, node, found, search.now, nlocktype, tlocktype,
@ -3424,7 +3424,7 @@ addrdataset(dns_db_t *db, dns_dbnode_t *node, dns_dbversion_t *version,
.type = DNS_TYPEPAIR_VALUE(rdataset->type, rdataset->covers),
.trust = rdataset->trust,
.last_used = now,
.node = qpnode,
.node = (dns_dbnode_t *)qpnode,
};
dns_slabheader_reset(newheader, db, node);
@ -3633,7 +3633,7 @@ getoriginnode(dns_db_t *db, dns_dbnode_t **nodep DNS__DB_FLARG) {
if (onode != NULL) {
newref(qpdb, onode, isc_rwlocktype_none,
isc_rwlocktype_none DNS__DB_FLARG_PASS);
*nodep = qpdb->origin_node;
*nodep = (dns_dbnode_t *)qpdb->origin_node;
} else {
result = ISC_R_NOTFOUND;
}
@ -3807,7 +3807,7 @@ static isc_result_t
rdatasetiter_first(dns_rdatasetiter_t *it DNS__DB_FLARG) {
qpc_rditer_t *iterator = (qpc_rditer_t *)it;
qpcache_t *qpdb = (qpcache_t *)(iterator->common.db);
qpcnode_t *qpnode = iterator->common.node;
qpcnode_t *qpnode = (qpcnode_t *)iterator->common.node;
dns_slabheader_t *header = NULL, *top_next = NULL;
isc_rwlocktype_t nlocktype = isc_rwlocktype_none;
@ -3850,7 +3850,7 @@ static isc_result_t
rdatasetiter_next(dns_rdatasetiter_t *it DNS__DB_FLARG) {
qpc_rditer_t *iterator = (qpc_rditer_t *)it;
qpcache_t *qpdb = (qpcache_t *)(iterator->common.db);
qpcnode_t *qpnode = iterator->common.node;
qpcnode_t *qpnode = (qpcnode_t *)iterator->common.node;
dns_slabheader_t *header = NULL, *top_next = NULL;
dns_typepair_t type, negtype;
dns_rdatatype_t rdtype, covers;
@ -3939,7 +3939,7 @@ rdatasetiter_current(dns_rdatasetiter_t *it,
dns_rdataset_t *rdataset DNS__DB_FLARG) {
qpc_rditer_t *iterator = (qpc_rditer_t *)it;
qpcache_t *qpdb = (qpcache_t *)(iterator->common.db);
qpcnode_t *qpnode = iterator->common.node;
qpcnode_t *qpnode = (qpcnode_t *)iterator->common.node;
dns_slabheader_t *header = NULL;
isc_rwlocktype_t nlocktype = isc_rwlocktype_none;
@ -4245,7 +4245,7 @@ dbiterator_current(dns_dbiterator_t *iterator, dns_dbnode_t **nodep,
newref(qpdb, node, isc_rwlocktype_none,
qpdbiter->tree_locked DNS__DB_FLARG_PASS);
*nodep = qpdbiter->node;
*nodep = (dns_dbnode_t *)qpdbiter->node;
return (ISC_R_SUCCESS);
}

View File

@ -1304,7 +1304,7 @@ closeversion(dns_db_t *db, dns_dbversion_t **versionp,
* it the current version.
*/
if (version->writer && commit) {
setsecure(db, version, qpdb->origin);
setsecure(db, version, (dns_dbnode_t *)qpdb->origin);
}
RWLOCK(&qpdb->lock, isc_rwlocktype_write);
@ -2115,12 +2115,12 @@ loading_addrdataset(void *arg, const dns_name_t *name,
.type = DNS_TYPEPAIR_VALUE(rdataset->type, rdataset->covers),
.ttl = rdataset->ttl + loadctx->now,
.trust = rdataset->trust,
.node = node,
.node = (dns_dbnode_t *)node,
.serial = 1,
.count = 1,
};
dns_slabheader_reset(newheader, (dns_db_t *)qpdb, node);
dns_slabheader_reset(newheader, (dns_db_t *)qpdb, (dns_dbnode_t *)node);
dns_slabheader_setownercase(newheader, name);
if ((rdataset->attributes & DNS_RDATASETATTR_RESIGN) != 0) {
@ -2226,7 +2226,7 @@ endload(dns_db_t *db, dns_rdatacallbacks_t *callbacks) {
if (qpdb->origin != NULL) {
dns_dbversion_t *version = qpdb->current_version;
RWUNLOCK(&qpdb->lock, isc_rwlocktype_write);
setsecure(db, version, qpdb->origin);
setsecure(db, version, (dns_dbnode_t *)qpdb->origin);
} else {
RWUNLOCK(&qpdb->lock, isc_rwlocktype_write);
}
@ -2587,7 +2587,7 @@ setup_delegation(qpz_search_t *search, dns_dbnode_t **nodep,
* count here because we're going to use the reference we
* already have in the search block.
*/
*nodep = node;
*nodep = (dns_dbnode_t *)node;
search->need_cleanup = false;
}
if (rdataset != NULL) {
@ -3080,7 +3080,7 @@ again:
if (nodep != NULL) {
newref(search->qpdb,
node DNS__DB_FLARG_PASS);
*nodep = node;
*nodep = (dns_dbnode_t *)node;
}
bindrdataset(search->qpdb, node, found,
search->now,
@ -3678,7 +3678,7 @@ found:
}
if (nodep != NULL) {
newref(search.qpdb, node DNS__DB_FLARG_PASS);
*nodep = node;
*nodep = (dns_dbnode_t *)node;
}
if ((search.version->secure && !search.version->havensec3)) {
bindrdataset(search.qpdb, node, nsecheader, 0,
@ -3745,7 +3745,7 @@ found:
} else {
search.need_cleanup = false;
}
*nodep = node;
*nodep = (dns_dbnode_t *)node;
}
if (type != dns_rdatatype_any) {
@ -3814,7 +3814,7 @@ allrdatasets(dns_db_t *db, dns_dbnode_t *dbnode, dns_dbversion_t *dbversion,
*iterator = (qpdb_rdatasetiter_t){
.common.methods = &rdatasetiter_methods,
.common.db = db,
.common.node = node,
.common.node = (dns_dbnode_t *)node,
.common.version = (dns_dbversion_t *)version,
.common.options = options,
.common.magic = DNS_RDATASETITER_MAGIC,
@ -3936,16 +3936,14 @@ setloop(dns_db_t *db, isc_loop_t *loop) {
static isc_result_t
getoriginnode(dns_db_t *db, dns_dbnode_t **nodep DNS__DB_FLARG) {
qpzonedb_t *qpdb = (qpzonedb_t *)db;
qpznode_t *onode = NULL;
REQUIRE(VALID_QPZONE(qpdb));
REQUIRE(nodep != NULL && *nodep == NULL);
/* Note that the access to the origin node doesn't require a DB lock */
onode = (qpznode_t *)qpdb->origin;
INSIST(onode != NULL);
newref(qpdb, onode DNS__DB_FLARG_PASS);
*nodep = onode;
INSIST(qpdb->origin != NULL);
newref(qpdb, qpdb->origin DNS__DB_FLARG_PASS);
*nodep = (dns_dbnode_t *)qpdb->origin;
return (ISC_R_SUCCESS);
}
@ -4005,7 +4003,7 @@ static isc_result_t
rdatasetiter_first(dns_rdatasetiter_t *iterator DNS__DB_FLARG) {
qpdb_rdatasetiter_t *qrditer = (qpdb_rdatasetiter_t *)iterator;
qpzonedb_t *qpdb = (qpzonedb_t *)(qrditer->common.db);
qpznode_t *node = qrditer->common.node;
qpznode_t *node = (qpznode_t *)qrditer->common.node;
qpz_version_t *version = qrditer->common.version;
dns_slabheader_t *header = NULL, *top_next = NULL;
isc_rwlocktype_t nlocktype = isc_rwlocktype_none;
@ -4046,7 +4044,7 @@ static isc_result_t
rdatasetiter_next(dns_rdatasetiter_t *iterator DNS__DB_FLARG) {
qpdb_rdatasetiter_t *qrditer = (qpdb_rdatasetiter_t *)iterator;
qpzonedb_t *qpdb = (qpzonedb_t *)(qrditer->common.db);
qpznode_t *node = qrditer->common.node;
qpznode_t *node = (qpznode_t *)qrditer->common.node;
qpz_version_t *version = qrditer->common.version;
dns_slabheader_t *header = NULL, *top_next = NULL;
dns_typepair_t type, negtype;
@ -4118,7 +4116,7 @@ rdatasetiter_current(dns_rdatasetiter_t *iterator,
dns_rdataset_t *rdataset DNS__DB_FLARG) {
qpdb_rdatasetiter_t *qrditer = (qpdb_rdatasetiter_t *)iterator;
qpzonedb_t *qpdb = (qpzonedb_t *)(qrditer->common.db);
qpznode_t *node = qrditer->common.node;
qpznode_t *node = (qpznode_t *)qrditer->common.node;
dns_slabheader_t *header = NULL;
isc_rwlocktype_t nlocktype = isc_rwlocktype_none;
@ -4508,7 +4506,7 @@ dbiterator_current(dns_dbiterator_t *iterator, dns_dbnode_t **nodep,
newref(qpdb, node DNS__DB_FLARG_PASS);
*nodep = qpdbiter->node;
*nodep = (dns_dbnode_t *)qpdbiter->node;
return (ISC_R_SUCCESS);
}
@ -4615,10 +4613,10 @@ addrdataset(dns_db_t *db, dns_dbnode_t *dbnode, dns_dbversion_t *dbversion,
*newheader = (dns_slabheader_t){
.type = DNS_TYPEPAIR_VALUE(rdataset->type, rdataset->covers),
.trust = rdataset->trust,
.node = node,
.node = (dns_dbnode_t *)node,
};
dns_slabheader_reset(newheader, db, node);
dns_slabheader_reset(newheader, db, (dns_dbnode_t *)node);
newheader->ttl = rdataset->ttl;
if (rdataset->ttl == 0U) {
DNS_SLABHEADER_SETATTR(newheader, DNS_SLABHEADERATTR_ZEROTTL);
@ -4729,7 +4727,7 @@ subtractrdataset(dns_db_t *db, dns_dbnode_t *dbnode, dns_dbversion_t *dbversion,
}
newheader = (dns_slabheader_t *)region.base;
dns_slabheader_reset(newheader, db, node);
dns_slabheader_reset(newheader, db, (dns_dbnode_t *)node);
newheader->ttl = rdataset->ttl;
newheader->type = DNS_TYPEPAIR_VALUE(rdataset->type, rdataset->covers);
atomic_init(&newheader->attributes, 0);
@ -4740,7 +4738,7 @@ subtractrdataset(dns_db_t *db, dns_dbnode_t *dbnode, dns_dbversion_t *dbversion,
atomic_init(&newheader->count,
atomic_fetch_add_relaxed(&init_count, 1));
newheader->last_used = 0;
newheader->node = node;
newheader->node = (dns_dbnode_t *)node;
newheader->db = (dns_db_t *)qpdb;
if ((rdataset->attributes & DNS_RDATASETATTR_RESIGN) != 0) {
DNS_SLABHEADER_SETATTR(newheader, DNS_SLABHEADERATTR_RESIGN);
@ -4795,7 +4793,8 @@ subtractrdataset(dns_db_t *db, dns_dbnode_t *dbnode, dns_dbversion_t *dbversion,
if (result == ISC_R_SUCCESS) {
dns_slabheader_destroy(&newheader);
newheader = (dns_slabheader_t *)subresult;
dns_slabheader_reset(newheader, db, node);
dns_slabheader_reset(newheader, db,
(dns_dbnode_t *)node);
dns_slabheader_copycase(newheader, header);
if (RESIGN(header)) {
DNS_SLABHEADER_SETATTR(
@ -4905,7 +4904,7 @@ deleterdataset(dns_db_t *db, dns_dbnode_t *dbnode, dns_dbversion_t *dbversion,
return (ISC_R_NOTIMPLEMENTED);
}
newheader = dns_slabheader_new(db, node);
newheader = dns_slabheader_new(db, (dns_dbnode_t *)node);
newheader->type = DNS_TYPEPAIR_VALUE(type, covers);
newheader->ttl = 0;
atomic_init(&newheader->attributes, DNS_SLABHEADERATTR_NONEXISTENT);
@ -5063,11 +5062,12 @@ glue_nsdname_cb(void *arg, const dns_name_t *name, dns_rdatatype_t qtype,
if (node_a != NULL) {
dns__db_detachnode(ctx->db,
(dns_dbnode_t *)&node_a DNS__DB_FLARG_PASS);
(dns_dbnode_t **)&node_a DNS__DB_FLARG_PASS);
}
if (node_aaaa != NULL) {
dns__db_detachnode(
ctx->db, (dns_dbnode_t *)&node_aaaa DNS__DB_FLARG_PASS);
ctx->db,
(dns_dbnode_t **)&node_aaaa DNS__DB_FLARG_PASS);
}
return (result);
@ -5240,7 +5240,8 @@ free_gluenode(dns_gluenode_t *gluenode) {
static uint32_t
qpznode_hash(const qpznode_t *node) {
return (isc_hash32(&node, sizeof(node), true));
const uintptr_t key = (uintptr_t)node;
return (isc_hash32(&key, sizeof(key), true));
}
static int

View File

@ -295,7 +295,7 @@ setup_delegation(rbtdb_search_t *search, dns_dbnode_t **nodep,
* count here because we're going to use the reference we
* already have in the search block.
*/
*nodep = node;
*nodep = (dns_dbnode_t *)node;
search->need_cleanup = false;
}
if (rdataset != NULL) {
@ -593,7 +593,7 @@ find_deepest_zonecut(rbtdb_search_t *search, dns_rbtnode_t *node,
if (nodep != NULL) {
dns__rbtdb_newref(search->rbtdb, node,
nlocktype DNS__DB_FLARG_PASS);
*nodep = node;
*nodep = (dns_dbnode_t *)node;
}
dns__rbtdb_bindrdataset(search->rbtdb, node, found,
search->now, nlocktype,
@ -748,7 +748,7 @@ find_coveringnsec(rbtdb_search_t *search, const dns_name_t *name,
dns_name_copy(fname, foundname);
*nodep = node;
*nodep = (dns_dbnode_t *)node;
result = DNS_R_COVERINGNSEC;
} else {
result = ISC_R_NOTFOUND;
@ -1011,7 +1011,7 @@ cache_find(dns_db_t *db, const dns_name_t *name, dns_dbversion_t *version,
if (nodep != NULL) {
dns__rbtdb_newref(search.rbtdb, node,
nlocktype DNS__DB_FLARG_PASS);
*nodep = node;
*nodep = (dns_dbnode_t *)node;
}
dns__rbtdb_bindrdataset(search.rbtdb, node, nsecheader,
search.now, nlocktype,
@ -1056,7 +1056,7 @@ cache_find(dns_db_t *db, const dns_name_t *name, dns_dbversion_t *version,
if (nodep != NULL) {
dns__rbtdb_newref(search.rbtdb, node,
nlocktype DNS__DB_FLARG_PASS);
*nodep = node;
*nodep = (dns_dbnode_t *)node;
}
dns__rbtdb_bindrdataset(search.rbtdb, node, nsheader,
search.now, nlocktype,
@ -1091,7 +1091,7 @@ cache_find(dns_db_t *db, const dns_name_t *name, dns_dbversion_t *version,
if (nodep != NULL) {
dns__rbtdb_newref(search.rbtdb, node,
nlocktype DNS__DB_FLARG_PASS);
*nodep = node;
*nodep = (dns_dbnode_t *)node;
}
if (NEGATIVE(found)) {
@ -1307,7 +1307,7 @@ cache_findzonecut(dns_db_t *db, const dns_name_t *name, unsigned int options,
if (nodep != NULL) {
dns__rbtdb_newref(search.rbtdb, node,
nlocktype DNS__DB_FLARG_PASS);
*nodep = node;
*nodep = (dns_dbnode_t *)node;
}
dns__rbtdb_bindrdataset(search.rbtdb, node, found, search.now,

View File

@ -285,7 +285,7 @@ setup_delegation(rbtdb_search_t *search, dns_dbnode_t **nodep,
* count here because we're going to use the reference we
* already have in the search block.
*/
*nodep = node;
*nodep = (dns_dbnode_t *)node;
search->need_cleanup = false;
}
if (rdataset != NULL) {
@ -905,7 +905,7 @@ again:
search->rbtdb, node,
isc_rwlocktype_read
DNS__DB_FLARG_PASS);
*nodep = node;
*nodep = (dns_dbnode_t *)node;
}
dns__rbtdb_bindrdataset(
search->rbtdb, node, found,
@ -1373,7 +1373,7 @@ found:
if (nodep != NULL) {
dns__rbtdb_newref(search.rbtdb, node,
nlocktype DNS__DB_FLARG_PASS);
*nodep = node;
*nodep = (dns_dbnode_t *)node;
}
if ((search.rbtversion->secure &&
!search.rbtversion->havensec3))
@ -1447,7 +1447,7 @@ found:
} else {
search.need_cleanup = false;
}
*nodep = node;
*nodep = (dns_dbnode_t *)node;
}
if (type != dns_rdatatype_any) {
@ -1758,12 +1758,13 @@ loading_addrdataset(void *arg, const dns_name_t *name,
.type = DNS_TYPEPAIR_VALUE(rdataset->type, rdataset->covers),
.ttl = rdataset->ttl + loadctx->now,
.trust = rdataset->trust,
.node = node,
.node = (dns_dbnode_t *)node,
.serial = 1,
.count = 1,
};
dns_slabheader_reset(newheader, (dns_db_t *)rbtdb, node);
dns_slabheader_reset(newheader, (dns_db_t *)rbtdb,
(dns_dbnode_t *)node);
dns_slabheader_setownercase(newheader, name);
if ((rdataset->attributes & DNS_RDATASETATTR_RESIGN) != 0) {
@ -1844,7 +1845,8 @@ endload(dns_db_t *db, dns_rdatacallbacks_t *callbacks) {
if (rbtdb->origin_node != NULL) {
dns_dbversion_t *version = rbtdb->current_version;
RWUNLOCK(&rbtdb->lock, isc_rwlocktype_write);
dns__rbtdb_setsecure(db, version, rbtdb->origin_node);
dns__rbtdb_setsecure(db, version,
(dns_dbnode_t *)rbtdb->origin_node);
} else {
RWUNLOCK(&rbtdb->lock, isc_rwlocktype_write);
}
@ -2214,11 +2216,12 @@ glue_nsdname_cb(void *arg, const dns_name_t *name, dns_rdatatype_t qtype,
if (node_a != NULL) {
dns__db_detachnode(ctx->db,
(dns_dbnode_t *)&node_a DNS__DB_FLARG_PASS);
(dns_dbnode_t **)&node_a DNS__DB_FLARG_PASS);
}
if (node_aaaa != NULL) {
dns__db_detachnode(
ctx->db, (dns_dbnode_t *)&node_aaaa DNS__DB_FLARG_PASS);
ctx->db,
(dns_dbnode_t **)&node_aaaa DNS__DB_FLARG_PASS);
}
return (result);
@ -2320,7 +2323,7 @@ newglue(dns_db_t *db, dns_dbversion_t *dbversion, dns_rbtnode_t *node,
* determining which NS records in the delegation are
* in-bailiwick).
*/
dns__rbtdb_nodefullname(db, node, ctx.nodename);
dns__rbtdb_nodefullname(db, (dns_dbnode_t *)node, ctx.nodename);
(void)dns_rdataset_additionaldata(rdataset, dns_rootname,
glue_nsdname_cb, &ctx);
@ -2341,14 +2344,16 @@ new_gluenode(dns_db_t *db, dns_dbversion_t *dbversion, dns_rbtnode_t *node,
};
isc_mem_attach(db->mctx, &gluenode->mctx);
dns_db_attachnode(db, node, (dns_dbnode_t **)&gluenode->node);
dns_db_attachnode(db, (dns_dbnode_t *)node,
(dns_dbnode_t **)&gluenode->node);
return (gluenode);
}
static uint32_t
rbtnode_hash(const dns_rbtnode_t *node) {
return (isc_hash32(&node, sizeof(node), true));
uintptr_t key = (uintptr_t)node;
return (isc_hash32(&key, sizeof(key), true));
}
static int

View File

@ -1802,7 +1802,8 @@ dns__rbtdb_closeversion(dns_db_t *db, dns_dbversion_t **versionp,
* it the current version.
*/
if (version->writer && commit && !IS_CACHE(rbtdb)) {
dns__rbtdb_setsecure(db, version, rbtdb->origin_node);
dns__rbtdb_setsecure(db, version,
(dns_dbnode_t *)rbtdb->origin_node);
}
RWLOCK(&rbtdb->lock, isc_rwlocktype_write);
@ -3277,7 +3278,7 @@ dns__rbtdb_addrdataset(dns_db_t *db, dns_dbnode_t *node,
* SOA records are only allowed at top of zone.
*/
if (rdataset->type == dns_rdatatype_soa &&
node != rbtdb->origin_node)
node != (dns_dbnode_t *)rbtdb->origin_node)
{
return (DNS_R_NOTZONETOP);
}
@ -3315,7 +3316,7 @@ dns__rbtdb_addrdataset(dns_db_t *db, dns_dbnode_t *node,
.type = DNS_TYPEPAIR_VALUE(rdataset->type, rdataset->covers),
.trust = rdataset->trust,
.last_used = now,
.node = rbtnode,
.node = (dns_dbnode_t *)rbtnode,
};
dns_slabheader_reset(newheader, db, node);
@ -3534,7 +3535,7 @@ dns__rbtdb_subtractrdataset(dns_db_t *db, dns_dbnode_t *node,
atomic_init(&newheader->count,
atomic_fetch_add_relaxed(&init_count, 1));
newheader->last_used = 0;
newheader->node = rbtnode;
newheader->node = (dns_dbnode_t *)rbtnode;
newheader->db = (dns_db_t *)rbtdb;
if ((rdataset->attributes & DNS_RDATASETATTR_RESIGN) != 0) {
DNS_SLABHEADER_SETATTR(newheader, DNS_SLABHEADERATTR_RESIGN);
@ -3694,7 +3695,8 @@ unlock:
RWLOCK(&rbtdb->lock, isc_rwlocktype_read);
version = rbtdb->current_version;
RWUNLOCK(&rbtdb->lock, isc_rwlocktype_read);
dns__rbtdb_setsecure(db, version, rbtdb->origin_node);
dns__rbtdb_setsecure(db, version,
(dns_dbnode_t *)rbtdb->origin_node);
}
return (result);
@ -3747,7 +3749,8 @@ dns__rbtdb_deleterdataset(dns_db_t *db, dns_dbnode_t *node,
RWLOCK(&rbtdb->lock, isc_rwlocktype_read);
version = rbtdb->current_version;
RWUNLOCK(&rbtdb->lock, isc_rwlocktype_read);
dns__rbtdb_setsecure(db, version, rbtdb->origin_node);
dns__rbtdb_setsecure(db, version,
(dns_dbnode_t *)rbtdb->origin_node);
}
return (result);
@ -3828,7 +3831,7 @@ dns__rbtdb_getoriginnode(dns_db_t *db, dns_dbnode_t **nodep DNS__DB_FLARG) {
if (onode != NULL) {
dns__rbtdb_newref(rbtdb, onode,
isc_rwlocktype_none DNS__DB_FLARG_PASS);
*nodep = rbtdb->origin_node;
*nodep = (dns_dbnode_t *)rbtdb->origin_node;
} else {
INSIST(IS_CACHE(rbtdb));
result = ISC_R_NOTFOUND;
@ -4146,7 +4149,7 @@ static isc_result_t
rdatasetiter_first(dns_rdatasetiter_t *iterator DNS__DB_FLARG) {
rbtdb_rdatasetiter_t *rbtiterator = (rbtdb_rdatasetiter_t *)iterator;
dns_rbtdb_t *rbtdb = (dns_rbtdb_t *)(rbtiterator->common.db);
dns_rbtnode_t *rbtnode = rbtiterator->common.node;
dns_rbtnode_t *rbtnode = (dns_rbtnode_t *)rbtiterator->common.node;
dns_rbtdb_version_t *rbtversion = rbtiterator->common.version;
dns_slabheader_t *header = NULL, *top_next = NULL;
uint32_t serial = IS_CACHE(rbtdb) ? 1 : rbtversion->serial;
@ -4194,7 +4197,7 @@ static isc_result_t
rdatasetiter_next(dns_rdatasetiter_t *iterator DNS__DB_FLARG) {
rbtdb_rdatasetiter_t *rbtiterator = (rbtdb_rdatasetiter_t *)iterator;
dns_rbtdb_t *rbtdb = (dns_rbtdb_t *)(rbtiterator->common.db);
dns_rbtnode_t *rbtnode = rbtiterator->common.node;
dns_rbtnode_t *rbtnode = (dns_rbtnode_t *)rbtiterator->common.node;
dns_rbtdb_version_t *rbtversion = rbtiterator->common.version;
dns_slabheader_t *header = NULL, *top_next = NULL;
uint32_t serial = IS_CACHE(rbtdb) ? 1 : rbtversion->serial;
@ -4288,7 +4291,7 @@ rdatasetiter_current(dns_rdatasetiter_t *iterator,
dns_rdataset_t *rdataset DNS__DB_FLARG) {
rbtdb_rdatasetiter_t *rbtiterator = (rbtdb_rdatasetiter_t *)iterator;
dns_rbtdb_t *rbtdb = (dns_rbtdb_t *)(rbtiterator->common.db);
dns_rbtnode_t *rbtnode = rbtiterator->common.node;
dns_rbtnode_t *rbtnode = (dns_rbtnode_t *)rbtiterator->common.node;
dns_slabheader_t *header = NULL;
isc_rwlocktype_t nlocktype = isc_rwlocktype_none;
@ -4811,7 +4814,7 @@ dbiterator_current(dns_dbiterator_t *iterator, dns_dbnode_t **nodep,
dns__rbtdb_newref(rbtdb, node, isc_rwlocktype_none DNS__DB_FLARG_PASS);
*nodep = rbtdbiter->node;
*nodep = (dns_dbnode_t *)rbtdbiter->node;
return (result);
}

View File

@ -606,7 +606,7 @@ getnodedata(dns_db_t *db, const dns_name_t *name, bool create,
dns_name_dup(name, sdlz->common.mctx, node->name);
}
*nodep = node;
*nodep = (dns_dbnode_t *)node;
return (ISC_R_SUCCESS);
}
@ -1271,7 +1271,8 @@ dbiterator_current(dns_dbiterator_t *iterator, dns_dbnode_t **nodep,
dns_name_t *name DNS__DB_FLARG) {
sdlz_dbiterator_t *sdlziter = (sdlz_dbiterator_t *)iterator;
attachnode(iterator->db, sdlziter->current, nodep DNS__DB_FLARG_PASS);
attachnode(iterator->db, (dns_dbnode_t *)sdlziter->current,
nodep DNS__DB_FLARG_PASS);
if (name != NULL) {
dns_name_copy(sdlziter->current->name, name);
return (ISC_R_SUCCESS);

View File

@ -109,13 +109,16 @@ ownercase_test_one(const char *str1, const char *str2) {
};
qpznode_t node = { .locknum = 0 };
dns_slabheader_t header = {
.node = &node,
.node = (dns_dbnode_t *)&node,
.db = (dns_db_t *)&qpdb,
};
unsigned char *raw = (unsigned char *)(&header) + sizeof(header);
dns_rdataset_t rdataset = {
.magic = DNS_RDATASET_MAGIC,
.slab = { .db = (dns_db_t *)&qpdb, .node = &node, .raw = raw },
.slab = { .db = (dns_db_t *)&qpdb,
.node = (dns_dbnode_t *)&node,
.raw = raw,
},
.methods = &dns_rdataslab_rdatasetmethods,
};
isc_buffer_t b;
@ -174,13 +177,16 @@ ISC_RUN_TEST_IMPL(setownercase) {
};
qpznode_t node = { .locknum = 0 };
dns_slabheader_t header = {
.node = &node,
.node = (dns_dbnode_t *)&node,
.db = (dns_db_t *)&qpdb,
};
unsigned char *raw = (unsigned char *)(&header) + sizeof(header);
dns_rdataset_t rdataset = {
.magic = DNS_RDATASET_MAGIC,
.slab = { .db = (dns_db_t *)&qpdb, .node = &node, .raw = raw },
.slab = { .db = (dns_db_t *)&qpdb,
.node = (dns_dbnode_t *)&node,
.raw = raw,
},
.methods = &dns_rdataslab_rdatasetmethods,
};
const char *str1 =