mirror of
https://github.com/libretro/RetroArch.git
synced 2024-11-27 02:00:41 +00:00
Get rid of some strlcats
This commit is contained in:
parent
05cf639712
commit
a6e210e9db
76
core_info.c
76
core_info.c
@ -1347,7 +1347,7 @@ static core_path_list_t *core_info_path_list_new(const char *core_dir,
|
||||
struct string_list *core_ext_list = NULL;
|
||||
bool dir_list_ok = false;
|
||||
char exts[32];
|
||||
size_t i;
|
||||
size_t i, len;
|
||||
|
||||
if (string_is_empty(core_exts) ||
|
||||
!path_list)
|
||||
@ -1373,13 +1373,21 @@ static core_path_list_t *core_info_path_list_new(const char *core_dir,
|
||||
|
||||
/* Get list of file extensions to include
|
||||
* > core + lock */
|
||||
strlcpy(exts, core_exts, sizeof(exts));
|
||||
strlcat(exts, "|" FILE_PATH_LOCK_EXTENSION_NO_DOT,
|
||||
sizeof(exts));
|
||||
len = strlcpy(exts, core_exts, sizeof(exts));
|
||||
exts[len ] = '|';
|
||||
exts[len+1] = 'l';
|
||||
exts[len+2] = 'c';
|
||||
exts[len+3] = 'k';
|
||||
#if defined(HAVE_DYNAMIC)
|
||||
/* > 'standalone exempt' */
|
||||
strlcat(exts, "|" FILE_PATH_STANDALONE_EXEMPT_EXTENSION_NO_DOT,
|
||||
sizeof(exts));
|
||||
exts[len+4] = '|';
|
||||
exts[len+5] = 'l';
|
||||
exts[len+6] = 's';
|
||||
exts[len+7] = 'a';
|
||||
exts[len+8] = 'e';
|
||||
exts[len+9] = '\0';
|
||||
#else
|
||||
exts[len+4] = '\0';
|
||||
#endif
|
||||
|
||||
/* Fetch core directory listing */
|
||||
@ -1512,17 +1520,21 @@ static bool core_info_path_is_standalone_exempt(
|
||||
core_aux_file_path_list_t *exempt_list,
|
||||
const char *core_file_name)
|
||||
{
|
||||
size_t i;
|
||||
size_t i, len;
|
||||
uint32_t hash;
|
||||
char exempt_filename[NAME_MAX_LENGTH];
|
||||
|
||||
if (exempt_list->size < 1)
|
||||
return false;
|
||||
|
||||
strlcpy(exempt_filename, core_file_name,
|
||||
sizeof(exempt_filename));
|
||||
strlcat(exempt_filename, FILE_PATH_STANDALONE_EXEMPT_EXTENSION,
|
||||
len = strlcpy(exempt_filename, core_file_name,
|
||||
sizeof(exempt_filename));
|
||||
exempt_filename[len ] = '.';
|
||||
exempt_filename[len+1] = 'l';
|
||||
exempt_filename[len+2] = 's';
|
||||
exempt_filename[len+3] = 'a';
|
||||
exempt_filename[len+4] = 'e';
|
||||
exempt_filename[len+5] = '\0';
|
||||
|
||||
hash = core_info_hash_string(exempt_filename);
|
||||
|
||||
@ -1882,6 +1894,7 @@ static void core_info_parse_config_file(
|
||||
static void core_info_list_resolve_all_extensions(
|
||||
core_info_list_t *core_info_list)
|
||||
{
|
||||
size_t _len = 0;
|
||||
size_t i = 0;
|
||||
size_t all_ext_len = 0;
|
||||
char *all_ext = NULL;
|
||||
@ -1895,9 +1908,7 @@ static void core_info_list_resolve_all_extensions(
|
||||
|
||||
all_ext_len += STRLEN_CONST("7z|") + STRLEN_CONST("zip|");
|
||||
|
||||
all_ext = (char*)calloc(1, all_ext_len);
|
||||
|
||||
if (!all_ext)
|
||||
if (!(all_ext = (char*)calloc(1, all_ext_len)))
|
||||
return;
|
||||
|
||||
core_info_list->all_ext = all_ext;
|
||||
@ -1907,15 +1918,23 @@ static void core_info_list_resolve_all_extensions(
|
||||
if (!core_info_list->list[i].supported_extensions)
|
||||
continue;
|
||||
|
||||
strlcat(core_info_list->all_ext,
|
||||
_len = strlcat(core_info_list->all_ext,
|
||||
core_info_list->list[i].supported_extensions, all_ext_len);
|
||||
strlcat(core_info_list->all_ext, "|", all_ext_len);
|
||||
_len = strlcat(core_info_list->all_ext, "|", all_ext_len);
|
||||
}
|
||||
#ifdef HAVE_7ZIP
|
||||
strlcat(core_info_list->all_ext, "7z|", all_ext_len);
|
||||
core_info_list->all_ext[_len ] = '7';
|
||||
core_info_list->all_ext[_len+1] = 'z';
|
||||
core_info_list->all_ext[_len+2] = '|';
|
||||
core_info_list->all_ext[_len+3] = '\0';
|
||||
_len += 3;
|
||||
#endif
|
||||
#ifdef HAVE_ZLIB
|
||||
strlcat(core_info_list->all_ext, "zip|", all_ext_len);
|
||||
core_info_list->all_ext[_len ] = 'z';
|
||||
core_info_list->all_ext[_len+1] = 'i';
|
||||
core_info_list->all_ext[_len+2] = 'p';
|
||||
core_info_list->all_ext[_len+3] = '|';
|
||||
core_info_list->all_ext[_len+3] = '\0';
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -2993,6 +3012,7 @@ bool core_info_get_core_lock(const char *core_path, bool validate_path)
|
||||
bool core_info_set_core_standalone_exempt(const char *core_path, bool exempt)
|
||||
{
|
||||
#if defined(HAVE_DYNAMIC)
|
||||
size_t _len;
|
||||
core_info_t *core_info = NULL;
|
||||
char exempt_file_path[PATH_MAX_LENGTH];
|
||||
|
||||
@ -3004,10 +3024,14 @@ bool core_info_set_core_standalone_exempt(const char *core_path, bool exempt)
|
||||
return false;
|
||||
|
||||
/* Get 'standalone exempt' file path */
|
||||
strlcpy(exempt_file_path, core_info->path,
|
||||
sizeof(exempt_file_path));
|
||||
strlcat(exempt_file_path, FILE_PATH_STANDALONE_EXEMPT_EXTENSION,
|
||||
_len = strlcpy(exempt_file_path, core_info->path,
|
||||
sizeof(exempt_file_path));
|
||||
exempt_file_path[_len ] = '.';
|
||||
exempt_file_path[_len+1] = 'l';
|
||||
exempt_file_path[_len+2] = 's';
|
||||
exempt_file_path[_len+3] = 'a';
|
||||
exempt_file_path[_len+4] = 'e';
|
||||
exempt_file_path[_len+5] = '\0';
|
||||
|
||||
/* Create or delete 'standalone exempt' file, as required */
|
||||
if (!core_info_update_core_aux_file(exempt_file_path, exempt))
|
||||
@ -3033,6 +3057,7 @@ bool core_info_set_core_standalone_exempt(const char *core_path, bool exempt)
|
||||
bool core_info_get_core_standalone_exempt(const char *core_path)
|
||||
{
|
||||
#if defined(HAVE_DYNAMIC)
|
||||
size_t _len;
|
||||
core_info_t *core_info = NULL;
|
||||
bool is_exempt = false;
|
||||
char exempt_file_path[PATH_MAX_LENGTH];
|
||||
@ -3045,10 +3070,15 @@ bool core_info_get_core_standalone_exempt(const char *core_path)
|
||||
return false;
|
||||
|
||||
/* Get 'standalone exempt' file path */
|
||||
strlcpy(exempt_file_path, core_info->path,
|
||||
sizeof(exempt_file_path));
|
||||
strlcat(exempt_file_path, FILE_PATH_STANDALONE_EXEMPT_EXTENSION,
|
||||
_len = strlcpy(
|
||||
exempt_file_path, core_info->path,
|
||||
sizeof(exempt_file_path));
|
||||
exempt_file_path[_len ] = '.';
|
||||
exempt_file_path[_len+1] = 'l';
|
||||
exempt_file_path[_len+2] = 's';
|
||||
exempt_file_path[_len+3] = 'a';
|
||||
exempt_file_path[_len+4] = 'e';
|
||||
exempt_file_path[_len+5] = '\0';
|
||||
|
||||
/* Check whether 'standalone exempt' file exists */
|
||||
is_exempt = path_is_valid(exempt_file_path);
|
||||
|
@ -710,11 +710,11 @@ static bool x11_display_server_set_window_decorations(void *data, bool on)
|
||||
const char *x11_display_server_get_output_options(void *data)
|
||||
{
|
||||
#ifdef HAVE_XRANDR
|
||||
int i;
|
||||
Display *dpy;
|
||||
XRRScreenResources *res;
|
||||
XRROutputInfo *info;
|
||||
Window root;
|
||||
int i;
|
||||
static char s[PATH_MAX_LENGTH];
|
||||
|
||||
if (!(dpy = XOpenDisplay(0)))
|
||||
@ -727,12 +727,16 @@ const char *x11_display_server_get_output_options(void *data)
|
||||
|
||||
for (i = 0; i < res->noutput; i++)
|
||||
{
|
||||
size_t _len;
|
||||
if (!(info = XRRGetOutputInfo(dpy, res, res->outputs[i])))
|
||||
return NULL;
|
||||
|
||||
strlcat(s, info->name, sizeof(s));
|
||||
_len = strlcat(s, info->name, sizeof(s));
|
||||
if ((i+1) < res->noutput)
|
||||
strlcat(s, "|", sizeof(s));
|
||||
{
|
||||
s[_len ] = '|';
|
||||
s[_len+1] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
return s;
|
||||
|
@ -1873,12 +1873,24 @@ static int action_bind_sublabel_core_backup_entry(
|
||||
const char *crc = list->list[i].alt
|
||||
? list->list[i].alt
|
||||
: list->list[i].path;
|
||||
|
||||
/* Set sublabel prefix */
|
||||
strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CORE_BACKUP_CRC), len);
|
||||
size_t _len = strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CORE_BACKUP_CRC), len);
|
||||
|
||||
/* Add crc string */
|
||||
strlcat(s, (string_is_empty(crc) ? "00000000" : crc), len);
|
||||
if (string_is_empty(crc))
|
||||
{
|
||||
s[_len ] = '0';
|
||||
s[_len+1] = '0';
|
||||
s[_len+2] = '0';
|
||||
s[_len+3] = '0';
|
||||
s[_len+4] = '0';
|
||||
s[_len+5] = '0';
|
||||
s[_len+6] = '0';
|
||||
s[_len+7] = '0';
|
||||
s[_len+8] = '\0';
|
||||
}
|
||||
else
|
||||
strlcat(s, crc, len);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -1917,6 +1917,7 @@ static unsigned menu_displaylist_parse_system_info(file_list_t *list)
|
||||
|
||||
if (frontend->get_powerstate)
|
||||
{
|
||||
size_t _len;
|
||||
int seconds = 0, percent = 0;
|
||||
char tmp2[128];
|
||||
enum frontend_powerstate state =
|
||||
@ -1969,11 +1970,13 @@ static unsigned menu_displaylist_parse_system_info(file_list_t *list)
|
||||
break;
|
||||
}
|
||||
|
||||
strlcpy(tmp,
|
||||
_len = strlcpy(tmp,
|
||||
msg_hash_to_str(
|
||||
MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_POWER_SOURCE),
|
||||
sizeof(tmp));
|
||||
strlcat(tmp, ": ", sizeof(tmp));
|
||||
tmp[_len ] = ':';
|
||||
tmp[_len+1] = ' ';
|
||||
tmp[_len+2] = '\0';
|
||||
strlcat(tmp, tmp2, sizeof(tmp));
|
||||
if (menu_entries_append_enum(list, tmp, "",
|
||||
MENU_ENUM_LABEL_SYSTEM_INFO_ENTRY,
|
||||
@ -1986,17 +1989,19 @@ static unsigned menu_displaylist_parse_system_info(file_list_t *list)
|
||||
video_context_driver_get_ident(&ident_info);
|
||||
tmp_string = ident_info.ident;
|
||||
|
||||
strlcpy(tmp,
|
||||
msg_hash_to_str(
|
||||
MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_VIDEO_CONTEXT_DRIVER),
|
||||
sizeof(tmp));
|
||||
strlcat(tmp,
|
||||
": ",
|
||||
sizeof(tmp));
|
||||
strlcat(tmp,
|
||||
tmp_string ? tmp_string
|
||||
: msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NOT_AVAILABLE),
|
||||
sizeof(tmp));
|
||||
{
|
||||
size_t _len = strlcpy(tmp,
|
||||
msg_hash_to_str(
|
||||
MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_VIDEO_CONTEXT_DRIVER),
|
||||
sizeof(tmp));
|
||||
tmp[_len ] = ':';
|
||||
tmp[_len+1] = ' ';
|
||||
tmp[_len+2] = '\0';
|
||||
strlcat(tmp,
|
||||
tmp_string ? tmp_string
|
||||
: msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NOT_AVAILABLE),
|
||||
sizeof(tmp));
|
||||
}
|
||||
if (menu_entries_append_enum(list, tmp, "",
|
||||
MENU_ENUM_LABEL_SYSTEM_INFO_ENTRY,
|
||||
MENU_SETTINGS_CORE_INFO_NONE, 0, 0))
|
||||
@ -7273,10 +7278,10 @@ unsigned menu_displaylist_build_list(
|
||||
off_string[1] = '\0';
|
||||
strlcat(on_string,
|
||||
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_ON),
|
||||
sizeof(on_string));
|
||||
sizeof(on_string));
|
||||
strlcat(off_string,
|
||||
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_OFF),
|
||||
sizeof(off_string));
|
||||
sizeof(off_string));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -9022,8 +9022,9 @@ static bool setting_append_list_input_player_options(
|
||||
|
||||
if (!string_is_empty(buffer[user]))
|
||||
{
|
||||
strlcpy(label, buffer[user], sizeof(label));
|
||||
strlcat(label, " ", sizeof(label));
|
||||
size_t _len = strlcpy(label, buffer[user], sizeof(label));
|
||||
label[_len ] = ' ';
|
||||
label[_len+1] = '\0';
|
||||
}
|
||||
else
|
||||
label[0] = '\0';
|
||||
|
@ -144,6 +144,7 @@ static void task_cdrom_dump_handler(retro_task_t *task)
|
||||
}
|
||||
case DUMP_STATE_WRITE_CUE:
|
||||
{
|
||||
size_t _len;
|
||||
char output_file[PATH_MAX_LENGTH];
|
||||
char cue_filename[PATH_MAX_LENGTH];
|
||||
/* write cuesheet to a file */
|
||||
@ -160,8 +161,13 @@ static void task_cdrom_dump_handler(retro_task_t *task)
|
||||
|
||||
filestream_close(state->file);
|
||||
|
||||
strlcpy(cue_filename, state->title, sizeof(cue_filename));
|
||||
strlcat(cue_filename, ".cue", sizeof(cue_filename));
|
||||
_len = strlcpy(cue_filename,
|
||||
state->title, sizeof(cue_filename));
|
||||
cue_filename[_len ] = '.';
|
||||
cue_filename[_len+1] = 'c';
|
||||
cue_filename[_len+2] = 'u';
|
||||
cue_filename[_len+3] = 'e';
|
||||
cue_filename[_len+4] = '\0';
|
||||
|
||||
fill_pathname_join_special(output_file,
|
||||
directory_core_assets, cue_filename, sizeof(output_file));
|
||||
|
Loading…
Reference in New Issue
Block a user