Turn some functions to returntype size_t

This commit is contained in:
LibretroAdmin 2025-01-12 23:03:41 +01:00
parent 955eeed31a
commit fb338b90bf
4 changed files with 23 additions and 33 deletions

View File

@ -136,33 +136,33 @@ void playlist_set_cached_external(playlist_t* pl)
/* Convenience function: copies specified playlist /* Convenience function: copies specified playlist
* path to specified playlist configuration object */ * path to specified playlist configuration object */
void playlist_config_set_path(playlist_config_t *config, const char *path) size_t playlist_config_set_path(playlist_config_t *config, const char *path)
{ {
if (!config) if (config)
return; {
if (!string_is_empty(path))
if (!string_is_empty(path)) return strlcpy(config->path, path, sizeof(config->path));
strlcpy(config->path, path, sizeof(config->path));
else
config->path[0] = '\0'; config->path[0] = '\0';
}
return 0;
} }
/* Convenience function: copies base content directory /* Convenience function: copies base content directory
* path to specified playlist configuration object. * path to specified playlist configuration object.
* Also sets autofix_paths boolean, depending on base * Also sets autofix_paths boolean, depending on base
* content directory value */ * content directory value */
void playlist_config_set_base_content_directory( size_t playlist_config_set_base_content_directory(
playlist_config_t* config, const char* path) playlist_config_t* config, const char* path)
{ {
if (!config) if (config)
return; {
config->autofix_paths = !string_is_empty(path);
config->autofix_paths = !string_is_empty(path); if (config->autofix_paths)
if (config->autofix_paths) return strlcpy(config->base_content_directory, path,
strlcpy(config->base_content_directory, path, sizeof(config->base_content_directory));
sizeof(config->base_content_directory));
else
config->base_content_directory[0] = '\0'; config->base_content_directory[0] = '\0';
}
return 0;
} }

View File

@ -158,11 +158,11 @@ typedef struct
/* Convenience function: copies specified playlist /* Convenience function: copies specified playlist
* path to specified playlist configuration object */ * path to specified playlist configuration object */
void playlist_config_set_path(playlist_config_t *config, const char *path); size_t playlist_config_set_path(playlist_config_t *config, const char *path);
/* Convenience function: copies base content directory /* Convenience function: copies base content directory
* path to specified playlist configuration object */ * path to specified playlist configuration object */
void playlist_config_set_base_content_directory(playlist_config_t* config, const char* path); size_t playlist_config_set_base_content_directory(playlist_config_t* config, const char* path);
/* Creates a copy of the specified playlist configuration. /* Creates a copy of the specified playlist configuration.
* Returns false in the event of an error */ * Returns false in the event of an error */

View File

@ -487,29 +487,19 @@ static void runtime_log_get_runtime_hms(runtime_log_t *runtime_log,
} }
/* Gets runtime as a pre-formatted string */ /* Gets runtime as a pre-formatted string */
void runtime_log_get_runtime_str(runtime_log_t *runtime_log, size_t runtime_log_get_runtime_str(runtime_log_t *runtime_log,
char *s, size_t len) char *s, size_t len)
{ {
size_t _len = strlcpy(s, size_t _len = strlcpy(s,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_RUNTIME), msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_RUNTIME),
len); len);
s[_len ] = ' ';
if (runtime_log) if (runtime_log)
snprintf(s + _len + 1, len - _len - 1, "%02u:%02u:%02u", _len += snprintf(s + _len, len - _len, " %02u:%02u:%02u",
runtime_log->runtime.hours, runtime_log->runtime.minutes, runtime_log->runtime.hours, runtime_log->runtime.minutes,
runtime_log->runtime.seconds); runtime_log->runtime.seconds);
else else
{ _len += strlcpy(s + _len, " 00:00:00", len - _len);
s[_len+1] = '0'; return _len;
s[_len+2] = '0';
s[_len+3] = ':';
s[_len+4] = '0';
s[_len+5] = '0';
s[_len+6] = ':';
s[_len+7] = '0';
s[_len+8] = '0';
s[_len+9] = '\0';
}
} }
/* Gets last played entry values */ /* Gets last played entry values */

View File

@ -96,7 +96,7 @@ void runtime_log_reset(runtime_log_t *runtime_log);
* cleaner to have a symmetrical set/get interface) */ * cleaner to have a symmetrical set/get interface) */
/* Gets runtime as a pre-formatted string */ /* Gets runtime as a pre-formatted string */
void runtime_log_get_runtime_str(runtime_log_t *runtime_log, char *str, size_t len); size_t runtime_log_get_runtime_str(runtime_log_t *runtime_log, char *s, size_t len);
/* Gets last played entry values */ /* Gets last played entry values */
void runtime_log_get_last_played(runtime_log_t *runtime_log, void runtime_log_get_last_played(runtime_log_t *runtime_log,