kernel: Add assert to detect negative timeouts
Add assert when negative (except K_FOREVER) is passed as timeout. Add negative timeout correction to 0. Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
This commit is contained in:
parent
94f742e4c4
commit
f831929cb5
1 changed files with 10 additions and 1 deletions
|
@ -368,7 +368,16 @@ static void pend(struct k_thread *thread, _wait_q_t *wait_q, s32_t timeout)
|
|||
}
|
||||
|
||||
if (timeout != K_FOREVER) {
|
||||
s32_t ticks = _TICK_ALIGN + k_ms_to_ticks_ceil32(timeout);
|
||||
s32_t ticks;
|
||||
|
||||
__ASSERT(timeout >= 0,
|
||||
"Only non-negative values are accepted.");
|
||||
|
||||
if (timeout < 0) {
|
||||
timeout = 0;
|
||||
}
|
||||
|
||||
ticks = _TICK_ALIGN + k_ms_to_ticks_ceil32(timeout);
|
||||
|
||||
z_add_thread_timeout(thread, ticks);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue