From afd73998e6a0353e79d0b1a85c6e13150d228367 Mon Sep 17 00:00:00 2001 From: LibretroAdmin Date: Sun, 9 Feb 2025 20:33:04 +0100 Subject: [PATCH] Silence warnings --- ai/game_ai.c | 76 +++++++++++++++++++-------------------- ai/game_ai.h | 47 ++++++++++++++++++++---- menu/drivers/materialui.c | 4 +-- menu/drivers/ozone.c | 9 +++-- menu/drivers/rgui.c | 4 +-- menu/drivers/xmb.c | 4 +-- menu/menu_displaylist.c | 2 -- menu/menu_driver.c | 4 +-- runahead.c | 4 +-- 9 files changed, 91 insertions(+), 63 deletions(-) diff --git a/ai/game_ai.c b/ai/game_ai.c index e8f01968a9..6a029a8d4d 100644 --- a/ai/game_ai.c +++ b/ai/game_ai.c @@ -11,6 +11,7 @@ #endif #include +#include #include "../deps/game_ai_lib/GameAI.h" @@ -51,65 +52,60 @@ void game_ai_debug_log(int level, const char *fmt, ...) va_end(vp); } -void array_to_bits_16(volatile signed short * result, const bool b[16]) +void array_to_bits_16(volatile signed short *result, const bool b[16]) { for (int bit = 0; bit <= 15; bit++) - { *result |= b[bit] ? (1 << bit) : 0; - } } /* Interface to RA */ -extern signed short int game_ai_input(unsigned int port, unsigned int device, unsigned int idx, unsigned int id, signed short int result) +signed short int game_ai_input(unsigned int port, unsigned int device, + unsigned int idx, unsigned int id, signed short int result) { - if (ga == NULL) - return 0; - - if (port < GAME_AI_MAX_PLAYERS) + if (ga && (port < GAME_AI_MAX_PLAYERS)) return g_buttons_bits[port]; - return 0; } -extern void game_ai_init() +void game_ai_init(void) { - if (create_game_ai == NULL) + if (!create_game_ai) { #ifdef _WIN32 - BOOL fFreeResult, fRunTimeLinkSuccess = FALSE; + BOOL fFreeResult, fRunTimeLinkSuccess = FALSE; - g_lib_handle = LoadLibrary(TEXT("game_ai.dll")); - retro_assert(hinstLib); + g_lib_handle = LoadLibrary(TEXT("game_ai.dll")); + retro_assert(hinstLib); - char full_module_path[MAX_PATH]; - DWORD dwLen = GetModuleFileNameA(g_lib_handle, static_cast(&full_module_path), MAX_PATH); + char full_module_path[MAX_PATH]; + DWORD dwLen = GetModuleFileNameA(g_lib_handle, static_cast(&full_module_path), MAX_PATH); - if (hinstLib != NULL) - { - create_game_ai = (create_game_ai_t) GetProcAddress(hinstLib, "create_game_ai"); - retro_assert(create_game_ai); + if (hinstLib) + { + create_game_ai = (create_game_ai_t) GetProcAddress(hinstLib, "create_game_ai"); + retro_assert(create_game_ai); - destroy_game_ai = (destroy_game_ai_t) GetProcAddress(hinstLib, "destroy_game_ai"); - retro_assert(destroy_game_ai); + destroy_game_ai = (destroy_game_ai_t) GetProcAddress(hinstLib, "destroy_game_ai"); + retro_assert(destroy_game_ai); - game_ai_lib_init = (game_ai_lib_init_t) GetProcAddress(hinstLib, "game_ai_lib_init"); - retro_assert(game_ai_lib_init); + game_ai_lib_init = (game_ai_lib_init_t) GetProcAddress(hinstLib, "game_ai_lib_init"); + retro_assert(game_ai_lib_init); - game_ai_lib_think = (game_ai_lib_think_t) GetProcAddress(hinstLib, "game_ai_lib_think"); - retro_assert(game_ai_lib_think); + game_ai_lib_think = (game_ai_lib_think_t) GetProcAddress(hinstLib, "game_ai_lib_think"); + retro_assert(game_ai_lib_think); - game_ai_lib_set_show_debug = (game_ai_lib_set_show_debug_t) GetProcAddress(hinstLib, "game_ai_lib_set_show_debug"); - retro_assert(game_ai_lib_set_show_debug); + game_ai_lib_set_show_debug = (game_ai_lib_set_show_debug_t) GetProcAddress(hinstLib, "game_ai_lib_set_show_debug"); + retro_assert(game_ai_lib_set_show_debug); - game_ai_lib_set_debug_log = (game_ai_lib_set_debug_log_t) GetProcAddress(hinstLib, "game_ai_lib_set_debug_log"); - retro_assert(game_ai_lib_set_debug_log); - } + game_ai_lib_set_debug_log = (game_ai_lib_set_debug_log_t) GetProcAddress(hinstLib, "game_ai_lib_set_debug_log"); + retro_assert(game_ai_lib_set_debug_log); + } #else g_lib_handle = dlopen("./libgame_ai.so", RTLD_NOW); retro_assert(g_lib_handle); - if(g_lib_handle != NULL) + if (g_lib_handle) { dlinfo(g_lib_handle, RTLD_DI_ORIGIN, (void *) &game_ai_lib_path); @@ -135,7 +131,7 @@ extern void game_ai_init() } } -extern void game_ai_shutdown() +void game_ai_shutdown(void) { if (g_lib_handle) { @@ -152,14 +148,14 @@ extern void game_ai_shutdown() } } -extern void game_ai_load(const char * name, void * ram_ptr, int ram_size, retro_log_printf_t log) +void game_ai_load(const char * name, void * ram_ptr, int ram_size, retro_log_printf_t log) { strcpy((char *) &g_game_name[0], name); - g_ram_ptr = ram_ptr; + g_ram_ptr = ram_ptr; g_ram_size = ram_size; - g_log = log; + g_log = log; if (ga) { @@ -168,12 +164,14 @@ extern void game_ai_load(const char * name, void * ram_ptr, int ram_size, retro_ } } -extern void game_ai_think(bool override_p1, bool override_p2, bool show_debug, const void *frame_data, unsigned int frame_width, unsigned int frame_height, unsigned int frame_pitch, unsigned int pixel_format) +void game_ai_think(bool override_p1, bool override_p2, bool show_debug, + const void *frame_data, unsigned int frame_width, unsigned int frame_height, + unsigned int frame_pitch, unsigned int pixel_format) { if (ga) game_ai_lib_set_show_debug(ga, show_debug); - if (ga == NULL && g_ram_ptr != NULL) + if (!ga && g_ram_ptr) { ga = create_game_ai((char *) &g_game_name[0]); retro_assert(ga); @@ -214,7 +212,5 @@ extern void game_ai_think(bool override_p1, bool override_p2, bool show_debug, c g_frameCount=0; } else - { g_frameCount++; - } } diff --git a/ai/game_ai.h b/ai/game_ai.h index 53f39530f4..725e8f77be 100644 --- a/ai/game_ai.h +++ b/ai/game_ai.h @@ -1,9 +1,44 @@ -#pragma once +/* RetroArch - A frontend for libretro. + * Copyright (C) 2010-2014 - Hans-Kristian Arntzen + * Copyright (C) 2011-2016 - Daniel De Matteis + * Copyright (C) 2021 - David G.F. + * + * RetroArch is free software: you can redistribute it and/or modify it under the terms + * of the GNU General Public License as published by the Free Software Found- + * ation, either version 3 of the License, or (at your option) any later version. + * + * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with RetroArch. + * If not, see . + */ + +#ifndef RARCH_GAME_AI_H__ +#define RARCH_GAME_AI_H__ + +#include +#include #include -signed short int game_ai_input(unsigned int port, unsigned int device, unsigned int idx, unsigned int id, signed short int result); -void game_ai_init(); -void game_ai_shutdown(); -void game_ai_load(const char * name, void * ram_ptr, int ram_size, retro_log_printf_t log); -void game_ai_think(bool override_p1, bool override_p2, bool show_debug, const void *frame_data, unsigned int frame_width, unsigned int frame_height, unsigned int frame_pitch, unsigned int pixel_format); \ No newline at end of file +RETRO_BEGIN_DECLS + +signed short int game_ai_input(unsigned int port, unsigned int device, + unsigned int idx, unsigned int id, signed short int result); + +void game_ai_init(void); + +void game_ai_shutdown(void); + +void game_ai_load(const char * name, void * ram_ptr, + int ram_size, retro_log_printf_t log); + +void game_ai_think(bool override_p1, bool override_p2, bool show_debug, + const void *frame_data, unsigned int frame_w, unsigned int frame_h, + unsigned int frame_pitch, unsigned int pixel_format); + +RETRO_END_DECLS + +#endif diff --git a/menu/drivers/materialui.c b/menu/drivers/materialui.c index 992c795902..c068d1a3bb 100644 --- a/menu/drivers/materialui.c +++ b/menu/drivers/materialui.c @@ -9372,7 +9372,7 @@ static enum menu_action materialui_parse_menu_entry_action( struct menu_state *menu_st = menu_state_get_ptr(); size_t selection_total = menu_st->entries.list ? MENU_LIST_GET_SELECTION(menu_st->entries.list, 0)->size : 0; size_t selection = menu_st->selection_ptr; - size_t new_selection = random_range(0, selection_total - 1); + size_t new_selection = random_range(0, (unsigned)(selection_total - 1)); menu_entry_t entry_new; MENU_ENTRY_INITIALIZE(entry_new); @@ -9380,7 +9380,7 @@ static enum menu_action materialui_parse_menu_entry_action( /* Keep randomizing until selection is a fresh playlist */ while (new_selection == selection || entry_new.type != FILE_TYPE_PLAYLIST_COLLECTION) { - new_selection = random_range(0, selection_total - 1); + new_selection = random_range(0, (unsigned)(selection_total - 1)); menu_entry_get(&entry_new, 0, new_selection, NULL, false); } diff --git a/menu/drivers/ozone.c b/menu/drivers/ozone.c index ef4b4da4db..6e5c23288b 100644 --- a/menu/drivers/ozone.c +++ b/menu/drivers/ozone.c @@ -8154,9 +8154,9 @@ static enum menu_action ozone_parse_menu_entry_action( ? ozone_get_onscreen_category_selection(ozone) : ozone->categories_selection_ptr; - new_selection = random_range(ozone->system_tab_end + 1, ozone->system_tab_end + horizontal_list_size); + new_selection = random_range(ozone->system_tab_end + 1, (unsigned)(ozone->system_tab_end + horizontal_list_size)); while (new_selection == (int)tab_selection) - new_selection = random_range(ozone->system_tab_end + 1, ozone->system_tab_end + horizontal_list_size); + new_selection = random_range(ozone->system_tab_end + 1, (unsigned)(ozone->system_tab_end + horizontal_list_size)); if (new_selection != (int)tab_selection) ozone_sidebar_goto(ozone, new_selection); @@ -8175,7 +8175,7 @@ static enum menu_action ozone_parse_menu_entry_action( struct menu_state *menu_st = menu_state_get_ptr(); size_t selection_total = menu_st->entries.list ? MENU_LIST_GET_SELECTION(menu_st->entries.list, 0)->size : 0; size_t selection = menu_st->selection_ptr; - size_t new_selection = random_range(0, selection_total - 1); + size_t new_selection = random_range(0, (unsigned)(selection_total - 1)); menu_entry_t entry_new; MENU_ENTRY_INITIALIZE(entry_new); @@ -8183,7 +8183,7 @@ static enum menu_action ozone_parse_menu_entry_action( /* Keep randomizing until selection is a fresh playlist */ while (new_selection == selection || entry_new.type != FILE_TYPE_PLAYLIST_COLLECTION) { - new_selection = random_range(0, selection_total - 1); + new_selection = random_range(0, (unsigned)(selection_total - 1)); menu_entry_get(&entry_new, 0, new_selection, NULL, false); } @@ -11654,7 +11654,6 @@ static void ozone_frame(void *data, video_frame_info_t *video_info) bool video_fullscreen = video_info->fullscreen; bool mouse_grabbed = video_info->input_driver_grab_mouse_state; bool menu_mouse_enable = video_info->menu_mouse_enable; - bool input_menu_swap_ok_cancel_buttons = video_info->input_menu_swap_ok_cancel_buttons; bool battery_level_enable = video_info->battery_level_enable; bool timedate_enable = video_info->timedate_enable; gfx_display_t *p_disp = (gfx_display_t*)video_info->disp_userdata; diff --git a/menu/drivers/rgui.c b/menu/drivers/rgui.c index 0236ba0b26..9b5731c918 100644 --- a/menu/drivers/rgui.c +++ b/menu/drivers/rgui.c @@ -8114,7 +8114,7 @@ static enum menu_action rgui_parse_menu_entry_action( { size_t selection_total = menu_st->entries.list ? MENU_LIST_GET_SELECTION(menu_st->entries.list, 0)->size : 0; size_t selection = menu_st->selection_ptr; - size_t new_selection = random_range(0, selection_total - 1); + size_t new_selection = random_range(0, (unsigned)(selection_total - 1)); menu_entry_t entry_new; MENU_ENTRY_INITIALIZE(entry_new); @@ -8122,7 +8122,7 @@ static enum menu_action rgui_parse_menu_entry_action( /* Keep randomizing until selection is a fresh playlist */ while (new_selection == selection || entry_new.type != FILE_TYPE_PLAYLIST_COLLECTION) { - new_selection = random_range(0, selection_total - 1); + new_selection = random_range(0, (unsigned)(selection_total - 1)); menu_entry_get(&entry_new, 0, new_selection, NULL, false); } diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 317dea7044..6a0c113cc5 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -5562,7 +5562,7 @@ static enum menu_action xmb_parse_menu_entry_action( struct menu_state *menu_st = menu_state_get_ptr(); size_t selection_total = menu_st->entries.list ? MENU_LIST_GET_SELECTION(menu_st->entries.list, 0)->size : 0; size_t selection = menu_st->selection_ptr; - size_t new_selection = random_range(0, selection_total - 1); + size_t new_selection = random_range(0, (unsigned)(selection_total - 1)); menu_entry_t entry_new; MENU_ENTRY_INITIALIZE(entry_new); @@ -5570,7 +5570,7 @@ static enum menu_action xmb_parse_menu_entry_action( /* Keep randomizing until selection is a fresh playlist */ while (new_selection == selection || entry_new.type != FILE_TYPE_PLAYLIST_COLLECTION) { - new_selection = random_range(0, selection_total - 1); + new_selection = random_range(0, (unsigned)(selection_total - 1)); menu_entry_get(&entry_new, 0, new_selection, NULL, false); } diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index fde2e6eefc..82f0a494f5 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -7914,9 +7914,7 @@ unsigned menu_displaylist_build_list( case DISPLAYLIST_LOAD_CONTENT_LIST: case DISPLAYLIST_LOAD_CONTENT_SPECIAL: { - const char *menu_ident = menu_driver_ident(); core_info_list_t *info_list = NULL; - core_info_get_list(&info_list); if (!string_is_empty(settings->paths.directory_menu_content)) diff --git a/menu/menu_driver.c b/menu/menu_driver.c index b5bf94534e..5e6782d5a8 100644 --- a/menu/menu_driver.c +++ b/menu/menu_driver.c @@ -8129,10 +8129,10 @@ size_t menu_playlist_random_selection(size_t selection, bool is_explore_list) selection_start = 2; } - new_selection = random_range(selection_start, selection_total - 1); + new_selection = random_range(selection_start, (unsigned)(selection_total - 1)); while (new_selection == selection && selection_start != selection_total - 1) - new_selection = random_range(selection_start, selection_total - 1); + new_selection = random_range(selection_start, (unsigned)(selection_total - 1)); return new_selection; } diff --git a/runahead.c b/runahead.c index f072d2b638..7d9ff3a12d 100644 --- a/runahead.c +++ b/runahead.c @@ -1562,8 +1562,8 @@ static INLINE void preempt_input_poll(preempt_t *preempt, for (p = 0; p < max_users; p++) { /* Check full digital joypad */ - joypad_state = state_cb(p, RETRO_DEVICE_JOYPAD, - 0, RETRO_DEVICE_ID_JOYPAD_MASK); + joypad_state = (int16_t)(state_cb(p, RETRO_DEVICE_JOYPAD, + 0, RETRO_DEVICE_ID_JOYPAD_MASK)); if (joypad_state != preempt->joypad_state[p]) { preempt->joypad_state[p] = joypad_state;