Fix errors and warnings pointed out by static code analysis (Clang)

This commit is contained in:
libretroadmin 2025-07-17 08:49:53 +02:00
parent c6d72062e2
commit f45fd77d68
15 changed files with 35 additions and 30 deletions

View File

@ -102,9 +102,9 @@ static bool grab_region(dsound_t *ds, uint32_t write_ptr,
#ifdef DEBUG
RARCH_WARN("[DirectSound] %s.\n", "DSERR_BUFFERLOST");
#endif
if ((res = IDirectSoundBuffer_Restore(ds->dsb)) != DS_OK)
if ((IDirectSoundBuffer_Restore(ds->dsb)) != DS_OK)
return false;
if ((res = IDirectSoundBuffer_Lock(ds->dsb, write_ptr, CHUNK_SIZE,
if ((IDirectSoundBuffer_Lock(ds->dsb, write_ptr, CHUNK_SIZE,
&region->chunk1, &region->size1, &region->chunk2, &region->size2, 0)) != DS_OK)
return false;
return true;

View File

@ -1899,7 +1899,8 @@ static void gl2_renderchain_init(
width = gl->video_width;
height = gl->video_height;
scaler.scale = &scale;
scaler.scale = &scale;
scaler.scale->flags = 0;
gl2_shader_scale(gl, &scaler, 1);

View File

@ -96,9 +96,9 @@ static void gfx_ctx_w_vk_check_window(void *data, bool *quit,
*/
if ( (win32_vk.flags & VK_DATA_FLAG_FULLSCREEN)
&& (g_win32_refresh_rate)
&& (g_win32_refresh_rate != refresh_rate)
&& (g_win32_refresh_rate != refresh_rate)
&& (fabsf(g_win32_refresh_rate - refresh_rate) > 0.1f)
&& (g_win32_resize_width == *width)
&& (g_win32_resize_width == *width)
&& (g_win32_resize_height == *height))
{
g_win32_refresh_rate = settings->floats.video_refresh_rate;
@ -234,10 +234,9 @@ static void gfx_ctx_w_vk_input_driver(void *data,
const char *joypad_name,
input_driver_t **input, void **input_data)
{
settings_t *settings = config_get_ptr();
#if _WIN32_WINNT >= 0x0501
#ifdef HAVE_WINRAWINPUT
settings_t *settings = config_get_ptr();
const char *input_driver = settings->arrays.input_driver;
/* winraw only available since XP */

View File

@ -4429,7 +4429,7 @@ static void video_frame_delay_leftover(video_driver_state_t *video_st,
static uint8_t overtime_count = 0; /* Frames to wait for another frame drop to increase reserve */
static uint8_t predict_count = 0; /* Frames to wait for another predictive delay decrease */
int8_t frame_delay_cur = *video_frame_delay_effective;
int8_t frame_delay_new = *video_frame_delay_effective;
int8_t frame_delay_new = 0;
bool frame_time_over = false;
bool frame_time_near = false;

View File

@ -1114,20 +1114,25 @@ static bool video_shader_write_root_preset(const struct video_shader *shader,
size_t i;
char key[64];
bool ret = true;
char *tmp = (char*)malloc(3 * PATH_MAX_LENGTH);
char *tmp_rel = tmp + PATH_MAX_LENGTH;
char *tmp_base = tmp + 2 * PATH_MAX_LENGTH;
char *tmp = NULL;
char *tmp_rel = NULL;
char *tmp_base = NULL;
config_file_t *conf = config_file_new_alloc();
if (!conf)
return false;
tmp = (char*)malloc(3 * PATH_MAX_LENGTH);
if (!tmp)
{
config_file_free(conf);
return false;
}
tmp_rel = tmp + PATH_MAX_LENGTH;
tmp_base = tmp + 2 * PATH_MAX_LENGTH;
RARCH_DBG("[Shaders] Saving full preset to: \"%s\".\n", path);
config_set_int(conf, "shaders", shader->passes);

View File

@ -862,7 +862,7 @@ static int16_t input_joypad_axis(
const input_device_driver_t *drv,
unsigned port, uint32_t joyaxis, float normal_mag)
{
int16_t val = (joyaxis != AXIS_NONE) ? drv->axis(port, joyaxis) : 0;
int16_t val = ((joyaxis != AXIS_NONE) && drv) ? drv->axis(port, joyaxis) : 0;
if (input_analog_deadzone)
{
@ -4226,8 +4226,6 @@ static bool input_keyboard_line_event(
composition = character & 0xffffff;
character &= 0xffffff;
}
if (_len && composition == 0)
word = state->buffer;
if (character)
input_keyboard_line_append(state, (char*)&character, strlen((char*)&character));
word = state->buffer;

View File

@ -671,11 +671,11 @@ static void net_http_conn_pool_remove(struct conn_pool_entry *entry)
/* *NOT* thread safe, caller must lock */
static void net_http_conn_pool_remove_expired(void)
{
struct conn_pool_entry *entry = conn_pool;
struct conn_pool_entry *prev = NULL;
struct timeval tv = { 0 };
int max = 0;
fd_set fds;
struct conn_pool_entry *entry = NULL;
struct conn_pool_entry *prev = NULL;
struct timeval tv = { 0 };
int max = 0;
FD_ZERO(&fds);
entry = conn_pool;
while (entry)

View File

@ -478,7 +478,6 @@ int filestream_cmp(const char *src, const char *dst)
{
char buf_src[256] = {0};
char buf_dst[256] = {0};
int64_t n = 0;
int ret = 0;
RFILE *fp_src = filestream_open(src, RETRO_VFS_FILE_ACCESS_READ, RETRO_VFS_FILE_ACCESS_HINT_NONE);
@ -490,7 +489,7 @@ int filestream_cmp(const char *src, const char *dst)
if (ret < 0)
goto close;
while ((n = filestream_read(fp_src, buf_src, sizeof(buf_src))) > 0 && ret == 0)
while ((filestream_read(fp_src, buf_src, sizeof(buf_src))) > 0 && ret == 0)
{
filestream_read(fp_dst, buf_dst, sizeof(buf_dst));
ret = memcmp(buf_src, buf_dst, sizeof(buf_src));

View File

@ -434,7 +434,7 @@ static int general_push(menu_displaylist_info_t *info,
{
size_t _len = 0;
size_t size = PATH_MAX_LENGTH;
char *newstr2 = malloc(size);
char *newstr2 = NULL;
settings_t *settings = config_get_ptr();
menu_handle_t *menu = menu_state_get_ptr()->driver_data;
#if defined(HAVE_FFMPEG) || defined(HAVE_MPV) || defined (HAVE_AUDIOMIXER)
@ -444,8 +444,9 @@ static int general_push(menu_displaylist_info_t *info,
#ifdef HAVE_IMAGEVIEWER
bool multimedia_builtin_imageviewer_enable = settings->bools.multimedia_builtin_imageviewer_enable;
#endif
if (!menu || !newstr2)
if (!menu)
return -1;
if (!(newstr2 = (char*)malloc(size)))
return -1;
if ( (id == PUSH_ARCHIVE_OPEN_DETECT_CORE)

View File

@ -3730,7 +3730,7 @@ static int generic_action_ok_remap_file_operation(const char *path,
/* Build the new path with the controller name */
_len = strlcpy(remap_path, core_name, sizeof(remap_path));
_len += strlcpy(remap_path + _len, PATH_DEFAULT_SLASH(), sizeof(remap_path) - _len);
_len += strlcpy(remap_path + _len, input_device_dir, sizeof(remap_path) - _len);
strlcpy(remap_path + _len, input_device_dir, sizeof(remap_path) - _len);
/* Deallocate as we no longer this */
free((char*)input_device_dir);
@ -6442,7 +6442,7 @@ static int action_ok_rdb_entry_submenu(const char *path,
if ((tok = strtok_r(NULL, "|", &save)))
{
_len += strlcpy(new_str + _len, "|", sizeof(new_str) - _len);
_len += strlcpy(new_str + _len, tok, sizeof(new_str) - _len);
strlcpy(new_str + _len, tok, sizeof(new_str) - _len);
}
free(label_cpy);
return generic_action_ok_displaylist_push(

View File

@ -11305,6 +11305,7 @@ static void materialui_list_insert(void *userdata,
node->thumbnails.primary.height = 0;
node->thumbnails.primary.alpha = 0.0f;
node->thumbnails.primary.delay_timer = 0.0f;
node->thumbnails.primary.flags = 0;
node->thumbnails.primary.flags &= ~GFX_THUMB_FLAG_FADE_ACTIVE;
node->thumbnails.secondary.status = GFX_THUMBNAIL_STATUS_UNKNOWN;

View File

@ -5033,7 +5033,7 @@ static void ozone_context_reset_horizontal_list(ozone_handle_t *ozone)
/* If the playlist icon doesn't exist, return default */
if (!path_is_valid(texturepath))
__len = fill_pathname_join_special(
fill_pathname_join_special(
texturepath, ozone->icons_path, "default.png",
sizeof(texturepath));

View File

@ -7101,7 +7101,7 @@ static unsigned menu_displaylist_netplay_refresh_rooms(file_list_t *list)
{
_len += strlcpy(s + _len, " (", sizeof(s) - _len);
_len += strlcpy(s + _len, room->country, sizeof(s) - _len);
_len += strlcpy(s + _len, ")", sizeof(s) - _len);
strlcpy(s + _len, ")", sizeof(s) - _len);
}
if (menu_entries_append(list, s, cnc_netplay_room,

View File

@ -4811,7 +4811,7 @@ bool command_event(enum event_command cmd, void *data)
sizeof(tmp_netplay_server)))
{
netplay_server = tmp_netplay_server;
netplay_session = tmp_netplay_session;
netplay_session = strdup(tmp_netplay_session);
}
if (p_rarch->connect_mitm_id)
@ -4834,7 +4834,8 @@ bool command_event(enum event_command cmd, void *data)
if (p_rarch->connect_mitm_id)
{
free(p_rarch->connect_mitm_id);
free(netplay_session);
if (netplay_session)
free(netplay_session);
p_rarch->connect_mitm_id = NULL;
netplay_session = NULL;
}

View File

@ -689,7 +689,7 @@ static enum patch_error xdelta_apply_patch(
} while (stream.avail_in);
*targetdata = (uint8_t*)malloc(*targetlength);
switch (ret = xd3_decode_memory(
switch (xd3_decode_memory(
patchdata, patchlen,
sourcedata, sourcelength,
*targetdata, targetlength, *targetlength, 0))