Small style nits and plain sense cleanups

This commit is contained in:
libretroadmin 2023-08-16 01:14:50 +02:00
parent 797c7ff381
commit c699e47534
4 changed files with 108 additions and 137 deletions

View file

@ -129,16 +129,13 @@ void disk_control_set_ext_callback(
bool disk_control_enabled(
disk_control_interface_t *disk_control)
{
if (!disk_control)
return false;
if (disk_control->cb.set_eject_state &&
disk_control->cb.get_eject_state &&
disk_control->cb.get_image_index &&
disk_control->cb.set_image_index &&
disk_control->cb.get_num_images)
if ( disk_control
&& disk_control->cb.set_eject_state
&& disk_control->cb.get_eject_state
&& disk_control->cb.get_image_index
&& disk_control->cb.set_image_index
&& disk_control->cb.get_num_images)
return true;
return false;
}
@ -419,9 +416,9 @@ bool disk_control_set_index(
if (!disk_control)
return false;
if (!disk_control->cb.get_eject_state ||
!disk_control->cb.get_num_images ||
!disk_control->cb.set_image_index)
if ( !disk_control->cb.get_eject_state
|| !disk_control->cb.get_num_images
|| !disk_control->cb.set_image_index)
return false;
/* Ensure that disk is currently ejected */
@ -460,8 +457,8 @@ bool disk_control_set_index(
* index record (if enabled) */
if (!error && disk_control->record_enabled)
{
if (disk_control->cb.get_image_index &&
disk_control->cb.get_image_path)
if ( disk_control->cb.get_image_index
&& disk_control->cb.get_image_path)
{
char new_image_path[PATH_MAX_LENGTH] = {0};
/* Get current image index + path */
@ -498,8 +495,8 @@ bool disk_control_set_index_next(
if (!disk_control)
return false;
if (!disk_control->cb.get_num_images ||
!disk_control->cb.get_image_index)
if ( !disk_control->cb.get_num_images
|| !disk_control->cb.get_image_index)
return false;
num_images = disk_control->cb.get_num_images();
@ -538,8 +535,8 @@ bool disk_control_set_index_prev(
if (!disk_control)
return false;
if (!disk_control->cb.get_num_images ||
!disk_control->cb.get_image_index)
if ( !disk_control->cb.get_num_images
|| !disk_control->cb.get_image_index)
return false;
num_images = disk_control->cb.get_num_images();
@ -584,11 +581,11 @@ bool disk_control_append_image(
if (!disk_control)
return false;
if (!disk_control->cb.get_image_index ||
!disk_control->cb.get_num_images ||
!disk_control->cb.add_image_index ||
!disk_control->cb.replace_image_index ||
!disk_control->cb.get_eject_state)
if ( !disk_control->cb.get_image_index
|| !disk_control->cb.get_num_images
|| !disk_control->cb.add_image_index
|| !disk_control->cb.replace_image_index
|| !disk_control->cb.get_eject_state)
return false;
if (string_is_empty(image_path))
@ -705,10 +702,10 @@ bool disk_control_set_initial_index(
goto error;
/* Check that 'initial index' functionality is enabled */
if (!disk_control->cb.set_initial_image ||
!disk_control->cb.get_num_images ||
!disk_control->cb.get_image_index ||
!disk_control->cb.get_image_path)
if ( !disk_control->cb.set_initial_image
|| !disk_control->cb.get_num_images
|| !disk_control->cb.get_image_index
|| !disk_control->cb.get_image_path)
goto error;
/* Attempt to initialise disk index record (reading
@ -719,10 +716,10 @@ bool disk_control_set_initial_index(
/* If record is enabled and initial index is *not*
* zero, notify current core */
if (disk_control->record_enabled &&
(disk_control->index_record.image_index != 0))
if ( disk_control->record_enabled
&& (disk_control->index_record.image_index != 0))
{
if (!disk_control->cb.set_initial_image(
if ( !disk_control->cb.set_initial_image(
disk_control->index_record.image_index,
disk_control->index_record.image_path))
{
@ -773,10 +770,10 @@ bool disk_control_verify_initial_index(
return false;
/* Check that 'initial index' functionality is enabled */
if (!disk_control->cb.set_initial_image ||
!disk_control->cb.get_num_images ||
!disk_control->cb.get_image_index ||
!disk_control->cb.get_image_path)
if ( !disk_control->cb.set_initial_image
|| !disk_control->cb.get_num_images
|| !disk_control->cb.get_image_index
|| !disk_control->cb.get_image_path)
return false;
/* Cache initial number of images
@ -798,10 +795,10 @@ bool disk_control_verify_initial_index(
* read here (since this corresponds to a
* 'first run', where no existing disk index
* file was present) */
if ((image_index == disk_control->index_record.image_index) &&
(string_is_equal(image_path, disk_control->index_record.image_path) ||
((disk_control->index_record.image_index == 0) &&
string_is_empty(disk_control->index_record.image_path))))
if ( (image_index == disk_control->index_record.image_index)
&& (string_is_equal(image_path, disk_control->index_record.image_path)
|| ((disk_control->index_record.image_index == 0)
&& string_is_empty(disk_control->index_record.image_path))))
success = true;
}

View file

@ -98,18 +98,6 @@ static bool DCifJSONStringHandler(void* context, const char *pValue, size_t leng
/* Initialisation */
/******************/
/* Resets existing disk index record */
static void disk_index_file_reset(disk_index_file_t *disk_index_file)
{
if (!disk_index_file)
return;
disk_index_file->modified = false;
disk_index_file->image_index = 0;
disk_index_file->image_path[0] = '\0';
disk_index_file->file_path[0] = '\0';
}
/* Parses disk index file referenced by
* disk_index_file->file_path.
* Does nothing if disk index file does not exist. */
@ -127,8 +115,8 @@ static bool disk_index_file_read(disk_index_file_t *disk_index_file)
file_path = disk_index_file->file_path;
if ( string_is_empty(file_path) ||
!path_is_valid(file_path)
if ( string_is_empty(file_path)
|| !path_is_valid(file_path)
)
return false;
@ -147,8 +135,7 @@ static bool disk_index_file_read(disk_index_file_t *disk_index_file)
}
/* Initialise JSON parser */
parser = rjson_open_rfile(file);
if (!parser)
if (!(parser = rjson_open_rfile(file)))
{
RARCH_ERR("[disk index file] Failed to create JSON parser.\n");
goto end;
@ -221,7 +208,6 @@ bool disk_index_file_init(
const char *content_file = NULL;
char content_name[256];
char disk_index_file_dir[PATH_MAX_LENGTH];
char disk_index_file_path[PATH_MAX_LENGTH];
/* Sanity check */
if (!disk_index_file)
@ -269,21 +255,17 @@ bool disk_index_file_init(
/* > Generate final path */
len = fill_pathname_join_special(
disk_index_file_path, disk_index_file_dir,
content_name, sizeof(disk_index_file_path));
strlcpy(disk_index_file_path + len,
disk_index_file->file_path, disk_index_file_dir,
content_name, sizeof(disk_index_file->file_path));
strlcpy(disk_index_file->file_path + len,
".ldci",
sizeof(disk_index_file_path) - len);
if (string_is_empty(disk_index_file_path))
goto error;
sizeof(disk_index_file->file_path) - len);
/* All is well - reset disk_index_file_t and
* attempt to load values from file */
disk_index_file_reset(disk_index_file);
strlcpy(
disk_index_file->file_path,
disk_index_file_path,
sizeof(disk_index_file->file_path));
disk_index_file->modified = false;
disk_index_file->image_index = 0;
disk_index_file->image_path[0] = '\0';
/* > If file does not exist (or some other
* error occurs) then this is a new record
@ -295,7 +277,10 @@ bool disk_index_file_init(
return true;
error:
disk_index_file_reset(disk_index_file);
disk_index_file->modified = false;
disk_index_file->image_index = 0;
disk_index_file->image_path[0] = '\0';
disk_index_file->file_path[0] = '\0';
return false;
}

View file

@ -656,8 +656,8 @@ enum manual_content_scan_playlist_refresh_status
}
/* Set core path/name */
if (!string_is_empty(core_name) &&
!string_is_equal(core_name, FILE_PATH_DETECT))
if ( !string_is_empty(core_name)
&& !string_is_equal(core_name, FILE_PATH_DETECT))
core_type = MANUAL_CONTENT_SCAN_CORE_SET;
if (!manual_content_scan_set_menu_core_name(
@ -749,9 +749,8 @@ bool manual_content_scan_get_menu_content_dir(const char **content_dir)
* actual system name used when generating the playlist */
bool manual_content_scan_get_menu_system_name(const char **system_name)
{
if (!system_name)
return false;
if (system_name)
{
switch (scan_settings.system_name_type)
{
case MANUAL_CONTENT_SCAN_SYSTEM_NAME_CONTENT_DIR:
@ -763,16 +762,16 @@ bool manual_content_scan_get_menu_system_name(const char **system_name)
MENU_ENUM_LABEL_VALUE_MANUAL_CONTENT_SCAN_SYSTEM_NAME_USE_CUSTOM);
return true;
case MANUAL_CONTENT_SCAN_SYSTEM_NAME_DATABASE:
if (string_is_empty(scan_settings.system_name_database))
return false;
else
if (!string_is_empty(scan_settings.system_name_database))
{
*system_name = scan_settings.system_name_database;
return true;
}
break;
default:
break;
}
}
return false;
}
@ -781,9 +780,8 @@ bool manual_content_scan_get_menu_system_name(const char **system_name)
* Returns true if core name is valid. */
bool manual_content_scan_get_menu_core_name(const char **core_name)
{
if (!core_name)
return false;
if (core_name)
{
switch (scan_settings.core_type)
{
case MANUAL_CONTENT_SCAN_CORE_DETECT:
@ -791,16 +789,16 @@ bool manual_content_scan_get_menu_core_name(const char **core_name)
MENU_ENUM_LABEL_VALUE_MANUAL_CONTENT_SCAN_CORE_NAME_DETECT);
return true;
case MANUAL_CONTENT_SCAN_CORE_SET:
if (string_is_empty(scan_settings.core_name))
return false;
else
if (!string_is_empty(scan_settings.core_name))
{
*core_name = scan_settings.core_name;
return true;
}
break;
default:
break;
}
}
return false;
}
@ -925,8 +923,8 @@ struct string_list *manual_content_scan_get_menu_core_name_list(void)
if (core_info_list)
{
core_info_t *core_info = NULL;
size_t i;
core_info_t *core_info = NULL;
/* Sort cores alphabetically */
core_info_qsort(core_info_list, CORE_INFO_LIST_SORT_DISPLAY_NAME);
@ -934,10 +932,7 @@ struct string_list *manual_content_scan_get_menu_core_name_list(void)
/* Loop through cores */
for (i = 0; i < core_info_list->count; i++)
{
core_info = NULL;
core_info = core_info_get(core_info_list, i);
if (core_info)
if ((core_info = core_info_get(core_info_list, i)))
{
if (string_is_empty(core_info->display_name))
continue;
@ -1003,32 +998,26 @@ bool manual_content_scan_get_task_config(
case MANUAL_CONTENT_SCAN_SYSTEM_NAME_CONTENT_DIR:
if (string_is_empty(scan_settings.system_name_content_dir))
return false;
strlcpy(
task_config->system_name,
scan_settings.system_name_content_dir,
sizeof(task_config->system_name));
break;
case MANUAL_CONTENT_SCAN_SYSTEM_NAME_CUSTOM:
if (string_is_empty(scan_settings.system_name_custom))
return false;
strlcpy(
task_config->system_name,
scan_settings.system_name_custom,
sizeof(task_config->system_name));
break;
case MANUAL_CONTENT_SCAN_SYSTEM_NAME_DATABASE:
if (string_is_empty(scan_settings.system_name_database))
return false;
strlcpy(
task_config->system_name,
scan_settings.system_name_database,
sizeof(task_config->system_name));
break;
default:
return false;
@ -1143,9 +1132,9 @@ bool manual_content_scan_get_task_config(
struct string_list *manual_content_scan_get_content_list(
manual_content_scan_task_config_t *task_config)
{
struct string_list *dir_list = NULL;
bool filter_exts;
bool include_compressed;
struct string_list *dir_list = NULL;
/* Sanity check */
if (!task_config)
@ -1226,8 +1215,8 @@ static bool manual_content_scan_get_playlist_content_path(
/* Check whether this is an archive file
* requiring special attention... */
if ((content_type == RARCH_COMPRESSED_ARCHIVE) &&
task_config->search_archives)
if ( (content_type == RARCH_COMPRESSED_ARCHIVE)
&& task_config->search_archives)
{
bool filter_exts = !string_is_empty(task_config->file_exts);
const char *archive_file = NULL;

View file

@ -1984,7 +1984,7 @@ static void ram_state_to_file(void)
enum rarch_content_type path_is_media_type(const char *path)
{
char ext_lower[128];
char ext_lower[16];
strlcpy(ext_lower, path_get_extension(path), sizeof(ext_lower));
string_to_lower(ext_lower);