From c29f133a63978bc1f4e1ff11750ef99d1417ab0e Mon Sep 17 00:00:00 2001 From: Benjamin Valentin Date: Tue, 5 May 2020 00:50:21 +0200 Subject: [PATCH] core/msg_bus: clarify API of msg_bus_post() Receiving threads must not modify the contents of the message as this is racy by definition. Also make `msg_bus_post()` accept `const void*` instead of `char *`. --- core/include/msg_bus.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/core/include/msg_bus.h b/core/include/msg_bus.h index 6d6cb17110..0faed44c20 100644 --- a/core/include/msg_bus.h +++ b/core/include/msg_bus.h @@ -103,6 +103,7 @@ static inline bool msg_is_from_bus(const msg_bus_t *bus, const msg_t *msg) * posted on the bus. * * Events can be received with @ref msg_receive. + * **The contents of the received message must not be modified.** * * @param[in] bus The message bus to attach to * @param[in] entry Message bus subscriber entry @@ -194,13 +195,13 @@ int msg_send_bus(msg_t *m, msg_bus_t *bus); * * @return The number of threads the event was posted to. */ -static inline int msg_bus_post(msg_bus_t *bus, uint8_t type, char *arg) +static inline int msg_bus_post(msg_bus_t *bus, uint8_t type, const void *arg) { assert(type < 32); msg_t m = { .type = type | ((bus->id) << 5), - .content.ptr = arg, + .content.ptr = (void *)arg, }; return msg_send_bus(&m, bus);