Silence some static code analysis warnings + code formatting/style nits

This commit is contained in:
libretroadmin 2025-07-18 08:11:25 +02:00
parent dddc66c797
commit 80b3ccebba
14 changed files with 80 additions and 77 deletions

View File

@ -1961,8 +1961,8 @@ static bool d3d11_init_swapchain(d3d11_video_t* d3d11,
BOOL allow_tearing_supported = FALSE;
if (SUCCEEDED(dxgiFactory5->lpVtbl->CheckFeatureSupport(
dxgiFactory5, DXGI_FEATURE_PRESENT_ALLOW_TEARING,
&allow_tearing_supported, sizeof(allow_tearing_supported))) &&
allow_tearing_supported)
&allow_tearing_supported, sizeof(allow_tearing_supported)))
&& allow_tearing_supported)
{
desc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_DISCARD;
desc.Flags |= DXGI_SWAP_CHAIN_FLAG_ALLOW_TEARING;

View File

@ -2518,8 +2518,8 @@ static bool video_shader_dir_init_shader_internal(
* index if found */
file_name = path_basename(file_path);
if ( !string_is_empty(file_name) &&
string_is_equal(file_name, shader_file_name))
if ( !string_is_empty(file_name)
&& string_is_equal(file_name, shader_file_name))
{
RARCH_LOG("[Shaders] %s \"%s\".\n",
msg_hash_to_str(MSG_FOUND_SHADER),

View File

@ -5033,7 +5033,7 @@ static void ozone_context_reset_horizontal_list(ozone_handle_t *ozone)
__len = fill_pathname_join_special(texturepath,
ozone->icons_path, sysname,
sizeof(texturepath));
__len += strlcpy(texturepath + __len, ".png", sizeof(texturepath) - __len);
strlcpy(texturepath + __len, ".png", sizeof(texturepath) - __len);
/* If the playlist icon doesn't exist, return default */
if (!path_is_valid(texturepath))
@ -5088,6 +5088,7 @@ static void ozone_context_reset_horizontal_list(ozone_handle_t *ozone)
if (node->console_name)
free(node->console_name);
node->console_name = NULL;
/* Note: console_name will *always* be valid here,
* but provide a fallback to prevent NULL pointer

View File

@ -225,7 +225,7 @@ static void input_autoconfigure_set_config_file(
sizeof(config_key));
/* Read device display name */
if (alternative > 0)
_len += snprintf(config_key + _len, sizeof(config_key) - _len,
snprintf(config_key + _len, sizeof(config_key) - _len,
"_alt%d",alternative);
if ( (entry = config_get_entry(config, config_key))
@ -255,8 +255,8 @@ static bool input_autoconfigure_scan_config_files_external(
/* Attempt to fetch file listing from driver-specific
* autoconfig directory */
if (!string_is_empty(dir_driver_autoconfig) &&
path_is_directory(dir_driver_autoconfig))
if ( !string_is_empty(dir_driver_autoconfig)
&& path_is_directory(dir_driver_autoconfig))
config_file_list = dir_list_new_special(
dir_driver_autoconfig, DIR_LIST_AUTOCONFIG,
"cfg", false);
@ -271,8 +271,8 @@ static bool input_autoconfigure_scan_config_files_external(
config_file_list = NULL;
}
if (!string_is_empty(dir_autoconfig) &&
path_is_directory(dir_autoconfig))
if ( !string_is_empty(dir_autoconfig)
&& path_is_directory(dir_autoconfig))
config_file_list = dir_list_new_special(
dir_autoconfig, DIR_LIST_AUTOCONFIG,
"cfg", false);
@ -491,11 +491,11 @@ static void reallocate_port_if_needed(unsigned detected_port, int vendor_id,
if (device_has_reserved_slot)
{
unsigned prev_assigned_port = settings->uints.input_joypad_index[player];
if ( detected_port != prev_assigned_port &&
!string_is_empty(input_config_get_device_name(prev_assigned_port)) &&
(( settings_value_vendor_id == input_config_get_device_vid(prev_assigned_port) &&
settings_value_product_id == input_config_get_device_pid(prev_assigned_port)) ||
strcmp(input_config_get_device_name(prev_assigned_port), settings_value_device_name) == 0))
if ( detected_port != prev_assigned_port
&& !string_is_empty(input_config_get_device_name(prev_assigned_port))
&& (( settings_value_vendor_id == input_config_get_device_vid(prev_assigned_port)
&& settings_value_product_id == input_config_get_device_pid(prev_assigned_port))
|| strcmp(input_config_get_device_name(prev_assigned_port), settings_value_device_name) == 0))
{
RARCH_DBG("[Autoconf] Same type of device already took this slot, continuing search...\n");
device_has_reserved_slot = false;
@ -706,8 +706,8 @@ static void input_autoconfigure_connect_handler(retro_task_t *task)
"test"))
fallback_device_name = "Test Gamepad";
#endif
if (!string_is_empty(fallback_device_name) &&
!string_is_equal(autoconfig_handle->device_info.name,
if ( !string_is_empty(fallback_device_name)
&& !string_is_equal(autoconfig_handle->device_info.name,
fallback_device_name))
{
char *name_backup = strdup(autoconfig_handle->device_info.name);
@ -926,12 +926,12 @@ bool input_autoconfigure_connect(
uint16_t last_pid = input_config_get_device_pid(port);
bool last_autoconfigured = input_config_get_device_autoconfigured(port);
if (!string_is_empty(last_device_name) &&
string_is_equal(autoconfig_handle->device_info.name,
last_device_name) &&
(autoconfig_handle->device_info.vid == last_vid) &&
(autoconfig_handle->device_info.pid == last_pid) &&
last_autoconfigured)
if ( !string_is_empty(last_device_name)
&& string_is_equal(autoconfig_handle->device_info.name,
last_device_name)
&& (autoconfig_handle->device_info.vid == last_vid)
&& (autoconfig_handle->device_info.pid == last_pid)
&& last_autoconfigured)
autoconfig_handle->flags |= AUTOCONF_FLAG_SUPPRESS_NOTIFICATIONS;
}

View File

@ -1006,9 +1006,9 @@ static bool content_file_load(
#ifdef HAVE_COMPRESSION
/* If this is compressed content and need_fullpath
* is true, extract it to a temporary file */
if (content_compressed &&
!CONTENT_FILE_ATTR_GET_BLOCK_EXTRACT(content->elems[i].attr) &&
!content_file_extract_from_archive(content_ctx, p_content,
if ( content_compressed
&& !CONTENT_FILE_ATTR_GET_BLOCK_EXTRACT(content->elems[i].attr)
&& !content_file_extract_from_archive(content_ctx, p_content,
valid_exts, &content_path, error_string))
return false;
#endif
@ -1797,8 +1797,8 @@ static bool task_push_to_history_list_from_playlist_pre_load_static(
}
}
if (!string_is_empty(core_path) &&
playlist_hist)
if ( !string_is_empty(core_path)
&& playlist_hist)
{
struct playlist_entry new_entry = {0};

View File

@ -158,8 +158,8 @@ static bool task_core_backup_finder(retro_task_t *task, void *user_data)
if (!task || !user_data)
return false;
if ((task->handler != task_core_backup_handler) &&
(task->handler != task_core_restore_handler))
if ( (task->handler != task_core_backup_handler)
&& (task->handler != task_core_restore_handler))
return false;
backup_handle = (core_backup_handle_t*)task->state;
@ -447,17 +447,17 @@ static void task_core_backup_handler(retro_task_t *task)
* by timestamp - simply loop from start to end
* and delete automatic backups until the required
* number have been removed */
while ((backup_handle->backup_index < list_size) &&
(backup_handle->num_auto_backups_to_remove > 0))
while ( (backup_handle->backup_index < list_size)
&& (backup_handle->num_auto_backups_to_remove > 0))
{
const core_backup_list_entry_t *entry = NULL;
if (core_backup_list_get_index(
backup_handle->backup_list,
backup_handle->backup_index,
&entry) &&
entry &&
(entry->backup_mode == CORE_BACKUP_MODE_AUTO))
&entry)
&& entry
&& (entry->backup_mode == CORE_BACKUP_MODE_AUTO))
{
/* Delete backup file (if it exists) */
if (path_is_valid(entry->backup_path))
@ -794,8 +794,8 @@ static void task_core_restore_handler(retro_task_t *task)
const char *core_filename = path_basename(
backup_handle->core_path);
if (play_feature_delivery_core_installed(core_filename) &&
!play_feature_delivery_delete(core_filename))
if ( play_feature_delivery_core_installed(core_filename)
&& !play_feature_delivery_delete(core_filename))
{
RARCH_ERR("[Core Restore] Failed to delete existing play feature delivery core: \"%s\".\n",
backup_handle->core_path);

View File

@ -701,8 +701,8 @@ static void task_core_updater_download_handler(retro_task_t *task)
/* Check whether existing core and remote core
* have the same CRC */
download_handle->crc_match = (download_handle->local_crc != 0) &&
(download_handle->local_crc == download_handle->remote_crc);
download_handle->crc_match = (download_handle->local_crc != 0)
&& (download_handle->local_crc == download_handle->remote_crc);
/* If CRC matches, end task immediately */
if (download_handle->crc_match)
@ -1751,8 +1751,8 @@ static void task_play_feature_delivery_core_install_handler(
task_set_title(task, strdup(task_title));
/* Check whether a core backup file was created */
if (!string_is_empty(pfd_install_handle->backup_core_path) &&
path_is_valid(pfd_install_handle->backup_core_path))
if ( !string_is_empty(pfd_install_handle->backup_core_path)
&& path_is_valid(pfd_install_handle->backup_core_path))
{
/* If install was successful, delete backup */
if (pfd_install_handle->success)
@ -2001,8 +2001,8 @@ static void task_play_feature_delivery_switch_cores_handler(
if (core_updater_list_get_index(
pfd_switch_cores_handle->core_list,
pfd_switch_cores_handle->list_index,
&list_entry) &&
path_is_valid(list_entry->local_core_path))
&list_entry)
&& path_is_valid(list_entry->local_core_path))
{
core_installed = true;
pfd_switch_cores_handle->installed_index =

View File

@ -843,8 +843,8 @@ static int database_info_list_iterate_found_match(
entry_path_str, archive_name, '#', str_len);
if (core_info_database_match_archive_member(
db_state->list->elems[db_state->list_index].data) &&
(hash = strchr(entry_path_str, '#')))
db_state->list->elems[db_state->list_index].data)
&& (hash = strchr(entry_path_str, '#')))
*hash = '\0';
#if !defined(RARCH_INTERNAL)

View File

@ -344,14 +344,15 @@ bool task_image_load_handler(retro_task_t *task)
/* Upscale image, if required */
if (image->upscale_threshold > 0)
{
if (((image->ti.width > 0) && (image->ti.height > 0)) &&
((image->ti.width < image->upscale_threshold) ||
(image->ti.height < image->upscale_threshold)))
if ( ((image->ti.width > 0)
&& (image->ti.height > 0))
&& ((image->ti.width < image->upscale_threshold)
|| (image->ti.height < image->upscale_threshold)))
{
unsigned min_size = (image->ti.width < image->ti.height) ?
image->ti.width : image->ti.height;
float scale_factor = (float)image->upscale_threshold /
(float)min_size;
unsigned min_size = (image->ti.width < image->ti.height)
? image->ti.width : image->ti.height;
float scale_factor = (float)image->upscale_threshold
/ (float)min_size;
unsigned scale_factor_int = (unsigned)scale_factor;
struct texture_image img_resampled = {
NULL,

View File

@ -312,8 +312,8 @@ static void task_manual_content_scan_handler(retro_task_t *task)
msg_hash_to_str(MSG_MANUAL_CONTENT_SCAN_PLAYLIST_CLEANUP),
sizeof(task_title));
if (!string_is_empty(entry->path) &&
(entry_file = path_basename(entry->path)))
if ( !string_is_empty(entry->path)
&& (entry_file = path_basename(entry->path)))
strlcpy(task_title + _len,
entry_file,
sizeof(task_title) - _len);
@ -328,9 +328,9 @@ static void task_manual_content_scan_handler(retro_task_t *task)
delete_entry = true;
/* If file exists, check whether it has a
* permitted file extension */
else if (manual_scan->file_exts_list &&
(entry_file_ext = path_get_extension(entry->path)) &&
!string_list_find_elem_prefix(
else if ( manual_scan->file_exts_list
&& (entry_file_ext = path_get_extension(entry->path))
&& !string_list_find_elem_prefix(
manual_scan->file_exts_list,
".", entry_file_ext))
delete_entry = true;

View File

@ -121,8 +121,8 @@ static bool find_content_by_crc(playlist_config_t *playlist_config,
if (!entry)
continue;
if (string_is_equal(entry->crc32, crc_ident) &&
!string_is_empty(entry->path))
if (string_is_equal(entry->crc32, crc_ident)
&& !string_is_empty(entry->path))
{
if (!string_list_append(paths, entry->path, attr))
{
@ -294,19 +294,20 @@ static void task_netplay_crc_scan_handler(retro_task_t *task)
}
}
if (string_is_empty(data->subsystem) ||
string_is_equal_case_insensitive(data->subsystem, "N/A"))
if ( string_is_empty(data->subsystem)
|| string_is_equal_case_insensitive(data->subsystem, "N/A"))
{
if (data->current.core_loaded && data->extensions &&
!string_is_empty(data->current.content) &&
!string_is_empty(data->current.extension))
if ( data->current.core_loaded
&& data->extensions
&& !string_is_empty(data->current.content)
&& !string_is_empty(data->current.extension))
{
if (!data->current.subsystem_content ||
!data->current.subsystem_content->size)
if ( !data->current.subsystem_content
|| !data->current.subsystem_content->size)
{
if (string_is_equal_case_insensitive(
data->current.content, data->content) &&
string_list_find_elem(
data->current.content, data->content)
&& string_list_find_elem(
data->extensions, data->current.extension))
{
RARCH_LOG("[Lobby] Filename match with currently loaded content.\n");
@ -933,8 +934,8 @@ bool task_push_netplay_content_reload(const char *hostname)
}
}
if ((flags & CONTENT_ST_FLAG_CORE_DOES_NOT_NEED_CONTENT) &&
!(scan_state.state & (STATE_LOAD|STATE_LOAD_SUBSYSTEM)))
if ( (flags & CONTENT_ST_FLAG_CORE_DOES_NOT_NEED_CONTENT)
&& !(scan_state.state & (STATE_LOAD|STATE_LOAD_SUBSYSTEM)))
scan_state.state |= STATE_LOAD_CONTENTLESS;
data->current.core_loaded = true;

View File

@ -140,9 +140,9 @@ done:
struct sockaddr_in addr = {0};
socklen_t addrlen = sizeof(addr);
if (!connect(dummy_fd, (struct sockaddr*)&device->addr,
sizeof(device->addr)) &&
!getsockname(dummy_fd, (struct sockaddr*)&addr, &addrlen))
if ( !connect(dummy_fd, (struct sockaddr*)&device->addr,
sizeof(device->addr))
&& !getsockname(dummy_fd, (struct sockaddr*)&addr, &addrlen))
{
/* Make sure this is not "0.0.0.0". */
if (addr.sin_addr.s_addr)

View File

@ -846,8 +846,8 @@ static bool task_pl_entry_thumbnail_finder(retro_task_t *task, void *user_data)
{
pl_thumb_handle_t *pl_thumb = NULL;
if ((pl_thumb = (pl_thumb_handle_t*)task->state))
return (entry_id->idx == pl_thumb->list_index) &&
string_is_equal(entry_id->playlist_path, pl_thumb->playlist_path);
return (entry_id->idx == pl_thumb->list_index)
&& string_is_equal(entry_id->playlist_path, pl_thumb->playlist_path);
}
return false;
}

View File

@ -1517,8 +1517,8 @@ QString MainWindow::getPlaylistDefaultCore(QString plName)
const char *defaultCorePath = playlist_get_default_core_path(playlist);
/* Get default core path */
if (!string_is_empty(defaultCorePath) &&
!string_is_equal(defaultCorePath, "DETECT"))
if ( !string_is_empty(defaultCorePath)
&& !string_is_equal(defaultCorePath, "DETECT"))
corePath = QString::fromUtf8(defaultCorePath);
/* Free playlist, if required */