]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
isc_refcount_init() now doesn't return isc_result_t and asserts on failed initialization
authorOndřej Surý <ondrej@sury.org>
Wed, 1 Aug 2018 09:46:11 +0000 (11:46 +0200)
committerOndřej Surý <ondrej@sury.org>
Mon, 13 Aug 2018 11:27:01 +0000 (13:27 +0200)
21 files changed:
bin/tests/system/dyndb/driver/db.c
lib/dns/acl.c
lib/dns/catz.c
lib/dns/dnstap.c
lib/dns/dst_api.c
lib/dns/keytable.c
lib/dns/nta.c
lib/dns/order.c
lib/dns/portlist.c
lib/dns/rbtdb.c
lib/dns/rpz.c
lib/dns/tsig.c
lib/dns/view.c
lib/dns/zone.c
lib/isc/Makefile.in
lib/isc/include/isc/refcount.h
lib/isc/refcount.c [deleted file]
lib/isc/win32/libisc.def.in
lib/isccfg/aclconf.c
lib/isccfg/parser.c
lib/ns/server.c

index af1626037a7de0c306f4bd4fa92c22ee1bcddec5..e9bdf27a25cc77d6fbf4a6ab8d392e7dbcfb1eaa 100644 (file)
@@ -773,7 +773,7 @@ create_db(isc_mem_t *mctx, const dns_name_t *origin, dns_dbtype_t type,
 
        CHECK(dns_name_dupwithoffsets(origin, mctx, &sampledb->common.origin));
 
-       CHECK(isc_refcount_init(&sampledb->refs, 1));
+       isc_refcount_init(&sampledb->refs, 1);
 
        /* Translate instance name to instance pointer. */
        sampledb->inst = driverarg;
index 4bdcf1c06c68688cde9d0215ff482e7ed2bc225c..f2f5532aaf97a46b6d83f7666782d8a042223d1c 100644 (file)
@@ -50,11 +50,7 @@ dns_acl_create(isc_mem_t *mctx, int n, dns_acl_t **target) {
 
        acl->name = NULL;
 
-       result = isc_refcount_init(&acl->refcount, 1);
-       if (result != ISC_R_SUCCESS) {
-               isc_mem_put(mctx, acl, sizeof(*acl));
-               return (result);
-       }
+       isc_refcount_init(&acl->refcount, 1);
 
        result = dns_iptable_create(mctx, &acl->iptable);
        if (result != ISC_R_SUCCESS) {
index 662497c64d296a7614e89bcc930611912334fd4c..d112284700fb819a2d29df660619d72f0581a7bd 100644 (file)
@@ -568,9 +568,7 @@ dns_catz_new_zones(dns_catz_zones_t **catzsp, dns_catz_zonemodmethods_t *zmm,
        if (result != ISC_R_SUCCESS)
                goto cleanup_newzones;
 
-       result = isc_refcount_init(&new_zones->refs, 1);
-       if (result != ISC_R_SUCCESS)
-               goto cleanup_mutex;
+       isc_refcount_init(&new_zones->refs, 1);
 
        result = isc_ht_init(&new_zones->zones, mctx, 4);
        if (result != ISC_R_SUCCESS)
@@ -592,7 +590,6 @@ dns_catz_new_zones(dns_catz_zones_t **catzsp, dns_catz_zonemodmethods_t *zmm,
        isc_ht_destroy(&new_zones->zones);
   cleanup_refcount:
        isc_refcount_destroy(&new_zones->refs);
-  cleanup_mutex:
        isc_mutex_destroy(&new_zones->lock);
   cleanup_newzones:
        isc_mem_put(mctx, new_zones, sizeof(*new_zones));
index 18c7a55657afe480209eec4cb4e3a6d2929e5710..2fdc43c2308abdebd76a5f85145bff4362585e9e 100644 (file)
@@ -214,7 +214,7 @@ dns_dt_create(isc_mem_t *mctx, dns_dtmode_t mode, const char *path,
 
        memset(env, 0, sizeof(dns_dtenv_t));
 
-       CHECK(isc_refcount_init(&env->refcount, 1));
+       isc_refcount_init(&env->refcount, 1);
        CHECK(isc_stats_create(mctx, &env->stats, dns_dnstapcounter_max));
        env->path = isc_mem_strdup(mctx, path);
        if (env->path == NULL)
index aef5e96fb74d6d74909f3df0c8084234fa98b756..7071b30891ca0e7a4f1bc719a7fb9280710fbf9d 100644 (file)
@@ -1354,13 +1354,7 @@ get_key_struct(const dns_name_t *name, unsigned int alg,
                return (NULL);
        }
 
-       result = isc_refcount_init(&key->refs, 1);
-       if (result != ISC_R_SUCCESS) {
-               dns_name_free(key->key_name, mctx);
-               isc_mem_put(mctx, key->key_name, sizeof(dns_name_t));
-               isc_mem_put(mctx, key, sizeof(dst_key_t));
-               return (NULL);
-       }
+       isc_refcount_init(&key->refs, 1);
        isc_mem_attach(mctx, &key->mctx);
        key->key_alg = alg;
        key->key_flags = flags;
index 464e05630138bc0a95fd239829fc961fc5b1386e..75cbf4e1f32647f57a130246dac54a60e0140f77 100644 (file)
@@ -89,15 +89,8 @@ dns_keytable_create(isc_mem_t *mctx, dns_keytable_t **keytablep) {
                goto cleanup_rbt;
        }
 
-       result = isc_refcount_init(&keytable->active_nodes, 0);
-       if (result != ISC_R_SUCCESS) {
-               goto cleanup_rwlock;
-       }
-
-       result = isc_refcount_init(&keytable->references, 1);
-       if (result != ISC_R_SUCCESS) {
-               goto cleanup_active_nodes;
-       }
+       isc_refcount_init(&keytable->active_nodes, 0);
+       isc_refcount_init(&keytable->references, 1);
 
        keytable->mctx = NULL;
        isc_mem_attach(mctx, &keytable->mctx);
@@ -106,12 +99,6 @@ dns_keytable_create(isc_mem_t *mctx, dns_keytable_t **keytablep) {
 
        return (ISC_R_SUCCESS);
 
- cleanup_active_nodes:
-       isc_refcount_destroy(&keytable->active_nodes);
-
- cleanup_rwlock:
-       isc_rwlock_destroy(&keytable->rwlock);
-
  cleanup_rbt:
        dns_rbt_destroy(&keytable->table);
 
@@ -798,7 +785,6 @@ dns_keynode_trust(dns_keynode_t *keynode) {
 
 isc_result_t
 dns_keynode_create(isc_mem_t *mctx, dns_keynode_t **target) {
-       isc_result_t result;
        dns_keynode_t *knode;
 
        REQUIRE(target != NULL && *target == NULL);
@@ -813,9 +799,7 @@ dns_keynode_create(isc_mem_t *mctx, dns_keynode_t **target) {
        knode->key = NULL;
        knode->next = NULL;
 
-       result = isc_refcount_init(&knode->refcount, 1);
-       if (result != ISC_R_SUCCESS)
-               return (result);
+       isc_refcount_init(&knode->refcount, 1);
 
        *target = knode;
        return (ISC_R_SUCCESS);
index 6cede2a6a761563976ff811dbc1dcad55804c54b..26f7033b2294ff08f0a1d3563209d4164b7301f2 100644 (file)
@@ -308,7 +308,6 @@ static isc_result_t
 nta_create(dns_ntatable_t *ntatable, const dns_name_t *name,
           dns_nta_t **target)
 {
-       isc_result_t result;
        dns_nta_t *nta = NULL;
        dns_view_t *view;
 
@@ -328,11 +327,7 @@ nta_create(dns_ntatable_t *ntatable, const dns_name_t *name,
        dns_rdataset_init(&nta->rdataset);
        dns_rdataset_init(&nta->sigrdataset);
 
-       result = isc_refcount_init(&nta->refcount, 1);
-       if (result != ISC_R_SUCCESS) {
-               isc_mem_put(view->mctx, nta, sizeof(dns_nta_t));
-               return (result);
-       }
+       isc_refcount_init(&nta->refcount, 1);
 
        nta->name = dns_fixedname_initname(&nta->fn);
        dns_name_copy(name, nta->name, NULL);
index 1dfada03f534deebec37889908c4c695bef3c37b..f3fb3c51e9d889bb2d667fed2f9b309607b86763 100644 (file)
@@ -49,7 +49,6 @@ struct dns_order {
 isc_result_t
 dns_order_create(isc_mem_t *mctx, dns_order_t **orderp) {
        dns_order_t *order;
-       isc_result_t result;
 
        REQUIRE(orderp != NULL && *orderp == NULL);
 
@@ -60,11 +59,7 @@ dns_order_create(isc_mem_t *mctx, dns_order_t **orderp) {
        ISC_LIST_INIT(order->ents);
 
        /* Implicit attach. */
-       result = isc_refcount_init(&order->references, 1);
-       if (result != ISC_R_SUCCESS) {
-               isc_mem_put(mctx, order, sizeof(*order));
-               return (result);
-       }
+       isc_refcount_init(&order->references, 1);
 
        order->mctx = NULL;
        isc_mem_attach(mctx, &order->mctx);
index 7de71785bb0c74877d52a19037d5c6fab332a43c..0a31ea30c8bfdff024b6eb834ffaf608a488dee7 100644 (file)
@@ -80,12 +80,7 @@ dns_portlist_create(isc_mem_t *mctx, dns_portlist_t **portlistp) {
                isc_mem_put(mctx, portlist, sizeof(*portlist));
                return (result);
        }
-       result = isc_refcount_init(&portlist->refcount, 1);
-       if (result != ISC_R_SUCCESS) {
-               DESTROYLOCK(&portlist->lock);
-               isc_mem_put(mctx, portlist, sizeof(*portlist));
-               return (result);
-       }
+       isc_refcount_init(&portlist->refcount, 1);
        portlist->list = NULL;
        portlist->allocated = 0;
        portlist->active = 0;
index 20a8c518d6a7e37633c30462455acf18db3aa1ed..f622d448a3699847993469704192eb19175322cc 100644 (file)
@@ -1268,11 +1268,9 @@ allocate_version(isc_mem_t *mctx, rbtdb_serial_t serial,
        if (version == NULL)
                return (NULL);
        version->serial = serial;
-       result = isc_refcount_init(&version->references, references);
-       if (result != ISC_R_SUCCESS) {
-               isc_mem_put(mctx, version, sizeof(*version));
-               return (NULL);
-       }
+
+       isc_refcount_init(&version->references, references);
+
        result = isc_rwlock_init(&version->glue_rwlock, 0, 0);
        if (result != ISC_R_SUCCESS) {
                isc_refcount_destroy(&version->references);
@@ -8360,9 +8358,7 @@ dns_rbtdb_create(isc_mem_t *mctx, const dns_name_t *origin, dns_dbtype_t type,
        for (i = 0; i < (int)(rbtdb->node_lock_count); i++) {
                result = NODE_INITLOCK(&rbtdb->node_locks[i].lock);
                if (result == ISC_R_SUCCESS) {
-                       result = isc_refcount_init(&rbtdb->node_locks[i].references, 0);
-                       if (result != ISC_R_SUCCESS)
-                               NODE_DESTROYLOCK(&rbtdb->node_locks[i].lock);
+                       isc_refcount_init(&rbtdb->node_locks[i].references, 0);
                }
                if (result != ISC_R_SUCCESS) {
                        while (i-- > 0) {
@@ -8471,11 +8467,7 @@ dns_rbtdb_create(isc_mem_t *mctx, const dns_name_t *origin, dns_dbtype_t type,
        /*
         * Misc. Initialization.
         */
-       result = isc_refcount_init(&rbtdb->references, 1);
-       if (result != ISC_R_SUCCESS) {
-               free_rbtdb(rbtdb, false, NULL);
-               return (result);
-       }
+       isc_refcount_init(&rbtdb->references, 1);
        rbtdb->attributes = 0;
        rbtdb->task = NULL;
        rbtdb->serve_stale_ttl = 0;
index 2010ca0a8b0659c616a49f7decb5e4b5098ea88e..5fe57d82b656fa72cb7b2a038dbd8c9e969a6c65 100644 (file)
@@ -1451,9 +1451,7 @@ dns_rpz_new_zones(dns_rpz_zones_t **rpzsp, char *rps_cstr,
        if (result != ISC_R_SUCCESS)
                goto cleanup_mutex;
 
-       result = isc_refcount_init(&zones->refs, 1);
-       if (result != ISC_R_SUCCESS)
-               goto cleanup_refcount;
+       isc_refcount_init(&zones->refs, 1);
 
        zones->rps_cstr = rps_cstr;
        zones->rps_cstr_size = rps_cstr_size;
@@ -1490,7 +1488,6 @@ cleanup_rbt:
        isc_refcount_decrement(&zones->refs, NULL);
        isc_refcount_destroy(&zones->refs);
 
-cleanup_refcount:
        DESTROYLOCK(&zones->maint_lock);
 
 cleanup_mutex:
@@ -1519,9 +1516,7 @@ dns_rpz_new_zone(dns_rpz_zones_t *rpzs, dns_rpz_zone_t **rpzp) {
        }
 
        memset(zone, 0, sizeof(*zone));
-       result = isc_refcount_init(&zone->refs, 1);
-       if (result != ISC_R_SUCCESS)
-               goto cleanup_refcount;
+       isc_refcount_init(&zone->refs, 1);
 
        result = isc_timer_create(rpzs->timermgr, isc_timertype_inactive,
                                  NULL, NULL, rpzs->updater,
@@ -1576,7 +1571,6 @@ cleanup_timer:
        isc_refcount_decrement(&zone->refs, NULL);
        isc_refcount_destroy(&zone->refs);
 
-cleanup_refcount:
        isc_mem_put(zone->rpzs->mctx, zone, sizeof(*zone));
 
        return (result);
index e6518e2f518290ec7201987143802ad000324516..921ba942793ad24751fd0f75d2e77574be87d2cb 100644 (file)
@@ -331,9 +331,8 @@ dns_tsigkey_createfromkey(const dns_name_t *name, const dns_name_t *algorithm,
                refs = 1;
        if (ring != NULL)
                refs++;
-       ret = isc_refcount_init(&tkey->refs, refs);
-       if (ret != ISC_R_SUCCESS)
-               goto cleanup_creator;
+
+       isc_refcount_init(&tkey->refs, refs);
 
        tkey->generated = generated;
        tkey->inception = inception;
@@ -373,7 +372,7 @@ dns_tsigkey_createfromkey(const dns_name_t *name, const dns_name_t *algorithm,
        while (refs-- > 0)
                isc_refcount_decrement(&tkey->refs, NULL);
        isc_refcount_destroy(&tkey->refs);
- cleanup_creator:
+
        if (tkey->key != NULL)
                dst_key_free(&tkey->key);
        if (tkey->creator != NULL) {
index ea506249924d398d11f6b9d3ec1038ca2463ba13..e0fe3ca9557492404a06e471bf9091de0e680a5a 100644 (file)
@@ -154,9 +154,7 @@ dns_view_create(isc_mem_t *mctx, dns_rdataclass_t rdclass,
        view->rdclass = rdclass;
        view->frozen = false;
        view->task = NULL;
-       result = isc_refcount_init(&view->references, 1);
-       if (result != ISC_R_SUCCESS)
-               goto cleanup_fwdtable;
+       isc_refcount_init(&view->references, 1);
        view->weakrefs = 0;
        view->attributes = (DNS_VIEWATTR_RESSHUTDOWN|DNS_VIEWATTR_ADBSHUTDOWN|
                            DNS_VIEWATTR_REQSHUTDOWN);
@@ -316,7 +314,6 @@ dns_view_create(isc_mem_t *mctx, dns_rdataclass_t rdclass,
        isc_refcount_decrement(&view->references, NULL);
        isc_refcount_destroy(&view->references);
 
- cleanup_fwdtable:
        if (view->fwdtable != NULL)
                dns_fwdtable_destroy(&view->fwdtable);
 
index 2150a98f3f1b9548d47dd314fcbde128c2f288f7..19de5a7e003a9d8e46fb991850fb6c728057be3e 100644 (file)
@@ -923,10 +923,7 @@ dns_zone_create(dns_zone_t **zonep, isc_mem_t *mctx) {
        zone->db = NULL;
        zone->zmgr = NULL;
        ISC_LINK_INIT(zone, link);
-       result = isc_refcount_init(&zone->erefs, 1);    /* Implicit attach. */
-       if (result != ISC_R_SUCCESS) {
-               goto free_dblock;
-       }
+       isc_refcount_init(&zone->erefs, 1);     /* Implicit attach. */
        zone->irefs = 0;
        dns_name_init(&zone->origin, NULL);
        zone->strnamerd = NULL;
@@ -1096,7 +1093,6 @@ dns_zone_create(dns_zone_t **zonep, isc_mem_t *mctx) {
        isc_refcount_decrement(&zone->erefs, NULL);
        isc_refcount_destroy(&zone->erefs);
 
- free_dblock:
        ZONEDB_DESTROYLOCK(&zone->dblock);
 
  free_mutex:
index 785ac6892b264507828426882dbba1de390f803c..6dff83c548950ad33bb80dee3d4be416b21d48b4 100644 (file)
@@ -56,7 +56,7 @@ OBJS =                @ISC_EXTRA_OBJS@ pk11.@O@ pk11_result.@O@ \
                md5.@O@ mem.@O@ mutexblock.@O@ \
                netaddr.@O@ netscope.@O@ nonce.@O@ openssl_shim.@O@ pool.@O@ \
                parseint.@O@ portset.@O@ quota.@O@ radix.@O@ random.@O@ \
-               ratelimiter.@O@ refcount.@O@ region.@O@ regex.@O@ result.@O@ \
+               ratelimiter.@O@ region.@O@ regex.@O@ result.@O@ \
                rwlock.@O@ \
                serial.@O@ sha1.@O@ sha2.@O@ sockaddr.@O@ stats.@O@ \
                string.@O@ strtoul.@O@ symtab.@O@ task.@O@ taskpool.@O@ \
@@ -74,7 +74,7 @@ SRCS =                @ISC_EXTRA_SRCS@ pk11.c pk11_result.c \
                md5.c mem.c mutexblock.c \
                netaddr.c netscope.c nonce.c openssl_shim.c pool.c \
                parseint.c portset.c quota.c radix.c random.c \
-               ratelimiter.c refcount.c region.c regex.c result.c rwlock.c \
+               ratelimiter.c region.c regex.c result.c rwlock.c \
                serial.c sha1.c sha2.c sockaddr.c stats.c string.c \
                strtoul.c symtab.c task.c taskpool.c timer.c \
                tm.c version.c
index 689429127603d7f6bb19c605f5fa809c70f20fa2..3b151d033bf6f0357e336efa4f38173316c5c65b 100644 (file)
@@ -43,7 +43,7 @@ ISC_LANG_BEGINDECLS
  */
 
 /*
- * isc_result_t
+ * void
  * isc_refcount_init(isc_refcount_t *ref, unsigned int n);
  *
  * Initialize the reference counter.  There will be 'n' initial references.
@@ -111,6 +111,8 @@ typedef struct isc_refcount {
 
 #if defined(ISC_REFCOUNT_HAVESTDATOMIC)
 
+#define isc_refcount_init(rp, n) atomic_init(&(rp)->refs, n)
+
 #define isc_refcount_current(rp)                                       \
        ((unsigned int)(atomic_load_explicit(&(rp)->refs,               \
                                             memory_order_relaxed)))
@@ -150,6 +152,8 @@ typedef struct isc_refcount {
 
 #else /* ISC_REFCOUNT_HAVESTDATOMIC */
 
+#define isc_refcount_init(rp, n) isc_atomic_store(&(rp)->refs, n)
+
 #define isc_refcount_current(rp)                               \
        ((unsigned int)(isc_atomic_xadd(&(rp)->refs, 0)))
 #define isc_refcount_destroy(rp) ISC_REQUIRE(isc_refcount_current(rp) == 0)
@@ -192,6 +196,12 @@ typedef struct isc_refcount {
        isc_mutex_t lock;
 } isc_refcount_t;
 
+#define isc_refcount_init(rp, n)                                       \
+       do {                                                            \
+               REQUIRE(isc_mutex_init(&(rp)->lock) == ISC_R_SUCCESS);  \
+               (rp)->refs = n;                                         \
+       } while(0);
+
 /*% Destroys a reference counter. */
 #define isc_refcount_destroy(rp)                                       \
        do {                                                            \
@@ -259,6 +269,7 @@ typedef struct isc_refcount {
        int refs;
 } isc_refcount_t;
 
+#define isc_refcount_init(rp, n) ((rp)->refs = n)
 #define isc_refcount_destroy(rp) ISC_REQUIRE((rp)->refs == 0)
 #define isc_refcount_current(rp) ((unsigned int)((rp)->refs))
 
@@ -292,9 +303,6 @@ typedef struct isc_refcount {
 
 #endif /* ISC_PLATFORM_USETHREADS */
 
-isc_result_t
-isc_refcount_init(isc_refcount_t *ref, unsigned int n);
-
 ISC_LANG_ENDDECLS
 
 #endif /* ISC_REFCOUNT_H */
diff --git a/lib/isc/refcount.c b/lib/isc/refcount.c
deleted file mode 100644 (file)
index 033af7b..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * See the COPYRIGHT file distributed with this work for additional
- * information regarding copyright ownership.
- */
-
-
-#include <config.h>
-
-#include <stddef.h>
-
-#include <isc/mutex.h>
-#include <isc/refcount.h>
-#include <isc/result.h>
-#include <isc/util.h>
-
-isc_result_t
-isc_refcount_init(isc_refcount_t *ref, unsigned int n) {
-       REQUIRE(ref != NULL);
-
-       ref->refs = n;
-#if defined(ISC_PLATFORM_USETHREADS) && !defined(ISC_REFCOUNT_HAVEATOMIC)
-       return (isc_mutex_init(&ref->lock));
-#else
-       return (ISC_R_SUCCESS);
-#endif
-}
index aa4e71178f804622792a057b457fe521382da164..9758c8284eb5f19a3a904d7ec1d816d32037c870 100644 (file)
@@ -520,7 +520,6 @@ isc_ratelimiter_setpertic
 isc_ratelimiter_setpushpop
 isc_ratelimiter_shutdown
 isc_ratelimiter_stall
-isc_refcount_init
 isc_regex_validate
 isc_region_compare
 isc_resource_getcurlimit
index 0196324015564ba7c8b8254eb281abd412c83744..e713f119816b04fbdf0913d9777ae110ce6fbb73 100644 (file)
@@ -36,7 +36,6 @@
 
 isc_result_t
 cfg_aclconfctx_create(isc_mem_t *mctx, cfg_aclconfctx_t **ret) {
-       isc_result_t result;
        cfg_aclconfctx_t *actx;
 
        REQUIRE(mctx != NULL);
@@ -46,9 +45,7 @@ cfg_aclconfctx_create(isc_mem_t *mctx, cfg_aclconfctx_t **ret) {
        if (actx == NULL)
                return (ISC_R_NOMEMORY);
 
-       result = isc_refcount_init(&actx->references, 1);
-       if (result != ISC_R_SUCCESS)
-               goto cleanup;
+       isc_refcount_init(&actx->references, 1);
 
        actx->mctx = NULL;
        isc_mem_attach(mctx, &actx->mctx);
@@ -60,10 +57,6 @@ cfg_aclconfctx_create(isc_mem_t *mctx, cfg_aclconfctx_t **ret) {
 
        *ret = actx;
        return (ISC_R_SUCCESS);
-
- cleanup:
-       isc_mem_put(mctx, actx, sizeof(*actx));
-       return (result);
 }
 
 void
index af7755c40ad41aeb82608c59f4330dda9be05e9d..b4ae56aa889828a0c53511ce9b25978c11175f9e 100644 (file)
@@ -451,11 +451,7 @@ cfg_parser_create(isc_mem_t *mctx, isc_log_t *lctx, cfg_parser_t **ret) {
        pctx->mctx = NULL;
        isc_mem_attach(mctx, &pctx->mctx);
 
-       result = isc_refcount_init(&pctx->references, 1);
-       if (result != ISC_R_SUCCESS) {
-               isc_mem_putanddetach(&pctx->mctx, pctx, sizeof(*pctx));
-               return (result);
-       }
+       isc_refcount_init(&pctx->references, 1);
 
        pctx->lctx = lctx;
        pctx->lexer = NULL;
@@ -3064,7 +3060,6 @@ cfg_obj_line(const cfg_obj_t *obj) {
 
 isc_result_t
 cfg_create_obj(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) {
-       isc_result_t result;
        cfg_obj_t *obj;
 
        REQUIRE(pctx != NULL);
@@ -3080,11 +3075,8 @@ cfg_create_obj(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) {
        obj->line = pctx->line;
        obj->pctx = pctx;
 
-       result = isc_refcount_init(&obj->references, 1);
-       if (result != ISC_R_SUCCESS) {
-               isc_mem_put(pctx->mctx, obj, sizeof(cfg_obj_t));
-               return (result);
-       }
+       isc_refcount_init(&obj->references, 1);
+
        *ret = obj;
 
        return (ISC_R_SUCCESS);
index cb489abc8336a36b2b5738d362280c7503a9f7ad..1278dd62671bbcd1e6aee81cb5ca12504f7289e8 100644 (file)
@@ -50,9 +50,7 @@ ns_server_create(isc_mem_t *mctx, ns_matchview_t matchingview,
 
        isc_mem_attach(mctx, &sctx->mctx);
 
-       result = isc_refcount_init(&sctx->references, 1);
-       if (result != ISC_R_SUCCESS)
-               goto cleanup;
+       isc_refcount_init(&sctx->references, 1);
 
        CHECKFATAL(isc_quota_init(&sctx->xfroutquota, 10));
        CHECKFATAL(isc_quota_init(&sctx->tcpquota, 10));
@@ -113,11 +111,6 @@ ns_server_create(isc_mem_t *mctx, ns_matchview_t matchingview,
        *sctxp = sctx;
 
        return (ISC_R_SUCCESS);
-
- cleanup:
-       isc_mem_putanddetach(&sctx->mctx, sctx, sizeof(*sctx));
-
-       return (result);
 }
 
 void