mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-29 05:28:00 +00:00
Remove duplicate INSIST checks for isc_refcount API
This commits removes superfluous checks when using the isc_refcount API. Examples of superfluous checks: 1. The isc_refcount_decrement function ensures there was not underflow, so this check is superfluous: INSIST(isc_refcount_decrement(&r) > 0); 2 .The isc_refcount_destroy() includes check whether the counter is zero, therefore this is superfluous: INSIST(isc_refcount_decrement(&r) == 1 && isc_refcount_destroy(&r));
This commit is contained in:
parent
e711b0304f
commit
6afa99362a
@ -8322,7 +8322,7 @@ dns_rbtdb_create(isc_mem_t *mctx, const dns_name_t *origin, dns_dbtype_t type,
|
||||
rbtdb->next_serial = 2;
|
||||
rbtdb->current_version = allocate_version(mctx, 1, 1, false);
|
||||
if (rbtdb->current_version == NULL) {
|
||||
INSIST(isc_refcount_decrement(&rbtdb->references) > 0);
|
||||
isc_refcount_decrement(&rbtdb->references);
|
||||
free_rbtdb(rbtdb, false, NULL);
|
||||
return (ISC_R_NOMEMORY);
|
||||
}
|
||||
@ -8343,7 +8343,7 @@ dns_rbtdb_create(isc_mem_t *mctx, const dns_name_t *origin, dns_dbtype_t type,
|
||||
isc_mem_put(mctx, rbtdb->current_version,
|
||||
sizeof(*rbtdb->current_version));
|
||||
rbtdb->current_version = NULL;
|
||||
INSIST(isc_refcount_decrement(&rbtdb->references) > 0);
|
||||
isc_refcount_decrement(&rbtdb->references);
|
||||
free_rbtdb(rbtdb, false, NULL);
|
||||
return (result);
|
||||
}
|
||||
|
@ -1484,9 +1484,9 @@ cleanup_task:
|
||||
dns_rbt_destroy(&zones->rbt);
|
||||
|
||||
cleanup_rbt:
|
||||
INSIST(isc_refcount_decrement(&zones->irefs) == 1);
|
||||
isc_refcount_decrement(&zones->irefs);
|
||||
isc_refcount_destroy(&zones->irefs);
|
||||
INSIST(isc_refcount_decrement(&zones->refs) == 1);
|
||||
isc_refcount_decrement(&zones->refs);
|
||||
isc_refcount_destroy(&zones->refs);
|
||||
|
||||
isc_mutex_destroy(&zones->maint_lock);
|
||||
@ -1567,7 +1567,7 @@ cleanup_ht:
|
||||
isc_timer_detach(&zone->updatetimer);
|
||||
|
||||
cleanup_timer:
|
||||
INSIST(isc_refcount_decrement(&zone->refs) > 0);
|
||||
isc_refcount_decrement(&zone->refs);
|
||||
isc_refcount_destroy(&zone->refs);
|
||||
|
||||
isc_mem_put(rpzs->mctx, zone, sizeof(*zone));
|
||||
|
@ -349,7 +349,7 @@ dns_tsigkey_createfromkey(const dns_name_t *name, const dns_name_t *algorithm,
|
||||
cleanup_refs:
|
||||
tkey->magic = 0;
|
||||
while (refs-- > 0) {
|
||||
INSIST(isc_refcount_decrement(&tkey->refs) > 0);
|
||||
isc_refcount_decrement(&tkey->refs);
|
||||
}
|
||||
isc_refcount_destroy(&tkey->refs);
|
||||
|
||||
|
@ -1086,7 +1086,7 @@ dns_zone_create(dns_zone_t **zonep, isc_mem_t *mctx) {
|
||||
return (ISC_R_SUCCESS);
|
||||
|
||||
free_refs:
|
||||
INSIST(isc_refcount_decrement(&zone->erefs) > 0);
|
||||
isc_refcount_decrement(&zone->erefs);
|
||||
isc_refcount_destroy(&zone->erefs);
|
||||
isc_refcount_destroy(&zone->irefs);
|
||||
|
||||
@ -1111,8 +1111,8 @@ zone_free(dns_zone_t *zone) {
|
||||
dns_include_t *include;
|
||||
|
||||
REQUIRE(DNS_ZONE_VALID(zone));
|
||||
REQUIRE(isc_refcount_current(&zone->erefs) == 0);
|
||||
REQUIRE(isc_refcount_current(&zone->irefs) == 0);
|
||||
isc_refcount_destroy(&zone->erefs);
|
||||
isc_refcount_destroy(&zone->irefs);
|
||||
REQUIRE(!LOCKED_ZONE(zone));
|
||||
REQUIRE(zone->timer == NULL);
|
||||
REQUIRE(zone->zmgr == NULL);
|
||||
@ -5471,7 +5471,7 @@ dns_zone_detach(dns_zone_t **zonep) {
|
||||
void
|
||||
dns_zone_iattach(dns_zone_t *source, dns_zone_t **target) {
|
||||
REQUIRE(DNS_ZONE_VALID(source));
|
||||
REQUIRE(target != NULL && *target == NULL);
|
||||
|
||||
LOCK_ZONE(source);
|
||||
zone_iattach(source, target);
|
||||
UNLOCK_ZONE(source);
|
||||
@ -5479,10 +5479,6 @@ dns_zone_iattach(dns_zone_t *source, dns_zone_t **target) {
|
||||
|
||||
static void
|
||||
zone_iattach(dns_zone_t *source, dns_zone_t **target) {
|
||||
|
||||
/*
|
||||
* 'source' locked by caller.
|
||||
*/
|
||||
REQUIRE(DNS_ZONE_VALID(source));
|
||||
REQUIRE(LOCKED_ZONE(source));
|
||||
REQUIRE(target != NULL && *target == NULL);
|
||||
@ -5491,6 +5487,7 @@ zone_iattach(dns_zone_t *source, dns_zone_t **target) {
|
||||
*target = source;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
zone_idetach(dns_zone_t **zonep) {
|
||||
dns_zone_t *zone;
|
||||
@ -5499,8 +5496,9 @@ zone_idetach(dns_zone_t **zonep) {
|
||||
* 'zone' locked by caller.
|
||||
*/
|
||||
REQUIRE(zonep != NULL && DNS_ZONE_VALID(*zonep));
|
||||
zone = *zonep;
|
||||
REQUIRE(LOCKED_ZONE(*zonep));
|
||||
|
||||
zone = *zonep;
|
||||
*zonep = NULL;
|
||||
|
||||
INSIST(isc_refcount_decrement(&zone->irefs) - 1 +
|
||||
@ -5513,6 +5511,7 @@ dns_zone_idetach(dns_zone_t **zonep) {
|
||||
bool free_needed;
|
||||
|
||||
REQUIRE(zonep != NULL && DNS_ZONE_VALID(*zonep));
|
||||
|
||||
zone = *zonep;
|
||||
*zonep = NULL;
|
||||
|
||||
|
@ -982,11 +982,11 @@ isc_mem_destroy(isc_mem_t **ctxp) {
|
||||
REQUIRE(VALID_CONTEXT(ctx));
|
||||
|
||||
#if ISC_MEM_TRACKLINES
|
||||
if (isc_refcount_decrement(&ctx->references) != 1) {
|
||||
if (isc_refcount_decrement(&ctx->references) > 1) {
|
||||
print_active(ctx, stderr);
|
||||
}
|
||||
#else
|
||||
INSIST(isc_refcount_decrement(&ctx->references) == 1);
|
||||
isc_refcount_decrement(&ctx->references);
|
||||
#endif
|
||||
isc_refcount_destroy(&ctx->references);
|
||||
destroy(ctx);
|
||||
|
@ -1933,7 +1933,7 @@ free_socket(isc__socket_t **socketp) {
|
||||
isc__socket_t *sock = *socketp;
|
||||
|
||||
INSIST(VALID_SOCKET(sock));
|
||||
INSIST(isc_refcount_current(&sock->references) == 0);
|
||||
isc_refcount_destroy(&sock->references);
|
||||
LOCK(&sock->lock);
|
||||
INSIST(!sock->connecting);
|
||||
INSIST(ISC_LIST_EMPTY(sock->recv_list));
|
||||
|
@ -340,7 +340,7 @@ ns_interfacemgr_getaclenv(ns_interfacemgr_t *mgr) {
|
||||
void
|
||||
ns_interfacemgr_attach(ns_interfacemgr_t *source, ns_interfacemgr_t **target) {
|
||||
REQUIRE(NS_INTERFACEMGR_VALID(source));
|
||||
INSIST(isc_refcount_increment(&source->references) > 0);
|
||||
isc_refcount_increment(&source->references);
|
||||
*target = source;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user