From b6311c9c062c6ec9aa11df9d6bd32283d4db3736 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Thu, 9 Jun 2022 01:43:12 +0300 Subject: [PATCH 28/28] sdl2: Fix clang analyze popup_goto_airlift_dialog() div by zero warning See osdn #44679 Signed-off-by: Marko Lindqvist --- client/gui-sdl2/gotodlg.c | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/client/gui-sdl2/gotodlg.c b/client/gui-sdl2/gotodlg.c index a7ecf7e68d..c8e0bd7df3 100644 --- a/client/gui-sdl2/gotodlg.c +++ b/client/gui-sdl2/gotodlg.c @@ -355,23 +355,26 @@ static void popup_goto_airlift_dialog(void) i = 0; x = block_x + adj_size(5); y = area.y + adj_size(1); - while (buf) { - buf->size.x = x; - buf->size.y = y; + fc_assert(col > 0); + if (col > 0) { + while (buf) { + buf->size.x = x; + buf->size.y = y; + + if (!((i + 1) % col)) { + x = block_x + adj_size(5); + y += buf->size.h + adj_size(1); + } else { + x += buf->size.w + adj_size(5); + } - if (!((i + 1) % col)) { - x = block_x + adj_size(5); - y += buf->size.h + adj_size(1); - } else { - x += buf->size.w + adj_size(5); - } + if (buf == goto_dlg->begin_widget_list) { + break; + } - if (buf == goto_dlg->begin_widget_list) { - break; + i++; + buf = buf->prev; } - - i++; - buf = buf->prev; } setup_vertical_scrollbar_area(goto_dlg->scroll, -- 2.35.1