(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);
}
file_list_add(list, idx, path, label, type,
file_list_add(list, (unsigned)idx, path, label, type,
directory_ptr, entry_idx);
return true;

View File

@ -1279,11 +1279,9 @@ static int generic_action_ok_command(enum event_command cmd)
/* TO-DO: Localization for errors */
static bool file_copy(const char *src_path, const char *dst_path, char *msg, size_t size)
{
RFILE *src, *dst;
int numr, numw;
bool ret = true;
src = filestream_open(src_path,
RFILE *dst = NULL;
bool ret = true;
RFILE *src = filestream_open(src_path,
RETRO_VFS_FILE_ACCESS_READ,
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))
{
int64_t numw;
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)
{
@ -4954,13 +4953,13 @@ static int action_ok_push_dropdown_item_resolution(const char *path,
pch = strtok(str, "x");
if (pch)
width = strtoul(pch, NULL, 0);
width = (unsigned)strtoul(pch, NULL, 0);
pch = strtok(NULL, " ");
if (pch)
height = strtoul(pch, NULL, 0);
height = (unsigned)strtoul(pch, NULL, 0);
pch = strtok(NULL, "(");
if (pch)
refreshrate = strtoul(pch, NULL, 0);
refreshrate = (unsigned)strtoul(pch, NULL, 0);
if (video_display_server_set_resolution(width, height,
refreshrate, (float)refreshrate, 0, 0, 0))

View File

@ -116,15 +116,13 @@ void ozone_draw_sidebar(ozone_handle_t *ozone, video_frame_info_t *video_info)
uint32_t text_alpha = ozone->animations.sidebar_text_alpha * 255.0f;
/* Initial ticker configuration */
ticker.type_enum = (enum menu_animation_ticker_type)settings->uints.menu_ticker_type;
ticker.spacer = ticker_spacer;
ticker.type_enum = (enum menu_animation_ticker_type)settings->uints.menu_ticker_type;
ticker.spacer = ticker_spacer;
selection_y = 0;
selection_old_y = 0;
horizontal_list_size = 0;
entry_width = 0;
if (!ozone->draw_sidebar)
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)
{
selection_y = y;
selection_y = (unsigned)y;
if (ozone->categories_selection_ptr > ozone->system_tab_end)
selection_y += ozone->dimensions.sidebar_entry_padding_vertical + 1;
}
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)
selection_old_y += ozone->dimensions.sidebar_entry_padding_vertical + 1;
}

View File

@ -1891,8 +1891,8 @@ static void rgui_render(void *data, bool is_idle)
ticker.selected = true;
menu_animation_ticker(&ticker);
title_width = 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_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;
/* Draw thumbnail title background */
rgui_fill_rect(rgui, rgui_frame_buf.data, fb_pitch,
@ -2159,7 +2159,6 @@ static void rgui_render(void *data, bool is_idle)
time_t current_time;
struct tm * time_info;
char timedate[16];
int n;
timedate[0] = '\0';
@ -2172,12 +2171,9 @@ static void rgui_render(void *data, bool is_idle)
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);
if ((n < 0) || (n >= 16))
n = 0; /* Silence GCC warnings... */
blit_line(
timedate_x,
(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 */
offset = (phase < (int)str_width) ? phase : 0;
width = str_width - phase;
width = (int)(str_width - phase);
width = (width < 0) ? 0 : width;
width = (width > (int)max_width) ? max_width : width;
@ -364,9 +364,9 @@ static void menu_animation_ticker_loop(uint64_t idx,
*width1 = width;
/* String 2 */
offset = phase - str_width;
offset = (int)(phase - str_width);
offset = offset < 0 ? 0 : offset;
width = max_width - *width1;
width = (int)(max_width - *width1);
width = (width > (int)spacer_width) ? spacer_width : width;
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_END)
)
entry_type = MENU_SETTINGS_INPUT_BEGIN + count;
entry_type = (unsigned)(MENU_SETTINGS_INPUT_BEGIN + count);
if (entry_type == 0)
entry_type = menu_setting_set_flags(setting);

View File

@ -1104,9 +1104,7 @@ static JSON_Parser_HandlerResult JSONStartArrayHandler(JSON_Parser parser)
if (pCtx->object_depth == 1)
{
if (string_is_equal(pCtx->current_meta_string, "items") && pCtx->array_depth == 1)
{
pCtx->in_items = true;
}
}
return JSON_Parser_Continue;
@ -1144,14 +1142,10 @@ static JSON_Parser_HandlerResult JSONStartObjectHandler(JSON_Parser parser)
if (pCtx->array_depth == 1)
{
if (pCtx->playlist->size < pCtx->playlist->cap)
{
pCtx->current_entry = &pCtx->playlist->entries[pCtx->playlist->size];
}
else
{
/* hit max item limit */
return JSON_Parser_Abort;
}
}
}
@ -1165,9 +1159,7 @@ static JSON_Parser_HandlerResult JSONEndObjectHandler(JSON_Parser parser)
if (pCtx->in_items && pCtx->object_depth == 2)
{
if (pCtx->array_depth == 1)
{
pCtx->playlist->size++;
}
}
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->current_entry_int_val && length && !string_is_empty(pValue))
{
*pCtx->current_entry_int_val = strtoul(pValue, NULL, 10);
}
*pCtx->current_entry_int_val = (int)strtoul(pValue, NULL, 10);
else if (pCtx->current_entry_uint_val && length && !string_is_empty(pValue))
{
*pCtx->current_entry_uint_val = strtoul(pValue, NULL, 10);
}
*pCtx->current_entry_uint_val = (unsigned)strtoul(pValue, NULL, 10);
else
{
/* 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 */
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;
*hours = *minutes / 60;