From 9f964ae39265952c51bc0f806d341ccb267e19b8 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Sun, 4 Mar 2001 20:13:49 +0000 Subject: (lio_listio): Add some asserts. --- rt/lio_listio.c | 50 ++++++++++++++++++++++++++++++-------------------- 1 file changed, 30 insertions(+), 20 deletions(-) (limited to 'rt') diff --git a/rt/lio_listio.c b/rt/lio_listio.c index aa267a8e31..e1df603fd8 100644 --- a/rt/lio_listio.c +++ b/rt/lio_listio.c @@ -19,6 +19,7 @@ Boston, MA 02111-1307, USA. */ #include +#include #include #include #include @@ -108,16 +109,20 @@ lio_listio (mode, list, nent, sig) total = 0; for (cnt = 0; cnt < nent; ++cnt) - if (requests[cnt] != NULL && list[cnt]->aio_lio_opcode != LIO_NOP) - { - waitlist[cnt].cond = &cond; - waitlist[cnt].next = requests[cnt]->waiting; - waitlist[cnt].counterp = &total; - waitlist[cnt].sigevp = NULL; - waitlist[cnt].caller_pid = 0; /* Not needed. */ - requests[cnt]->waiting = &waitlist[cnt]; - ++total; - } + { + assert (requests[cnt] == NULL || list[cnt] != NULL); + + if (requests[cnt] != NULL && list[cnt]->aio_lio_opcode != LIO_NOP) + { + waitlist[cnt].cond = &cond; + waitlist[cnt].next = requests[cnt]->waiting; + waitlist[cnt].counterp = &total; + waitlist[cnt].sigevp = NULL; + waitlist[cnt].caller_pid = 0; /* Not needed. */ + requests[cnt]->waiting = &waitlist[cnt]; + ++total; + } + } /* Since `pthread_cond_wait'/`pthread_cond_timedwait' are cancelation points we must be careful. We added entries to the waiting lists @@ -154,16 +159,21 @@ lio_listio (mode, list, nent, sig) total = 0; for (cnt = 0; cnt < nent; ++cnt) - if (requests[cnt] != NULL && list[cnt]->aio_lio_opcode != LIO_NOP) - { - waitlist->list[cnt].cond = NULL; - waitlist->list[cnt].next = requests[cnt]->waiting; - waitlist->list[cnt].counterp = &waitlist->counter; - waitlist->list[cnt].sigevp = &waitlist->sigev; - waitlist->list[cnt].caller_pid = caller_pid; - requests[cnt]->waiting = &waitlist->list[cnt]; - ++total; - } + { + assert (requests[cnt] == NULL || list[cnt] != NULL); + + if (requests[cnt] != NULL + && list[cnt]->aio_lio_opcode != LIO_NOP) + { + waitlist->list[cnt].cond = NULL; + waitlist->list[cnt].next = requests[cnt]->waiting; + waitlist->list[cnt].counterp = &waitlist->counter; + waitlist->list[cnt].sigevp = &waitlist->sigev; + waitlist->list[cnt].caller_pid = caller_pid; + requests[cnt]->waiting = &waitlist->list[cnt]; + ++total; + } + } waitlist->counter = total; waitlist->sigev = *sig; -- cgit v1.2.3