From: Matheus Afonso Martins Moreira Date: Wed, 6 Mar 2024 00:49:32 +0000 (-0300) Subject: movement: fix unintended timeout short circuiting X-Git-Url: https://git.earman.xyz/?a=commitdiff_plain;h=b1adbd548eabbf3212e9a53dbb8830d030b15fa7;p=sensor-watch.git movement: fix unintended timeout short circuiting Currently, movement drops time out events in case the previous loop indicates that sleep is not possible due to short circuiting behavior of logical and in C: if the left-hand side is false, the right hand side is not evaluated at all, which means the loop is not called. This was not intended to happen. Fix it by storing the result in a second boolean variable and working out the logic after the fact. --- diff --git a/movement/movement.c b/movement/movement.c index c64df0c..191429e 100644 --- a/movement/movement.c +++ b/movement/movement.c @@ -533,7 +533,8 @@ bool app_loop(void) { // first trip | can sleep | cannot sleep | can sleep | cannot sleep // second trip | can sleep | cannot sleep | cannot sleep | can sleep // && | can sleep | cannot sleep | cannot sleep | cannot sleep - can_sleep = can_sleep && wf->loop(event, &movement_state.settings, watch_face_contexts[movement_state.current_face_idx]); + bool can_sleep2 = wf->loop(event, &movement_state.settings, watch_face_contexts[movement_state.current_face_idx]); + can_sleep = can_sleep && can_sleep2; event.event_type = EVENT_NONE; if (movement_state.settings.bit.to_always && movement_state.current_face_idx != 0) { // ...but if the user has "timeout always" set, give it the boot.