From fb6162a6cceddd9af4a9d054f8cfcf2c3fcd2ef5 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sat, 17 Dec 2022 15:19:42 +0200 Subject: [PATCH 15/15] sdl2: Fix widget_scrollbar.c clang analyzer warnings Make some function parameters nonnull, so clang analyzer isn't worried about NULL dereferences with them. See osdn #46293 Signed-off-by: Marko Lindqvist --- client/gui-sdl2/widget.h | 10 ++++++---- client/gui-sdl2/widget_scrollbar.c | 4 +--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/client/gui-sdl2/widget.h b/client/gui-sdl2/widget.h index d4e26cdd9c..755df01e92 100644 --- a/client/gui-sdl2/widget.h +++ b/client/gui-sdl2/widget.h @@ -404,12 +404,14 @@ do { \ bool add_widget_to_vertical_scroll_widget_list(struct ADVANCED_DLG *pDlg, struct widget *pNew_Widget, struct widget *pAdd_Dock, bool dir, - Sint16 start_x, Sint16 start_y); + Sint16 start_x, Sint16 start_y) + fc__attribute((nonnull (2))); bool del_widget_from_vertical_scroll_widget_list(struct ADVANCED_DLG *pDlg, - struct widget *pWidget); + struct widget *pWidget) + fc__attribute((nonnull (2))); -/* misc */ +/* Misc */ SDL_Surface *create_bcgnd_surf(SDL_Surface *ptheme, enum widget_state state, Uint16 width, Uint16 height); void draw_frame(SDL_Surface *pDest, Sint16 start_x, Sint16 start_y, @@ -424,4 +426,4 @@ void draw_frame(SDL_Surface *pDest, Sint16 start_x, Sint16 start_y, #include "widget_scrollbar.h" #include "widget_window.h" -#endif /* FC__WIDGET_H */ +#endif /* FC__WIDGET_H */ diff --git a/client/gui-sdl2/widget_scrollbar.c b/client/gui-sdl2/widget_scrollbar.c index f011b6a672..6b864e24b8 100644 --- a/client/gui-sdl2/widget_scrollbar.c +++ b/client/gui-sdl2/widget_scrollbar.c @@ -982,7 +982,7 @@ static Uint16 scroll_mouse_motion_handler(SDL_MouseMotionEvent *pMotionEvent, net_slider_area = (pMotion->pVscroll->max - pMotion->pVscroll->min - pMotion->pVscroll->pScrollBar->size.h); net_count = round((float)pMotion->pVscroll->count / pMotion->pVscroll->step) - pMotion->pVscroll->active + 1; scroll_step = (float)net_slider_area / net_count; - + if ((yrel != 0) && ((normalized_y >= pMotion->pVscroll->min) || ((normalized_y < pMotion->pVscroll->min) @@ -1159,7 +1159,6 @@ bool add_widget_to_vertical_scroll_widget_list(struct ADVANCED_DLG *pDlg, struct widget *pEnd = NULL, *pOld_End = NULL; bool last = FALSE, seen = TRUE; - fc_assert_ret_val(pNew_Widget != NULL, FALSE); fc_assert_ret_val(pDlg != NULL, FALSE); fc_assert_ret_val(pDlg->pScroll != NULL, FALSE); @@ -1350,7 +1349,6 @@ bool del_widget_from_vertical_scroll_widget_list(struct ADVANCED_DLG *pDlg, { struct widget *pBuf = pWidget; - fc_assert_ret_val(pWidget != NULL, FALSE); fc_assert_ret_val(pDlg != NULL, FALSE); /* if begin == end -> size = 1 */ -- 2.35.1