mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
Merge pull request #5295 from OlegHahm/msg_init_queue_assert
core: assert correct msq queue size on creation
This commit is contained in:
commit
8690a888f5
@ -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
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)
|
||||
|
@ -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…
Reference in New Issue
Block a user