mirror of https://github.com/rusefi/rusefi-1.git
handle negative timer delta (#2110)
This commit is contained in:
parent
ce802ae43e
commit
67d0d7b330
|
@ -37,6 +37,13 @@ float Timer::getElapsedSeconds() const {
|
||||||
float Timer::getElapsedSeconds(efitick_t nowNt) const {
|
float Timer::getElapsedSeconds(efitick_t nowNt) const {
|
||||||
auto delta = nowNt - m_lastReset;
|
auto delta = nowNt - m_lastReset;
|
||||||
|
|
||||||
|
// Yes, things can happen slightly in the future if we get a lucky interrupt between
|
||||||
|
// the timestamp and this subtraction, that updates m_lastReset to what's now "the future",
|
||||||
|
// resulting in a negative delta.
|
||||||
|
if (delta < 0) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (delta > UINT32_MAX - 1) {
|
if (delta > UINT32_MAX - 1) {
|
||||||
delta = UINT32_MAX - 1;
|
delta = UINT32_MAX - 1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue