Cleanup some char variables - title variables will always be 128

in size
This commit is contained in:
libretroadmin 2024-09-10 00:15:23 +02:00
parent 285e38bd87
commit 36bcbefc96
8 changed files with 49 additions and 73 deletions

View File

@ -134,16 +134,16 @@ static unsigned input_autoconfigure_get_config_file_affinity(
#endif
/* Check for matching VID+PID */
pid_match = (autoconfig_handle->device_info.vid == config_vid) &&
(autoconfig_handle->device_info.pid == config_pid) &&
(autoconfig_handle->device_info.vid != 0) &&
(autoconfig_handle->device_info.pid != 0);
pid_match = (autoconfig_handle->device_info.vid == config_vid)
&& (autoconfig_handle->device_info.pid == config_pid)
&& (autoconfig_handle->device_info.vid != 0)
&& (autoconfig_handle->device_info.pid != 0);
/* > More Bliss-Box shenanigans... */
#ifdef HAVE_BLISSBOX
pid_match = pid_match &&
(autoconfig_handle->device_info.vid != BLISSBOX_VID) &&
(autoconfig_handle->device_info.pid != BLISSBOX_PID);
pid_match = pid_match
&& (autoconfig_handle->device_info.vid != BLISSBOX_VID)
&& (autoconfig_handle->device_info.pid != BLISSBOX_PID);
#endif
if (pid_match)
@ -369,24 +369,25 @@ static bool input_autoconfigure_scan_config_files_internal(
static void reallocate_port_if_needed(unsigned detected_port, int vendor_id,
int product_id, const char *device_name, const char *device_display_name)
{
settings_t *settings = config_get_ptr();
unsigned player;
unsigned first_free_player_slot = MAX_USERS + 1;
char settings_value[NAME_MAX_LENGTH];
char settings_value_device_name[NAME_MAX_LENGTH];
unsigned prev_assigned_player_slots[MAX_USERS];
bool device_has_reserved_slot = false;
bool no_reservation_at_all = true;
char settings_value[256] = {0};
int settings_value_vendor_id;
int settings_value_product_id;
char settings_value_device_name[256];
unsigned first_free_player_slot = MAX_USERS + 1;
bool device_has_reserved_slot = false;
bool no_reservation_at_all = true;
settings_t *settings = config_get_ptr();
for (player = 0; player < MAX_USERS; player++)
{
if (first_free_player_slot > MAX_USERS &&
( detected_port == settings->uints.input_joypad_index[player] ||
!input_config_get_device_name(settings->uints.input_joypad_index[player])) &&
settings->uints.input_device_reservation_type[player] != INPUT_DEVICE_RESERVATION_RESERVED )
( detected_port == settings->uints.input_joypad_index[player]
|| !input_config_get_device_name(settings->uints.input_joypad_index[player]))
&& settings->uints.input_device_reservation_type[player]
!= INPUT_DEVICE_RESERVATION_RESERVED )
{
first_free_player_slot = player;
RARCH_DBG("[Autoconf]: First unconfigured / unreserved player is %d\n",
@ -600,10 +601,10 @@ static void cb_input_autoconfigure_connect(
static void input_autoconfigure_connect_handler(retro_task_t *task)
{
char task_title[NAME_MAX_LENGTH + 16];
autoconfig_handle_t *autoconfig_handle = NULL;
bool match_found = false;
const char *device_display_name = NULL;
char task_title[NAME_MAX_LENGTH + 16];
task_title[0] = '\0';
@ -943,9 +944,9 @@ static void cb_input_autoconfigure_disconnect(
static void input_autoconfigure_disconnect_handler(retro_task_t *task)
{
char task_title[NAME_MAX_LENGTH + 16];
autoconfig_handle_t *autoconfig_handle = NULL;
const char *device_display_name = NULL;
char task_title[NAME_MAX_LENGTH + 16];
task_title[0] = '\0';

View File

@ -1051,7 +1051,7 @@ static void task_cloud_sync_end_handler(void *user_data, const char *path, bool
if ((sync_state = (task_cloud_sync_state_t *)task->state))
{
char title[512];
char title[128];
size_t len = strlcpy(title, "Cloud Sync finished", sizeof(title));
if (sync_state->failures || sync_state->conflicts)
len += strlcpy(title + len, " with ", sizeof(title) - len);

View File

@ -787,7 +787,7 @@ static bool content_file_extract_from_archive(
NULL : content_ctx->directory_cache,
tmp_path, sizeof(tmp_path)))
{
char msg[1024];
char msg[128];
snprintf(msg, sizeof(msg), "%s: \"%s\".\n",
msg_hash_to_str(MSG_FAILED_TO_EXTRACT_CONTENT_FROM_COMPRESSED_FILE),
*content_path);
@ -991,7 +991,7 @@ static bool content_file_load(
content_compressed, i, first_content_type,
&content_data, &content_size))
{
char msg[1024];
char msg[128];
snprintf(msg, sizeof(msg), "%s \"%s\"\n",
msg_hash_to_str(MSG_COULD_NOT_READ_CONTENT_FILE),
content_path);
@ -1071,7 +1071,7 @@ static bool content_file_load(
* (This disclaimer is out dated but I don't want to remove it)*/
if (!CopyFileFromAppW(wcontent_path, wnew_path, false))
{
char msg[1024];
char msg[128];
/* TODO/FIXME - localize */
snprintf(msg, sizeof(msg), "%s \"%s\". (during copy read or write)\n",
msg_hash_to_str(MSG_COULD_NOT_READ_CONTENT_FILE),
@ -1173,7 +1173,7 @@ static const struct retro_subsystem_info *content_file_init_subsystem(
if (!special)
{
char msg[1024];
char msg[128];
/* TODO/FIXME - localize */
snprintf(msg, sizeof(msg),
"Failed to find subsystem \"%s\" in libretro implementation.\n",
@ -1192,7 +1192,7 @@ static const struct retro_subsystem_info *content_file_init_subsystem(
if (special->num_roms != subsystem->size)
{
char msg[1024];
char msg[128];
/* TODO/FIXME - localize */
snprintf(msg, sizeof(msg),
"Libretro core requires %u content files for "
@ -1205,7 +1205,7 @@ static const struct retro_subsystem_info *content_file_init_subsystem(
}
else if (subsystem && subsystem->size)
{
char msg[1024];
char msg[128];
/* TODO/FIXME - localize */
snprintf(msg, sizeof(msg),
"Libretro core takes no content for subsystem \"%s\", "

View File

@ -758,16 +758,16 @@ static int database_info_list_iterate_found_match(
const char *archive_name
)
{
char entry_lbl[128];
char db_playlist_base_str[NAME_MAX_LENGTH];
/* TODO/FIXME - heap allocations are done here to avoid
* running out of stack space on systems with a limited stack size.
* We should use less fullsize paths in the future so that we don't
* need to have all these big char arrays here */
size_t str_len = PATH_MAX_LENGTH * sizeof(char);
char* db_crc = (char*)malloc(str_len);
char* db_playlist_base_str = (char*)malloc(str_len);
char* db_playlist_path = (char*)malloc(str_len);
char* entry_path_str = (char*)malloc(str_len);
char* entry_label = (char*)malloc(str_len);
char *hash = NULL;
playlist_t *playlist = NULL;
const char *db_path =
@ -810,16 +810,16 @@ static int database_info_list_iterate_found_match(
/* Use database name for label if found,
* otherwise use filename without extension */
if (!string_is_empty(db_info_entry->name))
strlcpy(entry_label, db_info_entry->name, str_len);
strlcpy(entry_lbl, db_info_entry->name, str_len);
else if (!string_is_empty(entry_path))
{
char *delim = (char*)strchr(entry_path, '#');
if (delim)
*delim = '\0';
fill_pathname(entry_label,
fill_pathname(entry_lbl,
path_basename_nocompression(entry_path), "", str_len);
path_remove_extension(entry_label);
path_remove_extension(entry_lbl);
RARCH_LOG("[Scanner]: No match for: \"%s\", CRC: 0x%08X\n", entry_path_str, db_state->crc);
}
@ -852,7 +852,7 @@ static int database_info_list_iterate_found_match(
/* the push function reads our entry as const,
* so these casts are safe */
entry.path = entry_path_str;
entry.label = entry_label;
entry.label = entry_lbl;
entry.core_path = (char*)"DETECT";
entry.core_name = (char*)"DETECT";
entry.db_name = db_playlist_base_str;
@ -872,12 +872,12 @@ static int database_info_list_iterate_found_match(
entry.last_played_second= 0;
playlist_push(playlist, &entry);
RARCH_LOG("[Scanner]: Add \"%s\" to \"%s\"\n", entry_label, entry.db_name);
RARCH_LOG("[Scanner]: Add \"%s\" to \"%s\"\n", entry_lbl, entry.db_name);
if (retroarch_override_setting_is_set(RARCH_OVERRIDE_SETTING_DATABASE_SCAN, NULL))
task_database_scan_console_output(entry_label, path_remove_extension(db_playlist_base_str), true);
task_database_scan_console_output(entry_lbl, path_remove_extension(db_playlist_base_str), true);
}
else if (retroarch_override_setting_is_set(RARCH_OVERRIDE_SETTING_DATABASE_SCAN, NULL))
task_database_scan_console_output(entry_label, path_remove_extension(db_playlist_base_str), false);
task_database_scan_console_output(entry_lbl, path_remove_extension(db_playlist_base_str), false);
playlist_write_file(playlist);
playlist_free(playlist);
@ -902,10 +902,8 @@ static int database_info_list_iterate_found_match(
}
free(db_crc);
free(db_playlist_base_str);
free(db_playlist_path);
free(entry_path_str);
free(entry_label);
return 0;
}
@ -932,8 +930,8 @@ static int task_database_iterate_crc_lookup(
const char *archive_entry,
bool path_contains_compressed_file)
{
if (!db_state->list ||
(unsigned)db_state->list_index == (unsigned)db_state->list->size)
if ( !db_state->list
|| (unsigned)db_state->list_index == (unsigned)db_state->list->size)
return database_info_list_iterate_end_no_match(db, db_state, name,
path_contains_compressed_file);

View File

@ -391,7 +391,7 @@ void* task_push_webdav_put(const char *url,
const char *headers, retro_task_callback_t cb, void *user_data)
{
struct http_connection_t *conn;
char expect[1024];
char expect[1024]; /* TODO/FIXME - check size */
size_t _len;
if (string_is_empty(url))

View File

@ -249,7 +249,7 @@ error:
static bool bsv_movie_start_record(input_driver_state_t * input_st, char *path)
{
size_t _len;
char msg[8192]; /* TODO/FIXME - check size */
char msg[128];
bsv_movie_t *state = NULL;
const char *movie_rec_str = NULL;
@ -446,7 +446,7 @@ error:
bool movie_start_record(input_driver_state_t *input_st, char*path)
{
size_t _len;
char msg[8192]; /* TODO/FIXME - check size */
char msg[128];
const char *movie_rec_str = msg_hash_to_str(MSG_STARTING_MOVIE_RECORD_TO);
retro_task_t *task = task_init();
moviectl_task_state_t *state = (moviectl_task_state_t *)calloc(1, sizeof(*state));

View File

@ -749,11 +749,8 @@ static bool apply_patch_content(uint8_t **buf,
/* Show an OSD message */
if (show_notification)
{
char msg[128];
const char *patch_filename = path_basename_nocompression(patch_path);
char msg[256];
msg[0] = '\0';
snprintf(msg, sizeof(msg), msg_hash_to_str(MSG_APPLYING_PATCH),
patch_filename ? patch_filename :
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_UNKNOWN));

View File

@ -755,16 +755,11 @@ static void task_load_handler(retro_task_t *task)
{
if (state->flags & SAVE_TASK_FLAG_AUTOLOAD)
{
char *msg = (char*)malloc(8192 * sizeof(char));
msg[0] = '\0';
snprintf(msg,
8192 * sizeof(char),
char msg[128];
snprintf(msg, sizeof(msg),
msg_hash_to_str(MSG_AUTOLOADING_SAVESTATE_FAILED),
path_basename(state->path));
task_set_error(task, strdup(msg));
free(msg);
}
else
task_set_error(task, strdup(msg_hash_to_str(MSG_FAILED_TO_LOAD_STATE)));
@ -781,32 +776,25 @@ static void task_load_handler(retro_task_t *task)
if (!task_get_mute(task))
{
size_t msg_size = 8192 * sizeof(char);
char *msg = (char*)malloc(msg_size);
msg[0] = '\0';
char msg[128];
if (state->flags & SAVE_TASK_FLAG_AUTOLOAD)
{
snprintf(msg,
msg_size - 1,
snprintf(msg, sizeof(msg),
msg_hash_to_str(MSG_AUTOLOADING_SAVESTATE_SUCCEEDED),
path_basename(state->path));
}
else
{
if (state->state_slot < 0)
strlcpy(msg,
msg_hash_to_str(MSG_LOADED_STATE_FROM_SLOT_AUTO),
msg_size - 1);
sizeof(msg));
else
snprintf(msg, msg_size - 1,
snprintf(msg, sizeof(msg),
msg_hash_to_str(MSG_LOADED_STATE_FROM_SLOT),
state->state_slot);
}
task_set_title(task, strdup(msg));
free(msg);
}
goto end;
@ -816,19 +804,11 @@ static void task_load_handler(retro_task_t *task)
not_found:
{
size_t msg_size = 8192 * sizeof(char);
char *msg = (char*)malloc(msg_size);
msg[0] = '\0';
snprintf(msg,
msg_size - 1,
"%s \"%s\".",
char msg[128];
snprintf(msg, sizeof(msg), "%s \"%s\".",
msg_hash_to_str(MSG_FAILED_TO_LOAD_STATE),
path_basename(state->path));
task_set_title(task, strdup(msg));
free(msg);
}
end: