From 5903cd4bc83a842d6ee78dc89425eed23aabd999 Mon Sep 17 00:00:00 2001 From: William Wilgus Date: Tue, 13 Dec 2022 17:12:40 -0500 Subject: [PATCH] [Bug Fix] setting.c fail to check F_TABLE_SETTING w/o arbitrary values table settings have a list of valid values when they do not have F_ALLOW_ARBITRARY_VALS flag they were not being treated as such Change-Id: Ib02643a65ee4fc2abb1be8563a1849076de2f708 --- apps/settings.c | 22 +++++++++++++++++++++- apps/settings_list.c | 4 ++-- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/apps/settings.c b/apps/settings.c index bc6f066e22..e60b1b5f1a 100644 --- a/apps/settings.c +++ b/apps/settings.c @@ -394,8 +394,28 @@ bool settings_load_config(const char* file, bool apply) else if (setting->flags & F_ALLOW_ARBITRARY_VALS) { *v = atoi(value); - logf("Val: %s\r\n",value); + logf("Val: %s = %d\r\n", value, *v); } + else if (setting->flags & F_TABLE_SETTING) + { + const struct table_setting *info = setting->table_setting; + temp = atoi(value); + *v = setting->default_val.int_; + if (info->values) + { + for(int i = 0; i < info->count; i++) + { + if (info->values[i] == temp) + { + *v = temp; + break; + } + } + } + logf("Val: %s", *v == temp ? "Found":"Error Not Found"); + logf("Val: %s = %d\r\n", value, *v); + } + else { logf("Error: %s: Not Found! [%s]\r\n", diff --git a/apps/settings_list.c b/apps/settings_list.c index ae98ae0187..ab02683d94 100644 --- a/apps/settings_list.c +++ b/apps/settings_list.c @@ -1644,8 +1644,8 @@ const struct settings_list settings[] = { OFFON_SETTING(F_SOUNDSETTING, dithering_enabled, LANG_DITHERING, false, "dithering enabled", dsp_dither_enable), /* surround */ - TABLE_SETTING(F_TIME_SETTING | F_SOUNDSETTING | F_ALLOW_ARBITRARY_VALS, - surround_enabled, LANG_SURROUND, 0, "surround enabled", off, + TABLE_SETTING(F_TIME_SETTING | F_SOUNDSETTING, surround_enabled, + LANG_SURROUND, 0, "surround enabled", off, UNIT_MS, formatter_time_unit_0_is_off, getlang_time_unit_0_is_off, dsp_surround_enable, 6,