From 1c9d3ad0bfcffb0327f558387973fa4767d2392f Mon Sep 17 00:00:00 2001
From: libretroadmin <reallibretroretroarch@gmail.com>
Date: Mon, 21 Nov 2022 20:56:28 +0100
Subject: [PATCH] Silence some warnings

---
 input/input_driver.c                          |  2 +-
 .../audio/resampler/drivers/sinc_resampler.c  |  2 +-
 libretro-common/lists/string_list.c           |  2 +-
 libretro-common/string/stdstring.c            |  2 +-
 menu/drivers/materialui.c                     | 50 ++++++------
 menu/drivers/rgui.c                           | 80 ++++++++-----------
 6 files changed, 62 insertions(+), 76 deletions(-)

diff --git a/input/input_driver.c b/input/input_driver.c
index 8289ebc078..c410767f09 100644
--- a/input/input_driver.c
+++ b/input/input_driver.c
@@ -3775,7 +3775,7 @@ void input_keys_pressed(
                port, RETRO_DEVICE_JOYPAD, 0,
                RARCH_ENABLE_HOTKEY))
       {
-         if (input_st->input_hotkey_block_counter < input_hotkey_block_delay)
+         if (input_st->input_hotkey_block_counter < (int)input_hotkey_block_delay)
             input_st->input_hotkey_block_counter++;
          else
             input_st->flags |= INP_FLAG_BLOCK_LIBRETRO_INPUT;
diff --git a/libretro-common/audio/resampler/drivers/sinc_resampler.c b/libretro-common/audio/resampler/drivers/sinc_resampler.c
index cd7eedf4a1..836f1a0edd 100644
--- a/libretro-common/audio/resampler/drivers/sinc_resampler.c
+++ b/libretro-common/audio/resampler/drivers/sinc_resampler.c
@@ -706,7 +706,7 @@ static void resampler_sinc_process_c(void *re_, struct resampler_data *data)
                unsigned phase           = resamp->time >> resamp->subphase_bits;
                float *phase_table       = resamp->phase_table + phase * taps;
 
-               for (i = 0; i < taps; i++)
+               for (i = 0; i < (int)taps; i++)
                {
                   float sinc_val        = phase_table[i];
 
diff --git a/libretro-common/lists/string_list.c b/libretro-common/lists/string_list.c
index 400f75cdc0..293999529f 100644
--- a/libretro-common/lists/string_list.c
+++ b/libretro-common/lists/string_list.c
@@ -448,7 +448,7 @@ int string_list_find_elem(const struct string_list *list, const char *elem)
 {
    if (list)
    {
-      int i;
+      size_t i;
       for (i = 0; i < list->size; i++)
       {
          if (string_is_equal_noncase(list->elems[i].data, elem))
diff --git a/libretro-common/string/stdstring.c b/libretro-common/string/stdstring.c
index 20d7a45995..4b36deb77f 100644
--- a/libretro-common/string/stdstring.c
+++ b/libretro-common/string/stdstring.c
@@ -233,7 +233,7 @@ void word_wrap(
 
    /* Early return if src string length is less
     * than line width */
-   if (src_len < line_width)
+   if (src_len < (size_t)line_width)
    {
       strlcpy(dst, src, dst_size);
       return;
diff --git a/menu/drivers/materialui.c b/menu/drivers/materialui.c
index 7404a914d4..1ec067aa56 100644
--- a/menu/drivers/materialui.c
+++ b/menu/drivers/materialui.c
@@ -468,9 +468,9 @@ typedef struct
    unsigned width;
    unsigned divider_width;
    unsigned selection_marker_width;
-   unsigned num_menu_tabs;
-   unsigned active_menu_tab_index;
-   unsigned last_active_menu_tab_index;
+   size_t   active_menu_tab_index;
+   size_t   last_active_menu_tab_index;
+   size_t   num_menu_tabs;
    materialui_nav_bar_action_tab_t back_tab;    /* unsigned alignment */
    materialui_nav_bar_action_tab_t resume_tab;  /* unsigned alignment */
    materialui_nav_bar_menu_tab_t menu_tabs[MUI_NAV_BAR_NUM_MENU_TABS_MAX]; /* unsigned alignment */
@@ -5295,9 +5295,9 @@ static size_t materialui_list_get_size(void *data, enum menu_list_type type)
       case MENU_LIST_PLAIN:
          return menu_entries_get_stack_size(0);
       case MENU_LIST_TABS:
-         if (!mui)
-            return 0;
-         return (size_t)mui->nav_bar.num_menu_tabs;
+         if (mui)
+            return mui->nav_bar.num_menu_tabs;
+         break;
       default:
          break;
    }
@@ -6058,12 +6058,12 @@ static void materialui_render_nav_bar_bottom(
       unsigned video_width, unsigned video_height,
       math_matrix_4x4 *mymat)
 {
-   int i;
+   size_t i;
    unsigned nav_bar_width           = video_width;
    unsigned nav_bar_height          = mui->nav_bar.width;
    int nav_bar_x                    = 0;
    int nav_bar_y                    = (int)video_height - (int)mui->nav_bar.width;
-   unsigned num_tabs                = mui->nav_bar.num_menu_tabs + MUI_NAV_BAR_NUM_ACTION_TABS;
+   size_t num_tabs                  = mui->nav_bar.num_menu_tabs + MUI_NAV_BAR_NUM_ACTION_TABS;
    float tab_width                  = (float)video_width / (float)num_tabs;
    unsigned tab_width_int           = (unsigned)(tab_width + 0.5f);
    unsigned selection_marker_width  = tab_width_int;
@@ -6183,12 +6183,12 @@ static void materialui_render_nav_bar_right(
       unsigned video_height,
       math_matrix_4x4 *mymat)
 {
-   int i;
+   size_t i;
    unsigned nav_bar_width           = mui->nav_bar.width;
    unsigned nav_bar_height          = video_height;
    int nav_bar_x                    = (int)video_width - (int)mui->nav_bar.width;
    int nav_bar_y                    = 0;
-   unsigned num_tabs                = mui->nav_bar.num_menu_tabs + MUI_NAV_BAR_NUM_ACTION_TABS;
+   size_t num_tabs                  = mui->nav_bar.num_menu_tabs + MUI_NAV_BAR_NUM_ACTION_TABS;
    float tab_height                 = (float)video_height / (float)num_tabs;
    unsigned tab_height_int          = (unsigned)(tab_height + 0.5f);
    unsigned selection_marker_width  = mui->nav_bar.selection_marker_width;
@@ -8404,7 +8404,7 @@ static void materialui_navigation_alphabet(void *data, size_t *unused)
 static void materialui_populate_nav_bar(
       materialui_handle_t *mui, const char *label, settings_t *settings)
 {
-   unsigned menu_tab_index          = 0;
+   size_t menu_tab_index            = 0;
    bool menu_content_show_playlists = 
       settings->bools.menu_content_show_playlists;
 
@@ -8546,14 +8546,16 @@ static void materialui_init_transition_animation(
       /* We're not changing menu levels here, so set
        * slide to match horizontal list 'movement'
        * direction */
-      if (mui->nav_bar.active_menu_tab_index < mui->nav_bar.last_active_menu_tab_index)
+      if (    mui->nav_bar.active_menu_tab_index 
+            < mui->nav_bar.last_active_menu_tab_index)
       {
          if (mui->nav_bar.menu_navigation_wrapped)
             mui->transition_x_offset = 1.0f;
          else
             mui->transition_x_offset = -1.0f;
       }
-      else if (mui->nav_bar.active_menu_tab_index > mui->nav_bar.last_active_menu_tab_index)
+      else if (mui->nav_bar.active_menu_tab_index 
+             > mui->nav_bar.last_active_menu_tab_index)
       {
          if (mui->nav_bar.menu_navigation_wrapped)
             mui->transition_x_offset = -1.0f;
@@ -9114,8 +9116,8 @@ static enum menu_action materialui_parse_menu_entry_action(
           *   there just aren't enough distinct inputs types
           *   to single out a rational Select/OK action
           *   when fullscreen thumbnails are shown) */
-         if ((action != MENU_ACTION_SELECT) &&
-             (action != MENU_ACTION_OK))
+         if (   (action != MENU_ACTION_SELECT)
+             && (action != MENU_ACTION_OK))
             return MENU_ACTION_NOOP;
       }
    }
@@ -9320,7 +9322,7 @@ static enum menu_action materialui_parse_menu_entry_action(
          if ((mui->nav_bar.location == MUI_NAV_BAR_LOCATION_HIDDEN) &&
              (materialui_list_get_size(mui, MENU_LIST_PLAIN) == 1))
          {
-            int i;
+            size_t i;
             unsigned main_menu_tab_index                 = 0;
             materialui_nav_bar_menu_tab_t *main_menu_tab = NULL;
 
@@ -9670,11 +9672,9 @@ static int materialui_list_push(void *data, void *userdata,
 static size_t materialui_list_get_selection(void *data)
 {
    materialui_handle_t *mui   = (materialui_handle_t*)data;
-
-   if (!mui)
-      return 0;
-
-   return (size_t)mui->nav_bar.active_menu_tab_index;
+   if (mui)
+      return mui->nav_bar.active_menu_tab_index;
+   return 0;
 }
 
 /* Pointer down event - used to:
@@ -10069,10 +10069,10 @@ static int materialui_pointer_up(void *userdata,
 
                /* Check if pointer location is within the
                 * bounds of the pointer item */
-               if ((x < entry_x) ||
-                   (x > (entry_x + node->entry_width)) ||
-                   (y < entry_y) ||
-                   (y > (entry_y + node->entry_height)))
+               if (   (x < entry_x)
+                   || (x > (entry_x + node->entry_width))
+                   || (y < entry_y)
+                   || (y > (entry_y + node->entry_height)))
                   break;
 
                /* Pointer input is valid - perform action */
diff --git a/menu/drivers/rgui.c b/menu/drivers/rgui.c
index a6fc3cd44d..d24c939127 100644
--- a/menu/drivers/rgui.c
+++ b/menu/drivers/rgui.c
@@ -4420,60 +4420,46 @@ static void rgui_render_messagebox(rgui_t *rgui, const char *message,
 static int rgui_osk_ptr_at_pos(void *data, int x, int y,
       unsigned width, unsigned height)
 {
-   size_t key_index;
-   unsigned osk_x, osk_y;
-   unsigned key_width;
-   unsigned key_height;
-   unsigned ptr_width;
-   unsigned ptr_height;
-   unsigned keyboard_width;
-   unsigned keyboard_height;
-   unsigned keyboard_offset_y;
-   unsigned osk_width;
-   unsigned osk_height;
-   unsigned fb_width, fb_height;
-   unsigned key_text_offset_x  = 8;
-   unsigned key_text_offset_y  = 6;
-   unsigned ptr_offset_x       = 2;
-   unsigned ptr_offset_y       = 2;
-   unsigned keyboard_offset_x  = 10;
    /* This is a lazy copy/paste from rgui_render_osk(),
     * but it will do for now... */
    rgui_t *rgui                = (rgui_t*)data;
-   gfx_display_t *p_disp       = NULL;
 
-   if (!rgui)
-      return -1;
-   p_disp                      = disp_get_ptr();
-
-   key_width                   = rgui->font_width  + (key_text_offset_x * 2);
-   key_height                  = rgui->font_height + (key_text_offset_y * 2);
-   ptr_width                   = key_width  - (ptr_offset_x * 2);
-   ptr_height                  = key_height - (ptr_offset_y * 2);
-   keyboard_width              = key_width  * OSK_CHARS_PER_LINE;
-   keyboard_height             = key_height * 4;
-   keyboard_offset_y           = 10 + 15 + (2 * rgui->font_height_stride);
-   osk_width                   = keyboard_width + 20;
-   osk_height                  = keyboard_offset_y + keyboard_height + 10;
-
-   /* Get dimensions/layout */
-   fb_width                    = p_disp->framebuf_width;
-   fb_height                   = p_disp->framebuf_height;
-
-   osk_x                       = (fb_width  - osk_width)  / 2;
-   osk_y                       = (fb_height - osk_height) / 2;
-
-   for (key_index = 0; key_index < 44; key_index++)
+   if (rgui)
    {
-      unsigned key_row         = (unsigned)(key_index / OSK_CHARS_PER_LINE);
-      unsigned key_column      = (unsigned)(key_index - (key_row * OSK_CHARS_PER_LINE));
+      size_t key_index;
+      const unsigned key_text_offset_x  = 8;
+      const unsigned key_text_offset_y  = 6;
+      const unsigned ptr_offset_x       = 2;
+      const unsigned ptr_offset_y       = 2;
+      const unsigned keyboard_offset_x  = 10;
+      gfx_display_t *p_disp       = disp_get_ptr();
+      unsigned key_width          = rgui->font_width  +(key_text_offset_x * 2);
+      unsigned key_height         = rgui->font_height +(key_text_offset_y * 2);
+      unsigned ptr_width          = key_width  - (ptr_offset_x * 2);
+      unsigned ptr_height         = key_height - (ptr_offset_y * 2);
+      unsigned keyboard_width     = key_width  * OSK_CHARS_PER_LINE;
+      unsigned keyboard_height    = key_height * 4;
+      unsigned keyboard_offset_y  = 10 + 15 + (2 * rgui->font_height_stride);
+      unsigned osk_width          = keyboard_width + 20;
+      unsigned osk_height         = keyboard_offset_y + keyboard_height + 10;
+      /* Get dimensions/layout */
+      unsigned fb_width           = p_disp->framebuf_width;
+      unsigned fb_height          = p_disp->framebuf_height;
+      unsigned osk_x              = (fb_width  - osk_width)  / 2;
+      unsigned osk_y              = (fb_height - osk_height) / 2;
 
-      unsigned osk_ptr_x       = osk_x + keyboard_offset_x + ptr_offset_x + (key_column * key_width);
-      unsigned osk_ptr_y       = osk_y + keyboard_offset_y + ptr_offset_y + (key_row    * key_height);
+      for (key_index = 0; key_index < 44; key_index++)
+      {
+         unsigned key_row         = (unsigned)(key_index / OSK_CHARS_PER_LINE);
+         unsigned key_column      = (unsigned)(key_index - (key_row * OSK_CHARS_PER_LINE));
 
-      if (x > osk_ptr_x && x < osk_ptr_x + ptr_width &&
-          y > osk_ptr_y && y < osk_ptr_y + ptr_height)
-         return (int)key_index;
+         unsigned osk_ptr_x       = osk_x + keyboard_offset_x + ptr_offset_x + (key_column * key_width);
+         unsigned osk_ptr_y       = osk_y + keyboard_offset_y + ptr_offset_y + (key_row    * key_height);
+
+         if (  x > osk_ptr_x && x < osk_ptr_x + ptr_width &&
+               y > osk_ptr_y && y < osk_ptr_y + ptr_height)
+            return (int)key_index;
+      }
    }
 
    return -1;