]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
delay assignment until after REQUIRE
authorMark Andrews <marka@isc.org>
Thu, 30 Jan 2020 07:19:11 +0000 (18:19 +1100)
committerOndřej Surý <ondrej@isc.org>
Sat, 8 Feb 2020 14:32:42 +0000 (06:32 -0800)
(cherry picked from commit c65c06301c56860b5b75bbbc42c00f6459a646f8)

18 files changed:
bin/tests/optional/sig0_test.c
lib/dns/master.c
lib/dns/rdata.c
lib/dns/rdataslab.c
lib/dns/tcpmsg.c
lib/dns/tests/rbt_serialize_test.c
lib/irs/dnsconf.c
lib/irs/resconf.c
lib/isc/event.c
lib/isc/heap.c
lib/isc/ht.c
lib/isc/lex.c
lib/isc/ondestroy.c
lib/isc/task.c
lib/isc/timer.c
lib/isc/unix/app.c
lib/isc/unix/ifiter_getifaddrs.c
lib/isc/unix/interfaceiter.c

index dcf64ba34d9b0fcc956cbc7c7427125fcdb41f23..aa0c999a53bfa261b7a834ed6e13e5a0b2d72069 100644 (file)
@@ -71,10 +71,8 @@ static const dns_master_style_t *style = &dns_master_style_debug;
 
 static void
 senddone(isc_task_t *task, isc_event_t *event) {
-       isc_socketevent_t *sevent = (isc_socketevent_t *)event;
-
-       REQUIRE(sevent != NULL);
-       REQUIRE(sevent->ev_type == ISC_SOCKEVENT_SENDDONE);
+       REQUIRE(event != NULL);
+       REQUIRE(event->ev_type == ISC_SOCKEVENT_SENDDONE);
        REQUIRE(task == task1);
 
        printf("senddone\n");
@@ -84,15 +82,17 @@ senddone(isc_task_t *task, isc_event_t *event) {
 
 static void
 recvdone(isc_task_t *task, isc_event_t *event) {
-       isc_socketevent_t *sevent = (isc_socketevent_t *)event;
+       isc_socketevent_t *sevent;
        isc_buffer_t source;
        isc_result_t result;
        dns_message_t *response;
 
-       REQUIRE(sevent != NULL);
-       REQUIRE(sevent->ev_type == ISC_SOCKEVENT_RECVDONE);
+       REQUIRE(event != NULL);
+       REQUIRE(event->ev_type == ISC_SOCKEVENT_RECVDONE);
        REQUIRE(task == task1);
 
+       sevent = (isc_socketevent_t *)event;
+
        printf("recvdone\n");
        if (sevent->result != ISC_R_SUCCESS) {
                printf("failed\n");
index 2a87bca3bc9909cd345dc2c17adc25176b1a9bf0..b71bd368483bce3796925b453427d225a463af74 100644 (file)
@@ -3203,8 +3203,9 @@ load_quantum(isc_task_t *task, isc_event_t *event) {
        dns_loadctx_t *lctx;
 
        REQUIRE(event != NULL);
+       REQUIRE(DNS_LCTX_VALID(event->ev_arg));
+
        lctx = event->ev_arg;
-       REQUIRE(DNS_LCTX_VALID(lctx));
 
        if (lctx->canceled)
                result = ISC_R_CANCELED;
index 3a4f769453e32893cfea4eed879daa0c900c8a45..0a82dccebec9c113ff490c54260cc96951fa44c8 100644 (file)
@@ -1218,8 +1218,11 @@ dns_rdata_tostruct(const dns_rdata_t *rdata, void *target, isc_mem_t *mctx) {
 
 void
 dns_rdata_freestruct(void *source) {
-       dns_rdatacommon_t *common = source;
-       REQUIRE(common != NULL);
+       dns_rdatacommon_t *common;
+
+       REQUIRE(source != NULL);
+
+       common = source;
 
        FREESTRUCTSWITCH
 }
index 930a8220e990eea4e17336a308e0a4b31f6f9ab9..be0baf35189ce30cdae69069fa706616b322e8c7 100644 (file)
@@ -400,12 +400,15 @@ rdataset_next(dns_rdataset_t *rdataset) {
 
 static void
 rdataset_current(dns_rdataset_t *rdataset, dns_rdata_t *rdata) {
-       unsigned char *raw = rdataset->private5;
+       unsigned char *raw;
        isc_region_t r;
        unsigned int length;
        unsigned int flags = 0;
 
-       REQUIRE(raw != NULL);
+       REQUIRE(rdataset != NULL);
+       REQUIRE(rdataset->private5 != NULL);
+
+       raw = rdataset->private5;
 
        length = raw[0] * 256 + raw[1];
 #if DNS_RDATASET_FIXED
index bb2a5d918d479a6634db95f837308a20f91d3199..8f5a97b0bd21828c54e0aca25cfea7e404fe55a7 100644 (file)
@@ -98,13 +98,16 @@ recv_length(isc_task_t *task, isc_event_t *ev_in) {
 
 static void
 recv_message(isc_task_t *task, isc_event_t *ev_in) {
-       isc_socketevent_t *ev = (isc_socketevent_t *)ev_in;
+       isc_socketevent_t *ev;;
        isc_event_t *dev;
-       dns_tcpmsg_t *tcpmsg = ev_in->ev_arg;
+       dns_tcpmsg_t *tcpmsg;
 
-       (void)task;
+       REQUIRE(VALID_TCPMSG(ev_in->ev_arg));
 
-       INSIST(VALID_TCPMSG(tcpmsg));
+       ev = (isc_socketevent_t *)ev_in;
+       tcpmsg = ev_in->ev_arg;
+
+       (void)task;
 
        dev = &tcpmsg->event;
        tcpmsg->address = ev->address;
index ffb44e2089725e26cd825bab390b51cdf4d7a2c3..16aacd1453988636ca9940db929da75ced7dffb7 100644 (file)
@@ -134,7 +134,7 @@ static isc_result_t
 write_data(FILE *file, unsigned char *datap, void *arg, uint64_t *crc) {
        isc_result_t result;
        size_t ret = 0;
-       data_holder_t *data = (data_holder_t *)datap;
+       data_holder_t *data;
        data_holder_t temp;
        off_t where;
 
@@ -142,7 +142,8 @@ write_data(FILE *file, unsigned char *datap, void *arg, uint64_t *crc) {
 
        REQUIRE(file != NULL);
        REQUIRE(crc != NULL);
-       REQUIRE(data != NULL);
+       REQUIRE(datap != NULL);
+       data = (data_holder_t *)datap;
        REQUIRE((data->len == 0 && data->data == NULL) ||
                (data->len != 0 && data->data != NULL));
 
index ee89af01e093ea4936336b7388745d3b114327b7..4666d24255cb09239f881f50b8208237133bec0e 100644 (file)
@@ -238,8 +238,9 @@ irs_dnsconf_destroy(irs_dnsconf_t **confp) {
        irs_dnsconf_dnskey_t *keyent;
 
        REQUIRE(confp != NULL);
+       REQUIRE(IRS_DNSCONF_VALID((*confp)));
+
        conf = *confp;
-       REQUIRE(IRS_DNSCONF_VALID(conf));
 
        while ((keyent = ISC_LIST_HEAD(conf->trusted_keylist)) != NULL) {
                ISC_LIST_UNLINK(conf->trusted_keylist, keyent, link);
index 7288c727973608a92c92908f4cdfbd2e62a2164a..c541b4847393b0c324f27968959482a306f91777 100644 (file)
@@ -606,8 +606,9 @@ irs_resconf_destroy(irs_resconf_t **confp) {
        unsigned int i;
 
        REQUIRE(confp != NULL);
+       REQUIRE(IRS_RESCONF_VALID((*confp)));
+
        conf = *confp;
-       REQUIRE(IRS_RESCONF_VALID(conf));
 
        while ((searchentry = ISC_LIST_HEAD(conf->searchlist)) != NULL) {
                ISC_LIST_UNLINK(conf->searchlist, searchentry, link);
index 500b6fdcef6be757ebc57d1a3fdff6d96006d5aa..975173a4a84129f8662df5c452cd1dc229d3fa6d 100644 (file)
@@ -89,8 +89,9 @@ isc_event_free(isc_event_t **eventp) {
        isc_event_t *event;
 
        REQUIRE(eventp != NULL);
+       REQUIRE((*eventp) != NULL);
+
        event = *eventp;
-       REQUIRE(event != NULL);
 
        REQUIRE(!ISC_LINK_LINKED(event, ev_link));
        REQUIRE(!ISC_LINK_LINKED(event, ev_ratelink));
index 22fa81ca0edfa4f6bf559a8280a6752bee705c24..8733c715b39e43af801deeabbdb7c463222aff5c 100644 (file)
@@ -115,8 +115,9 @@ isc_heap_destroy(isc_heap_t **heapp) {
        isc_heap_t *heap;
 
        REQUIRE(heapp != NULL);
+       REQUIRE(VALID_HEAP((*heapp)));
+
        heap = *heapp;
-       REQUIRE(VALID_HEAP(heap));
 
        if (heap->array != NULL)
                isc_mem_put(heap->mctx, heap->array,
index 0b85c8196beb72d12c630ad2786e83705b93bef0..0e287b54cda168eca1e3b10bb6ce7659395e636d 100644 (file)
@@ -93,10 +93,9 @@ isc_ht_destroy(isc_ht_t **htp) {
        size_t i;
 
        REQUIRE(htp != NULL);
+       REQUIRE(ISC_HT_VALID((*htp)));
 
        ht = *htp;
-       REQUIRE(ISC_HT_VALID(ht));
-
        ht->magic = 0;
 
        for (i = 0; i < ht->size; i++) {
index 698d93e65c30b2154da46d8717db529ddce7ea8b..9c384fd5e694d63b79e330a46b4f456de0298f37 100644 (file)
@@ -124,14 +124,14 @@ void
 isc_lex_destroy(isc_lex_t **lexp) {
        isc_lex_t *lex;
 
-       /*
-        * Destroy the lexer.
-        */
-
        REQUIRE(lexp != NULL);
+       REQUIRE(VALID_LEX((*lexp)));
+
        lex = *lexp;
-       REQUIRE(VALID_LEX(lex));
 
+       /*
+        * Destroy the lexer.
+        */
        while (!EMPTY(lex->sources))
                RUNTIME_CHECK(isc_lex_close(lex) == ISC_R_SUCCESS);
        if (lex->data != NULL)
@@ -937,17 +937,19 @@ isc_lex_getoctaltoken(isc_lex_t *lex, isc_token_t *token, bool eol)
 void
 isc_lex_ungettoken(isc_lex_t *lex, isc_token_t *tokenp) {
        inputsource *source;
-       /*
-        * Unget the current token.
-        */
 
        REQUIRE(VALID_LEX(lex));
-       source = HEAD(lex->sources);
-       REQUIRE(source != NULL);
+       REQUIRE(HEAD(lex->sources) != NULL);
        REQUIRE(tokenp != NULL);
+
+       source = HEAD(lex->sources);
+
        REQUIRE(isc_buffer_consumedlength(source->pushback) != 0 ||
                tokenp->type == isc_tokentype_eof);
 
+       /*
+        * Unget the current token.
+        */
        UNUSED(tokenp);
 
        isc_buffer_first(source->pushback);
@@ -962,9 +964,11 @@ isc_lex_getlasttokentext(isc_lex_t *lex, isc_token_t *tokenp, isc_region_t *r)
        inputsource *source;
 
        REQUIRE(VALID_LEX(lex));
-       source = HEAD(lex->sources);
-       REQUIRE(source != NULL);
+       REQUIRE(HEAD(lex->sources) != NULL);
        REQUIRE(tokenp != NULL);
+
+       source = HEAD(lex->sources);
+
        REQUIRE(isc_buffer_consumedlength(source->pushback) != 0 ||
                tokenp->type == isc_tokentype_eof);
 
index 64d4d9179c934d6e600e0e9a0f61691434c9412c..5f14c582abbb5c9e3916e0413fe0058c72cc8d49 100644 (file)
@@ -42,11 +42,10 @@ isc_ondestroy_register(isc_ondestroy_t *ondest, isc_task_t *task,
        REQUIRE(VALID_ONDESTROY(ondest));
        REQUIRE(task != NULL);
        REQUIRE(eventp != NULL);
+       REQUIRE((*eventp) != NULL);
 
        theevent = *eventp;
 
-       REQUIRE(theevent != NULL);
-
        isc_task_attach(task, &thetask);
 
        theevent->ev_sender = thetask;
index f9c4354bd2252c1d734f00c7f92a771a368b442b..0e1f9ac7989e15ebb2bf995cb8771912189d4105 100644 (file)
@@ -339,14 +339,16 @@ isc_result_t
 isc__task_create(isc_taskmgr_t *manager0, unsigned int quantum,
                 isc_task_t **taskp)
 {
-       isc__taskmgr_t *manager = (isc__taskmgr_t *)manager0;
+       isc__taskmgr_t *manager;
        isc__task_t *task;
        bool exiting;
        isc_result_t result;
 
-       REQUIRE(VALID_MANAGER(manager));
+       REQUIRE(VALID_MANAGER(manager0));
        REQUIRE(taskp != NULL && *taskp == NULL);
 
+       manager = (isc__taskmgr_t *)manager0;
+
        task = isc_mem_get(manager->mctx, sizeof(*task));
        if (task == NULL)
                return (ISC_R_NOMEMORY);
@@ -542,16 +544,16 @@ task_send(isc__task_t *task, isc_event_t **eventp) {
        bool was_idle = false;
        isc_event_t *event;
 
+       REQUIRE(eventp != NULL);
+       REQUIRE((*eventp) != NULL);
+       REQUIRE((*eventp)->ev_type > 0);
+       REQUIRE(task->state != task_state_done);
+       REQUIRE(!ISC_LINK_LINKED((*eventp), ev_ratelink));
+
        /*
         * Caller must be holding the task lock.
         */
-
-       REQUIRE(eventp != NULL);
        event = *eventp;
-       REQUIRE(event != NULL);
-       REQUIRE(event->ev_type > 0);
-       REQUIRE(task->state != task_state_done);
-       REQUIRE(!ISC_LINK_LINKED(event, ev_ratelink));
 
        XTRACE("task_send");
 
@@ -811,19 +813,21 @@ isc_result_t
 isc__task_onshutdown(isc_task_t *task0, isc_taskaction_t action,
                     void *arg)
 {
-       isc__task_t *task = (isc__task_t *)task0;
+       isc__task_t *task;
        bool disallowed = false;
        isc_result_t result = ISC_R_SUCCESS;
        isc_event_t *event;
 
+       REQUIRE(VALID_TASK(task0));
+       REQUIRE(action != NULL);
+
+       task = (isc__task_t *)task0;
+
        /*
         * Send a shutdown event with action 'action' and argument 'arg' when
         * 'task' is shutdown.
         */
 
-       REQUIRE(VALID_TASK(task));
-       REQUIRE(action != NULL);
-
        event = isc_event_allocate(task->manager->mctx,
                                   NULL,
                                   ISC_TASKEVENT_SHUTDOWN,
@@ -897,29 +901,35 @@ isc__task_setname(isc_task_t *task0, const char *name, void *tag) {
 
 const char *
 isc__task_getname(isc_task_t *task0) {
-       isc__task_t *task = (isc__task_t *)task0;
+       isc__task_t *task;
 
-       REQUIRE(VALID_TASK(task));
+       REQUIRE(VALID_TASK(task0));
+
+       task = (isc__task_t *)task0;
 
        return (task->name);
 }
 
 void *
 isc__task_gettag(isc_task_t *task0) {
-       isc__task_t *task = (isc__task_t *)task0;
+       isc__task_t *task;
 
-       REQUIRE(VALID_TASK(task));
+       REQUIRE(VALID_TASK(task0));
+
+       task = (isc__task_t *)task0;
 
        return (task->tag);
 }
 
 void
 isc__task_getcurrenttime(isc_task_t *task0, isc_stdtime_t *t) {
-       isc__task_t *task = (isc__task_t *)task0;
+       isc__task_t *task;
 
-       REQUIRE(VALID_TASK(task));
+       REQUIRE(VALID_TASK(task0));
        REQUIRE(t != NULL);
 
+       task = (isc__task_t *)task0;
+
        LOCK(&task->lock);
        *t = task->now;
        UNLOCK(&task->lock);
@@ -927,11 +937,13 @@ isc__task_getcurrenttime(isc_task_t *task0, isc_stdtime_t *t) {
 
 void
 isc__task_getcurrenttimex(isc_task_t *task0, isc_time_t *t) {
-       isc__task_t *task = (isc__task_t *)task0;
+       isc__task_t *task;
 
-       REQUIRE(VALID_TASK(task));
+       REQUIRE(VALID_TASK(task0));
        REQUIRE(t != NULL);
 
+       task = (isc__task_t *)task0;
+
        LOCK(&task->lock);
        *t = task->tnow;
        UNLOCK(&task->lock);
@@ -1722,14 +1734,14 @@ isc_taskmgr_excltask(isc_taskmgr_t *mgr0, isc_task_t **taskp) {
 isc_result_t
 isc__task_beginexclusive(isc_task_t *task0) {
 #ifdef USE_WORKER_THREADS
-       isc__task_t *task = (isc__task_t *)task0;
+       isc__task_t *task;
        isc__taskmgr_t *manager;
 
-       REQUIRE(VALID_TASK(task));
-
-       manager = task->manager;
+       REQUIRE(VALID_TASK(task0));
 
+       task = (isc__task_t *)task0;
        REQUIRE(task->state == task_state_running);
+       manager = task->manager;
 /*
  *  TODO REQUIRE(task == task->manager->excl);
  *  it should be here, it fails on shutdown server->task
@@ -1754,13 +1766,15 @@ isc__task_beginexclusive(isc_task_t *task0) {
 void
 isc__task_endexclusive(isc_task_t *task0) {
 #ifdef USE_WORKER_THREADS
-       isc__task_t *task = (isc__task_t *)task0;
+       isc__task_t *task;
        isc__taskmgr_t *manager;
 
-       REQUIRE(VALID_TASK(task));
-       manager = task->manager;
+       REQUIRE(VALID_TASK(task0));
 
+       task = (isc__task_t *)task0;
        REQUIRE(task->state == task_state_running);
+       manager = task->manager;
+
        LOCK(&manager->lock);
        REQUIRE(manager->exclusive_requested);
        manager->exclusive_requested = false;
index 2baa9e6ea10e277cfe836b4d7e676c2b7c150d65..4824abd6abf7798cfc6ad0ee822c2442420a948d 100644 (file)
@@ -377,11 +377,15 @@ isc__timer_create(isc_timermgr_t *manager0, isc_timertype_t type,
                  isc_task_t *task, isc_taskaction_t action, void *arg,
                  isc_timer_t **timerp)
 {
-       isc__timermgr_t *manager = (isc__timermgr_t *)manager0;
+       isc__timermgr_t *manager;
        isc__timer_t *timer;
        isc_result_t result;
        isc_time_t now;
 
+       REQUIRE(VALID_MANAGER(manager0));
+       REQUIRE(task != NULL);
+       REQUIRE(action != NULL);
+
        /*
         * Create a new 'type' timer managed by 'manager'.  The timers
         * parameters are specified by 'expires' and 'interval'.  Events
@@ -389,10 +393,7 @@ isc__timer_create(isc_timermgr_t *manager0, isc_timertype_t type,
         * called with 'arg' as the arg value.  The new timer is returned
         * in 'timerp'.
         */
-
-       REQUIRE(VALID_MANAGER(manager));
-       REQUIRE(task != NULL);
-       REQUIRE(action != NULL);
+       manager = (isc__timermgr_t *)manager0;
        if (expires == NULL)
                expires = isc_time_epoch;
        if (interval == NULL)
@@ -498,7 +499,7 @@ isc__timer_reset(isc_timer_t *timer0, isc_timertype_t type,
                 const isc_time_t *expires, const isc_interval_t *interval,
                 bool purge)
 {
-       isc__timer_t *timer = (isc__timer_t *)timer0;
+       isc__timer_t *timer;
        isc_time_t now;
        isc__timermgr_t *manager;
        isc_result_t result;
@@ -509,7 +510,8 @@ isc__timer_reset(isc_timer_t *timer0, isc_timertype_t type,
         * are purged from its task's event queue.
         */
 
-       REQUIRE(VALID_TIMER(timer));
+       REQUIRE(VALID_TIMER(timer0));
+       timer = (isc__timer_t *)timer0;
        manager = timer->manager;
        REQUIRE(VALID_MANAGER(manager));
 
@@ -571,10 +573,11 @@ isc__timer_reset(isc_timer_t *timer0, isc_timertype_t type,
 
 isc_timertype_t
 isc_timer_gettype(isc_timer_t *timer0) {
-       isc__timer_t *timer = (isc__timer_t *)timer0;
+       isc__timer_t *timer;
        isc_timertype_t t;
 
-       REQUIRE(VALID_TIMER(timer));
+       REQUIRE(VALID_TIMER(timer0));
+       timer = (isc__timer_t *)timer0;
 
        LOCK(&timer->lock);
        t = timer->type;
@@ -585,7 +588,7 @@ isc_timer_gettype(isc_timer_t *timer0) {
 
 isc_result_t
 isc__timer_touch(isc_timer_t *timer0) {
-       isc__timer_t *timer = (isc__timer_t *)timer0;
+       isc__timer_t *timer;
        isc_result_t result;
        isc_time_t now;
 
@@ -593,7 +596,8 @@ isc__timer_touch(isc_timer_t *timer0) {
         * Set the last-touched time of 'timer' to the current time.
         */
 
-       REQUIRE(VALID_TIMER(timer));
+       REQUIRE(VALID_TIMER(timer0));
+       timer = (isc__timer_t *)timer0;
 
        LOCK(&timer->lock);
 
@@ -616,13 +620,14 @@ isc__timer_touch(isc_timer_t *timer0) {
 
 void
 isc__timer_attach(isc_timer_t *timer0, isc_timer_t **timerp) {
-       isc__timer_t *timer = (isc__timer_t *)timer0;
+       isc__timer_t *timer;
 
        /*
         * Attach *timerp to timer.
         */
 
-       REQUIRE(VALID_TIMER(timer));
+       REQUIRE(VALID_TIMER(timer0));
+       timer = (isc__timer_t *)timer0;
        REQUIRE(timerp != NULL && *timerp == NULL);
 
        LOCK(&timer->lock);
@@ -842,8 +847,8 @@ static void
 set_index(void *what, unsigned int index) {
        isc__timer_t *timer;
 
+       REQUIRE(VALID_TIMER(what));
        timer = what;
-       REQUIRE(VALID_TIMER(timer));
 
        timer->index = index;
 }
@@ -933,9 +938,10 @@ isc__timermgr_create(isc_mem_t *mctx, isc_timermgr_t **managerp) {
 void
 isc_timermgr_poke(isc_timermgr_t *manager0) {
 #ifdef USE_TIMER_THREAD
-       isc__timermgr_t *manager = (isc__timermgr_t *)manager0;
+       isc__timermgr_t *manager;
 
-       REQUIRE(VALID_MANAGER(manager));
+       REQUIRE(VALID_MANAGER(manager0));
+       manager = (isc__timermgr_t *)manager0;
 
        SIGNAL(&manager->wakeup);
 #else
index a6e9882a13fd4ad38ae8455e78427c3851fd20c1..567f300195c1477a792b1b58fbbcf084fc3464c8 100644 (file)
@@ -996,7 +996,9 @@ isc__appctx_destroy(isc_appctx_t **ctxp) {
        isc__appctx_t *ctx;
 
        REQUIRE(ctxp != NULL);
+
        ctx = (isc__appctx_t *)*ctxp;
+
        REQUIRE(VALID_APPCTX(ctx));
 
        isc_mem_putanddetach(&ctx->mctx, ctx, sizeof(*ctx));
@@ -1006,27 +1008,33 @@ isc__appctx_destroy(isc_appctx_t **ctxp) {
 
 void
 isc__appctx_settaskmgr(isc_appctx_t *ctx0, isc_taskmgr_t *taskmgr) {
-       isc__appctx_t *ctx = (isc__appctx_t *)ctx0;
+       isc__appctx_t *ctx;
 
-       REQUIRE(VALID_APPCTX(ctx));
+       REQUIRE(VALID_APPCTX(ctx0));
+
+       ctx = (isc__appctx_t *)ctx0;
 
        ctx->taskmgr = taskmgr;
 }
 
 void
 isc__appctx_setsocketmgr(isc_appctx_t *ctx0, isc_socketmgr_t *socketmgr) {
-       isc__appctx_t *ctx = (isc__appctx_t *)ctx0;
+       isc__appctx_t *ctx;
 
-       REQUIRE(VALID_APPCTX(ctx));
+       REQUIRE(VALID_APPCTX(ctx0));
+
+       ctx = (isc__appctx_t *)ctx0;
 
        ctx->socketmgr = socketmgr;
 }
 
 void
 isc__appctx_settimermgr(isc_appctx_t *ctx0, isc_timermgr_t *timermgr) {
-       isc__appctx_t *ctx = (isc__appctx_t *)ctx0;
+       isc__appctx_t *ctx;
 
-       REQUIRE(VALID_APPCTX(ctx));
+       REQUIRE(VALID_APPCTX(ctx0));
+
+       ctx = (isc__appctx_t *)ctx0;
 
        ctx->timermgr = timermgr;
 }
index de6f060d6a93a1b0ef4c1c97a646667b80dc7204..61a42425d8ab09a4b7a5383cb4185df0d15cffdd 100644 (file)
@@ -131,8 +131,8 @@ internal_current(isc_interfaceiter_t *iter) {
                return (linux_if_inet6_current(iter));
 #endif
 
-       INSIST(ifa != NULL);
-       INSIST(ifa->ifa_name != NULL);
+       REQUIRE(iter->pos != NULL);
+       REQUIRE(iter->pos->ifa_name != NULL);
 
        if (ifa->ifa_addr == NULL)
                return (ISC_R_IGNORE);
@@ -207,6 +207,7 @@ internal_next(isc_interfaceiter_t *iter) {
 
 static void
 internal_destroy(isc_interfaceiter_t *iter) {
+       REQUIRE(VALID_IFITER(iter));
 
 #ifdef __linux
        if (iter->proc != NULL)
index deafe4ed9836243b478a210c8ccf0155506d1000..2973dbe0bf68e8151402b3ce623b5cc61997dba8 100644 (file)
@@ -292,9 +292,11 @@ void
 isc_interfaceiter_destroy(isc_interfaceiter_t **iterp)
 {
        isc_interfaceiter_t *iter;
+
        REQUIRE(iterp != NULL);
+       REQUIRE(VALID_IFITER((*iterp)));
+
        iter = *iterp;
-       REQUIRE(VALID_IFITER(iter));
 
        internal_destroy(iter);
        if (iter->buf != NULL)