ao_lco_v2: Use int32_t for temporary box value in step_box
authorKeith Packard <keithp@keithp.com>
Thu, 17 Feb 2022 05:44:52 +0000 (21:44 -0800)
committerKeith Packard <keithp@keithp.com>
Thu, 17 Feb 2022 05:44:52 +0000 (21:44 -0800)
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 <keithp@keithp.com>
src/telelco-v2.0/ao_lco_v2.c

index a04ceb9fc89efdd936cf059ea2d72972ee3c40c2..f71f3d10806a6b46255b02a8cef4a36eff06bcfa 100644 (file)
@@ -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;