Skip to content

Commit

Permalink
Use returntype for fill_pathname_basedir
Browse files Browse the repository at this point in the history
  • Loading branch information
LibretroAdmin committed Dec 28, 2024
1 parent 9376b99 commit 4297f02
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 17 deletions.
8 changes: 4 additions & 4 deletions command.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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,
Expand Down
4 changes: 1 addition & 3 deletions gfx/video_filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 1 addition & 5 deletions libretro-common/formats/m3u/m3u_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 */
Expand Down
5 changes: 3 additions & 2 deletions libretro-common/media/media_detect_cd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
Expand Down
4 changes: 1 addition & 3 deletions runloop.c
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down

0 comments on commit 4297f02

Please sign in to comment.