settings: Update int fallback check for settings with cfg_vals

This atoi() was added long ago in commit d490f441, and it looks
like it's intended to allow arbitrary values in table settings.
These table settings have some symbolic values (eg. off, on) but
are otherwise int-valued.

As far as I can see the only settings that can take this branch
are all table settings with F_ALLOW_ARBITRARY_VALS. It doesn't
make a lot of sense to accept random integers without that flag,
so make the atoi() conversion dependent on it.

Change-Id: I7bb1bc4997601b73ad8dcbf2f3ddf434d16adf23
This commit is contained in:
Aidan MacDonald 2022-11-30 00:24:26 +00:00
parent 6346be51a3
commit 8aa3b22160

View file

@ -361,12 +361,8 @@ bool settings_load_config(const char* file, bool apply)
else else
*v = temp; *v = temp;
} }
else else if (setting->flags & F_ALLOW_ARBITRARY_VALS)
{ /* atoi breaks choice settings because they {
* don't have int-like values, and would
* fall back to the first value (i.e. 0)
* due to atoi */
if (setting->flags & F_CHOICE_SETTING)
*v = atoi(value); *v = atoi(value);
} }
} }