Silence LGTM static code analysis warnings

This commit is contained in:
twinaphex 2021-03-24 00:25:24 +01:00
parent 1a263586e3
commit 8f79e14d0a
12 changed files with 97 additions and 113 deletions

View File

@ -513,14 +513,14 @@ typedef struct vk
vkUpdateDescriptorSets(device, 1, &write, 0, NULL); \
}
#define VULKAN_WRITE_QUAD_VBO(pv, _x, _y, _width, _height, _tex_x, _tex_y, _tex_width, _tex_height, color) \
#define VULKAN_WRITE_QUAD_VBO(pv, _x, _y, _width, _height, _tex_x, _tex_y, _tex_width, _tex_height, vulkan_color) \
{ \
float r = color->r; \
float g = color->g; \
float b = color->b; \
float a = color->a; \
pv[0].x = (_x) + 0.0f * (_width); \
pv[0].y = (_y) + 0.0f * (_height); \
float r = (vulkan_color)->r; \
float g = (vulkan_color)->g; \
float b = (vulkan_color)->b; \
float a = (vulkan_color)->a; \
pv[0].x = (_x) + 0.0f * (_width); \
pv[0].y = (_y) + 0.0f * (_height); \
pv[0].tex_x = (_tex_x) + 0.0f * (_tex_width); \
pv[0].tex_y = (_tex_y) + 0.0f * (_tex_height); \
pv[0].color.r = r; \

View File

@ -3737,7 +3737,15 @@ static void *gl2_init(const video_info_t *video,
gl_query_core_context_set(true);
gl->core_context_in_use = true;
gl_set_core_context(hwr->context_type);
if (hwr->context_type == RETRO_HW_CONTEXT_OPENGL_CORE)
{
/* Ensure that the rest of the frontend knows we have a core context */
gfx_ctx_flags_t flags;
flags.flags = 0;
BIT32_SET(flags.flags, GFX_CTX_FLAGS_GL_CORE_CONTEXT);
video_context_driver_set_flags(&flags);
}
RARCH_LOG("[GL]: Using Core GL context, setting up VAO...\n");
if (!gl_check_capability(GL_CAPS_VAO))

View File

@ -211,20 +211,20 @@ static void vulkan_raster_font_render_line(
height = glyph->height;
{
struct vk_vertex *pv = font->pv + font->vertices;
float _x = (x + (off_x + delta_x) * scale)
struct vk_vertex *pv = font->pv + font->vertices;
float _x = (x + (off_x + delta_x) * scale)
* inv_win_width;
float _y = (y + (off_y + delta_y) * scale)
float _y = (y + (off_y + delta_y) * scale)
* inv_win_height;
float _width = width * scale * inv_win_width;
float _height = height * scale * inv_win_height;
float _tex_x = tex_x * inv_tex_size_x;
float _tex_y = tex_y * inv_tex_size_y;
float _tex_width = width * inv_tex_size_x;
float _tex_height = height * inv_tex_size_y;
const struct vk_color *color = &vk_color;
float _width = width * scale * inv_win_width;
float _height = height * scale * inv_win_height;
float _tex_x = tex_x * inv_tex_size_x;
float _tex_y = tex_y * inv_tex_size_y;
float _tex_width = width * inv_tex_size_x;
float _tex_height = height * inv_tex_size_y;
const struct vk_color *_color = &vk_color;
VULKAN_WRITE_QUAD_VBO(pv, _x, _y, _width, _height, _tex_x, _tex_y, _tex_width, _tex_height, color);
VULKAN_WRITE_QUAD_VBO(pv, _x, _y, _width, _height, _tex_x, _tex_y, _tex_width, _tex_height, _color);
}
font->vertices += 6;

View File

@ -259,7 +259,7 @@ static void *font_renderer_ft_init(const char *font_path, float font_size)
FcPattern *found = NULL;
FcConfig* config = FcInitLoadConfigAndFonts();
FcResult result = FcResultNoMatch;
FcChar8* font_path = NULL;
FcChar8 *_font_path = NULL;
int face_index = 0;
/* select Sans fonts */
FcPattern* pattern = FcNameParse((const FcChar8*)"Sans");
@ -286,13 +286,13 @@ static void *font_renderer_ft_init(const char *font_path, float font_size)
/* uh-oh, for some reason, we can't find any font */
if (result != FcResultMatch)
goto error;
if (FcPatternGetString(found, FC_FILE, 0, &font_path) != FcResultMatch)
if (FcPatternGetString(found, FC_FILE, 0, &_font_path) != FcResultMatch)
goto error;
if (FcPatternGetInteger(found, FC_INDEX, 0, &face_index) != FcResultMatch)
goto error;
/* Initialize font renderer */
err = FT_New_Face(handle->lib, (const char*)font_path,
err = FT_New_Face(handle->lib, (const char*)_font_path,
face_index, &handle->face);
/* free up fontconfig internal structures */

View File

@ -569,9 +569,9 @@ static void menu_action_setting_disp_set_label_input_desc(
{
if (remap_idx < RARCH_FIRST_CUSTOM_BIND)
strlcpy(s, descriptor, len);
else if (!string_is_empty(descriptor) && remap_idx >= RARCH_FIRST_CUSTOM_BIND && remap_idx % 2 == 0)
else if (!string_is_empty(descriptor) && remap_idx % 2 == 0)
snprintf(s, len, "%s %c", descriptor, '+');
else if (remap_idx >= RARCH_FIRST_CUSTOM_BIND && remap_idx % 2 != 0)
else if (remap_idx % 2 != 0)
snprintf(s, len, "%s %c", descriptor, '-');
}

View File

@ -1586,10 +1586,10 @@ static bool menu_content_find_first_core(menu_content_ctx_defer_info_t *def_info
#ifdef HAVE_COMPRESSION
if (path_is_compressed_file(default_info_dir))
{
size_t len = strlen(default_info_dir);
size_t _len = strlen(default_info_dir);
/* In case of a compressed archive, we have to join with a hash */
/* We are going to write at the position of dir: */
def_info->s[len] = '#';
def_info->s[_len] = '#';
}
#endif
}

View File

@ -1398,7 +1398,7 @@ static int action_bind_sublabel_playlist_entry(
* playlist, so we can add both in one go */
n = strlcat(tmp, entry->last_played_str, sizeof(tmp));
if ((n < 0) || (n >= 64))
if (n >= 64)
n = 0; /* Silence GCC warnings... */
(void)n;
if (!string_is_empty(tmp))

View File

@ -380,25 +380,25 @@ typedef struct xmb_handle
bool is_quick_menu;
} xmb_handle_t;
float scale_mod[8] = {
static float xmb_scale_mod[8] = {
1, 1, 1, 1, 1, 1, 1, 1
};
static float coord_shadow[] = {
static float xmb_coord_shadow[] = {
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0
};
static float coord_black[] = {
static float xmb_coord_black[] = {
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0
};
static float coord_white[] = {
static float xmb_coord_white[] = {
1, 1, 1, 1,
1, 1, 1, 1,
1, 1, 1, 1,
@ -860,9 +860,9 @@ static void xmb_draw_icon(
if (xmb_shadows_enable)
{
gfx_display_set_alpha(coord_shadow, color[3] * 0.35f);
gfx_display_set_alpha(xmb_coord_shadow, color[3] * 0.35f);
coords.color = coord_shadow;
coords.color = xmb_coord_shadow;
draw.x = x + shadow_offset;
draw.y = height - y - shadow_offset;
@ -3059,8 +3059,8 @@ static int xmb_draw_item(
const float half_size = xmb->icon_size / 2.0f;
uintptr_t texture_switch = 0;
bool do_draw_text = false;
unsigned ticker_limit = 35 * scale_mod[0];
unsigned line_ticker_width = 45 * scale_mod[3];
unsigned ticker_limit = 35 * xmb_scale_mod[0];
unsigned line_ticker_width = 45 * xmb_scale_mod[3];
xmb_node_t * node = (xmb_node_t*)list->list[i].userdata;
bool use_smooth_ticker = settings->bools.menu_ticker_smooth;
enum gfx_animation_ticker_type
@ -3196,8 +3196,8 @@ static int xmb_draw_item(
&& menu_xmb_vertical_thumbnails)
)
{
ticker_limit = 40 * scale_mod[1];
line_ticker_width = 50 * scale_mod[3];
ticker_limit = 40 * xmb_scale_mod[1];
line_ticker_width = 50 * xmb_scale_mod[3];
/* Can increase text length if thumbnail is downscaled */
if (xmb_thumbnail_scale_factor < 100)
@ -3206,16 +3206,16 @@ static int xmb_draw_item(
1.0f - ((float)xmb_thumbnail_scale_factor / 100.0f);
ticker_limit +=
(unsigned)(ticker_scale_factor * 15.0f * scale_mod[1]);
(unsigned)(ticker_scale_factor * 15.0f * xmb_scale_mod[1]);
line_ticker_width +=
(unsigned)(ticker_scale_factor * 10.0f * scale_mod[3]);
(unsigned)(ticker_scale_factor * 10.0f * xmb_scale_mod[3]);
}
}
else
{
ticker_limit = 70 * scale_mod[2];
line_ticker_width = 60 * scale_mod[3];
ticker_limit = 70 * xmb_scale_mod[2];
line_ticker_width = 60 * xmb_scale_mod[3];
}
}
@ -3368,7 +3368,7 @@ static int xmb_draw_item(
if (use_smooth_ticker)
{
ticker_smooth.selected = (i == current);
ticker_smooth.field_width = xmb->font_size * 0.5f * 35 * scale_mod[7];
ticker_smooth.field_width = xmb->font_size * 0.5f * 35 * xmb_scale_mod[7];
ticker_smooth.src_str = entry.value;
ticker_smooth.dst_str = tmp;
ticker_smooth.dst_str_len = sizeof(tmp);
@ -3379,7 +3379,7 @@ static int xmb_draw_item(
else
{
ticker.s = tmp;
ticker.len = 35 * scale_mod[7];
ticker.len = 35 * xmb_scale_mod[7];
ticker.selected = (i == current);
ticker.str = entry.value;
@ -4694,7 +4694,7 @@ static void xmb_frame(void *data, video_frame_info_t *video_info)
left_thumbnail_margin_width = xmb->icon_size * 3.4f;
right_thumbnail_margin_width =
(float)video_width - (xmb->icon_size / 6) -
(xmb->margins_screen_left * scale_mod[5]) -
(xmb->margins_screen_left * xmb_scale_mod[5]) -
xmb->icon_spacing_horizontal - pseudo_font_length;
thumbnail_margin_height_under = ((float)video_height * under_thumb_margin) - xmb->margins_screen_top - xmb->icon_size;
thumbnail_margin_height_full = (float)video_height - xmb->margins_title_top - ((xmb->icon_size / 4.0f) * 2.0f);
@ -4726,10 +4726,10 @@ static void xmb_frame(void *data, video_frame_info_t *video_info)
xmb->raster_block.carr.coords.vertices = 0;
xmb->raster_block2.carr.coords.vertices = 0;
gfx_display_set_alpha(coord_black, MIN(
gfx_display_set_alpha(xmb_coord_black, MIN(
(float)xmb_alpha_factor / 100,
xmb->alpha));
gfx_display_set_alpha(coord_white, xmb->alpha);
gfx_display_set_alpha(xmb_coord_white, xmb->alpha);
xmb_draw_bg(
userdata,
@ -4742,8 +4742,8 @@ static void xmb_frame(void *data, video_frame_info_t *video_info)
libretro_running,
xmb->alpha,
xmb->textures.bg,
coord_black,
coord_white);
xmb_coord_black,
xmb_coord_white);
selection = menu_navigation_get_selection();
@ -5014,7 +5014,7 @@ static void xmb_frame(void *data, video_frame_info_t *video_info)
size_t x_pos = xmb->icon_size / 6;
size_t x_pos_icon = xmb->margins_title_left;
if (coord_white[3] != 0 && !xmb->assets_missing)
if (xmb_coord_white[3] != 0 && !xmb->assets_missing)
{
if (dispctx && dispctx->blend_begin)
dispctx->blend_begin(userdata);
@ -5065,7 +5065,7 @@ static void xmb_frame(void *data, video_frame_info_t *video_info)
char timedate[255];
int x_pos = 0;
if (coord_white[3] != 0 && !xmb->assets_missing)
if (xmb_coord_white[3] != 0 && !xmb->assets_missing)
{
int x_pos = 0;
@ -5119,7 +5119,7 @@ static void xmb_frame(void *data, video_frame_info_t *video_info)
gfx_display_set_alpha(item_color,
MIN(xmb->textures_arrow_alpha, xmb->alpha));
if (coord_white[3] != 0 && !xmb->assets_missing)
if (xmb_coord_white[3] != 0 && !xmb->assets_missing)
{
if (dispctx && dispctx->blend_begin)
dispctx->blend_begin(userdata);
@ -5322,14 +5322,14 @@ static void xmb_frame(void *data, video_frame_info_t *video_info)
bool cursor_visible = (video_fullscreen || mouse_grabbed) &&
menu_mouse_enable;
gfx_display_set_alpha(coord_white, MIN(xmb->alpha, 1.00f));
gfx_display_set_alpha(xmb_coord_white, MIN(xmb->alpha, 1.00f));
if (cursor_visible)
gfx_display_draw_cursor(
userdata,
video_width,
video_height,
cursor_visible,
&coord_white[0],
&xmb_coord_white[0],
xmb->cursor_size,
xmb->textures.list[XMB_TEXTURE_POINTER],
xmb->pointer.x,
@ -5381,7 +5381,7 @@ static void xmb_layout_ps3(xmb_handle_t *xmb, int width)
xmb->margins_label_left = 85.0 * scale_factor;
xmb->margins_label_top = new_font_size / 3.0;
xmb->margins_setting_left = 600.0 * scale_factor * scale_mod[6];
xmb->margins_setting_left = 600.0 * scale_factor * xmb_scale_mod[6];
xmb->margins_dialog = 48 * scale_factor;
xmb->margins_slice = 16 * scale_factor;
@ -5592,25 +5592,25 @@ static void *xmb_init(void **userdata, bool video_is_threaded)
if (scale_value < 100)
{
/* text length & word wrap (base 35 apply to file browser, 1st column) */
scale_mod[0] = -0.03 * scale_value + 4.083;
xmb_scale_mod[0] = -0.03 * scale_value + 4.083;
/* playlist text length when thumbnail is ON (small, base 40) */
scale_mod[1] = -0.03 * scale_value + 3.95;
xmb_scale_mod[1] = -0.03 * scale_value + 3.95;
/* playlist text length when thumbnail is OFF (large, base 70) */
scale_mod[2] = -0.02 * scale_value + 3.033;
xmb_scale_mod[2] = -0.02 * scale_value + 3.033;
/* sub-label length & word wrap */
scale_mod[3] = -0.014 * scale_value + 2.416;
xmb_scale_mod[3] = -0.014 * scale_value + 2.416;
/* thumbnail size & vertical margin from top */
scale_mod[4] = -0.03 * scale_value + 3.916;
xmb_scale_mod[4] = -0.03 * scale_value + 3.916;
/* thumbnail horizontal left margin (horizontal positioning) */
scale_mod[5] = -0.06 * scale_value + 6.933;
xmb_scale_mod[5] = -0.06 * scale_value + 6.933;
/* margin before 2nd column start (shaders parameters, cheats...) */
scale_mod[6] = -0.028 * scale_value + 3.866;
xmb_scale_mod[6] = -0.028 * scale_value + 3.866;
/* text length & word wrap (base 35 apply to 2nd column in cheats, shaders, etc) */
scale_mod[7] = 134.179 * pow(scale_value, -1.0778);
xmb_scale_mod[7] = 134.179 * pow(scale_value, -1.0778);
for (i = 0; i < 8; i++)
if (scale_mod[i] < 1)
scale_mod[i] = 1;
if (xmb_scale_mod[i] < 1)
xmb_scale_mod[i] = 1;
}
if (!menu)
@ -6158,7 +6158,7 @@ static void xmb_context_reset_textures(
(settings->uints.menu_xmb_theme == XMB_ICON_THEME_MONOCHROME_INVERTED) ||
(settings->uints.menu_xmb_theme == XMB_ICON_THEME_AUTOMATIC_INVERTED)
)
memcpy(item_color, coord_black, sizeof(item_color));
memcpy(item_color, xmb_coord_black, sizeof(item_color));
else
{
if (
@ -6177,7 +6177,7 @@ static void xmb_context_reset_textures(
}
}
else
memcpy(item_color, coord_white, sizeof(item_color));
memcpy(item_color, xmb_coord_white, sizeof(item_color));
}
return;

View File

@ -3851,7 +3851,7 @@ static unsigned menu_displaylist_parse_content_information(
/* Silence gcc compiler warning
* (getting so sick of these...) */
if ((n < 0) || (n >= PATH_MAX_LENGTH))
if (n >= PATH_MAX_LENGTH)
n = 0;
(void)n;
if (menu_entries_append_enum(info->list, tmp,
@ -3874,7 +3874,7 @@ static unsigned menu_displaylist_parse_content_information(
/* Silence gcc compiler warning
* (getting so sick of these...) */
if ((n < 0) || (n >= PATH_MAX_LENGTH))
if (n >= PATH_MAX_LENGTH)
n = 0;
(void)n;
@ -3899,7 +3899,7 @@ static unsigned menu_displaylist_parse_content_information(
/* Silence gcc compiler warning
* (getting so sick of these...) */
if ((n < 0) || (n >= PATH_MAX_LENGTH))
if (n >= PATH_MAX_LENGTH)
n = 0;
(void)n;
@ -3971,7 +3971,7 @@ static unsigned menu_displaylist_parse_content_information(
/* Silence gcc compiler warning
* (getting so sick of these...) */
if ((n < 0) || (n >= PATH_MAX_LENGTH))
if (n >= PATH_MAX_LENGTH)
n = 0;
(void)n;
@ -4009,7 +4009,7 @@ static unsigned menu_displaylist_parse_content_information(
/* Silence gcc compiler warning
* (getting so sick of these...) */
if ((n < 0) || (n >= PATH_MAX_LENGTH))
if (n >= PATH_MAX_LENGTH)
n = 0;
(void)n;

View File

@ -2274,7 +2274,6 @@ static bool menu_driver_displaylist_push_internal(
else if (string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_PLAYLISTS_TAB)))
{
struct rarch_state *p_rarch = &rarch_st;
settings_t *settings = p_rarch->configuration_settings;
const char *dir_playlist = settings->paths.directory_playlist;
filebrowser_clear_type();
@ -2465,7 +2464,7 @@ int generic_menu_entry_action(
bool pending_push = false;
menu_driver_ctl(MENU_NAVIGATION_CTL_CLEAR, &pending_push);
}
else if (selection_buf_size > 0)
else
menu_driver_ctl(MENU_NAVIGATION_CTL_SET_LAST, NULL);
}
@ -2738,11 +2737,11 @@ void menu_entry_get(menu_entry_t *entry, size_t stack_idx,
{
if (entry->enum_idx == MENU_ENUM_LABEL_CHEEVOS_PASSWORD)
{
size_t i;
size_t j;
size_t size = strlcpy(entry->password_value, entry->value,
sizeof(entry->password_value));
for (i = 0; i < size; i++)
entry->password_value[i] = '*';
for (j = 0; j < size; j++)
entry->password_value[j] = '*';
}
}
}
@ -12351,24 +12350,7 @@ static void command_event_init_controllers(struct rarch_state *p_rarch)
pad.device = device;
pad.port = i;
switch (device)
{
case RETRO_DEVICE_JOYPAD:
/* Ideally these checks shouldn't be required but if we always
* call core_set_controller_port_device input won't work on
* cores that don't set port information properly */
if (ports_size != 0)
core_set_controller_port_device(&pad);
break;
case RETRO_DEVICE_NONE:
default:
/* Some cores do not properly range check port argument.
* This is broken behavior of course, but avoid breaking
* cores needlessly. */
core_set_controller_port_device(&pad);
break;
}
core_set_controller_port_device(&pad);
}
}
@ -17709,7 +17691,18 @@ static bool rarch_environment_cb(unsigned cmd, void *data)
}
#if defined(HAVE_OPENGL) || defined(HAVE_OPENGL_CORE)
if (!gl_set_core_context(cb->context_type)) { }
/* TODO/FIXME - should check first if an OpenGL
* driver is running */
if (cb->context_type == RETRO_HW_CONTEXT_OPENGL_CORE)
{
/* Ensure that the rest of the frontend knows
* we have a core context */
gfx_ctx_flags_t flags;
flags.flags = 0;
BIT32_SET(flags.flags, GFX_CTX_FLAGS_GL_CORE_CONTEXT);
video_context_driver_set_flags(&flags);
}
#endif
cb->get_current_framebuffer = video_driver_get_current_framebuffer;

View File

@ -1804,23 +1804,6 @@ void video_driver_set_gpu_api_devices(enum gfx_ctx_api api, struct string_list *
struct string_list* video_driver_get_gpu_api_devices(enum gfx_ctx_api api);
static INLINE bool gl_set_core_context(enum retro_hw_context_type ctx_type)
{
gfx_ctx_flags_t flags;
if (ctx_type != RETRO_HW_CONTEXT_OPENGL_CORE)
return false;
/**
* Ensure that the rest of the frontend knows we have a core context
*/
flags.flags = 0;
BIT32_SET(flags.flags, GFX_CTX_FLAGS_GL_CORE_CONTEXT);
video_context_driver_set_flags(&flags);
return true;
}
extern video_driver_t video_gl_core;
extern video_driver_t video_gl2;
extern video_driver_t video_gl1;

View File

@ -1129,7 +1129,7 @@ void runtime_log_get_last_played_str(runtime_log_t *runtime_log,
n = strlcat(str, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PLAYLIST_INLINE_CORE_DISPLAY_NEVER), len);
}
if ((n < 0) || (n >= 64))
if (n >= 64)
n = 0; /* Silence GCC warnings... */
(void)n;
}