Remove some temporary buffers (#15624)

This commit is contained in:
zoltanvb 2023-08-20 19:59:15 +02:00 committed by GitHub
parent 10c60cdd4d
commit 7a475c7195
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -573,7 +573,6 @@ static bool runtime_last_played_human(runtime_log_t *runtime_log,
time_t current;
time_t delta;
unsigned i;
char tmp[32];
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};
tmp[0] = '\0';
if (!runtime_log)
return false;
@ -606,12 +603,11 @@ static bool runtime_last_played_human(runtime_log_t *runtime_log,
delta /= periods[i];
/* Generate string */
_len = snprintf(tmp, sizeof(tmp), "%u ", (int)delta);
strlcpy(tmp + _len,
_len = snprintf(str, len, "%u ", (int)delta);
_len += strlcpy(str + _len,
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] = '\0';
strlcpy(str + _len,
@ -633,9 +629,7 @@ void runtime_log_get_last_played_str(runtime_log_t *runtime_log,
if (runtime_log)
{
char tmp[64];
bool has_am_pm = false;
tmp[0] = '\0';
/* Handle 12-hour clock options
* > These require extra work, due to AM/PM localisation */
switch (timedate_style)
@ -773,10 +767,7 @@ void runtime_log_get_last_played_str(runtime_log_t *runtime_log,
/* Get time */
struct tm time_info;
runtime_log_get_last_played_time(runtime_log, &time_info);
strftime_am_pm(tmp, sizeof(tmp), format_str, &time_info);
str[ _len] = ' ';
str[++_len] = '\0';
strlcpy(str + _len, tmp, len - _len);
strftime_am_pm(str + _len, len - _len, format_str, &time_info);
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);
return;
case PLAYLIST_LAST_PLAYED_STYLE_AGO:
if (!(runtime_last_played_human(runtime_log, tmp, sizeof(tmp))))
strlcat(tmp,
str[ _len] = ' ';
str[++_len] = '\0';
if (!(runtime_last_played_human(runtime_log, str + _len, len - _len - 2)))
strlcat(str + _len,
msg_hash_to_str(
MENU_ENUM_LABEL_VALUE_PLAYLIST_INLINE_CORE_DISPLAY_NEVER),
sizeof(tmp));
str[ _len] = ' ';
str[++_len] = '\0';
strlcpy(str + _len, tmp, len - _len);
len - _len - 2);
return;
case PLAYLIST_LAST_PLAYED_STYLE_YMD_HMS:
default: