kernel: sched: Use k_ticks_t in z_tick_sleep
z_tick_sleep was using int32_t what could cause a possible overflow when converting from k_ticks_t. Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
This commit is contained in:
parent
8453a73ede
commit
7a815d5d99
1 changed files with 9 additions and 4 deletions
|
@ -1256,14 +1256,19 @@ static inline void z_vrfy_k_yield(void)
|
|||
#include <syscalls/k_yield_mrsh.c>
|
||||
#endif
|
||||
|
||||
static int32_t z_tick_sleep(int32_t ticks)
|
||||
static int32_t z_tick_sleep(k_ticks_t ticks)
|
||||
{
|
||||
#ifdef CONFIG_MULTITHREADING
|
||||
uint32_t expected_wakeup_time;
|
||||
|
||||
__ASSERT(!arch_is_in_isr(), "");
|
||||
|
||||
LOG_DBG("thread %p for %d ticks", _current, ticks);
|
||||
#ifndef CONFIG_TIMEOUT_64BIT
|
||||
/* LOG subsys does not handle 64-bit values
|
||||
* https://github.com/zephyrproject-rtos/zephyr/issues/26246
|
||||
*/
|
||||
LOG_DBG("thread %p for %u ticks", _current, ticks);
|
||||
#endif
|
||||
|
||||
/* wait of 0 ms is treated as a 'yield' */
|
||||
if (ticks == 0) {
|
||||
|
@ -1277,7 +1282,7 @@ static int32_t z_tick_sleep(int32_t ticks)
|
|||
timeout = Z_TIMEOUT_TICKS(ticks);
|
||||
#else
|
||||
ticks += _TICK_ALIGN;
|
||||
timeout = (k_ticks_t) ticks;
|
||||
timeout = Z_TIMEOUT_TICKS(ticks);
|
||||
#endif
|
||||
|
||||
expected_wakeup_time = ticks + z_tick_get_32();
|
||||
|
@ -1295,7 +1300,7 @@ static int32_t z_tick_sleep(int32_t ticks)
|
|||
|
||||
__ASSERT(!z_is_thread_state_set(_current, _THREAD_SUSPENDED), "");
|
||||
|
||||
ticks = expected_wakeup_time - z_tick_get_32();
|
||||
ticks = (k_ticks_t)expected_wakeup_time - z_tick_get_32();
|
||||
if (ticks > 0) {
|
||||
return ticks;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue