Skip to content

Commit

Permalink
Downgrade some more variables to NAME_MAX_LENGTH
Browse files Browse the repository at this point in the history
  • Loading branch information
LibretroAdmin committed Sep 9, 2024
1 parent 998edca commit 73e5d95
Show file tree
Hide file tree
Showing 17 changed files with 60 additions and 62 deletions.
4 changes: 2 additions & 2 deletions frontend/drivers/platform_gx.c
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ static void frontend_gx_exitspawn(char *s, size_t len, char *args)
if (!string_is_empty(gx_rom_path))
should_load_game = true;
#elif defined(HW_RVL)
char salamander_basename[PATH_MAX_LENGTH];
char salamander_basename[NAME_MAX_LENGTH];

if (gx_fork_mode == FRONTEND_FORK_NONE)
return;
Expand All @@ -426,8 +426,8 @@ static void frontend_gx_exitspawn(char *s, size_t len, char *args)
/* fall-through */
case FRONTEND_FORK_RESTART:
{
char salamander_name[NAME_MAX_LENGTH];
char new_path[PATH_MAX_LENGTH];
char salamander_name[PATH_MAX_LENGTH];

if (frontend_driver_get_salamander_basename(salamander_name,
sizeof(salamander_name)))
Expand Down
4 changes: 2 additions & 2 deletions frontend/frontend_salamander.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ static void find_first_libretro_core(char *first_file,

for (i = 0; i < list->size && !ret; i++)
{
char fname[PATH_MAX_LENGTH] = {0};
char salamander_name[PATH_MAX_LENGTH] = {0};
char salamander_name[NAME_MAX_LENGTH] = {0};
char fname[NAME_MAX_LENGTH] = {0};
const char *libretro_elem = (const char*)list->elems[i].data;

RARCH_LOG("Checking library: \"%s\".\n", libretro_elem);
Expand Down
8 changes: 4 additions & 4 deletions manual_content_scan.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ typedef struct
enum manual_content_scan_system_name_type system_name_type;
enum manual_content_scan_core_type core_type;

char core_name[NAME_MAX_LENGTH];
char system_name_database[NAME_MAX_LENGTH];
char system_name_custom[NAME_MAX_LENGTH];
char content_dir[DIR_MAX_LENGTH];
char system_name_content_dir[DIR_MAX_LENGTH];
char system_name_database[PATH_MAX_LENGTH];
char system_name_custom[PATH_MAX_LENGTH];
char core_name[NAME_MAX_LENGTH];
char core_path[PATH_MAX_LENGTH];
char file_exts_core[PATH_MAX_LENGTH];
char file_exts_custom[PATH_MAX_LENGTH];
Expand Down Expand Up @@ -1356,7 +1356,7 @@ void manual_content_scan_add_content_to_playlist(
if (!playlist_entry_exists(playlist, playlist_content_path))
{
struct playlist_entry entry = {0};
char label[PATH_MAX_LENGTH];
char label[NAME_MAX_LENGTH];

label[0] = '\0';

Expand Down
8 changes: 4 additions & 4 deletions manual_content_scan.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,11 @@ enum manual_content_scan_playlist_refresh_status
* for a manual content scan task */
typedef struct
{
char playlist_file[PATH_MAX_LENGTH];
char core_name[NAME_MAX_LENGTH];
char system_name[NAME_MAX_LENGTH];
char database_name[NAME_MAX_LENGTH];
char content_dir[DIR_MAX_LENGTH];
char system_name[PATH_MAX_LENGTH];
char database_name[PATH_MAX_LENGTH];
char core_name[PATH_MAX_LENGTH];
char playlist_file[PATH_MAX_LENGTH];
char core_path[PATH_MAX_LENGTH];
char file_exts[PATH_MAX_LENGTH];
char dat_file_path[PATH_MAX_LENGTH];
Expand Down
2 changes: 1 addition & 1 deletion menu/cbs/menu_cbs_get_value.c
Original file line number Diff line number Diff line change
Expand Up @@ -1257,7 +1257,7 @@ static void menu_action_setting_disp_set_label_menu_file_directory(
char *s2, size_t len2)
{
#if IOS
char tmp[PATH_MAX_LENGTH] = {0};
char tmp[PATH_MAX_LENGTH];
fill_pathname_abbreviate_special(tmp, path, sizeof(tmp));
MENU_ACTION_SETTING_GENERIC_DISP_SET_LABEL_2(w, s, len,
tmp, "(DIR)", STRLEN_CONST("(DIR)"), s2, len2);
Expand Down
2 changes: 1 addition & 1 deletion menu/cbs/menu_cbs_label.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ static int action_bind_label_playlist_collection_entry(
/* Handle collection playlists */
else
{
char playlist_name[PATH_MAX_LENGTH];
char playlist_name[NAME_MAX_LENGTH];
strlcpy(playlist_name, playlist_file, sizeof(playlist_name));
path_remove_extension(playlist_name);

Expand Down
22 changes: 10 additions & 12 deletions menu/cbs/menu_cbs_ok.c
Original file line number Diff line number Diff line change
Expand Up @@ -1512,7 +1512,7 @@ int generic_action_ok_displaylist_push(
break;
case ACTION_OK_DL_DATABASE_MANAGER_LIST:
{
char lpl_basename[PATH_MAX_LENGTH];
char lpl_basename[NAME_MAX_LENGTH];
struct menu_state *menu_st = menu_state_get_ptr();
filebrowser_clear_type();
fill_pathname_join_special(tmp,
Expand Down Expand Up @@ -2633,7 +2633,7 @@ static int action_ok_playlist_entry_collection(const char *path,
{
playlist_config_t playlist_config;
char content_path[PATH_MAX_LENGTH];
char content_label[PATH_MAX_LENGTH];
char content_label[NAME_MAX_LENGTH];
char core_path[PATH_MAX_LENGTH];
size_t selection_ptr = entry_idx;
bool playlist_initialized = false;
Expand Down Expand Up @@ -5693,9 +5693,9 @@ static int action_ok_add_to_favorites(const char *path,
if (!string_is_empty(content_path))
{
union string_list_elem_attr attr;
char core_name[NAME_MAX_LENGTH];
char content_label[NAME_MAX_LENGTH];
char core_path[PATH_MAX_LENGTH];
char core_name[PATH_MAX_LENGTH];
char content_label[PATH_MAX_LENGTH];
runloop_state_t *runloop_st = runloop_state_get_ptr();
struct retro_system_info *sysinfo = &runloop_st->system.info;
struct string_list *str_list = NULL;
Expand Down Expand Up @@ -5832,11 +5832,10 @@ static int action_ok_add_entry_to_playlist(const char *path,
if (!string_is_empty(entry->path))
{
union string_list_elem_attr attr;
char core_display_name[PATH_MAX_LENGTH];
char core_display_name[NAME_MAX_LENGTH];
char core_name[NAME_MAX_LENGTH];
char core_path[PATH_MAX_LENGTH];
char core_name[PATH_MAX_LENGTH];
struct string_list
*str_list = NULL;
struct string_list *str_list = NULL;

core_display_name[0] = '\0';
core_path[0] = '\0';
Expand Down Expand Up @@ -5999,11 +5998,10 @@ static int action_ok_add_to_favorites_playlist(const char *path,
if (!string_is_empty(entry->path))
{
union string_list_elem_attr attr;
char core_display_name[PATH_MAX_LENGTH];
char core_display_name[NAME_MAX_LENGTH];
char core_name[NAME_MAX_LENGTH];
char core_path[PATH_MAX_LENGTH];
char core_name[PATH_MAX_LENGTH];
struct string_list
*str_list = NULL;
struct string_list *str_list = NULL;

core_display_name[0] = '\0';
core_path[0] = '\0';
Expand Down
2 changes: 1 addition & 1 deletion menu/cbs/menu_cbs_title.c
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ static int action_get_title_deferred_playlist_list(const char *path, const char
/* Handle collection playlists */
else
{
char playlist_name[PATH_MAX_LENGTH];
char playlist_name[NAME_MAX_LENGTH];
strlcpy(playlist_name, playlist_file, sizeof(playlist_name));
path_remove_extension(playlist_name);

Expand Down
5 changes: 3 additions & 2 deletions menu/drivers/materialui.c
Original file line number Diff line number Diff line change
Expand Up @@ -680,11 +680,12 @@ typedef struct materialui_handle
enum materialui_landscape_layout_optimization_type
last_landscape_layout_optimization;
enum materialui_list_view_type list_view_type;
char sysicons_path[PATH_MAX_LENGTH];
char icons_path[PATH_MAX_LENGTH];

char msgbox[1024];
char menu_title[NAME_MAX_LENGTH];
char fullscreen_thumbnail_label[NAME_MAX_LENGTH];
char sysicons_path[PATH_MAX_LENGTH];
char icons_path[PATH_MAX_LENGTH];
} materialui_handle_t;

static void hex32_to_rgba_normalized(uint32_t hex, float* rgba, float alpha)
Expand Down
13 changes: 6 additions & 7 deletions menu/drivers/ozone.c
Original file line number Diff line number Diff line change
Expand Up @@ -617,14 +617,18 @@ struct ozone_handle
uint8_t sidebar_index_list[SCROLL_INDEX_SIZE];
uint8_t sidebar_index_size;

char title[PATH_MAX_LENGTH];
char title[NAME_MAX_LENGTH];
char selection_core_name[NAME_MAX_LENGTH];
char selection_playtime[NAME_MAX_LENGTH];
char selection_lastplayed[NAME_MAX_LENGTH];
char selection_entry_enumeration[NAME_MAX_LENGTH];
char fullscreen_thumbnail_label[NAME_MAX_LENGTH];

char assets_path[PATH_MAX_LENGTH];
char png_path[PATH_MAX_LENGTH];
char icons_path[PATH_MAX_LENGTH];
char icons_path_default[PATH_MAX_LENGTH];
char tab_path[PATH_MAX_LENGTH];
char fullscreen_thumbnail_label[NAME_MAX_LENGTH];

/* These have to be huge, because runloop_st->name.savestate
* has a hard-coded size of 8192...
Expand All @@ -633,11 +637,6 @@ struct ozone_handle
char savestate_thumbnail_file_path[8204]; /* TODO/FIXME - check size */
char prev_savestate_thumbnail_file_path[8204]; /* TODO/FIXME - check size */

char selection_core_name[NAME_MAX_LENGTH];
char selection_playtime[NAME_MAX_LENGTH];
char selection_lastplayed[NAME_MAX_LENGTH];
char selection_entry_enumeration[NAME_MAX_LENGTH];

char thumbnails_left_status_prev;
char thumbnails_right_status_prev;

Expand Down
18 changes: 9 additions & 9 deletions menu/menu_displaylist.c
Original file line number Diff line number Diff line change
Expand Up @@ -2552,7 +2552,7 @@ static int create_string_list_rdb_entry_int(
size_t _len;
char str[16];
char tmp[128];
char out_lbl[PATH_MAX_LENGTH];
char out_lbl[NAME_MAX_LENGTH];
str[0] = '\0';
out_lbl[0] = '\0';

Expand Down Expand Up @@ -4516,7 +4516,7 @@ static unsigned menu_displaylist_parse_cores(
#ifndef HAVE_DYNAMIC
if (frontend_driver_has_fork())
{
char salamander_name[PATH_MAX_LENGTH];
char salamander_name[NAME_MAX_LENGTH];

salamander_name[0] = '\0';

Expand Down Expand Up @@ -4587,10 +4587,10 @@ static unsigned menu_displaylist_parse_cores(
static unsigned menu_displaylist_parse_add_to_playlist_list(
file_list_t *list, settings_t *settings)
{
char playlist_display_name[NAME_MAX_LENGTH];
unsigned count = 0;
const char *dir_playlist = settings->paths.directory_playlist;
bool show_hidden_files = settings->bools.show_hidden_files;
char playlist_display_name[PATH_MAX_LENGTH];
struct string_list *str_list = dir_list_new_special(
dir_playlist, DIR_LIST_COLLECTIONS, NULL, show_hidden_files);

Expand Down Expand Up @@ -5048,7 +5048,7 @@ static unsigned menu_displaylist_parse_content_information(
if (!string_is_empty(db_name))
{
char *db_name_no_ext = NULL;
char db_name_no_ext_buff[PATH_MAX_LENGTH];
char db_name_no_ext_buff[NAME_MAX_LENGTH];
/* Remove .lpl extension
* > path_remove_extension() requires a char * (not const)
* so have to use a temporary buffer... */
Expand Down Expand Up @@ -12312,7 +12312,7 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type,
if (!string_is_empty(cd_info.title))
{
/* TODO/FIXME - localize */
char title[sizeof("Title: ") + sizeof(cd_info.title)]; /* TODO/FIXME - C89 compliance */
char title[NAME_MAX_LENGTH];
size_t _len = strlcpy(title, "Title: ", sizeof(title));
strlcpy(title + _len, cd_info.title, sizeof(title) - _len);

Expand Down Expand Up @@ -12687,7 +12687,7 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type,

for (i = 0; i < profiles_count; i++)
{
char title[PATH_MAX_LENGTH];
char title[NAME_MAX_LENGTH];
char* profile = SWITCH_CPU_PROFILES[i];
char* speed = SWITCH_CPU_SPEEDS[i];
size_t _len = strlcpy(title, profile, sizeof(title));
Expand Down Expand Up @@ -13133,7 +13133,7 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type,
case DISPLAYLIST_CORE_CONTENT_DIRS_SUBDIR:
{
#ifdef HAVE_NETWORKING
char new_label[PATH_MAX_LENGTH];
char new_label[NAME_MAX_LENGTH];
char *save = NULL;
char *info_path_cpy = strdup(info->path);
const char *con = strtok_r(info_path_cpy, ";", &save);
Expand Down Expand Up @@ -13169,7 +13169,7 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type,
menu_entries_clear(info->list);
{
#ifdef HAVE_NETWORKING
char new_label[PATH_MAX_LENGTH];
char new_label[NAME_MAX_LENGTH];
const char *
network_buildbot_assets_url = settings->paths.network_buildbot_assets_url;

Expand Down Expand Up @@ -14988,7 +14988,7 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type,
case DISPLAYLIST_USER_BINDS_LIST:
menu_entries_clear(info->list);
{
char lbl[PATH_MAX_LENGTH];
char lbl[NAME_MAX_LENGTH];
unsigned val = atoi(info->path);
const char *temp_val = msg_hash_to_str(
(enum msg_hash_enums)(MENU_ENUM_LABEL_INPUT_USER_1_BINDS + (val-1)));
Expand Down
8 changes: 4 additions & 4 deletions menu/menu_driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -434,8 +434,8 @@ typedef struct

char pass_dir[DIR_MAX_LENGTH];
char preset_dir[DIR_MAX_LENGTH];
char preset_file_name[PATH_MAX_LENGTH];
char pass_file_name[PATH_MAX_LENGTH];
char preset_file_name[NAME_MAX_LENGTH];
char pass_file_name[NAME_MAX_LENGTH];
} last_shader_selection;
#endif

Expand All @@ -444,7 +444,7 @@ typedef struct
struct
{
char directory[DIR_MAX_LENGTH];
char file_name[PATH_MAX_LENGTH];
char file_name[NAME_MAX_LENGTH];
} last_start_content;

char menu_state_msg[8192];
Expand All @@ -456,7 +456,7 @@ typedef struct
char scratch_buf[PATH_MAX_LENGTH];
char scratch2_buf[PATH_MAX_LENGTH];
char db_playlist_file[PATH_MAX_LENGTH];
char filebrowser_label[PATH_MAX_LENGTH];
char filebrowser_label[NAME_MAX_LENGTH];
char detect_content_path[PATH_MAX_LENGTH];
} menu_handle_t;

Expand Down
14 changes: 7 additions & 7 deletions playlist.c
Original file line number Diff line number Diff line change
Expand Up @@ -2760,7 +2760,7 @@ static bool playlist_read_file(playlist_t *playlist)
else
{
char default_core_path[PATH_MAX_LENGTH];
char default_core_name[PATH_MAX_LENGTH];
char default_core_name[NAME_MAX_LENGTH];

default_core_path[0] = '\0';
default_core_name[0] = '\0';
Expand Down Expand Up @@ -3089,19 +3089,19 @@ static int playlist_qsort_func(const struct playlist_entry *a,
* have no other option...) */
if (string_is_empty(a_str))
{
if (!(a_fallback_label = (char*)calloc(PATH_MAX_LENGTH, sizeof(char))))
if (!(a_fallback_label = (char*)calloc(NAME_MAX_LENGTH, sizeof(char))))
goto end;

if (!string_is_empty(a->path))
fill_pathname(a_fallback_label,
path_basename_nocompression(a->path),
"",
PATH_MAX_LENGTH * sizeof(char));
NAME_MAX_LENGTH * sizeof(char));
/* If filename is also empty, use core name
* instead -> this matches the behaviour of
* menu_displaylist_parse_playlist() */
else if (!string_is_empty(a->core_name))
strlcpy(a_fallback_label, a->core_name, PATH_MAX_LENGTH * sizeof(char));
strlcpy(a_fallback_label, a->core_name, NAME_MAX_LENGTH * sizeof(char));

/* If both filename and core name are empty,
* then have to compare an empty string
Expand All @@ -3113,16 +3113,16 @@ static int playlist_qsort_func(const struct playlist_entry *a,

if (string_is_empty(b_str))
{
if (!(b_fallback_label = (char*)calloc(PATH_MAX_LENGTH, sizeof(char))))
if (!(b_fallback_label = (char*)calloc(NAME_MAX_LENGTH, sizeof(char))))
goto end;

if (!string_is_empty(b->path))
fill_pathname(b_fallback_label,
path_basename_nocompression(b->path),
"",
PATH_MAX_LENGTH * sizeof(char));
NAME_MAX_LENGTH * sizeof(char));
else if (!string_is_empty(b->core_name))
strlcpy(b_fallback_label, b->core_name, PATH_MAX_LENGTH * sizeof(char));
strlcpy(b_fallback_label, b->core_name, NAME_MAX_LENGTH * sizeof(char));

b_str = b_fallback_label;
}
Expand Down
2 changes: 1 addition & 1 deletion runloop.c
Original file line number Diff line number Diff line change
Expand Up @@ -4148,7 +4148,7 @@ static bool runloop_path_init_subsystem(runloop_state_t *runloop_st)
{
char ext[32];
union string_list_elem_attr attr;
char savename[PATH_MAX_LENGTH];
char savename[NAME_MAX_LENGTH];
char path[PATH_MAX_LENGTH];
size_t _len = 0;
const struct retro_subsystem_memory_info *mem =
Expand Down
4 changes: 2 additions & 2 deletions runtime_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,8 @@ runtime_log_t *runtime_log_init(
bool log_per_core)
{
char log_file_dir[DIR_MAX_LENGTH];
char content_name[PATH_MAX_LENGTH];
char core_name[PATH_MAX_LENGTH];
char content_name[NAME_MAX_LENGTH];
char core_name[nAME_MAX_LENGTH];
char log_file_path[PATH_MAX_LENGTH];
char tmp_buf[PATH_MAX_LENGTH];
bool supports_no_game = false;
Expand Down
2 changes: 1 addition & 1 deletion tasks/task_database.c
Original file line number Diff line number Diff line change
Expand Up @@ -1040,7 +1040,7 @@ static int task_database_iterate_playlist_lutro(
if (!playlist_entry_exists(playlist, path))
{
struct playlist_entry entry;
char game_title[PATH_MAX_LENGTH];
char game_title[NAME_MAX_LENGTH];
fill_pathname(game_title,
path_basename(path), "", sizeof(game_title));
path_remove_extension(game_title);
Expand Down
Loading

0 comments on commit 73e5d95

Please sign in to comment.