Skip to content

Commit

Permalink
Returning max delay value that is uint-wrap around safe.
Browse files Browse the repository at this point in the history
  • Loading branch information
dok-net committed Jul 19, 2023
1 parent 261fd96 commit f05cb54
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion cores/esp8266/Schedule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ bool schedule_recurrent_function_us(const std::function<bool(void)>& fn,

uint32_t get_scheduled_recurrent_delay_us()
{
if (!rFirst) return ~static_cast<uint32_t>(0);
if (!rFirst) return ~static_cast<decltype(micros())>(0) >> 1;
// handle already expired rTarget.
const int32_t remaining = rTarget - micros();
return (remaining > 0) ? static_cast<uint32_t>(remaining) : 0;
Expand Down

0 comments on commit f05cb54

Please sign in to comment.