From 986b9d380bb2cf1da0004c287afea85a89b2d3ca Mon Sep 17 00:00:00 2001 From: Martine Lenders Date: Thu, 15 Nov 2018 14:06:57 +0100 Subject: [PATCH] gnrc_netreg: make message queue check more readable --- sys/net/gnrc/netreg/gnrc_netreg.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/sys/net/gnrc/netreg/gnrc_netreg.c b/sys/net/gnrc/netreg/gnrc_netreg.c index df0450468b..2361d4c075 100644 --- a/sys/net/gnrc/netreg/gnrc_netreg.c +++ b/sys/net/gnrc/netreg/gnrc_netreg.c @@ -39,13 +39,14 @@ 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) +#if DEVELHELP + +# if defined(MODULE_GNRC_NETAPI_MBOX) || defined(MODULE_GNRC_NETAPI_CALLBACKS) 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 + (sched_threads[entry->target.pid]->msg_array != NULL); +# else + bool has_msg_q = (sched_threads[entry->target.pid]->msg_array != NULL); +# endif /* only threads with a message queue are allowed to register at gnrc */ if (!has_msg_q) { @@ -53,7 +54,7 @@ int gnrc_netreg_register(gnrc_nettype_t type, gnrc_netreg_entry_t *entry) "using msg_init_queue() !!!!\n\n", entry->target.pid); } assert(has_msg_q); -#endif +#endif /* DEVELHELP */ if (_INVALID_TYPE(type)) { return -EINVAL;