mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-12-28 16:01:18 +01:00
core/msg: handle error in msg_queue_capacity()
Rather than using an `assert()` on `thread_get()`, check for the thread to exist and return a capacity of `0` if it does not. This fixes compilation with `-fanalyzer` with `NDEBUG` defined, is more consistent with other core APIs, and makes the API usable for threads with a dynamic life cycle. Co-authored-by: crasbe <crasbe@gmail.com>
This commit is contained in:
parent
55f9d1c930
commit
d36465d532
@ -393,10 +393,11 @@ unsigned msg_avail_thread(kernel_pid_t pid);
|
||||
unsigned msg_avail(void);
|
||||
|
||||
/**
|
||||
* @brief Get maximum capacity of a thread's queue length
|
||||
* @brief Get maximum capacity of a thread's queue length
|
||||
*
|
||||
* @return Number of total messages that fit in the queue of @p pid on success
|
||||
* @return 0, if no caller's message queue is initialized
|
||||
* @return Number of total messages that fit in the queue of @p pid on success
|
||||
* @retval 0 Either the thread identified by PID @p pid does not exist or
|
||||
* has no message queue initialized (yet)
|
||||
*/
|
||||
unsigned msg_queue_capacity(kernel_pid_t pid);
|
||||
|
||||
|
||||
@ -484,7 +484,9 @@ unsigned msg_queue_capacity(kernel_pid_t pid)
|
||||
|
||||
thread_t *thread = thread_get(pid);
|
||||
|
||||
assert(thread != NULL);
|
||||
if (!thread) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int queue_cap = 0;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user