From 2f06b7c66dfa05c51d8b2afbc1e3c94e20767e4f Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Wed, 16 Feb 2022 21:44:52 -0800 Subject: [PATCH] ao_lco_v2: Use int32_t for temporary box value in step_box Stepping to the next box will generate negative values and values beyond the highest box number. Use a type capable of holding all of those values, instead of int16_t. Signed-off-by: Keith Packard --- src/telelco-v2.0/ao_lco_v2.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/telelco-v2.0/ao_lco_v2.c b/src/telelco-v2.0/ao_lco_v2.c index a04ceb9f..f71f3d10 100644 --- a/src/telelco-v2.0/ao_lco_v2.c +++ b/src/telelco-v2.0/ao_lco_v2.c @@ -132,7 +132,7 @@ ao_lco_set_select(void) static void ao_lco_step_box(int8_t dir) { - int16_t new_box = ao_lco_box; + int32_t new_box = (int32_t) ao_lco_box; do { new_box += dir; @@ -142,8 +142,8 @@ ao_lco_step_box(int8_t dir) new_box = ao_lco_max_box; if (new_box == ao_lco_box) break; - } while (!ao_lco_box_present(new_box)); - ao_lco_set_box(new_box); + } while (!ao_lco_box_present((uint16_t) new_box)); + ao_lco_set_box((uint16_t) new_box); } static struct ao_task ao_lco_drag_task; -- 2.30.2