Turn iteration variables from unsigned to size_t or int

This commit is contained in:
libretroadmin 2025-08-06 08:04:11 +02:00
parent fe5ea7ad45
commit 9b6ddfb727
8 changed files with 34 additions and 45 deletions

View File

@ -5192,8 +5192,7 @@ const char *input_config_get_prefix(unsigned user, bool meta)
*/ */
static void input_config_save_keybinds_user(config_file_t *conf, unsigned user) static void input_config_save_keybinds_user(config_file_t *conf, unsigned user)
{ {
unsigned i = 0; size_t i = 0;
for (i = 0; input_config_bind_map_get_valid(i); i++) for (i = 0; input_config_bind_map_get_valid(i); i++)
{ {
char key[64]; char key[64];
@ -5236,7 +5235,7 @@ static void input_config_save_keybinds_user_override(config_file_t *conf,
unsigned user, unsigned bind_id, unsigned user, unsigned bind_id,
const struct retro_keybind *override_bind) const struct retro_keybind *override_bind)
{ {
unsigned i = bind_id; size_t i = bind_id;
if (input_config_bind_map_get_valid(i)) if (input_config_bind_map_get_valid(i))
{ {
@ -6613,7 +6612,7 @@ uint8_t input_config_bind_map_get_retro_key(unsigned bind_index)
void input_config_reset_autoconfig_binds(unsigned port) void input_config_reset_autoconfig_binds(unsigned port)
{ {
unsigned i; size_t i;
if (port >= MAX_USERS) if (port >= MAX_USERS)
return; return;
@ -6639,7 +6638,7 @@ void input_config_reset_autoconfig_binds(unsigned port)
void input_config_set_autoconfig_binds(unsigned port, void *data) void input_config_set_autoconfig_binds(unsigned port, void *data)
{ {
unsigned i; size_t i;
config_file_t *config = (config_file_t*)data; config_file_t *config = (config_file_t*)data;
struct retro_keybind *binds = NULL; struct retro_keybind *binds = NULL;
@ -6737,8 +6736,8 @@ void input_config_parse_joy_axis(
void *conf_data, const char *prefix, void *conf_data, const char *prefix,
const char *axis, void *bind_data) const char *axis, void *bind_data)
{ {
char tmp[64]; char tmp[64];
char key[64]; char key[64];
config_file_t *conf = (config_file_t*)conf_data; config_file_t *conf = (config_file_t*)conf_data;
struct retro_keybind *bind = (struct retro_keybind*)bind_data; struct retro_keybind *bind = (struct retro_keybind*)bind_data;
struct config_entry_list *tmp_a = NULL; struct config_entry_list *tmp_a = NULL;
@ -6833,8 +6832,7 @@ void input_config_parse_joy_button(
tmp[0] = '\0'; tmp[0] = '\0';
fill_pathname_join_delim(key, s, fill_pathname_join_delim(key, s, "btn", '_', sizeof(key));
"btn", '_', sizeof(key));
if (config_get_array(conf, key, tmp, sizeof(tmp))) if (config_get_array(conf, key, tmp, sizeof(tmp)))
{ {

View File

@ -504,7 +504,7 @@ char *bin_to_hex_alloc(const uint8_t *data, size_t len)
static int database_cursor_iterate(libretrodb_cursor_t *cur, static int database_cursor_iterate(libretrodb_cursor_t *cur,
database_info_t *db_info) database_info_t *db_info)
{ {
unsigned i; size_t i;
struct rmsgpack_dom_value item; struct rmsgpack_dom_value item;
const char* str = NULL; const char* str = NULL;

View File

@ -2578,7 +2578,6 @@ static size_t playlist_get_old_format_metadata_value(
static bool playlist_read_file(playlist_t *playlist) static bool playlist_read_file(playlist_t *playlist)
{ {
unsigned i;
int test_char; int test_char;
bool res = true; bool res = true;
#if defined(HAVE_ZLIB) #if defined(HAVE_ZLIB)
@ -2673,6 +2672,7 @@ static bool playlist_read_file(playlist_t *playlist)
} }
else else
{ {
size_t i;
size_t _len = RBUF_LEN(playlist->entries); size_t _len = RBUF_LEN(playlist->entries);
char line_buf[PLAYLIST_ENTRIES][PATH_MAX_LENGTH] = {{0}}; char line_buf[PLAYLIST_ENTRIES][PATH_MAX_LENGTH] = {{0}};
@ -2914,7 +2914,7 @@ bool playlist_init_cached(const playlist_config_t *config)
**/ **/
playlist_t *playlist_init(const playlist_config_t *config) playlist_t *playlist_init(const playlist_config_t *config)
{ {
playlist_t *playlist = (playlist_t*)malloc(sizeof(*playlist)); playlist_t *playlist = (playlist_t*)malloc(sizeof(*playlist));
if (!playlist) if (!playlist)
return NULL; return NULL;
@ -3116,7 +3116,6 @@ static int playlist_qsort_func(const struct playlist_entry *a,
ret = strcasecmp(a_str, b_str); ret = strcasecmp(a_str, b_str);
end: end:
a_str = NULL; a_str = NULL;
b_str = NULL; b_str = NULL;

View File

@ -576,8 +576,7 @@ midi_driver_t *midi_drivers[] = {
static midi_driver_t *midi_driver_find_driver(const char *ident) static midi_driver_t *midi_driver_find_driver(const char *ident)
{ {
unsigned i; size_t i;
for (i = 0; i < ARRAY_SIZE(midi_drivers); ++i) for (i = 0; i < ARRAY_SIZE(midi_drivers); ++i)
{ {
if (string_is_equal(midi_drivers[i]->ident, ident)) if (string_is_equal(midi_drivers[i]->ident, ident))
@ -1230,7 +1229,7 @@ static size_t find_driver_nonempty(
int driver_find_index(const char *label, const char *drv) int driver_find_index(const char *label, const char *drv)
{ {
unsigned i; size_t i;
char str[NAME_MAX_LENGTH]; char str[NAME_MAX_LENGTH];
str[0] = '\0'; str[0] = '\0';
@ -1257,16 +1256,13 @@ int driver_find_index(const char *label, const char *drv)
**/ **/
static void driver_find_last(const char *label, char *s, size_t len) static void driver_find_last(const char *label, char *s, size_t len)
{ {
unsigned i; size_t i;
for (i = 0; for (i = 0;
find_driver_nonempty(label, i, s, len) > 0; i++) { } find_driver_nonempty(label, i, s, len) > 0; i++) { }
if (i) if (i)
i = i - 1; i = i - 1;
else else
i = 0; i = 0;
find_driver_nonempty(label, i, s, len); find_driver_nonempty(label, i, s, len);
} }
@ -5228,8 +5224,7 @@ bool command_event(enum event_command cmd, void *data)
break; break;
case CMD_EVENT_RUMBLE_STOP: case CMD_EVENT_RUMBLE_STOP:
{ {
unsigned i; size_t i;
for (i = 0; i < MAX_USERS; i++) for (i = 0; i < MAX_USERS; i++)
{ {
unsigned joy_idx = settings->uints.input_joypad_index[i]; unsigned joy_idx = settings->uints.input_joypad_index[i];
@ -5722,12 +5717,12 @@ void retroarch_override_setting_unset(
static void retroarch_override_setting_free_state(void) static void retroarch_override_setting_free_state(void)
{ {
unsigned i; size_t i;
for (i = 0; i < RARCH_OVERRIDE_SETTING_LAST; i++) for (i = 0; i < RARCH_OVERRIDE_SETTING_LAST; i++)
{ {
if (i == RARCH_OVERRIDE_SETTING_LIBRETRO_DEVICE) if (i == RARCH_OVERRIDE_SETTING_LIBRETRO_DEVICE)
{ {
unsigned j; size_t j;
for (j = 0; j < MAX_USERS; j++) for (j = 0; j < MAX_USERS; j++)
retroarch_override_setting_unset( retroarch_override_setting_unset(
RARCH_OVERRIDE_SETTING_LIBRETRO_DEVICE, &j); RARCH_OVERRIDE_SETTING_LIBRETRO_DEVICE, &j);
@ -6174,7 +6169,7 @@ const struct retro_subsystem_info *libretro_find_subsystem_info(
const struct retro_subsystem_info *info, unsigned num_info, const struct retro_subsystem_info *info, unsigned num_info,
const char *ident) const char *ident)
{ {
unsigned i; size_t i;
for (i = 0; i < num_info; i++) for (i = 0; i < num_info; i++)
{ {
if ( string_is_equal(info[i].ident, ident) if ( string_is_equal(info[i].ident, ident)
@ -6203,16 +6198,12 @@ const struct retro_controller_description *
libretro_find_controller_description( libretro_find_controller_description(
const struct retro_controller_info *info, unsigned id) const struct retro_controller_info *info, unsigned id)
{ {
unsigned i; size_t i;
for (i = 0; i < info->num_types; i++) for (i = 0; i < info->num_types; i++)
{ {
if (info->types[i].id != id) if (info->types[i].id == id)
continue; return &info->types[i];
return &info->types[i];
} }
return NULL; return NULL;
} }
@ -8667,7 +8658,7 @@ bool retroarch_main_quit(void)
enum retro_language retroarch_get_language_from_iso(const char *iso639) enum retro_language retroarch_get_language_from_iso(const char *iso639)
{ {
unsigned i; size_t i;
enum retro_language lang = RETRO_LANGUAGE_ENGLISH; enum retro_language lang = RETRO_LANGUAGE_ENGLISH;
struct lang_pair struct lang_pair

View File

@ -765,7 +765,7 @@ static void runahead_input_state_set_last(
unsigned port, unsigned device, unsigned port, unsigned device,
unsigned index, unsigned id, int16_t value) unsigned index, unsigned id, int16_t value)
{ {
unsigned i; size_t i;
input_list_element *element = NULL; input_list_element *element = NULL;
if (!runloop_st->input_state_list) if (!runloop_st->input_state_list)

View File

@ -2747,7 +2747,7 @@ bool runloop_environment_cb(unsigned cmd, void *data)
case RETRO_ENVIRONMENT_SET_SUBSYSTEM_INFO: case RETRO_ENVIRONMENT_SET_SUBSYSTEM_INFO:
{ {
unsigned i; size_t i;
const struct retro_subsystem_info *info = const struct retro_subsystem_info *info =
(const struct retro_subsystem_info*)data; (const struct retro_subsystem_info*)data;
unsigned log_level = settings->uints.libretro_log_level; unsigned log_level = settings->uints.libretro_log_level;
@ -2801,7 +2801,7 @@ bool runloop_environment_cb(unsigned cmd, void *data)
case RETRO_ENVIRONMENT_SET_CONTROLLER_INFO: case RETRO_ENVIRONMENT_SET_CONTROLLER_INFO:
{ {
unsigned i, j; size_t i, j;
const struct retro_controller_info *info const struct retro_controller_info *info
= (const struct retro_controller_info*)data; = (const struct retro_controller_info*)data;
unsigned log_level = settings->uints.libretro_log_level; unsigned log_level = settings->uints.libretro_log_level;
@ -2846,7 +2846,7 @@ bool runloop_environment_cb(unsigned cmd, void *data)
{ {
if (sys_info) if (sys_info)
{ {
unsigned i; size_t i;
const struct retro_memory_map *mmaps = const struct retro_memory_map *mmaps =
(const struct retro_memory_map*)data; (const struct retro_memory_map*)data;
rarch_memory_descriptor_t *descriptors = NULL; rarch_memory_descriptor_t *descriptors = NULL;
@ -4133,7 +4133,7 @@ void runloop_event_deinit_core(void)
static bool runloop_path_init_subsystem(runloop_state_t *runloop_st) static bool runloop_path_init_subsystem(runloop_state_t *runloop_st)
{ {
unsigned i, j; size_t i, j;
const struct retro_subsystem_info *info = NULL; const struct retro_subsystem_info *info = NULL;
rarch_system_info_t *sys_info = &runloop_st->system; rarch_system_info_t *sys_info = &runloop_st->system;
bool subsystem_path_empty = path_is_empty(RARCH_PATH_SUBSYSTEM); bool subsystem_path_empty = path_is_empty(RARCH_PATH_SUBSYSTEM);
@ -8288,7 +8288,7 @@ void runloop_path_deinit_subsystem(void)
void runloop_path_set_special(char **argv, unsigned num_content) void runloop_path_set_special(char **argv, unsigned num_content)
{ {
unsigned i; size_t i;
char str[PATH_MAX_LENGTH]; char str[PATH_MAX_LENGTH];
union string_list_elem_attr attr; union string_list_elem_attr attr;
bool is_dir = false; bool is_dir = false;

View File

@ -1396,7 +1396,7 @@ static void content_load_init_wrap(
static bool content_load(content_ctx_info_t *info, static bool content_load(content_ctx_info_t *info,
content_state_t *p_content) content_state_t *p_content)
{ {
unsigned i; size_t i;
bool success = false; bool success = false;
int rarch_argc = 0; int rarch_argc = 0;
char *rarch_argv[MAX_ARGS] = {NULL}; char *rarch_argv[MAX_ARGS] = {NULL};
@ -2777,7 +2777,7 @@ uint8_t content_get_flags(void)
/* Clears the pending subsystem rom buffer*/ /* Clears the pending subsystem rom buffer*/
void content_clear_subsystem(void) void content_clear_subsystem(void)
{ {
unsigned i; size_t i;
content_state_t *p_content = content_state_get_ptr(); content_state_t *p_content = content_state_get_ptr();
p_content->pending_subsystem_rom_id = 0; p_content->pending_subsystem_rom_id = 0;
@ -2828,7 +2828,7 @@ void content_set_subsystem(unsigned idx)
/* Sets the subsystem by name */ /* Sets the subsystem by name */
bool content_set_subsystem_by_name(const char* subsystem_name) bool content_set_subsystem_by_name(const char* subsystem_name)
{ {
unsigned i; size_t i;
runloop_state_t *runloop_st = runloop_state_get_ptr(); runloop_state_t *runloop_st = runloop_state_get_ptr();
rarch_system_info_t *sys_info = &runloop_st->system; rarch_system_info_t *sys_info = &runloop_st->system;
/* Core not loaded completely, use the data we peeked on load core */ /* Core not loaded completely, use the data we peeked on load core */
@ -2853,7 +2853,7 @@ bool content_set_subsystem_by_name(const char* subsystem_name)
size_t content_get_subsystem_friendly_name(const char* subsystem_name, char *s, size_t len) size_t content_get_subsystem_friendly_name(const char* subsystem_name, char *s, size_t len)
{ {
unsigned i; size_t i;
runloop_state_t *runloop_st = runloop_state_get_ptr(); runloop_state_t *runloop_st = runloop_state_get_ptr();
rarch_system_info_t *sys_info = &runloop_st->system; rarch_system_info_t *sys_info = &runloop_st->system;
/* Core not loaded completely, use the data we peeked on load core */ /* Core not loaded completely, use the data we peeked on load core */
@ -2918,7 +2918,7 @@ void content_unset_does_not_need_content(void)
*/ */
static uint32_t file_crc32(uint32_t crc, const char *path) static uint32_t file_crc32(uint32_t crc, const char *path)
{ {
unsigned i; size_t i;
RFILE *file = NULL; RFILE *file = NULL;
unsigned char *buf = NULL; unsigned char *buf = NULL;
if (!path) if (!path)

View File

@ -333,7 +333,8 @@ void RARCH_LOG_V(const char *tag, const char *fmt, va_list ap)
void RARCH_LOG_BUFFER(uint8_t *data, size_t len) void RARCH_LOG_BUFFER(uint8_t *data, size_t len)
{ {
unsigned i, offset; size_t i;
size_t offset;
int padding = len % 16; int padding = len % 16;
uint8_t buf[16] = {0}; uint8_t buf[16] = {0};