From d3d7a49d7abc0d1f65db313338c5d189e4e4d1e8 Mon Sep 17 00:00:00 2001 From: Martine Lenders Date: Wed, 14 Jun 2017 13:25:29 +0200 Subject: [PATCH] gnrc_netreg: make message queue requirement more visible --- sys/net/gnrc/netreg/gnrc_netreg.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/sys/net/gnrc/netreg/gnrc_netreg.c b/sys/net/gnrc/netreg/gnrc_netreg.c index b77f76fbae..df0450468b 100644 --- a/sys/net/gnrc/netreg/gnrc_netreg.c +++ b/sys/net/gnrc/netreg/gnrc_netreg.c @@ -16,6 +16,7 @@ #include #include "assert.h" +#include "log.h" #include "utlist.h" #include "net/gnrc/netreg.h" #include "net/gnrc/nettype.h" @@ -38,13 +39,20 @@ void gnrc_netreg_init(void) int gnrc_netreg_register(gnrc_nettype_t type, gnrc_netreg_entry_t *entry) { +#ifdef DEVELHELP #if defined(MODULE_GNRC_NETAPI_MBOX) || defined(MODULE_GNRC_NETAPI_CALLBACKS) - /* only threads with a message queue are allowed to register at gnrc */ - assert((entry->type != GNRC_NETREG_TYPE_DEFAULT) || - sched_threads[entry->target.pid]->msg_array); + bool has_msg_q = (entry->type != GNRC_NETREG_TYPE_DEFAULT) || + sched_threads[entry->target.pid]->msg_array; #else + bool has_msg_q = sched_threads[entry->target.pid]->msg_array; +#endif + /* only threads with a message queue are allowed to register at gnrc */ - assert(sched_threads[entry->target.pid]->msg_array); + if (!has_msg_q) { + LOG_ERROR("\n!!!! gnrc_netreg: initialize message queue of thread %u " + "using msg_init_queue() !!!!\n\n", entry->target.pid); + } + assert(has_msg_q); #endif if (_INVALID_TYPE(type)) {