Skip to content
Commit e9cdcc23 authored by Robert Lubos's avatar Robert Lubos Committed by Carles Cufí
Browse files

kernel: timeout: Fix macro usage in next_timeout function



The `next_timeout()` function used to call the `elapsed()` function
directly in the `MAX` macro call. This caused the `elapsed()` function
to be executed twice, with possible different results, if the system
clock incremented its value in a meantime.

As a result, the whole `MAX(0, to->dticks - elapsed()` expresion could
return an incorrect value of -1, which represents the K_FOREVER timeout.
This led to a stall in devices running tickless kernel (as observed on
nRF52840).

Signed-off-by: default avatarRobert Lubos <robert.lubos@nordicsemi.no>
parent 583226a8
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment