Bug fix dynamic menus

Dynamic menus had a buffer_len variable in the parent function but it
was discarded before passing to the callbacks

Why!!?? No clue but everything that used it was assuming MAXPATH
Wouldn't be surprised to see some bugs pop out from this one..

init_menu_lists() was assuming MENU_HAS_DESC and setting the
menu title + icon based on such even though it could be invalid
didn't see anywhere in the code that was currently using MENU_DYNAMIC_DESC
in relation to a top level menu but considering it caused all kinds
of corruption to the menu when I tried its probably been tried
and abandoned before...

Change-Id: I8d961d748918bfa8ea6adb5ad60491af4d739d6e
This commit is contained in:
William Wilgus 2019-09-20 03:07:29 -05:00
parent d0883d747a
commit 10e5e56f3c
6 changed files with 43 additions and 19 deletions

View file

@ -41,9 +41,10 @@ static unsigned short hw_eq_setting_lang_ids[AUDIOHW_EQ_SETTING_NUM] =
#endif
};
static char * hw_eq_get_name(int selected_item, void * data, char *buffer)
static char * hw_eq_get_name(int selected_item, void * data,
char *buffer, size_t buffer_len)
{
snprintf(buffer, MAX_PATH,
snprintf(buffer, buffer_len,
str(hw_eq_setting_lang_ids[HW_EQ_IDX_SETTING(data)]),
HW_EQ_IDX_BAND(data) + 1);
return buffer;

View file

@ -100,11 +100,12 @@ MENUITEM_SETTING(force_mono, &global_settings.fm_force_mono, NULL);
#ifndef FM_MODE
extern int radio_mode;
static char* get_mode_text(int selected_item, void * data, char *buffer)
static char* get_mode_text(int selected_item, void * data,
char *buffer, size_t buffer_len)
{
(void)selected_item;
(void)data;
snprintf(buffer, MAX_PATH, "%s %s", str(LANG_MODE),
snprintf(buffer, buffer_len, "%s %s", str(LANG_MODE),
radio_mode ? str(LANG_PRESET) :
str(LANG_RADIO_SCAN_MODE));
return buffer;

View file

@ -500,14 +500,15 @@ static int seconds_to_min(int secs)
/* A string representation of either whether a sleep timer will be started or
canceled, and how long it will be or how long is remaining in brackets */
static char* sleep_timer_getname(int selected_item, void * data, char *buffer)
static char* sleep_timer_getname(int selected_item, void * data,
char *buffer, size_t buffer_len)
{
(void)selected_item;
(void)data;
int sec = get_sleep_timer();
char timer_buf[10];
/* we have no sprintf, so MAX_PATH is a guess */
snprintf(buffer, MAX_PATH, "%s (%s)",
snprintf(buffer, buffer_len, "%s (%s)",
str(sec ? LANG_SLEEP_TIMER_CANCEL_CURRENT
: LANG_SLEEP_TIMER_START_CURRENT),
sleep_timer_formatter(timer_buf, sizeof(timer_buf),