Remove some temporary buffers (#15624)
This commit is contained in:
parent
10c60cdd4d
commit
7a475c7195
|
@ -573,7 +573,6 @@ static bool runtime_last_played_human(runtime_log_t *runtime_log,
|
||||||
time_t current;
|
time_t current;
|
||||||
time_t delta;
|
time_t delta;
|
||||||
unsigned i;
|
unsigned i;
|
||||||
char tmp[32];
|
|
||||||
|
|
||||||
unsigned units[7][2] =
|
unsigned units[7][2] =
|
||||||
{
|
{
|
||||||
|
@ -588,8 +587,6 @@ static bool runtime_last_played_human(runtime_log_t *runtime_log,
|
||||||
|
|
||||||
float periods[6] = {60.0f, 60.0f, 24.0f, 7.0f, 4.35f, 12.0f};
|
float periods[6] = {60.0f, 60.0f, 24.0f, 7.0f, 4.35f, 12.0f};
|
||||||
|
|
||||||
tmp[0] = '\0';
|
|
||||||
|
|
||||||
if (!runtime_log)
|
if (!runtime_log)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -606,12 +603,11 @@ static bool runtime_last_played_human(runtime_log_t *runtime_log,
|
||||||
delta /= periods[i];
|
delta /= periods[i];
|
||||||
|
|
||||||
/* Generate string */
|
/* Generate string */
|
||||||
_len = snprintf(tmp, sizeof(tmp), "%u ", (int)delta);
|
_len = snprintf(str, len, "%u ", (int)delta);
|
||||||
strlcpy(tmp + _len,
|
_len += strlcpy(str + _len,
|
||||||
msg_hash_to_str((enum msg_hash_enums)units[i][(delta == 1) ? 0 : 1]),
|
msg_hash_to_str((enum msg_hash_enums)units[i][(delta == 1) ? 0 : 1]),
|
||||||
sizeof(tmp) - _len);
|
len - _len);
|
||||||
|
|
||||||
_len = strlcat(str, tmp, len);
|
|
||||||
str[ _len] = ' ';
|
str[ _len] = ' ';
|
||||||
str[++_len] = '\0';
|
str[++_len] = '\0';
|
||||||
strlcpy(str + _len,
|
strlcpy(str + _len,
|
||||||
|
@ -633,9 +629,7 @@ void runtime_log_get_last_played_str(runtime_log_t *runtime_log,
|
||||||
|
|
||||||
if (runtime_log)
|
if (runtime_log)
|
||||||
{
|
{
|
||||||
char tmp[64];
|
|
||||||
bool has_am_pm = false;
|
bool has_am_pm = false;
|
||||||
tmp[0] = '\0';
|
|
||||||
/* Handle 12-hour clock options
|
/* Handle 12-hour clock options
|
||||||
* > These require extra work, due to AM/PM localisation */
|
* > These require extra work, due to AM/PM localisation */
|
||||||
switch (timedate_style)
|
switch (timedate_style)
|
||||||
|
@ -773,10 +767,7 @@ void runtime_log_get_last_played_str(runtime_log_t *runtime_log,
|
||||||
/* Get time */
|
/* Get time */
|
||||||
struct tm time_info;
|
struct tm time_info;
|
||||||
runtime_log_get_last_played_time(runtime_log, &time_info);
|
runtime_log_get_last_played_time(runtime_log, &time_info);
|
||||||
strftime_am_pm(tmp, sizeof(tmp), format_str, &time_info);
|
strftime_am_pm(str + _len, len - _len, format_str, &time_info);
|
||||||
str[ _len] = ' ';
|
|
||||||
str[++_len] = '\0';
|
|
||||||
strlcpy(str + _len, tmp, len - _len);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1028,14 +1019,13 @@ void runtime_log_get_last_played_str(runtime_log_t *runtime_log,
|
||||||
runtime_log->last_played.day, runtime_log->last_played.month);
|
runtime_log->last_played.day, runtime_log->last_played.month);
|
||||||
return;
|
return;
|
||||||
case PLAYLIST_LAST_PLAYED_STYLE_AGO:
|
case PLAYLIST_LAST_PLAYED_STYLE_AGO:
|
||||||
if (!(runtime_last_played_human(runtime_log, tmp, sizeof(tmp))))
|
str[ _len] = ' ';
|
||||||
strlcat(tmp,
|
str[++_len] = '\0';
|
||||||
|
if (!(runtime_last_played_human(runtime_log, str + _len, len - _len - 2)))
|
||||||
|
strlcat(str + _len,
|
||||||
msg_hash_to_str(
|
msg_hash_to_str(
|
||||||
MENU_ENUM_LABEL_VALUE_PLAYLIST_INLINE_CORE_DISPLAY_NEVER),
|
MENU_ENUM_LABEL_VALUE_PLAYLIST_INLINE_CORE_DISPLAY_NEVER),
|
||||||
sizeof(tmp));
|
len - _len - 2);
|
||||||
str[ _len] = ' ';
|
|
||||||
str[++_len] = '\0';
|
|
||||||
strlcpy(str + _len, tmp, len - _len);
|
|
||||||
return;
|
return;
|
||||||
case PLAYLIST_LAST_PLAYED_STYLE_YMD_HMS:
|
case PLAYLIST_LAST_PLAYED_STYLE_YMD_HMS:
|
||||||
default:
|
default:
|
||||||
|
|
Loading…
Reference in New Issue