Commit 39cb4dc6 authored by Mark Andrews's avatar Mark Andrews Committed by Ondřej Surý

delay assignment until after REQUIRE

(cherry picked from commit c65c0630)
parent 12cda20a
......@@ -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");
......
......@@ -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;
......
......@@ -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
}
......
......@@ -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
......
......@@ -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;
......
......@@ -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));
......
......@@ -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);
......
......@@ -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);
......
......@@ -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));
......
......@@ -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,
......
......@@ -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++) {
......
......@@ -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);
......
......@@ -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;
......
......@@ -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;
......
......@@ -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
......
......@@ -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;
}
......
......@@ -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)
......
......@@ -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)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment