mirror of
https://github.com/libretro/RetroArch
synced 2025-03-20 19:21:27 +00:00
Prefer strlcpy over snprintf when possible - cleanup some Lakka code
This commit is contained in:
parent
a8c43daef6
commit
5a16f91365
@ -1365,23 +1365,24 @@ static void load_timezone(char *setting)
|
|||||||
{
|
{
|
||||||
char haystack[TIMEZONE_LENGTH+32];
|
char haystack[TIMEZONE_LENGTH+32];
|
||||||
static char *needle = "TIMEZONE=";
|
static char *needle = "TIMEZONE=";
|
||||||
size_t needle_len = strlen(needle);
|
size_t needle_len = strlen(needle);
|
||||||
|
RFILE *tzfp = filestream_open(LAKKA_TIMEZONE_PATH,
|
||||||
RFILE *tzfp = filestream_open(LAKKA_TIMEZONE_PATH,
|
|
||||||
RETRO_VFS_FILE_ACCESS_READ,
|
RETRO_VFS_FILE_ACCESS_READ,
|
||||||
RETRO_VFS_FILE_ACCESS_HINT_NONE);
|
RETRO_VFS_FILE_ACCESS_HINT_NONE);
|
||||||
|
|
||||||
if (tzfp != NULL)
|
if (tzfp)
|
||||||
{
|
{
|
||||||
|
char *start = NULL;
|
||||||
|
|
||||||
filestream_gets(tzfp, haystack, sizeof(haystack)-1);
|
filestream_gets(tzfp, haystack, sizeof(haystack)-1);
|
||||||
filestream_close(tzfp);
|
filestream_close(tzfp);
|
||||||
|
|
||||||
char *start = strstr(haystack, needle);
|
start = strstr(haystack, needle);
|
||||||
|
|
||||||
if (start)
|
if (start)
|
||||||
snprintf(setting, TIMEZONE_LENGTH, "%s", start + needle_len);
|
strlcpy(setting, start + needle_len, TIMEZONE_LENGTH);
|
||||||
else
|
else
|
||||||
strlcpy(setting, DEFAULT_TIMEZONE, TIMEZONE_LENGTH);
|
strlcpy(setting, DEFAULT_TIMEZONE, TIMEZONE_LENGTH);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
strlcpy(setting, DEFAULT_TIMEZONE, TIMEZONE_LENGTH);
|
strlcpy(setting, DEFAULT_TIMEZONE, TIMEZONE_LENGTH);
|
||||||
@ -1399,7 +1400,7 @@ bool config_overlay_enable_default(void)
|
|||||||
|
|
||||||
static struct config_array_setting *populate_settings_array(settings_t *settings, int *size)
|
static struct config_array_setting *populate_settings_array(settings_t *settings, int *size)
|
||||||
{
|
{
|
||||||
unsigned count = 0;
|
unsigned count = 0;
|
||||||
struct config_array_setting *tmp = (struct config_array_setting*)calloc(1, (*size + 1) * sizeof(struct config_array_setting));
|
struct config_array_setting *tmp = (struct config_array_setting*)calloc(1, (*size + 1) * sizeof(struct config_array_setting));
|
||||||
|
|
||||||
if (!tmp)
|
if (!tmp)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user