On Sun Mar 12, 2023 at 3:22 AM EDT, Lorenz (xha) wrote:
> - } else {> + draw_options_page();> + } else if (state.options.userlen > 0) {> ++state.options.page;> + draw_options_page();> }> - draw_options_page();
Why make the change with draw_options_page()? Looks like this could be
simplified by leaving draw_options_page alone, and only changing the
else to the else if.
> @@ -7805,8 +7806,10 @@ optionsinput(uint8_t inputs)> if (state.options.pos == 0) {> uint8_t pos;> if (state.options.page == 0) {> - state.options.page = state.options.userlen / 20 + 1;> - pos = MIN(19, state.options.userlen % 20 - 1);> + if (state.options.userlen > 0) {> + state.options.page = state.options.userlen / 20 + 1;> + pos = MIN(19, state.options.userlen % 20 - 1);> + }> } else {> --state.options.page;> pos = state.options.page > 0 ? 19 : OPT_LAST;
This has undefined behavior: pos is never initialized when both
state.options.page and state.options.userlen are 0.
Also, I think the ideal behavior here is that if there aren't any other
pages, pressing up at the top should set the position to the bottom
rather than just doing nothing.