From: Joseph Bryant Date: Sun, 18 Aug 2024 20:50:41 +0000 (+0100) Subject: avoid delta overflow in countdown draw X-Git-Url: https://git.earman.xyz/?a=commitdiff_plain;h=dcd4d12c0ab55aea50fc93f4de390a815d4ff6f5;p=sensor-watch.git avoid delta overflow in countdown draw --- diff --git a/movement/watch_faces/complication/countdown_face.c b/movement/watch_faces/complication/countdown_face.c index be04040..6ae3d93 100644 --- a/movement/watch_faces/complication/countdown_face.c +++ b/movement/watch_faces/complication/countdown_face.c @@ -87,7 +87,10 @@ static void draw(countdown_state_t *state, uint8_t subsecond) { switch (state->mode) { case cd_running: - delta = state->target_ts - state->now_ts; + if (state->target_ts <= state->now_ts) + delta = 0; + else + delta = state->target_ts - state->now_ts; result = div(delta, 60); state->seconds = result.rem; result = div(result.quot, 60);