I’ve been using a program, compiled using GCC 4.4.1 (ISO C99) and noticed this quirk today. Although it works on target without any problem neither does compiler emit any warning with -Wall.
void mutex_init(mutex_t *mutex)
{
if(unlikely(mutex->magic == MUTX_MAGIC_CHAR))
return;
mutex->owner = NULL;
mutex->prior = NULL;
mutex->magic = MUTX_MAGIC_CHAR;
thread_queue_init(&mutex->queue);
}
shouldn’t it be like
*mutex->owner = NULL;
No,
magic->owneris equivalent to(*magic).owner.The
->operator is meant to work on pointers to structures, while the.operator work on structures directly.