Skip to content

Commit

Permalink
Change config_get_path/array return back to bool (#17333)
Browse files Browse the repository at this point in the history
  • Loading branch information
warmenhoven authored Jan 2, 2025
1 parent 0dcf196 commit 53d9452
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 15 deletions.
6 changes: 3 additions & 3 deletions configuration.c
Original file line number Diff line number Diff line change
Expand Up @@ -6389,7 +6389,7 @@ void input_config_parse_mouse_button(

fill_pathname_join_delim(key, s, "mbtn", '_', sizeof(key));

if (config_get_array(conf, key, tmp, sizeof(tmp)) > 0)
if (config_get_array(conf, key, tmp, sizeof(tmp)))
{
bind->mbutton = NO_BTN;

Expand Down Expand Up @@ -6460,7 +6460,7 @@ void input_config_parse_joy_axis(
fill_pathname_join_delim(key_label, s,
"axis_label", '_', sizeof(key_label));

if (config_get_array(conf, key, tmp, sizeof(tmp)) > 0)
if (config_get_array(conf, key, tmp, sizeof(tmp)))
{
if ( tmp[0] == 'n'
&& tmp[1] == 'u'
Expand Down Expand Up @@ -6551,7 +6551,7 @@ void input_config_parse_joy_button(
fill_pathname_join_delim(key_label, s,
"btn_label", '_', sizeof(key_label));

if (config_get_array(conf, key, tmp, sizeof(tmp)) > 0)
if (config_get_array(conf, key, tmp, sizeof(tmp)))
{
btn = tmp;
if ( btn[0] == 'n'
Expand Down
2 changes: 1 addition & 1 deletion gfx/video_filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ static bool create_softfilter_graph(rarch_softfilter_t *filt,
name[0] = '\0';
strlcpy(key, "filter", sizeof(key));

if (config_get_array(filt->conf, key, name, sizeof(name)) == 0)
if (!config_get_array(filt->conf, key, name, sizeof(name)))
{
RARCH_ERR("Could not find 'filter' array in config.\n");
return false;
Expand Down
2 changes: 1 addition & 1 deletion libretro-common/audio/dsp_filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ static bool create_filter_graph(retro_dsp_filter_t *dsp, float sample_rate)

snprintf(key, sizeof(key), "filter%u", i);

if (config_get_array(dsp->conf, key, name, sizeof(name)) == 0)
if (!config_get_array(dsp->conf, key, name, sizeof(name)))
return false;

dsp->instances[i].impl = find_implementation(dsp, name);
Expand Down
13 changes: 8 additions & 5 deletions libretro-common/file/config_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -1167,26 +1167,29 @@ size_t config_get_config_path(config_file_t *conf, char *s, size_t len)
return 0;
}

size_t config_get_array(config_file_t *conf, const char *key,
bool config_get_array(config_file_t *conf, const char *key,
char *buf, size_t size)
{
const struct config_entry_list *entry = config_get_entry(conf, key);
if (entry)
return strlcpy(buf, entry->value, size) < size;
return 0;
return false;
}

size_t config_get_path(config_file_t *conf, const char *key,
bool config_get_path(config_file_t *conf, const char *key,
char *buf, size_t size)
{
#if defined(RARCH_CONSOLE) || !defined(RARCH_INTERNAL)
return config_get_array(conf, key, buf, size);
#else
const struct config_entry_list *entry = config_get_entry(conf, key);
if (entry)
return fill_pathname_expand_special(buf, entry->value, size);
{
fill_pathname_expand_special(buf, entry->value, size);
return true;
}
return false;
#endif
return 0;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions libretro-common/include/file/config_file.h
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ bool config_get_char(config_file_t *conf, const char *entry, char *in);
bool config_get_string(config_file_t *conf, const char *entry, char **in);

/* Extracts a string to a preallocated buffer. Avoid memory allocation. */
size_t config_get_array(config_file_t *conf, const char *entry, char *s, size_t len);
bool config_get_array(config_file_t *conf, const char *entry, char *s, size_t len);

/**
* config_get_config_path:
Expand All @@ -278,7 +278,7 @@ size_t config_get_config_path(config_file_t *conf, char *s, size_t len);

/* Extracts a string to a preallocated buffer. Avoid memory allocation.
* Recognized magic like ~/. Similar to config_get_array() otherwise. */
size_t config_get_path(config_file_t *conf, const char *entry, char *s, size_t len);
bool config_get_path(config_file_t *conf, const char *entry, char *s, size_t len);

/**
* config_get_bool:
Expand Down
2 changes: 1 addition & 1 deletion menu/drivers/rgui.c
Original file line number Diff line number Diff line change
Expand Up @@ -3168,7 +3168,7 @@ static void rgui_load_custom_theme(

/* Load wallpaper, if required */
if (config_get_array(conf, wallpaper_key,
wallpaper_file, sizeof(wallpaper_file)) > 0)
wallpaper_file, sizeof(wallpaper_file)))
{
char wallpaper_path[PATH_MAX_LENGTH];
wallpaper_path[0] = '\0';
Expand Down
4 changes: 2 additions & 2 deletions tasks/task_overlay.c
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ static bool task_overlay_load_desc(
goto end;
}

if (config_get_array(conf, overlay_desc_key, overlay, sizeof(overlay)) == 0)
if (!config_get_array(conf, overlay_desc_key, overlay, sizeof(overlay)))
{
RARCH_ERR("[Overlay]: Didn't find key: %s.\n", overlay_desc_key);
ret = false;
Expand Down Expand Up @@ -836,7 +836,7 @@ static void task_overlay_deferred_load(retro_task_t *task)
overlay->w = overlay->h = 1.0f;

if (config_get_array(conf, overlay->config.rect.key,
overlay->config.rect.array, sizeof(overlay->config.rect.array)) > 0)
overlay->config.rect.array, sizeof(overlay->config.rect.array)))
{
char *tok, *save;
char *elem0 = NULL;
Expand Down

0 comments on commit 53d9452

Please sign in to comment.