Browse Source

Merge pull request #5295 from OlegHahm/msg_init_queue_assert

core: assert correct msq queue size on creation
pr/spi.typo
Oleg Hahm 7 years ago
parent
commit
8690a888f5
  1. 5
      core/include/msg.h
  2. 14
      core/msg.c
  3. 4
      sys/net/gnrc/application_layer/zep/gnrc_zep.c

5
core/include/msg.h

@ -369,11 +369,8 @@ int msg_avail(void);
* not be NULL.
* @param[in] num Number of ``msg_t`` structures in array.
* **MUST BE POWER OF TWO!**
*
* @return 0, if successful
* @return -1, on error
*/
int msg_init_queue(msg_t *array, int num);
void msg_init_queue(msg_t *array, int num);
/**
* @brief Prints the message queue of the current thread.

14
core/msg.c

@ -376,17 +376,11 @@ int msg_avail(void)
return queue_index;
}
int msg_init_queue(msg_t *array, int num)
void msg_init_queue(msg_t *array, int num)
{
/* check if num is a power of two by comparing to its complement */
if (num && (num & (num - 1)) == 0) {
thread_t *me = (thread_t*) sched_active_thread;
me->msg_array = array;
cib_init(&(me->msg_queue), num);
return 0;
}
return -1;
thread_t *me = (thread_t*) sched_active_thread;
me->msg_array = array;
cib_init(&(me->msg_queue), num);
}
void msg_queue_print(void)

4
sys/net/gnrc/application_layer/zep/gnrc_zep.c

@ -561,9 +561,7 @@ void *_event_loop(void *args)
KERNEL_PID_UNDEF
};
if (msg_init_queue(msg_q, GNRC_ZEP_MSG_QUEUE_SIZE)) {
return NULL;
}
msg_init_queue(msg_q, GNRC_ZEP_MSG_QUEUE_SIZE);
my_reg.pid = thread_getpid();

Loading…
Cancel
Save