Browse Source

msg: Fix incorrect queues initializations

From core/include/msg.h:

/**
 * @brief Initialize the current thread's message queue.
 *
 * @param[in] array Pointer to preallocated array of ``msg_t`` structures, must
 *                  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);

sizeof(array) does does not compute an array size. Replace calls to sizeof()
with proper values

Closes #3269.

Fix two crashes in the tests and probably more in the network stack.
dev/timer
Benoît Canet 8 years ago
parent
commit
5e7ea2d9e4
  1. 2
      sys/net/link_layer/ping/ping.c
  2. 2
      sys/net/routing/aodvv2/aodv.c
  3. 6
      tests/vtimer_msg/main.c
  4. 6
      tests/vtimer_msg_diff/main.c

2
sys/net/link_layer/ping/ping.c

@ -140,7 +140,7 @@ static void *l2_pkt_handler(void *unused)
radio_packet_t *p;
l2_ping_payload_t *pp;
msg_init_queue(msg_q, sizeof(msg_q));
msg_init_queue(msg_q, RCV_BUFFER_SIZE);
while (1) {
msg_receive(&m);

2
sys/net/routing/aodvv2/aodv.c

@ -242,7 +242,7 @@ static void *_aodv_sender_thread(void *arg)
(void) arg;
msg_t msgq[RCV_MSG_Q_SIZE];
msg_init_queue(msgq, sizeof msgq);
msg_init_queue(msgq, RCV_MSG_Q_SIZE);
AODV_DEBUG("_aodv_sender_thread initialized.\n");
while (true) {

6
tests/vtimer_msg/main.c

@ -26,6 +26,8 @@
#include "thread.h"
#include "msg.h"
#define MSG_QUEUE_SIZE 1
char timer_stack[THREAD_STACKSIZE_MAIN];
char timer_stack_local[THREAD_STACKSIZE_MAIN];
@ -49,8 +51,8 @@ void *timer_thread(void *arg)
/* we need a queue if the second message arrives while the first is still processed */
/* without a queue, the message would get lost */
/* because of the way this timer works, there can be max 1 queued message */
msg_t msgq[1];
msg_init_queue(msgq, sizeof(msgq));
msg_t msgq[MSG_QUEUE_SIZE];
msg_init_queue(msgq, MSG_QUEUE_SIZE);
while (1) {
msg_t m;

6
tests/vtimer_msg_diff/main.c

@ -31,6 +31,8 @@
#define MAXCOUNT 100
#define MAXDIFF 10000
#define MSG_QUEUE_SIZE 16
char timer_stack[THREAD_STACKSIZE_MAIN*4];
struct timer_msg {
@ -56,8 +58,8 @@ void *timer_thread(void *arg)
(void) arg;
printf("This is thread %" PRIkernel_pid "\n", thread_getpid());
msg_t msgq[16];
msg_init_queue(msgq, sizeof(msgq));
msg_t msgq[MSG_QUEUE_SIZE];
msg_init_queue(msgq, MSG_QUEUE_SIZE);
while (1) {
msg_t m;

Loading…
Cancel
Save