I have dispatchQueue.c:215: warning: control reaches end of non-void function warning from the code below..
Can anyone please explain why?
void *dispatcher_threadloop(void *arg){
//thread loop of the dispatch thread- pass the tast to one of worker thread
dispatch_queue_thread_t *dThread = arg;
dispatch_queue_t *dQueue;
dQueue = dThread->queue;
if (dQueue->HEAD!=NULL){
for(;;){
printf("test");
sem_wait(&(dQueue->queue_task_semaphore));
dThread->current_task = dQueue->HEAD;
dQueue->HEAD = dQueue->HEAD->next;
dQueue->HEAD->prev = NULL;
sem_post(&(dQueue->queue_task_semaphore));
break;
//TODO
}
}
}
Well, imagine what happens if
dQueue->HEADisNULL: theifwon’t be entered, so you get to the end of the function which is supposed to return avoid*– but you don’t return anything.Try returning some sensible value at the bottom of your function to fix this. Or add an assertion which states that this code should be unreachable, like: