From 12194ad9e6ce267c8d8d30e3aa9ac8e77c961633 Mon Sep 17 00:00:00 2001 From: Martine Lenders Date: Fri, 20 Nov 2020 13:40:44 +0100 Subject: [PATCH 1/2] mbox: provide function to unset initialized mbox --- core/include/mbox.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/core/include/mbox.h b/core/include/mbox.h index 62a439271119..121b9ae65a59 100644 --- a/core/include/mbox.h +++ b/core/include/mbox.h @@ -185,6 +185,17 @@ static inline size_t mbox_avail(mbox_t *mbox) return cib_avail(&mbox->cib); } +/** + * @brief Unset's the mbox, effectively deinitializing and invalidating it. + * + * @param[in] mbox ptr to mailbox to operate on + */ +static inline void mbox_unset(mbox_t *mbox) +{ + mbox->msg_array = NULL; + mbox->cib.mask = 0; +} + #ifdef __cplusplus } #endif From 6229fda7bdc4c57e123ff4db3331820f2fef7b55 Mon Sep 17 00:00:00 2001 From: Martine Lenders Date: Fri, 20 Nov 2020 13:42:43 +0100 Subject: [PATCH 2/2] lwip: use new mbox_unset() function --- pkg/lwip/include/arch/sys_arch.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/lwip/include/arch/sys_arch.h b/pkg/lwip/include/arch/sys_arch.h index c9dda62357c0..64c38a3441a7 100644 --- a/pkg/lwip/include/arch/sys_arch.h +++ b/pkg/lwip/include/arch/sys_arch.h @@ -101,13 +101,13 @@ typedef struct { static inline bool sys_mbox_valid(sys_mbox_t *mbox) { - return (mbox != NULL) && (mbox->mbox.cib.mask != 0); + return (mbox != NULL) && (mbox_size(&mbox->mbox) != 0); } static inline void sys_mbox_set_invalid(sys_mbox_t *mbox) { if (mbox != NULL) { - mbox->mbox.cib.mask = 0; + mbox_unset(&mbox->mbox); } }