From 4297f02544d083a13a4ecaa441ec4303665e8532 Mon Sep 17 00:00:00 2001 From: LibretroAdmin Date: Sat, 28 Dec 2024 23:11:24 +0100 Subject: [PATCH] Use returntype for fill_pathname_basedir --- command.c | 8 ++++---- gfx/video_filter.c | 4 +--- libretro-common/formats/m3u/m3u_file.c | 6 +----- libretro-common/media/media_detect_cd.c | 5 +++-- runloop.c | 4 +--- 5 files changed, 10 insertions(+), 17 deletions(-) diff --git a/command.c b/command.c index 6db93037c86f..f7d8756f2d14 100644 --- a/command.c +++ b/command.c @@ -1841,11 +1841,11 @@ bool command_event_save_core_config( const char *dir_menu_config, const char *rarch_path_config) { - size_t _len; char msg[128]; char config_dir[DIR_MAX_LENGTH]; char config_path[PATH_MAX_LENGTH]; char config_name[NAME_MAX_LENGTH]; + size_t _len = 0; bool new_path_available = false; bool overrides_active = false; const char *core_path = NULL; @@ -1854,12 +1854,12 @@ bool command_event_save_core_config( msg[0] = '\0'; if (!string_is_empty(dir_menu_config)) - strlcpy(config_dir, dir_menu_config, sizeof(config_dir)); + _len = strlcpy(config_dir, dir_menu_config, sizeof(config_dir)); else if (!string_is_empty(rarch_path_config)) /* Fallback */ - fill_pathname_basedir(config_dir, rarch_path_config, + _len = fill_pathname_basedir(config_dir, rarch_path_config, sizeof(config_dir)); - if (string_is_empty(config_dir)) + if (_len == 0) { const char *_msg = msg_hash_to_str(MSG_CONFIG_DIRECTORY_NOT_SET); runloop_msg_queue_push(_msg, strlen(_msg), 1, 180, true, NULL, diff --git a/gfx/video_filter.c b/gfx/video_filter.c index bb36be994868..0f260faed51c 100644 --- a/gfx/video_filter.c +++ b/gfx/video_filter.c @@ -442,9 +442,7 @@ rarch_softfilter_t *rarch_softfilter_new(const char *filter_config, if (!frontend_driver_get_core_extension(ext_name, sizeof(ext_name))) goto error; - plugs = dir_list_new(basedir, ext_name, false, false, false, false); - - if (!plugs) + if (!(plugs = dir_list_new(basedir, ext_name, false, false, false, false))) { RARCH_ERR("[SoftFilter]: Could not build up string list...\n"); goto error; diff --git a/libretro-common/formats/m3u/m3u_file.c b/libretro-common/formats/m3u/m3u_file.c index bc85d3f6416e..560162e62a7a 100644 --- a/libretro-common/formats/m3u/m3u_file.c +++ b/libretro-common/formats/m3u/m3u_file.c @@ -260,8 +260,6 @@ m3u_file_t *m3u_file_init(const char *path) m3u_file_t *m3u_file = NULL; char m3u_path[PATH_MAX_LENGTH]; - m3u_path[0] = '\0'; - /* Sanity check */ if (string_is_empty(path)) return NULL; @@ -274,9 +272,7 @@ m3u_file_t *m3u_file_init(const char *path) return NULL; /* Create m3u_file_t object */ - m3u_file = (m3u_file_t*)malloc(sizeof(*m3u_file)); - - if (!m3u_file) + if (!(m3u_file = (m3u_file_t*)malloc(sizeof(*m3u_file)))) return NULL; /* Initialise members */ diff --git a/libretro-common/media/media_detect_cd.c b/libretro-common/media/media_detect_cd.c index ef872aa634ef..c8ea47f72095 100644 --- a/libretro-common/media/media_detect_cd.c +++ b/libretro-common/media/media_detect_cd.c @@ -236,6 +236,7 @@ bool media_detect_cd_info_cue(const char *path, media_detect_cd_info_t *info) if (!string_is_empty(track_path)) { + size_t _len; if (strstr(track_path, "/") || strstr(track_path, "\\")) { #ifdef MEDIA_CUE_PARSE_DEBUG @@ -245,8 +246,8 @@ bool media_detect_cd_info_cue(const char *path, media_detect_cd_info_t *info) return media_detect_cd_info(track_path, data_track_pregap_bytes, info); } - fill_pathname_basedir(track_abs_path, path, sizeof(track_abs_path)); - strlcat(track_abs_path, track_path, sizeof(track_abs_path)); + _len = fill_pathname_basedir(track_abs_path, path, sizeof(track_abs_path)); + strlcpy(track_abs_path + _len, track_path, sizeof(track_abs_path) - _len); #ifdef MEDIA_CUE_PARSE_DEBUG printf("using abs path %s\n", track_abs_path); fflush(stdout); diff --git a/runloop.c b/runloop.c index 23cccdd6a8a8..80c8891cce74 100644 --- a/runloop.c +++ b/runloop.c @@ -1956,10 +1956,8 @@ bool runloop_environment_cb(unsigned cmd, void *data) RARCH_WARN("[Environ]: SYSTEM DIR is empty, assume CONTENT DIR %s\n", fullpath); - fill_pathname_basedir(tmp_path, fullpath, sizeof(tmp_path)); - + _len = fill_pathname_basedir(tmp_path, fullpath, sizeof(tmp_path)); /* Removes trailing slash (unless root dir) */ - _len = strlen(tmp_path); if (string_count_occurrences_single_character(tmp_path, PATH_DEFAULT_SLASH_C()) > 1 && tmp_path[_len - 1] == PATH_DEFAULT_SLASH_C()) tmp_path[_len - 1] = '\0';