IdleLEDs: Explicitly cast idle_time_limit to uint32_t

When calculating `end_time`, explicitly cast `idle_time_limit` to 32 bits,
otherwise the `idle_time_limit * 1000` operation will be done on 16 bits, which
would overflow at about 65 seconds. With the cast, the operation will use all 32
bits, and we avoid the overflow.

Many thanks to @nevd for the report and the help in debugging & testing the fix.

Signed-off-by: Gergely Nagy <algernon@keyboard.io>
pull/445/head
Gergely Nagy 6 years ago
parent 300e1afacb
commit 31d64a2f3d
No known key found for this signature in database
GPG Key ID: AC1E90BAC433F68F

@ -43,7 +43,7 @@ EventHandlerResult IdleLEDs::onKeyswitchEvent(Key &mapped_key, byte row, byte co
::LEDControl.refreshAll();
}
end_time_ = Kaleidoscope.millisAtCycleStart() + idle_time_limit * 1000;
end_time_ = Kaleidoscope.millisAtCycleStart() + (uint32_t)idle_time_limit * 1000;
return EventHandlerResult::OK;
}

Loading…
Cancel
Save