diff --git a/cheevos/cheevos.c b/cheevos/cheevos.c index f9b605fa43..18457e45d4 100644 --- a/cheevos/cheevos.c +++ b/cheevos/cheevos.c @@ -568,7 +568,7 @@ int rcheevos_get_richpresence(char *s, size_t len) if (rcheevos_is_player_active()) { int ret = rc_runtime_get_richpresence( - &rcheevos_locals.runtime, s, len, + &rcheevos_locals.runtime, s, (unsigned)len, &rcheevos_peek, NULL, NULL); if (ret <= 0 && rcheevos_locals.game.title) @@ -583,7 +583,7 @@ int rcheevos_get_richpresence(char *s, size_t len) { /* TODO/FIXME - localize */ strlcpy(s, "Spectating ", len); - return strlcat(s, rcheevos_locals.game.title, len); + return (int)strlcat(s, rcheevos_locals.game.title, len); } return 0; } diff --git a/command.c b/command.c index 9bccb3684a..93cc3cb8e1 100644 --- a/command.c +++ b/command.c @@ -652,7 +652,7 @@ bool command_read_ram(command_t *cmd, const char *arg) unsigned int nbytes = 0; unsigned int alloc_size = 0; unsigned int addr = -1; - unsigned int len = 0; + size_t len = 0; if (sscanf(arg, "%x %u", &addr, &nbytes) != 2) return true; @@ -786,7 +786,7 @@ uint8_t *command_memory_get_pointer( strlcpy(reply_at, " -1 descriptor data is readonly\n", len); else { - *max_bytes = (desc->core.len - offset); + *max_bytes = (unsigned int)(desc->core.len - offset); return (uint8_t*)desc->core.ptr + desc->core.offset + offset; } } diff --git a/gfx/gfx_animation.c b/gfx/gfx_animation.c index a57d55e465..4a1589ce2e 100644 --- a/gfx/gfx_animation.c +++ b/gfx/gfx_animation.c @@ -443,13 +443,13 @@ static void ticker_smooth_scan_string_fw( * string once offset has been subtracted */ if (*char_offset < num_chars) { - unsigned chars_remaining = num_chars - *char_offset; + size_t chars_remaining = num_chars - *char_offset; /* Determine number of characters to copy */ if ((chars_remaining > 0) && (field_width > *x_offset)) { *num_chars_to_copy = (field_width - *x_offset) / glyph_width; if (*num_chars_to_copy > chars_remaining) - *num_chars_to_copy = chars_remaining; + *num_chars_to_copy = (unsigned)chars_remaining; } } } @@ -566,7 +566,7 @@ static void gfx_animation_ticker_smooth_loop_fw(uint64_t idx, /* Determine number of characters to copy */ *num_chars_to_copy3 = remaining_width / glyph_width; if (*num_chars_to_copy3 > num_chars) - *num_chars_to_copy3 = num_chars; + *num_chars_to_copy3 = (unsigned)num_chars; } } @@ -1517,7 +1517,7 @@ static bool gfx_animation_ticker_smooth_fw( if (src_str_len < 1) goto end; - src_str_width = src_str_len * glyph_width; + src_str_width = (unsigned)(src_str_len * glyph_width); /* If src string width is <= text field width, we * can just copy the entire string */ @@ -1573,7 +1573,7 @@ static bool gfx_animation_ticker_smooth_fw( if ((spacer_len = utf8len(ticker->spacer)) < 1) goto end; - spacer_width = spacer_len * glyph_width; + spacer_width = (unsigned)(spacer_len * glyph_width); /* Determine animation type */ switch (ticker->type_enum) diff --git a/gfx/gfx_widgets.c b/gfx/gfx_widgets.c index c8dd870788..dea7c1974e 100644 --- a/gfx/gfx_widgets.c +++ b/gfx/gfx_widgets.c @@ -314,7 +314,7 @@ void gfx_widgets_msg_queue_push( width = text_width - (text_width >> 2); word_wrap(msg, msg_len, title, title_length, - (title_length * width) / text_width, + (int)((title_length * width) / text_width), 100, 2); msg_widget->text_height *= 2; diff --git a/gfx/video_driver.c b/gfx/video_driver.c index 1222dec4e3..41e5398f04 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -4189,8 +4189,8 @@ void video_frame_delay_auto(video_driver_state_t *video_st, video_frame_delay_au unsigned frame_time_limit_max = frame_time_target * 1.90f; unsigned frame_time_limit_cap = frame_time_target * 3.00f; unsigned frame_time_limit_ign = frame_time_target * 3.50f; - unsigned frame_time_min = frame_time_target; - unsigned frame_time_max = frame_time_target; + retro_time_t frame_time_min = frame_time_target; + retro_time_t frame_time_max = frame_time_target; unsigned frame_time_count_pos = 0; unsigned frame_time_count_min = 0; unsigned frame_time_count_med = 0; @@ -4203,7 +4203,7 @@ void video_frame_delay_auto(video_driver_state_t *video_st, video_frame_delay_au /* Calculate average frame time */ for (i = 1; i < frame_time_frames + 1; i++) { - unsigned frame_time_i = 0; + retro_time_t frame_time_i = 0; if (i > frame_time_index) continue; @@ -4245,8 +4245,8 @@ void video_frame_delay_auto(video_driver_state_t *video_st, video_frame_delay_au /* Special handlings for different video driver frame timings */ if (frame_time < frame_time_limit_med && frame_time > frame_time_target) { - unsigned frame_time_frames_half = frame_time_frames / 2; - unsigned frame_time_delta = frame_time_max - frame_time_min; + retro_time_t frame_time_frames_half = frame_time_frames / 2; + retro_time_t frame_time_delta = frame_time_max - frame_time_min; /* Ensure outcome on certain conditions */ int mode = 0; diff --git a/libretro-common/formats/json/rjson.c b/libretro-common/formats/json/rjson.c index 44bf9e2a01..696db7074f 100644 --- a/libretro-common/formats/json/rjson.c +++ b/libretro-common/formats/json/rjson.c @@ -982,7 +982,7 @@ size_t rjson_get_source_column(rjson_t *json) int rjson_get_source_context_len(rjson_t *json) { const unsigned char *from = json->input_buf, *to = json->input_end, *p = json->input_p; - return ((p + 256 < to ? p + 256 : to) - (p > from + 256 ? p - 256 : from)); + return (int)(((p + 256 < to ? p + 256 : to) - (p > from + 256 ? p - 256 : from))); } const char* rjson_get_source_context_buf(rjson_t *json) @@ -1013,7 +1013,7 @@ bool rjson_check_context(rjson_t *json, unsigned int depth, ...) unsigned int rjson_get_context_depth(rjson_t *json) { - return json->stack_top - json->stack; + return (unsigned int)(json->stack_top - json->stack); } size_t rjson_get_context_count(rjson_t *json) diff --git a/libretro-common/string/stdstring.c b/libretro-common/string/stdstring.c index 9dd9ab9011..20d7a45995 100644 --- a/libretro-common/string/stdstring.c +++ b/libretro-common/string/stdstring.c @@ -692,8 +692,9 @@ void string_remove_all_whitespace(char *str_trimmed, const char *str) int string_index_last_occurance(const char *str, char c) { const char *pos = strrchr(str, c); - - return pos ? (pos - str) : -1; + if (pos) + return (int)(pos - str); + return -1; } /** @@ -707,7 +708,7 @@ int string_find_index_substring_string(const char *str, const char *substr) { const char *pos = strstr(str, substr); if (pos) - return pos - str; + return (int)(pos - str); return -1; } diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index 822035a7a9..33ae289538 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -6117,7 +6117,7 @@ static void netplay_refresh_lan_cb(const void *data) (struct netplay_room*)calloc(hosts->size, sizeof(*net_st->room_list)); if (!net_st->room_list) goto done; - net_st->room_count = hosts->size; + net_st->room_count = (int)hosts->size; for (i = 0; i < net_st->room_count; i++) { @@ -6458,7 +6458,7 @@ int action_cb_push_dropdown_item_resolution(const char *path, float num = refreshrate / 60.0f; unsigned refresh_mod = num > 0 ? (unsigned)(floorf(num + 0.5f)) : (unsigned)(ceilf(num - 0.5f)); #else - unsigned refresh_mod = lroundf((float)(refreshrate / 60.0f)); + unsigned refresh_mod = (unsigned)lroundf((float)(refreshrate / 60.0f)); #endif float refresh_exact = refreshrate; diff --git a/menu/drivers/ozone.c b/menu/drivers/ozone.c index 80e6617c2a..0059faecf7 100644 --- a/menu/drivers/ozone.c +++ b/menu/drivers/ozone.c @@ -344,7 +344,7 @@ typedef struct typedef struct { const char *str; - int width; + size_t width; } ozone_footer_label_t; typedef struct ozone_theme @@ -2733,8 +2733,7 @@ static int ozone_wiggle(ozone_handle_t* ozone, float t) */ static void ozone_apply_cursor_wiggle_offset(ozone_handle_t* ozone, int* x, size_t* y) { - retro_time_t cur_time; - retro_time_t t; + retro_time_t cur_time, t; /* Don't do anything if we are not wiggling */ if (!ozone || !ozone->cursor_wiggle_state.wiggling) @@ -2867,7 +2866,7 @@ static void ozone_draw_cursor_fallback( video_width, video_height, x_offset - ozone->dimensions.spacer_3px, - y, + (int)y, width + ozone->dimensions.spacer_3px * 2, height, video_width, @@ -2884,7 +2883,7 @@ static void ozone_draw_cursor_fallback( video_width, video_height, x_offset - ozone->dimensions.spacer_5px, - y - ozone->dimensions.spacer_3px, + (int)(y - ozone->dimensions.spacer_3px), width + 1 + ozone->dimensions.spacer_5px * 2, ozone->dimensions.spacer_3px, video_width, @@ -2899,7 +2898,7 @@ static void ozone_draw_cursor_fallback( video_width, video_height, x_offset - ozone->dimensions.spacer_5px, - y + height, + (int)(y + height), width + 1 + ozone->dimensions.spacer_5px * 2, ozone->dimensions.spacer_3px, video_width, @@ -2914,7 +2913,7 @@ static void ozone_draw_cursor_fallback( video_width, video_height, x_offset - ozone->dimensions.spacer_5px, - y, + (int)y, ozone->dimensions.spacer_3px, height, video_width, @@ -2929,7 +2928,7 @@ static void ozone_draw_cursor_fallback( video_width, video_height, x_offset + width + ozone->dimensions.spacer_3px, - y, + (int)y, ozone->dimensions.spacer_3px, height, video_width, @@ -6440,9 +6439,10 @@ static void ozone_draw_messagebox( const char *message, math_matrix_4x4 *mymat) { + size_t x, y; unsigned i, y_position; char wrapped_message[MENU_SUBLABEL_MAX_LENGTH]; - int x, y, longest_width = 0; + int longest_width = 0; int usable_width = 0; struct string_list list = {0}; float scale_factor = 0.0f; @@ -6516,9 +6516,9 @@ static void ozone_draw_messagebox( * > The actual size and offset of a texture slice * is quite 'loose', and depends upon source image * size, draw size and scale factor... */ - unsigned slice_new_w = longest_width + 48 * 2 * scale_factor; - unsigned slice_new_h = ozone->fonts.footer.line_height * (list.size + 2); - int slice_x = x - longest_width/2 - 48 * scale_factor; + size_t slice_new_w = longest_width + 48 * 2 * scale_factor; + size_t slice_new_h = ozone->fonts.footer.line_height * (list.size + 2); + int slice_x = x - longest_width / 2 - 48 * scale_factor; int slice_y = y - ozone->fonts.footer.line_height + ((slice_new_h >= 256) ? (16.0f * scale_factor) @@ -6532,8 +6532,8 @@ static void ozone_draw_messagebox( slice_x, slice_y, 256, 256, - slice_new_w, - slice_new_h, + (unsigned)slice_new_w, + (unsigned)slice_new_h, width, height, ozone->theme_dynamic.message_background, 16, scale_factor, @@ -9258,7 +9258,7 @@ static void ozone_render(void *data, else if ((ozone->is_quick_menu && ozone->depth >= 2) || ozone->is_state_slot) { - ozone_update_savestate_thumbnail_path(ozone, i); + ozone_update_savestate_thumbnail_path(ozone, (unsigned)i); ozone_update_savestate_thumbnail_image(ozone); } } @@ -10173,7 +10173,7 @@ static void ozone_selection_changed(ozone_handle_t *ozone, bool allow_animation) ozone_update_thumbnail_image(ozone); } - ozone_update_savestate_thumbnail_path(ozone, ozone->selection); + ozone_update_savestate_thumbnail_path(ozone, (unsigned)ozone->selection); ozone_update_savestate_thumbnail_image(ozone); } } @@ -10872,7 +10872,7 @@ static void ozone_populate_entries(void *data, { ozone->want_thumbnail_bar = false; ozone->skip_thumbnail_reset = false; - ozone_update_savestate_thumbnail_path(ozone, menu_navigation_get_selection()); + ozone_update_savestate_thumbnail_path(ozone, (unsigned)menu_navigation_get_selection()); ozone_update_savestate_thumbnail_image(ozone); } else if (gfx_thumbnail_is_enabled(ozone->thumbnail_path_data, GFX_THUMBNAIL_RIGHT) || @@ -10965,7 +10965,7 @@ static void ozone_toggle(void *userdata, bool menu_on) ozone->want_thumbnail_bar = false; ozone->skip_thumbnail_reset = false; gfx_thumbnail_reset(&ozone->thumbnails.savestate); - ozone_update_savestate_thumbnail_path(ozone, menu_navigation_get_selection()); + ozone_update_savestate_thumbnail_path(ozone, (unsigned)menu_navigation_get_selection()); ozone_update_savestate_thumbnail_image(ozone); } diff --git a/menu/drivers/rgui.c b/menu/drivers/rgui.c index 3c55ef9d26..6291466810 100644 --- a/menu/drivers/rgui.c +++ b/menu/drivers/rgui.c @@ -6796,7 +6796,7 @@ static void rgui_scan_selected_entry_thumbnail(rgui_t *rgui, bool force_load) if (selection < list_size) { - rgui_update_savestate_thumbnail_path(rgui, selection); + rgui_update_savestate_thumbnail_path(rgui, (unsigned)selection); rgui_update_savestate_thumbnail_image(rgui); } } diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 9cd74121fd..b408685927 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -1858,7 +1858,7 @@ static void xmb_list_open_new(xmb_handle_t *xmb, { /* This shows savestate thumbnail after * opening savestate submenu */ - xmb_update_savestate_thumbnail_path(xmb, current); + xmb_update_savestate_thumbnail_path(xmb, (unsigned)current); xmb_update_savestate_thumbnail_image(xmb); } @@ -3843,7 +3843,7 @@ static int xmb_draw_item( else if (entry_type == FILE_TYPE_RPL_ENTRY && show_history_icons != PLAYLIST_SHOW_HISTORY_ICONS_DEFAULT) { - switch (xmb_get_system_tab(xmb, xmb->categories_selection_ptr)) + switch (xmb_get_system_tab(xmb, (unsigned)xmb->categories_selection_ptr)) { case XMB_SYSTEM_TAB_MAIN: { diff --git a/network/netplay/netplay_frontend.c b/network/netplay/netplay_frontend.c index 7a2d787c5b..607323e8a8 100644 --- a/network/netplay/netplay_frontend.c +++ b/network/netplay/netplay_frontend.c @@ -9106,10 +9106,10 @@ bool netplay_decode_hostname(const char *hostname, { if (port) { - unsigned tmp_port = strtoul(hostname_data.elems[1].data, NULL, 10); + unsigned long int tmp_port = (unsigned long int)strtoul(hostname_data.elems[1].data, NULL, 10); if (tmp_port && tmp_port <= 65535) - *port = tmp_port; + *port = (unsigned)tmp_port; } } if (hostname_data.size >= 3 && diff --git a/runloop.c b/runloop.c index f1df58faef..8e467565b4 100644 --- a/runloop.c +++ b/runloop.c @@ -491,7 +491,7 @@ static bool runloop_environ_cb_get_system_info(unsigned cmd, void *data) runloop_st->subsystem_current_count = size <= SUBSYSTEM_MAX_SUBSYSTEMS - ? size + ? (unsigned)size : SUBSYSTEM_MAX_SUBSYSTEMS; } break;