From 85b437e6dce54da87fe1e572a4b9cd47a75be99c Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Thu, 9 Jun 2022 01:48:13 +0300 Subject: [PATCH 12/12] 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 | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/client/gui-sdl2/gotodlg.c b/client/gui-sdl2/gotodlg.c index f5e5b40b41..d1c7ea9bdc 100644 --- a/client/gui-sdl2/gotodlg.c +++ b/client/gui-sdl2/gotodlg.c @@ -354,23 +354,25 @@ static void popup_goto_airlift_dialog(void) i = 0; x = block_x + adj_size(5); y = area.y + adj_size(1); - while (pBuf) { - pBuf->size.x = x; - pBuf->size.y = y; + if (col > 0) { + while (pBuf) { + pBuf->size.x = x; + pBuf->size.y = y; + + if (!((i + 1) % col)) { + x = block_x + adj_size(5); + y += pBuf->size.h + adj_size(1); + } else { + x += pBuf->size.w + adj_size(5); + } - if (!((i + 1) % col)) { - x = block_x + adj_size(5); - y += pBuf->size.h + adj_size(1); - } else { - x += pBuf->size.w + adj_size(5); - } + if (pBuf == pGotoDlg->pBeginWidgetList) { + break; + } - if (pBuf == pGotoDlg->pBeginWidgetList) { - break; + i++; + pBuf = pBuf->prev; } - - i++; - pBuf = pBuf->prev; } setup_vertical_scrollbar_area(pGotoDlg->pScroll, -- 2.35.1