(OSX) Code analysis cleanups

This commit is contained in:
Twinaphex 2019-04-08 23:13:39 +02:00
parent b25c571b23
commit 076a0d2f56
8 changed files with 23 additions and 42 deletions

View File

@ -116,7 +116,7 @@ bool file_list_insert(file_list_t *list,
free(copy); free(copy);
} }
file_list_add(list, idx, path, label, type, file_list_add(list, (unsigned)idx, path, label, type,
directory_ptr, entry_idx); directory_ptr, entry_idx);
return true; return true;

View File

@ -1279,11 +1279,9 @@ static int generic_action_ok_command(enum event_command cmd)
/* TO-DO: Localization for errors */ /* TO-DO: Localization for errors */
static bool file_copy(const char *src_path, const char *dst_path, char *msg, size_t size) static bool file_copy(const char *src_path, const char *dst_path, char *msg, size_t size)
{ {
RFILE *src, *dst; RFILE *dst = NULL;
int numr, numw;
bool ret = true; bool ret = true;
RFILE *src = filestream_open(src_path,
src = filestream_open(src_path,
RETRO_VFS_FILE_ACCESS_READ, RETRO_VFS_FILE_ACCESS_READ,
RETRO_VFS_FILE_ACCESS_HINT_NONE); RETRO_VFS_FILE_ACCESS_HINT_NONE);
@ -1305,8 +1303,9 @@ static bool file_copy(const char *src_path, const char *dst_path, char *msg, siz
while (!filestream_eof(src)) while (!filestream_eof(src))
{ {
int64_t numw;
char buffer[100] = {0}; char buffer[100] = {0};
numr = filestream_read(src, buffer, sizeof(buffer)); int64_t numr = filestream_read(src, buffer, sizeof(buffer));
if (filestream_error(dst) != 0) if (filestream_error(dst) != 0)
{ {
@ -4954,13 +4953,13 @@ static int action_ok_push_dropdown_item_resolution(const char *path,
pch = strtok(str, "x"); pch = strtok(str, "x");
if (pch) if (pch)
width = strtoul(pch, NULL, 0); width = (unsigned)strtoul(pch, NULL, 0);
pch = strtok(NULL, " "); pch = strtok(NULL, " ");
if (pch) if (pch)
height = strtoul(pch, NULL, 0); height = (unsigned)strtoul(pch, NULL, 0);
pch = strtok(NULL, "("); pch = strtok(NULL, "(");
if (pch) if (pch)
refreshrate = strtoul(pch, NULL, 0); refreshrate = (unsigned)strtoul(pch, NULL, 0);
if (video_display_server_set_resolution(width, height, if (video_display_server_set_resolution(width, height,
refreshrate, (float)refreshrate, 0, 0, 0)) refreshrate, (float)refreshrate, 0, 0, 0))

View File

@ -123,8 +123,6 @@ void ozone_draw_sidebar(ozone_handle_t *ozone, video_frame_info_t *video_info)
selection_old_y = 0; selection_old_y = 0;
horizontal_list_size = 0; horizontal_list_size = 0;
entry_width = 0;
if (!ozone->draw_sidebar) if (!ozone->draw_sidebar)
return; return;
@ -150,14 +148,14 @@ void ozone_draw_sidebar(ozone_handle_t *ozone, video_frame_info_t *video_info)
{ {
if (i == ozone->categories_selection_ptr) if (i == ozone->categories_selection_ptr)
{ {
selection_y = y; selection_y = (unsigned)y;
if (ozone->categories_selection_ptr > ozone->system_tab_end) if (ozone->categories_selection_ptr > ozone->system_tab_end)
selection_y += ozone->dimensions.sidebar_entry_padding_vertical + 1; selection_y += ozone->dimensions.sidebar_entry_padding_vertical + 1;
} }
if (i == ozone->categories_active_idx_old) if (i == ozone->categories_active_idx_old)
{ {
selection_old_y = y; selection_old_y = (unsigned)y;
if (ozone->categories_active_idx_old > ozone->system_tab_end) if (ozone->categories_active_idx_old > ozone->system_tab_end)
selection_old_y += ozone->dimensions.sidebar_entry_padding_vertical + 1; selection_old_y += ozone->dimensions.sidebar_entry_padding_vertical + 1;
} }

View File

@ -1891,7 +1891,7 @@ static void rgui_render(void *data, bool is_idle)
ticker.selected = true; ticker.selected = true;
menu_animation_ticker(&ticker); menu_animation_ticker(&ticker);
title_width = utf8len(thumbnail_title_buf) * FONT_WIDTH_STRIDE; title_width = (unsigned)(utf8len(thumbnail_title_buf) * FONT_WIDTH_STRIDE);
title_x = RGUI_TERM_START_X(fb_width) + ((RGUI_TERM_WIDTH(fb_width) * FONT_WIDTH_STRIDE) - title_width) / 2; title_x = RGUI_TERM_START_X(fb_width) + ((RGUI_TERM_WIDTH(fb_width) * FONT_WIDTH_STRIDE) - title_width) / 2;
/* Draw thumbnail title background */ /* Draw thumbnail title background */
@ -2159,7 +2159,6 @@ static void rgui_render(void *data, bool is_idle)
time_t current_time; time_t current_time;
struct tm * time_info; struct tm * time_info;
char timedate[16]; char timedate[16];
int n;
timedate[0] = '\0'; timedate[0] = '\0';
@ -2172,12 +2171,9 @@ static void rgui_render(void *data, bool is_idle)
if (time_info) if (time_info)
{ {
n = snprintf(timedate, sizeof(timedate), "%02u:%02u", snprintf(timedate, sizeof(timedate), "%02u:%02u",
(unsigned)time_info->tm_hour, (unsigned)time_info->tm_min); (unsigned)time_info->tm_hour, (unsigned)time_info->tm_min);
if ((n < 0) || (n >= 16))
n = 0; /* Silence GCC warnings... */
blit_line( blit_line(
timedate_x, timedate_x,
(RGUI_TERM_HEIGHT(fb_height) * FONT_HEIGHT_STRIDE) + (RGUI_TERM_HEIGHT(fb_height) * FONT_HEIGHT_STRIDE) +

View File

@ -356,7 +356,7 @@ static void menu_animation_ticker_loop(uint64_t idx,
/* String 1 */ /* String 1 */
offset = (phase < (int)str_width) ? phase : 0; offset = (phase < (int)str_width) ? phase : 0;
width = str_width - phase; width = (int)(str_width - phase);
width = (width < 0) ? 0 : width; width = (width < 0) ? 0 : width;
width = (width > (int)max_width) ? max_width : width; width = (width > (int)max_width) ? max_width : width;
@ -364,9 +364,9 @@ static void menu_animation_ticker_loop(uint64_t idx,
*width1 = width; *width1 = width;
/* String 2 */ /* String 2 */
offset = phase - str_width; offset = (int)(phase - str_width);
offset = offset < 0 ? 0 : offset; offset = offset < 0 ? 0 : offset;
width = max_width - *width1; width = (int)(max_width - *width1);
width = (width > (int)spacer_width) ? spacer_width : width; width = (width > (int)spacer_width) ? spacer_width : width;
width = width - offset; width = width - offset;

View File

@ -2302,7 +2302,7 @@ static int menu_displaylist_parse_settings_internal(void *data,
(entry_type >= MENU_SETTINGS_INPUT_BEGIN) && (entry_type >= MENU_SETTINGS_INPUT_BEGIN) &&
(entry_type < MENU_SETTINGS_INPUT_END) (entry_type < MENU_SETTINGS_INPUT_END)
) )
entry_type = MENU_SETTINGS_INPUT_BEGIN + count; entry_type = (unsigned)(MENU_SETTINGS_INPUT_BEGIN + count);
if (entry_type == 0) if (entry_type == 0)
entry_type = menu_setting_set_flags(setting); entry_type = menu_setting_set_flags(setting);

View File

@ -1104,10 +1104,8 @@ static JSON_Parser_HandlerResult JSONStartArrayHandler(JSON_Parser parser)
if (pCtx->object_depth == 1) if (pCtx->object_depth == 1)
{ {
if (string_is_equal(pCtx->current_meta_string, "items") && pCtx->array_depth == 1) if (string_is_equal(pCtx->current_meta_string, "items") && pCtx->array_depth == 1)
{
pCtx->in_items = true; pCtx->in_items = true;
} }
}
return JSON_Parser_Continue; return JSON_Parser_Continue;
} }
@ -1144,16 +1142,12 @@ static JSON_Parser_HandlerResult JSONStartObjectHandler(JSON_Parser parser)
if (pCtx->array_depth == 1) if (pCtx->array_depth == 1)
{ {
if (pCtx->playlist->size < pCtx->playlist->cap) if (pCtx->playlist->size < pCtx->playlist->cap)
{
pCtx->current_entry = &pCtx->playlist->entries[pCtx->playlist->size]; pCtx->current_entry = &pCtx->playlist->entries[pCtx->playlist->size];
}
else else
{
/* hit max item limit */ /* hit max item limit */
return JSON_Parser_Abort; return JSON_Parser_Abort;
} }
} }
}
return JSON_Parser_Continue; return JSON_Parser_Continue;
} }
@ -1165,10 +1159,8 @@ static JSON_Parser_HandlerResult JSONEndObjectHandler(JSON_Parser parser)
if (pCtx->in_items && pCtx->object_depth == 2) if (pCtx->in_items && pCtx->object_depth == 2)
{ {
if (pCtx->array_depth == 1) if (pCtx->array_depth == 1)
{
pCtx->playlist->size++; pCtx->playlist->size++;
} }
}
retro_assert(pCtx->object_depth > 0); retro_assert(pCtx->object_depth > 0);
@ -1229,13 +1221,9 @@ static JSON_Parser_HandlerResult JSONNumberHandler(JSON_Parser parser, char *pVa
if (pCtx->array_depth == 1) if (pCtx->array_depth == 1)
{ {
if (pCtx->current_entry_int_val && length && !string_is_empty(pValue)) if (pCtx->current_entry_int_val && length && !string_is_empty(pValue))
{ *pCtx->current_entry_int_val = (int)strtoul(pValue, NULL, 10);
*pCtx->current_entry_int_val = strtoul(pValue, NULL, 10);
}
else if (pCtx->current_entry_uint_val && length && !string_is_empty(pValue)) else if (pCtx->current_entry_uint_val && length && !string_is_empty(pValue))
{ *pCtx->current_entry_uint_val = (unsigned)strtoul(pValue, NULL, 10);
*pCtx->current_entry_uint_val = strtoul(pValue, NULL, 10);
}
else else
{ {
/* must be a value for an unknown member we aren't tracking, skip it */ /* must be a value for an unknown member we aren't tracking, skip it */

View File

@ -775,7 +775,7 @@ void runtime_log_convert_hms2usec(unsigned hours, unsigned minutes, unsigned sec
/* Convert from microseconds to hours, minutes, seconds */ /* Convert from microseconds to hours, minutes, seconds */
void runtime_log_convert_usec2hms(retro_time_t usec, unsigned *hours, unsigned *minutes, unsigned *seconds) void runtime_log_convert_usec2hms(retro_time_t usec, unsigned *hours, unsigned *minutes, unsigned *seconds)
{ {
*seconds = usec / 1000000; *seconds = (unsigned)(usec / 1000000);
*minutes = *seconds / 60; *minutes = *seconds / 60;
*hours = *minutes / 60; *hours = *minutes / 60;