1
0
mirror of https://github.com/libretro/RetroArch synced 2025-02-16 12:39:59 +00:00

Try to fix Coverity warnings

This commit is contained in:
twinaphex 2018-03-19 06:58:36 +01:00
parent 62d2b9a54e
commit 72dc03a1c6
5 changed files with 99 additions and 76 deletions

@ -1037,7 +1037,7 @@ static int cheevos_parse_expression(cheevos_expr_t *expr, const char* mem)
for (aux = mem;; aux++)
{
if(*aux == '"' || *aux == ':')
if (*aux == '"' || *aux == ':')
break;
expr->count += *aux == '_';
}
@ -1094,13 +1094,13 @@ static int cheevos_parse_expression(cheevos_expr_t *expr, const char* mem)
}
else
{
if(aux[1] == 'h' || aux[1] == 'H')
if (aux[1] == 'h' || aux[1] == 'H')
expr->terms[i].multiplier = (double)strtol(aux + 2, &end, 16);
else
expr->terms[i].multiplier = strtod(aux + 1, &end);
aux = end;
if(*aux == '$')
if (*aux == '$')
{
aux++;
expr->terms[i].compare_next = true;
@ -1964,7 +1964,7 @@ static void cheevos_test_cheevo_set(const cheevoset_t *set)
task_push_http_transfer(url, true, NULL,
cheevos_unlocked, cheevo);
if(settings->bools.cheevos_auto_screenshot)
if (settings && settings->bools.cheevos_auto_screenshot)
{
char shotname[256];
@ -1974,7 +1974,8 @@ static void cheevos_test_cheevo_set(const cheevoset_t *set)
cheevo->id);
shotname[sizeof(shotname) - 1] = '\0';
if(take_screenshot(shotname, true, video_driver_cached_frame_has_valid_framebuffer()))
if (take_screenshot(shotname, true,
video_driver_cached_frame_has_valid_framebuffer()))
RARCH_LOG("[CHEEVOS]: got a screenshot for cheevo %u\n", cheevo->id);
else
RARCH_LOG("[CHEEVOS]: failed to get screenshot for cheevo %u\n", cheevo->id);
@ -3163,7 +3164,7 @@ found:
mode = CHEEVOS_ACTIVE_HARDCORE;
for (; cheevo < end; cheevo++)
if(cheevo->active & mode)
if (cheevo->active & mode)
number_of_unlocked--;
snprintf(msg, sizeof(msg),

@ -729,7 +729,7 @@ static void check_proc_acpi_battery(const char * node, bool * have_battery,
{
char *endptr = NULL;
if (*endptr == ' ')
if (endptr && *endptr == ' ')
remaining = (int)strtol(val, &endptr, 10);
}
}
@ -741,7 +741,7 @@ static void check_proc_acpi_battery(const char * node, bool * have_battery,
char *endptr = NULL;
if (string_is_equal(key, "design capacity"))
if (*endptr == ' ')
if (endptr && *endptr == ' ')
maximum = (int)strtol(val, &endptr, 10);
}

@ -1155,25 +1155,31 @@ static int generic_action_ok(const char *path,
struct video_shader *shader = menu_shader_get();
struct video_shader_pass *shader_pass = shader ? &shader->pass[(unsigned)hack_shader_pass] : NULL;
flush_char = msg_hash_to_str((enum msg_hash_enums)flush_id);
strlcpy(
shader_pass->source.path,
action_path,
sizeof(shader_pass->source.path));
video_shader_resolve_parameters(NULL, menu_shader_get());
if (shader_pass)
{
strlcpy(
shader_pass->source.path,
action_path,
sizeof(shader_pass->source.path));
video_shader_resolve_parameters(NULL, shader);
}
}
break;
case ACTION_OK_LOAD_RECORD_CONFIGFILE:
{
global_t *global = global_get_ptr();
flush_char = msg_hash_to_str(flush_id);
strlcpy(global->record.config, action_path,
sizeof(global->record.config));
flush_char = msg_hash_to_str(flush_id);
if (global)
strlcpy(global->record.config, action_path,
sizeof(global->record.config));
}
break;
case ACTION_OK_LOAD_REMAPPING_FILE:
{
config_file_t *conf = config_file_new(action_path);
flush_char = msg_hash_to_str(flush_id);
flush_char = msg_hash_to_str(flush_id);
if (conf)
input_remapping_load_file(conf, action_path);

@ -837,14 +837,6 @@ static void materialui_render_label_value(
const char *value, float *label_color,
uint32_t sublabel_color)
{
/* This will be used instead of label_color if texture_switch is 'off' icon */
float pure_white[16]= {
1.00, 1.00, 1.00, 1.00,
1.00, 1.00, 1.00, 1.00,
1.00, 1.00, 1.00, 1.00,
1.00, 1.00, 1.00, 1.00,
};
menu_entry_t entry;
menu_animation_ctx_ticker_t ticker;
char label_str[255];
@ -999,6 +991,16 @@ static void materialui_render_label_value(
);
if (texture_switch)
{
/* This will be used instead of label_color if
* texture_switch is 'off' icon */
float pure_white[16]= {
1.00, 1.00, 1.00, 1.00,
1.00, 1.00, 1.00, 1.00,
1.00, 1.00, 1.00, 1.00,
1.00, 1.00, 1.00, 1.00,
};
materialui_draw_icon(video_info,
mui->icon_size,
(uintptr_t)texture_switch,
@ -1009,7 +1011,8 @@ static void materialui_render_label_value(
0,
1,
switch_is_on ? &label_color[0] : &pure_white[0]
);
);
}
menu_entry_free(&entry);
}
@ -1176,36 +1179,35 @@ static void materialui_frame(void *data, video_frame_info_t *video_info)
char title[255];
char title_buf[255];
char title_msg[255];
float black_bg[16] = {
0, 0, 0, 0.75,
0, 0, 0, 0.75,
0, 0, 0, 0.75,
0, 0, 0, 0.75,
};
float pure_white[16] = {
1.00, 1.00, 1.00, 1.00,
1.00, 1.00, 1.00, 1.00,
1.00, 1.00, 1.00, 1.00,
1.00, 1.00, 1.00, 1.00,
};
float white_bg[16] = {
0.98, 0.98, 0.98, 1.00,
0.98, 0.98, 0.98, 1.00,
0.98, 0.98, 0.98, 1.00,
0.98, 0.98, 0.98, 1.00,
};
float white_transp_bg[16] = {
0.98, 0.98, 0.98, 0.90,
0.98, 0.98, 0.98, 0.90,
0.98, 0.98, 0.98, 0.90,
0.98, 0.98, 0.98, 0.90,
};
float grey_bg[16] = {
0.78, 0.78, 0.78, 0.90,
0.78, 0.78, 0.78, 0.90,
0.78, 0.78, 0.78, 0.90,
0.78, 0.78, 0.78, 0.90,
};
/* TODO/FIXME convert this over to new hex format */
float greyish_blue[16] = {
0.22, 0.28, 0.31, 1.00,
@ -1227,10 +1229,6 @@ static void materialui_frame(void *data, video_frame_info_t *video_info)
0.00, 0.00, 0.00, 0.20,
};
uint32_t black_opaque_54 = 0x0000008a;
uint32_t black_opaque_87 = 0x000000de;
uint32_t white_opaque_70 = 0xffffffb3;
/* https://material.google.com/style/color.html#color-color-palette */
/* Hex values converted to RGB normalized decimals, alpha set to 1 */
float blue_500[16] = {0};
@ -1249,19 +1247,6 @@ static void materialui_frame(void *data, video_frame_info_t *video_info)
float footer_bg_color_real[16] = {0};
float header_bg_color_real[16] = {0};
file_list_t *list = NULL;
materialui_node_t *node = NULL;
unsigned width = video_info->width;
unsigned height = video_info->height;
unsigned ticker_limit = 0;
unsigned i = 0;
unsigned header_height = 0;
size_t selection = 0;
size_t title_margin = 0;
materialui_handle_t *mui = (materialui_handle_t*)data;
bool background_rendered = false;
bool libretro_running = video_info->libretro_running;
/* Default is blue theme */
float *header_bg_color = NULL;
float *highlighted_entry_color = NULL;
@ -1270,15 +1255,37 @@ static void materialui_frame(void *data, video_frame_info_t *video_info)
float *active_tab_marker_color = NULL;
float *passive_tab_icon_color = grey_bg;
file_list_t *list = NULL;
materialui_node_t *node = NULL;
unsigned width = video_info->width;
unsigned height = video_info->height;
unsigned ticker_limit = 0;
unsigned i = 0;
unsigned header_height = 0;
uint32_t sublabel_color = 0x888888ff;
uint32_t font_normal_color = 0;
uint32_t font_hover_color = 0;
uint32_t font_header_color = 0;
size_t usable_width = width - (mui->margin * 2);
uint32_t black_opaque_54 = 0x0000008a;
uint32_t black_opaque_87 = 0x000000de;
uint32_t white_opaque_70 = 0xffffffb3;
size_t usable_width = 0;
size_t selection = 0;
size_t title_margin = 0;
bool background_rendered = false;
bool libretro_running = video_info->libretro_running;
materialui_handle_t *mui = (materialui_handle_t*)data;
if (!mui)
return;
usable_width = width - (mui->margin * 2);
mui->frame_count++;
msg[0] = title[0] = title_buf[0] = title_msg[0] = '\0';
@ -1449,7 +1456,7 @@ static void materialui_frame(void *data, video_frame_info_t *video_info)
draw.matrix_data = NULL;
draw.texture = menu_display_white_texture;
draw.prim_type = MENU_DISPLAY_PRIM_TRIANGLESTRIP;
draw.color = &body_bg_color[0];
draw.color = body_bg_color ? &body_bg_color[0] : NULL;
draw.vertex = NULL;
draw.tex_coord = NULL;
draw.vertex_count = 4;
@ -1520,7 +1527,7 @@ static void materialui_frame(void *data, video_frame_info_t *video_info)
node->line_height,
width,
height,
&highlighted_entry_color[0]
highlighted_entry_color ? &highlighted_entry_color[0] : NULL
);
font_driver_bind_block(mui->font, &mui->raster_block);
@ -1534,7 +1541,7 @@ static void materialui_frame(void *data, video_frame_info_t *video_info)
height,
font_normal_color,
font_hover_color,
&active_tab_marker_color[0],
active_tab_marker_color ? &active_tab_marker_color[0] : NULL,
sublabel_color
);
@ -1542,7 +1549,9 @@ static void materialui_frame(void *data, video_frame_info_t *video_info)
video_info);
font_driver_bind_block(mui->font, NULL);
font_driver_flush(video_info->width, video_info->height, mui->font2,
font_driver_flush(video_info->width,
video_info->height,
mui->font2,
video_info);
font_driver_bind_block(mui->font2, NULL);
@ -1557,7 +1566,7 @@ static void materialui_frame(void *data, video_frame_info_t *video_info)
header_height,
width,
height,
&header_bg_color[0]);
header_bg_color ? &header_bg_color[0] : NULL);
mui->tabs_height = 0;
@ -1592,18 +1601,25 @@ static void materialui_frame(void *data, video_frame_info_t *video_info)
if (menu_entries_ctl(MENU_ENTRIES_CTL_SHOW_BACK, NULL))
{
float pure_white[16] = {
1.00, 1.00, 1.00, 1.00,
1.00, 1.00, 1.00, 1.00,
1.00, 1.00, 1.00, 1.00,
1.00, 1.00, 1.00, 1.00,
};
title_margin = mui->icon_size;
materialui_draw_icon(video_info,
mui->icon_size,
mui->textures.list[MUI_TEXTURE_BACK],
0,
0,
width,
height,
0,
1,
&pure_white[0]
);
mui->icon_size,
mui->textures.list[MUI_TEXTURE_BACK],
0,
0,
width,
height,
0,
1,
&pure_white[0]
);
}
ticker_limit = usable_width / mui->glyph_width;

@ -141,20 +141,20 @@ bool menu_shader_manager_init(void)
}
}
if (!string_is_empty(new_path))
if (
!string_is_empty(new_path) && conf &&
video_shader_read_conf_cgp(conf, menu_driver_shader)
)
{
if (conf)
{
if (video_shader_read_conf_cgp(conf, menu_driver_shader))
{
video_shader_resolve_relative(menu_driver_shader, new_path);
video_shader_resolve_parameters(conf, menu_driver_shader);
}
config_file_free(conf);
}
free(new_path);
video_shader_resolve_relative(menu_driver_shader, new_path);
video_shader_resolve_parameters(conf, menu_driver_shader);
}
if (new_path)
free(new_path);
if (conf)
config_file_free(conf);
return true;
}