Reduce strlcat calls where possible

This commit is contained in:
libretroadmin 2023-06-19 06:00:10 +02:00
parent a7ac52fe91
commit e8242253a7
19 changed files with 261 additions and 188 deletions

View File

@ -683,16 +683,16 @@ int rcheevos_get_richpresence(char *s, size_t len)
if (ret <= 0 && rcheevos_locals.game.title)
{
/* TODO/FIXME - localize */
strlcpy(s, "Playing ", len);
strlcat(s, rcheevos_locals.game.title, len);
size_t _len = strlcpy(s, "Playing ", len);
strlcpy(s + _len, rcheevos_locals.game.title, len - _len);
}
return ret;
}
if (rcheevos_locals.game.title)
{
/* TODO/FIXME - localize */
strlcpy(s, "Spectating ", len);
return (int)strlcat(s, rcheevos_locals.game.title, len);
size_t _len = strlcpy(s, "Spectating ", len);
return (int)strlcpy(s + _len, rcheevos_locals.game.title, len - _len);
}
return 0;
}

View File

@ -82,8 +82,8 @@ static void get_first_valid_core(char* path_return, size_t len)
if (strlen(ent->d_name) > strlen(extension)
&& !strcmp(ent->d_name + strlen(ent->d_name) - strlen(extension), extension))
{
strlcpy(path_return, "sdmc:/retroarch/cores/", len);
strlcat(path_return, ent->d_name, len);
size_t _len = strlcpy(path_return, "sdmc:/retroarch/cores/", len);
strlcpy(path_return + _len, ent->d_name, len - _len);
break;
}
}

View File

@ -141,10 +141,11 @@ static void gx_devthread(void *a)
{
if (!gx_devices[i].interface->isInserted())
{
size_t _len;
char n[8];
gx_devices[i].mounted = false;
strlcpy(n, gx_devices[i].name, sizeof(n));
strlcat(n, ":", sizeof(n));
_len = strlcpy(n, gx_devices[i].name, sizeof(n));
strlcpy(n + _len, ":", sizeof(n) - _len);
fatUnmount(n);
}
}
@ -215,13 +216,14 @@ static void frontend_gx_get_env(int *argc, char *argv[],
/* When using external loaders (Wiiflow, etc),
getcwd doesn't return the path correctly and as a result,
the cfg file is not found. */
if ( string_starts_with_size(argv[0], "usb1", STRLEN_CONST("usb1")) ||
string_starts_with_size(argv[0], "usb2", STRLEN_CONST("usb2")))
if ( string_starts_with_size(argv[0], "usb1", STRLEN_CONST("usb1"))
|| string_starts_with_size(argv[0], "usb2", STRLEN_CONST("usb2")))
{
strlcpy(g_defaults.dirs[DEFAULT_DIR_CORE], "usb",
size_t _len = strlcpy(g_defaults.dirs[DEFAULT_DIR_CORE], "usb",
sizeof(g_defaults.dirs[DEFAULT_DIR_CORE]));
strlcat(g_defaults.dirs[DEFAULT_DIR_CORE], argv[0] + 4,
sizeof(g_defaults.dirs[DEFAULT_DIR_CORE]));
strlcpy(g_defaults.dirs[DEFAULT_DIR_CORE] + _len,
argv[0] + 4,
sizeof(g_defaults.dirs[DEFAULT_DIR_CORE]) - _len);
}
/* Needed on Wii; loaders follow a dumb standard where the path and

View File

@ -63,9 +63,8 @@ static enum HDD_INIT_STATUS hddStatus = HDD_INIT_STATUS_UNKNOWN;
static void create_path_names(void)
{
char user_path[FILENAME_MAX];
strlcpy(user_path, cwd, sizeof(user_path));
strlcat(user_path, "retroarch", sizeof(user_path));
size_t _len = strlcpy(user_path, cwd, sizeof(user_path));
strlcpy(user_path + _len, "retroarch", sizeof(user_path) - _len);
fill_pathname_basedir(g_defaults.dirs[DEFAULT_DIR_PORT], cwd, sizeof(g_defaults.dirs[DEFAULT_DIR_PORT]));
/* Content in the same folder */
@ -216,16 +215,17 @@ static void mount_partition(void)
return;
}
/* If we're booting from HDD, we must update the cwd variable
* and add : to the mount point */
if (bootDeviceID == BOOT_DEVICE_HDD || bootDeviceID == BOOT_DEVICE_HDD0)
{
/* If we're booting from HDD, we must update the cwd variable and add : to the mount point */
strlcpy(cwd, new_cwd, sizeof(cwd));
strlcat(mountPoint, ":", sizeof(mountPoint));
size_t _len = strlcpy(cwd, new_cwd, sizeof(cwd));
strlcpy(mountPoint + _len, ":", sizeof(mountPoint) - _len);
}
else
{
/* We MUST put mountPoint as empty to avoid wrong results
with LoadELFFromFileWithPartition */
with LoadELFFromFileWithPartition */
strlcpy(mountPoint, "", sizeof(mountPoint));
}
}

View File

@ -171,8 +171,10 @@ static void get_first_valid_core(char *path_return, size_t len)
break;
if (strlen(ent->d_name) > strlen(extension) && !strcmp(ent->d_name + strlen(ent->d_name) - strlen(extension), extension))
{
strlcpy(path_return, SD_PREFIX "/retroarch/cores", len);
strlcat(path_return, "/", len);
size_t _len = strlcpy(path_return, SD_PREFIX "/retroarch/cores", len);
strlcpy(path_return + _len,
"/",
len - _len);
strlcat(path_return, ent->d_name, len);
break;
}

View File

@ -1741,13 +1741,13 @@ static void frontend_unix_get_env(int *argc,
if (xdg)
{
strlcpy(base_path, xdg, sizeof(base_path));
strlcat(base_path, "/retroarch", sizeof(base_path));
size_t _len = strlcpy(base_path, xdg, sizeof(base_path));
strlcpy(base_path + _len, "/retroarch", sizeof(base_path) - _len);
}
else if (home)
{
strlcpy(base_path, home, sizeof(base_path));
strlcat(base_path, "/.config/retroarch", sizeof(base_path));
size_t _len = strlcpy(base_path, home, sizeof(base_path));
strlcpy(base_path + _len, "/.config/retroarch", sizeof(base_path) - _len);
}
else
strlcpy(base_path, "retroarch", sizeof(base_path));
@ -2255,21 +2255,23 @@ static int frontend_unix_parse_drive_list(void *data, bool load_content)
if (xdg)
{
strlcpy(base_path, xdg, sizeof(base_path));
strlcat(base_path, "/retroarch", sizeof(base_path));
size_t _len = strlcpy(base_path, xdg, sizeof(base_path));
strlcpy(base_path + _len, "/retroarch", sizeof(base_path) - _len);
}
else if (home)
{
strlcpy(base_path, home, sizeof(base_path));
strlcat(base_path, "/.config/retroarch", sizeof(base_path));
size_t _len = strlcpy(base_path, home, sizeof(base_path));
strlcpy(base_path + _len, "/.config/retroarch", sizeof(base_path) - _len);
}
#endif
strlcpy(udisks_media_path, "/run/media", sizeof(udisks_media_path));
if (user)
{
strlcat(udisks_media_path, "/", sizeof(udisks_media_path));
strlcat(udisks_media_path, user, sizeof(udisks_media_path));
size_t _len = strlcpy(udisks_media_path, "/run/media", sizeof(udisks_media_path));
if (user)
{
strlcpy(udisks_media_path + _len, "/", sizeof(udisks_media_path) - _len);
strlcat(udisks_media_path, user, sizeof(udisks_media_path));
}
}
if (!string_is_empty(base_path))

View File

@ -1283,6 +1283,7 @@ static void ctr_render_bottom_screen(void *data)
{
case CTR_BOTTOM_MENU_NOT_AVAILABLE:
{
size_t _len;
char str_path[PATH_MAX_LENGTH];
const char *dir_assets = settings->paths.directory_bottom_assets;
@ -1295,8 +1296,10 @@ static void ctr_render_bottom_screen(void *data)
msg_hash_to_str(MSG_3DS_BOTTOM_MENU_ASSET_NOT_FOUND),
&params);
strlcpy(str_path, dir_assets, sizeof(str_path));
strlcat(str_path, "\n/bottom_menu.png", sizeof(str_path));
_len = strlcpy(str_path, dir_assets, sizeof(str_path));
strlcpy(str_path + _len,
"\n/bottom_menu.png",
sizeof(str_path) - _len);
params.scale = 1.10f;
params.y -= 0.10f;

View File

@ -7176,7 +7176,10 @@ static void materialui_frame(void *data, video_frame_info_t *video_info)
_len = strlcpy(msg, label, sizeof(msg));
msg[_len ] = '\n';
msg[_len+1] = '\0';
strlcat(msg, str, sizeof(msg));
_len += 1;
strlcpy(msg + _len,
str,
sizeof(msg) - _len);
materialui_render_messagebox(mui,
p_disp,
userdata, video_width, video_height,
@ -7519,9 +7522,10 @@ static void materialui_status_bar_init(
sizeof(mui->status_bar.runtime_fallback_str));
mui->status_bar.runtime_fallback_str[_len ] = ' ';
mui->status_bar.runtime_fallback_str[_len+1] = '\0';
strlcat(mui->status_bar.runtime_fallback_str,
_len += 1;
strlcpy(mui->status_bar.runtime_fallback_str + _len,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_DISABLED),
sizeof(mui->status_bar.runtime_fallback_str));
sizeof(mui->status_bar.runtime_fallback_str) - _len);
_len = strlcpy(mui->status_bar.last_played_fallback_str,
msg_hash_to_str(
@ -7529,9 +7533,10 @@ static void materialui_status_bar_init(
sizeof(mui->status_bar.last_played_fallback_str));
mui->status_bar.last_played_fallback_str[_len ] = ' ';
mui->status_bar.last_played_fallback_str[_len+1] = '\0';
strlcat(mui->status_bar.last_played_fallback_str,
_len += 1;
strlcpy(mui->status_bar.last_played_fallback_str + _len,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_DISABLED),
sizeof(mui->status_bar.last_played_fallback_str)
sizeof(mui->status_bar.last_played_fallback_str) - _len
);
}
}
@ -10966,8 +10971,10 @@ static void materialui_list_insert(
{
char val[255];
unsigned user_value = i + 1;
snprintf(val, sizeof(val), "%d", user_value);
strlcat(val, "_input_binds_list", sizeof(val));
size_t _len = snprintf(val, sizeof(val), "%d", user_value);
strlcpy(val + _len,
"_input_binds_list",
sizeof(val) - _len);
if (string_is_equal(label, val))
{

View File

@ -4665,7 +4665,10 @@ static void rgui_render_osk(
size_t _len = strlcpy(msg, input_label, sizeof(msg));
msg[_len ] = '\n';
msg[_len+1] = '\0';
strlcat(msg, input_str, sizeof(msg));
_len += 1;
strlcpy(msg + _len,
input_str,
sizeof(msg) - _len);
rgui_render_messagebox(rgui, msg, fb_width, fb_height);
return;
}
@ -6879,11 +6882,9 @@ static void rgui_update_savestate_thumbnail_path(void *data, unsigned i)
strlcat(path, FILE_PATH_PNG_EXTENSION, sizeof(path));
if (path_is_valid(path))
{
strlcpy(
rgui->savestate_thumbnail_file_path, path,
strlcpy(rgui->savestate_thumbnail_file_path,
path,
sizeof(rgui->savestate_thumbnail_file_path));
}
}
}
}

View File

@ -6362,7 +6362,10 @@ static void xmb_frame(void *data, video_frame_info_t *video_info)
size_t _len = strlcpy(msg, label, sizeof(msg));
msg[_len ] = '\n';
msg[_len+1] = '\0';
strlcat(msg, str, sizeof(msg));
_len += 1;
strlcpy(msg + _len,
str,
sizeof(msg) - _len);
render_background = true;
}

View File

@ -207,13 +207,16 @@ static void handle_discord_join(const char *secret)
if ((room_id = (int)strtol(secret, NULL, 10)))
{
size_t _len;
discord_state_t *discord_st = &discord_state_st;
snprintf(discord_st->peer_party_id,
sizeof(discord_st->peer_party_id),
"%d", room_id);
strlcpy(url, FILE_PATH_LOBBY_LIBRETRO_URL, sizeof(url));
strlcat(url, discord_st->peer_party_id, sizeof(url));
_len = strlcpy(url, FILE_PATH_LOBBY_LIBRETRO_URL, sizeof(url));
strlcpy(url + _len,
discord_st->peer_party_id,
sizeof(url) - _len);
task_push_http_transfer(url, true, NULL, handle_discord_join_cb, NULL);
}
@ -475,9 +478,12 @@ void discord_init(const char *discord_app_id, char *args)
strlcpy(command, args, sizeof(command));
else
{
size_t _len;
path_basedir(full_path);
strlcpy(command, full_path, sizeof(command));
strlcat(command, args, sizeof(command));
_len = strlcpy(command, full_path, sizeof(command));
strlcpy(command + _len,
args,
sizeof(command) - _len);
}
#else
command[0] = 's';

View File

@ -761,6 +761,7 @@ static bool netplay_handshake_init_send(netplay_t *netplay,
#ifdef HAVE_MENU
static void handshake_password(void *userdata, const char *line)
{
size_t _len;
struct password_buf_s password_buf;
char password[8+NETPLAY_PASS_LEN]; /* 8 for salt, 128 for password */
char hash[NETPLAY_PASS_HASH_LEN+1]; /* + NULL terminator */
@ -772,10 +773,12 @@ static void handshake_password(void *userdata, const char *line)
return;
connection = &netplay->connections[0];
snprintf(password, sizeof(password), "%08lX", (unsigned long)connection->salt);
_len = snprintf(password, sizeof(password),
"%08lX", (unsigned long)connection->salt);
if (!string_is_empty(line))
strlcat(password, line, sizeof(password));
strlcpy(password + _len,
line,
sizeof(password) - _len);
password_buf.cmd[0] = htonl(NETPLAY_CMD_PASSWORD);
password_buf.cmd[1] = htonl(sizeof(password_buf.password));

View File

@ -360,12 +360,11 @@ struct string_list *play_feature_delivery_available_cores(void)
if (!string_is_empty(core_name))
{
char core_file[256];
core_file[0] = '\0';
/* Generate core file name */
strlcpy(core_file, core_name, sizeof(core_file));
strlcat(core_file, "_libretro_android.so", sizeof(core_file));
size_t _len = strlcpy(core_file, core_name, sizeof(core_file));
strlcpy(core_file + _len,
"_libretro_android.so",
sizeof(core_file) - _len);
/* Add entry to list */
if (!string_is_empty(core_file))
string_list_append(core_list, core_file, attr);

View File

@ -469,23 +469,23 @@ void recording_driver_update_streaming_url(void)
case STREAMING_MODE_TWITCH:
if (!string_is_empty(settings->arrays.twitch_stream_key))
{
strlcpy(settings->paths.path_stream_url,
size_t _len = strlcpy(settings->paths.path_stream_url,
twitch_url,
sizeof(settings->paths.path_stream_url));
strlcat(settings->paths.path_stream_url,
strlcpy(settings->paths.path_stream_url + _len,
settings->arrays.twitch_stream_key,
sizeof(settings->paths.path_stream_url));
sizeof(settings->paths.path_stream_url) - _len);
}
break;
case STREAMING_MODE_YOUTUBE:
if (!string_is_empty(settings->arrays.youtube_stream_key))
{
strlcpy(settings->paths.path_stream_url,
size_t _len = strlcpy(settings->paths.path_stream_url,
youtube_url,
sizeof(settings->paths.path_stream_url));
strlcat(settings->paths.path_stream_url,
strlcpy(settings->paths.path_stream_url + _len,
settings->arrays.youtube_stream_key,
sizeof(settings->paths.path_stream_url));
sizeof(settings->paths.path_stream_url) - _len);
}
break;
case STREAMING_MODE_LOCAL:
@ -500,12 +500,12 @@ void recording_driver_update_streaming_url(void)
case STREAMING_MODE_FACEBOOK:
if (!string_is_empty(settings->arrays.facebook_stream_key))
{
strlcpy(settings->paths.path_stream_url,
size_t _len = strlcpy(settings->paths.path_stream_url,
facebook_url,
sizeof(settings->paths.path_stream_url));
strlcat(settings->paths.path_stream_url,
strlcpy(settings->paths.path_stream_url + _len,
settings->arrays.facebook_stream_key,
sizeof(settings->paths.path_stream_url));
sizeof(settings->paths.path_stream_url) - _len);
}
break;
}

View File

@ -519,8 +519,10 @@ void input_autoconfigure_blissbox_override_handler(
/* override name given to autoconfig so it knows what kind of pad this is */
if (len > 0)
{
strlcpy(device_name, "Bliss-Box 4-Play ", len);
strlcat(device_name, pad->name, len);
size_t _len = strlcpy(device_name, "Bliss-Box 4-Play ", len);
strlcpy(device_name + _len,
pad->name,
len - _len);
}
blissbox_pads[index] = pad;

View File

@ -274,6 +274,7 @@ static void task_core_backup_handler(retro_task_t *task)
break;
case CORE_BACKUP_PRE_ITERATE:
{
size_t _len;
char task_title[PATH_MAX_LENGTH];
char backup_path[PATH_MAX_LENGTH];
@ -314,9 +315,11 @@ static void task_core_backup_handler(retro_task_t *task)
/* Update task title */
task_free_title(task);
strlcpy(task_title, msg_hash_to_str(MSG_BACKING_UP_CORE),
_len = strlcpy(task_title, msg_hash_to_str(MSG_BACKING_UP_CORE),
sizeof(task_title));
strlcat(task_title, backup_handle->core_name, sizeof(task_title));
strlcpy(task_title + _len,
backup_handle->core_name,
sizeof(task_title) - _len);
task_set_title(task, strdup(task_title));
/* Go to iteration phase */
@ -412,6 +415,7 @@ static void task_core_backup_handler(retro_task_t *task)
* history size limit */
if (num_backups > backup_handle->auto_backup_history_size)
{
size_t _len;
char task_title[PATH_MAX_LENGTH];
/* Get number of old backups to remove */
@ -420,9 +424,12 @@ static void task_core_backup_handler(retro_task_t *task)
/* Update task title */
task_free_title(task);
strlcpy(task_title, msg_hash_to_str(MSG_PRUNING_CORE_BACKUP_HISTORY),
_len = strlcpy(task_title,
msg_hash_to_str(MSG_PRUNING_CORE_BACKUP_HISTORY),
sizeof(task_title));
strlcat(task_title, backup_handle->core_name, sizeof(task_title));
strlcpy(task_title + _len,
backup_handle->core_name,
sizeof(task_title) - _len);
task_set_title(task, strdup(task_title));
/* Go to history clean-up phase */
@ -479,6 +486,7 @@ static void task_core_backup_handler(retro_task_t *task)
break;
case CORE_BACKUP_END:
{
size_t _len;
char task_title[PATH_MAX_LENGTH];
/* Set final task title */
task_free_title(task);
@ -486,19 +494,21 @@ static void task_core_backup_handler(retro_task_t *task)
if (backup_handle->success)
{
if (backup_handle->crc_match)
strlcpy(task_title,
_len = strlcpy(task_title,
msg_hash_to_str(MSG_CORE_BACKUP_ALREADY_EXISTS),
sizeof(task_title));
else
strlcpy(task_title,
_len = strlcpy(task_title,
msg_hash_to_str(MSG_CORE_BACKUP_COMPLETE),
sizeof(task_title));
}
else
strlcpy(task_title, msg_hash_to_str(MSG_CORE_BACKUP_FAILED),
_len = strlcpy(task_title, msg_hash_to_str(MSG_CORE_BACKUP_FAILED),
sizeof(task_title));
strlcat(task_title, backup_handle->core_name, sizeof(task_title));
strlcpy(task_title + _len,
backup_handle->core_name,
sizeof(task_title) - _len);
task_set_title(task, strdup(task_title));
}
/* fall-through */
@ -530,6 +540,7 @@ void *task_push_core_backup(
size_t auto_backup_history_size,
const char *dir_core_assets, bool mute)
{
size_t _len;
task_finder_data_t find_data;
const char *core_name = NULL;
retro_task_t *task = NULL;
@ -537,8 +548,8 @@ void *task_push_core_backup(
char task_title[PATH_MAX_LENGTH];
/* Sanity check */
if (string_is_empty(core_path) ||
!path_is_valid(core_path))
if ( string_is_empty(core_path)
|| !path_is_valid(core_path))
goto error;
/* Concurrent backup/restore tasks for the same core
@ -601,9 +612,11 @@ void *task_push_core_backup(
goto error;
/* Get initial task title */
strlcpy(task_title, msg_hash_to_str(MSG_CORE_BACKUP_SCANNING_CORE),
_len = strlcpy(task_title, msg_hash_to_str(MSG_CORE_BACKUP_SCANNING_CORE),
sizeof(task_title));
strlcat(task_title, backup_handle->core_name, sizeof(task_title));
strlcpy(task_title + _len,
backup_handle->core_name,
sizeof(task_title) - _len);
/* Configure task */
task->handler = task_core_backup_handler;
@ -737,6 +750,7 @@ static void task_core_restore_handler(retro_task_t *task)
break;
case CORE_RESTORE_PRE_ITERATE:
{
size_t _len;
char task_title[PATH_MAX_LENGTH];
/* Open backup file */
@ -803,11 +817,14 @@ static void task_core_restore_handler(retro_task_t *task)
/* Update task title */
task_free_title(task);
strlcpy(task_title, (backup_handle->backup_type == CORE_BACKUP_TYPE_ARCHIVE) ?
msg_hash_to_str(MSG_RESTORING_CORE) :
msg_hash_to_str(MSG_INSTALLING_CORE),
_len = strlcpy(task_title,
(backup_handle->backup_type == CORE_BACKUP_TYPE_ARCHIVE)
? msg_hash_to_str(MSG_RESTORING_CORE)
: msg_hash_to_str(MSG_INSTALLING_CORE),
sizeof(task_title));
strlcat(task_title, backup_handle->core_name, sizeof(task_title));
strlcpy(task_title + _len,
backup_handle->core_name,
sizeof(task_title) - _len);
task_set_title(task, strdup(task_title));
/* Go to iteration phase */
@ -870,6 +887,7 @@ static void task_core_restore_handler(retro_task_t *task)
break;
case CORE_RESTORE_END:
{
size_t _len;
char task_title[PATH_MAX_LENGTH];
/* Set final task title */
@ -878,23 +896,28 @@ static void task_core_restore_handler(retro_task_t *task)
if (backup_handle->success)
{
if (backup_handle->crc_match)
strlcpy(task_title, (backup_handle->backup_type == CORE_BACKUP_TYPE_ARCHIVE) ?
msg_hash_to_str(MSG_CORE_RESTORATION_ALREADY_INSTALLED) :
msg_hash_to_str(MSG_CORE_INSTALLATION_ALREADY_INSTALLED),
_len = strlcpy(task_title,
(backup_handle->backup_type == CORE_BACKUP_TYPE_ARCHIVE)
? msg_hash_to_str(MSG_CORE_RESTORATION_ALREADY_INSTALLED)
: msg_hash_to_str(MSG_CORE_INSTALLATION_ALREADY_INSTALLED),
sizeof(task_title));
else
strlcpy(task_title, (backup_handle->backup_type == CORE_BACKUP_TYPE_ARCHIVE) ?
msg_hash_to_str(MSG_CORE_RESTORATION_COMPLETE) :
msg_hash_to_str(MSG_CORE_INSTALLATION_COMPLETE),
_len = strlcpy(task_title,
(backup_handle->backup_type == CORE_BACKUP_TYPE_ARCHIVE)
? msg_hash_to_str(MSG_CORE_RESTORATION_COMPLETE)
: msg_hash_to_str(MSG_CORE_INSTALLATION_COMPLETE),
sizeof(task_title));
}
else
strlcpy(task_title, (backup_handle->backup_type == CORE_BACKUP_TYPE_ARCHIVE) ?
msg_hash_to_str(MSG_CORE_RESTORATION_FAILED) :
msg_hash_to_str(MSG_CORE_INSTALLATION_FAILED),
_len = strlcpy(task_title,
(backup_handle->backup_type == CORE_BACKUP_TYPE_ARCHIVE)
? msg_hash_to_str(MSG_CORE_RESTORATION_FAILED)
: msg_hash_to_str(MSG_CORE_INSTALLATION_FAILED),
sizeof(task_title));
strlcat(task_title, backup_handle->core_name, sizeof(task_title));
strlcpy(task_title + _len,
backup_handle->core_name,
sizeof(task_title) - _len);
task_set_title(task, strdup(task_title));
}
/* fall-through */
@ -916,6 +939,7 @@ task_finished:
bool task_push_core_restore(const char *backup_path, const char *dir_libretro,
bool *core_loaded)
{
size_t _len;
task_finder_data_t find_data;
enum core_backup_type backup_type;
core_info_t *core_info = NULL;
@ -952,9 +976,13 @@ bool task_push_core_restore(const char *backup_path, const char *dir_libretro,
{
const char *backup_filename = path_basename(backup_path);
char msg[PATH_MAX_LENGTH];
strlcpy(msg, msg_hash_to_str(MSG_CORE_RESTORATION_INVALID_CONTENT), sizeof(msg));
_len = strlcpy(msg,
msg_hash_to_str(MSG_CORE_RESTORATION_INVALID_CONTENT),
sizeof(msg));
if (backup_filename)
strlcat(msg, backup_filename, sizeof(msg));
strlcpy(msg + _len,
backup_filename,
sizeof(msg) - _len);
RARCH_ERR("[core restore] Invalid core file selected: %s\n", backup_path);
runloop_msg_queue_push(msg, 1, 100, true,
@ -980,12 +1008,14 @@ bool task_push_core_restore(const char *backup_path, const char *dir_libretro,
if (core_info_get_core_lock(core_path, true))
{
char msg[PATH_MAX_LENGTH];
strlcpy(msg,
_len = strlcpy(msg,
(backup_type == CORE_BACKUP_TYPE_ARCHIVE)
? msg_hash_to_str(MSG_CORE_RESTORATION_DISABLED)
: msg_hash_to_str(MSG_CORE_INSTALLATION_DISABLED),
? msg_hash_to_str(MSG_CORE_RESTORATION_DISABLED)
: msg_hash_to_str(MSG_CORE_INSTALLATION_DISABLED),
sizeof(msg));
strlcat(msg, core_name, sizeof(msg));
strlcpy(msg + _len,
core_name,
sizeof(msg) - _len);
RARCH_ERR("[core restore] Restoration disabled - core is locked: %s\n", core_path);
runloop_msg_queue_push(msg, 1, 100, true,
@ -1031,9 +1061,12 @@ bool task_push_core_restore(const char *backup_path, const char *dir_libretro,
goto error;
/* Get initial task title */
strlcpy(task_title, msg_hash_to_str(MSG_CORE_BACKUP_SCANNING_CORE),
_len = strlcpy(task_title,
msg_hash_to_str(MSG_CORE_BACKUP_SCANNING_CORE),
sizeof(task_title));
strlcat(task_title, backup_handle->core_name, sizeof(task_title));
strlcpy(task_title + _len,
backup_handle->core_name,
sizeof(task_title) - _len);
/* Configure task */
task->handler = task_core_restore_handler;

View File

@ -296,6 +296,7 @@ static void task_manual_content_scan_handler(retro_task_t *task)
if (entry)
{
size_t _len;
const char *entry_file = NULL;
const char *entry_file_ext = NULL;
char task_title[PATH_MAX_LENGTH];
@ -303,13 +304,15 @@ static void task_manual_content_scan_handler(retro_task_t *task)
/* Update progress display */
task_free_title(task);
strlcpy(task_title,
_len = strlcpy(task_title,
msg_hash_to_str(MSG_MANUAL_CONTENT_SCAN_PLAYLIST_CLEANUP),
sizeof(task_title));
if (!string_is_empty(entry->path) &&
(entry_file = path_basename(entry->path)))
strlcat(task_title, entry_file, sizeof(task_title));
strlcpy(task_title + _len,
entry_file,
sizeof(task_title) - _len);
task_set_title(task, strdup(task_title));
task_set_progress(task, (manual_scan->playlist_index * 100) /
@ -359,18 +362,21 @@ static void task_manual_content_scan_handler(retro_task_t *task)
if (!string_is_empty(content_path))
{
size_t _len;
char task_title[PATH_MAX_LENGTH];
const char *content_file = path_basename(content_path);
/* Update progress display */
task_free_title(task);
strlcpy(task_title,
_len = strlcpy(task_title,
msg_hash_to_str(MSG_MANUAL_CONTENT_SCAN_IN_PROGRESS),
sizeof(task_title));
if (!string_is_empty(content_file))
strlcat(task_title, content_file, sizeof(task_title));
strlcpy(task_title + _len,
content_file,
sizeof(task_title) - _len);
task_set_title(task, strdup(task_title));
task_set_progress(task,
@ -417,6 +423,7 @@ static void task_manual_content_scan_handler(retro_task_t *task)
if (!string_is_empty(m3u_path))
{
size_t _len;
char task_title[PATH_MAX_LENGTH];
const char *m3u_name = path_basename_nocompression(m3u_path);
m3u_file_t *m3u_file = NULL;
@ -424,12 +431,14 @@ static void task_manual_content_scan_handler(retro_task_t *task)
/* Update progress display */
task_free_title(task);
strlcpy(task_title,
_len = strlcpy(task_title,
msg_hash_to_str(MSG_MANUAL_CONTENT_SCAN_M3U_CLEANUP),
sizeof(task_title));
if (!string_is_empty(m3u_name))
strlcat(task_title, m3u_name, sizeof(task_title));
strlcpy(task_title + _len,
m3u_name,
sizeof(task_title) - _len);
task_set_title(task, strdup(task_title));
task_set_progress(task, (manual_scan->m3u_index * 100) /
@ -464,6 +473,7 @@ static void task_manual_content_scan_handler(retro_task_t *task)
break;
case MANUAL_SCAN_END:
{
size_t _len;
char task_title[PATH_MAX_LENGTH];
/* Ensure playlist is alphabetically sorted
@ -477,11 +487,12 @@ static void task_manual_content_scan_handler(retro_task_t *task)
/* Update progress display */
task_free_title(task);
strlcpy(
_len = strlcpy(
task_title, msg_hash_to_str(MSG_MANUAL_CONTENT_SCAN_END),
sizeof(task_title));
strlcat(task_title, manual_scan->task_config->system_name,
sizeof(task_title));
strlcpy(task_title + _len,
manual_scan->task_config->system_name,
sizeof(task_title) - _len);
task_set_title(task, strdup(task_title));
}
@ -517,6 +528,7 @@ bool task_push_manual_content_scan(
const playlist_config_t *playlist_config,
const char *playlist_directory)
{
size_t _len;
task_finder_data_t find_data;
char task_title[PATH_MAX_LENGTH];
retro_task_t *task = NULL;
@ -585,11 +597,12 @@ bool task_push_manual_content_scan(
goto error;
/* > Get task title */
strlcpy(
_len = strlcpy(
task_title, msg_hash_to_str(MSG_MANUAL_CONTENT_SCAN_START),
sizeof(task_title));
strlcat(task_title, manual_scan->task_config->system_name,
sizeof(task_title));
strlcpy(task_title + _len,
manual_scan->task_config->system_name,
sizeof(task_title) - _len);
/* > Configure task */
task->handler = task_manual_content_scan_handler;

View File

@ -648,9 +648,9 @@ static void task_overlay_deferred_load(retro_task_t *task)
for (i = 0; i < loader->pos_increment; i++, loader->pos++)
{
size_t _len;
char conf_key_base[10];
char conf_key[32];
char overlay_full_screen_key[32];
char tmp_str[PATH_MAX_LENGTH];
float tmp_float = 0.0;
bool tmp_bool = false;
@ -671,12 +671,24 @@ static void task_overlay_deferred_load(retro_task_t *task)
overlay = &loader->overlays[loader->pos];
snprintf(conf_key_base, sizeof(conf_key_base), "overlay%u", loader->pos);
_len = strlcpy(conf_key, conf_key_base, sizeof(conf_key));
strlcpy(overlay->config.descs.key, conf_key_base,
sizeof(overlay->config.descs.key));
strlcat(overlay->config.descs.key, "_descs",
strlcpy(conf_key + _len, "_rect", sizeof(conf_key) - _len);
strlcpy(overlay->config.rect.key, conf_key,
sizeof(overlay->config.rect.key));
strlcpy(conf_key + _len, "_name", sizeof(conf_key) - _len);
strlcpy(overlay->config.names.key, conf_key,
sizeof(overlay->config.names.key));
strlcpy(conf_key + _len, "_descs", sizeof(conf_key) - _len);
strlcpy(overlay->config.descs.key, conf_key,
sizeof(overlay->config.descs.key));
strlcpy(conf_key + _len, "_overlay", sizeof(conf_key) - _len);
strlcpy(overlay->config.paths.key, conf_key,
sizeof(overlay->config.paths.key));
if (!config_get_uint(conf, overlay->config.descs.key,
&overlay->config.descs.size))
{
@ -697,35 +709,31 @@ static void task_overlay_deferred_load(retro_task_t *task)
overlay->descs = overlay_desc;
overlay->size = overlay->config.descs.size;
strlcpy(overlay_full_screen_key, conf_key_base,
sizeof(overlay_full_screen_key));
strlcat(overlay_full_screen_key, "_full_screen",
sizeof(overlay_full_screen_key));
overlay->flags &= ~OVERLAY_FULL_SCREEN;
if (config_get_bool(conf, overlay_full_screen_key, &tmp_bool)
&& tmp_bool)
overlay->flags |= OVERLAY_FULL_SCREEN;
strlcpy(conf_key + _len, "_alpha_mod", sizeof(conf_key) - _len);
if (config_get_float(conf, conf_key, &tmp_float))
overlay->config.alpha_mod = tmp_float;
else
overlay->config.alpha_mod = 1.0f;
overlay->config.normalized = false;
overlay->config.alpha_mod = 1.0f;
overlay->config.range_mod = 1.0f;
strlcpy(conf_key + _len, "_range_mod", sizeof(conf_key) - _len);
if (config_get_float(conf, conf_key, &tmp_float))
overlay->config.range_mod = tmp_float;
else
overlay->config.range_mod = 1.0f;
strlcpy(conf_key, conf_key_base, sizeof(conf_key));
strlcat(conf_key, "_normalized", sizeof(conf_key));
strlcpy(conf_key + _len, "_normalized", sizeof(conf_key) - _len);
if (config_get_bool(conf, conf_key, &tmp_bool)
&& tmp_bool)
overlay->config.normalized = tmp_bool;
else
overlay->config.normalized = false;
strlcpy(conf_key, conf_key_base, sizeof(conf_key));
strlcat(conf_key, "_alpha_mod", sizeof(conf_key));
if (config_get_float(conf, conf_key, &tmp_float))
overlay->config.alpha_mod = tmp_float;
strlcpy(conf_key, conf_key_base, sizeof(conf_key));
strlcat(conf_key, "_range_mod", sizeof(conf_key));
if (config_get_float(conf, conf_key, &tmp_float))
overlay->config.range_mod = tmp_float;
strlcpy(conf_key + _len, "_full_screen", sizeof(conf_key) - _len);
if (config_get_bool(conf, conf_key, &tmp_bool)
&& tmp_bool)
overlay->flags |= OVERLAY_FULL_SCREEN;
else
overlay->flags &= ~OVERLAY_FULL_SCREEN;
/* Precache load image array for simplicity. */
texture_img = (struct texture_image*)
@ -739,11 +747,6 @@ static void task_overlay_deferred_load(retro_task_t *task)
overlay->load_images = texture_img;
strlcpy(overlay->config.paths.key, conf_key_base,
sizeof(overlay->config.paths.key));
strlcat(overlay->config.paths.key, "_overlay",
sizeof(overlay->config.paths.key));
if (config_get_path(conf, overlay->config.paths.key,
tmp_str, sizeof(tmp_str)))
strlcpy(overlay->config.paths.path,
@ -775,19 +778,15 @@ static void task_overlay_deferred_load(retro_task_t *task)
overlay->image = image_tex;
}
strlcpy(overlay->config.names.key, conf_key_base,
sizeof(overlay->config.names.key));
strlcat(overlay->config.names.key, "_name",
sizeof(overlay->config.names.key));
config_get_array(conf, overlay->config.names.key,
overlay->name, sizeof(overlay->name));
/* Attempt to determine native aspect ratio */
strlcpy(conf_key, conf_key_base, sizeof(conf_key));
strlcat(conf_key, "_aspect_ratio", sizeof(conf_key));
overlay->aspect_ratio = 0.0f;
strlcpy(conf_key + _len, "_aspect_ratio", sizeof(conf_key) - _len);
if (config_get_float(conf, conf_key, &tmp_float))
overlay->aspect_ratio = tmp_float;
else
overlay->aspect_ratio = 0.0f;
if (overlay->aspect_ratio <= 0.0f)
{
@ -806,11 +805,6 @@ static void task_overlay_deferred_load(retro_task_t *task)
overlay->x = overlay->y = 0.0f;
overlay->w = overlay->h = 1.0f;
strlcpy(overlay->config.rect.key, conf_key_base,
sizeof(overlay->config.rect.key));
strlcat(overlay->config.rect.key, "_rect",
sizeof(overlay->config.rect.key));
if (config_get_array(conf, overlay->config.rect.key,
overlay->config.rect.array, sizeof(overlay->config.rect.array)))
{
@ -841,26 +835,9 @@ static void task_overlay_deferred_load(retro_task_t *task)
overlay->center_x = overlay->x + 0.5f * overlay->w;
overlay->center_y = overlay->y + 0.5f * overlay->h;
/* Check whether x/y separation are force disabled
* for this overlay */
strlcpy(conf_key, conf_key_base, sizeof(conf_key));
strlcat(conf_key, "_block_x_separation", sizeof(conf_key));
overlay->flags &= ~OVERLAY_BLOCK_X_SEPARATION;
if (config_get_bool(conf, conf_key, &tmp_bool)
&& tmp_bool)
overlay->flags |= OVERLAY_BLOCK_X_SEPARATION;
strlcpy(conf_key, conf_key_base, sizeof(conf_key));
strlcat(conf_key, "_block_y_separation", sizeof(conf_key));
overlay->flags &= ~OVERLAY_BLOCK_Y_SEPARATION;
if (config_get_bool(conf, conf_key, &tmp_bool)
&& tmp_bool)
overlay->flags |= OVERLAY_BLOCK_Y_SEPARATION;
/* Check whether x/y separation are enabled
* for this overlay in auto-scale mode */
strlcpy(conf_key, conf_key_base, sizeof(conf_key));
strlcat(conf_key, "_auto_x_separation", sizeof(conf_key));
strlcpy(conf_key + _len, "_auto_x_separation", sizeof(conf_key) - _len);
overlay->flags |= OVERLAY_AUTO_X_SEPARATION;
if (config_get_bool(conf, conf_key, &tmp_bool))
{
@ -874,12 +851,28 @@ static void task_overlay_deferred_load(retro_task_t *task)
overlay->flags &= ~OVERLAY_AUTO_X_SEPARATION;
}
strlcpy(conf_key, conf_key_base, sizeof(conf_key));
strlcat(conf_key, "_auto_y_separation", sizeof(conf_key));
overlay->flags &= ~OVERLAY_AUTO_Y_SEPARATION;
strlcpy(conf_key + _len, "_auto_y_separation", sizeof(conf_key) - _len);
if (config_get_bool(conf, conf_key, &tmp_bool)
&& tmp_bool)
overlay->flags |= OVERLAY_AUTO_Y_SEPARATION;
else
overlay->flags &= ~OVERLAY_AUTO_Y_SEPARATION;
/* Check whether x/y separation are force disabled
* for this overlay */
strlcpy(conf_key + _len, "_block_x_separation", sizeof(conf_key) - _len);
if (config_get_bool(conf, conf_key, &tmp_bool)
&& tmp_bool)
overlay->flags |= OVERLAY_BLOCK_X_SEPARATION;
else
overlay->flags &= ~OVERLAY_BLOCK_X_SEPARATION;
strlcpy(conf_key + _len, "_block_y_separation", sizeof(conf_key) - _len);
if (config_get_bool(conf, conf_key, &tmp_bool)
&& tmp_bool)
overlay->flags |= OVERLAY_BLOCK_Y_SEPARATION;
else
overlay->flags &= ~OVERLAY_BLOCK_Y_SEPARATION;
}
return;

View File

@ -76,10 +76,11 @@ task_finished:
if (MIST_IS_SUCCESS(result))
{
char msg[PATH_MAX_LENGTH];
strlcpy(msg, msg_hash_to_str(MSG_CORE_INSTALLED),
sizeof(msg));
strlcat(msg, state->name,
size_t _len = strlcpy(msg, msg_hash_to_str(MSG_CORE_INSTALLED),
sizeof(msg));
strlcpy(msg + _len,
state->name,
sizeof(msg) - _len);
runloop_msg_queue_push(msg, 1, 180, true, NULL,
MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_ERROR);
@ -97,6 +98,7 @@ void task_push_steam_core_dlc_install(
AppId app_id,
const char *name)
{
size_t _len;
char task_title[PATH_MAX_LENGTH];
retro_task_t *task = task_init();
@ -107,9 +109,11 @@ void task_push_steam_core_dlc_install(
state->name = strdup(name);
state->has_downloaded = false;
strlcpy(task_title, msg_hash_to_str(MSG_CORE_STEAM_INSTALLING),
_len = strlcpy(task_title, msg_hash_to_str(MSG_CORE_STEAM_INSTALLING),
sizeof(task_title));
strlcat(task_title, name, sizeof(task_title));
strlcpy(task_title + _len,
name,
sizeof(task_title) - _len);
task->handler = task_steam_core_dlc_install_handler;
task->state = state;