summaryrefslogtreecommitdiff
path: root/src/modules/rtv
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@pengaru.com>2023-07-04 20:50:56 -0700
committerVito Caputo <vcaputo@pengaru.com>2023-07-04 22:17:07 -0700
commit3ef4f9fd1e6ae233adb0bbfd90573623ee1059e6 (patch)
treea4ce04703e37a683f33d8675c6f10e21d4070e6a /src/modules/rtv
parent68f6dee32dea0fb1bfe40d901169cf68aa6528d0 (diff)
modules/*: return invalid setting on -EINVAL in setup
In the interests of improving error handling of interactive setups, return the setting that was invalid when setup returns -EINVAL. For now this is only supported for non-finalized/non-baking setup calls, i.e. (!res_setup). In the future I want this also supported for finalizing when res_setup is set. A lot of the -EINVAL returns are actually during that stage (or need to be added) due to that being when the more sensitive parsing occurs going from strings to native numeric types and such. The main reason it's not already being done in this commit is it'll churn quite a bit to get there, since the setup funcs don't generally have the setting pointers onhand at that phase. It'll require changing the string-value-centric local variables to instead all be the til_setting_t* holding those values. And if setup funcs aren't going to be so value-centric, the settings API will likely change to not even return the values directly anymore and only return the full-blown til_settings_t as the main return pointer, perhaps rid of their res_setting use even. Anyway, while here I did some random little cleanups too.
Diffstat (limited to 'src/modules/rtv')
-rw-r--r--src/modules/rtv/rtv.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/modules/rtv/rtv.c b/src/modules/rtv/rtv.c
index 12f5580..18a2a1a 100644
--- a/src/modules/rtv/rtv.c
+++ b/src/modules/rtv/rtv.c
@@ -463,10 +463,8 @@ static int rtv_setup(const til_settings_t *settings, til_setting_t **res_setting
assert(res_setting && *res_setting && (*res_setting)->value_as_nested_settings);
snow_module_settings = (*res_setting)->value_as_nested_settings;
snow_module_name = til_settings_get_value_by_idx(snow_module_settings, 0, &snow_module_name_setting);
- if (!snow_module_name)
- return -EINVAL;
- if (!snow_module_name_setting->desc) {
+ if (!snow_module_name || !snow_module_name_setting->desc) {
r = til_setting_desc_new(snow_module_settings,
&(til_setting_spec_t){
/* this is basically just to get the .as_label */
@@ -478,7 +476,7 @@ static int rtv_setup(const til_settings_t *settings, til_setting_t **res_setting
if (r < 0)
return r;
- *res_setting = snow_module_name_setting;
+ *res_setting = snow_module_name ? snow_module_name_setting : NULL;
return 1;
}
@@ -486,8 +484,11 @@ static int rtv_setup(const til_settings_t *settings, til_setting_t **res_setting
if (strcasecmp(snow_module_name, "none")) {
const til_module_t *snow_module = til_lookup_module(snow_module_name);
- if (!snow_module)
+ if (!snow_module) {
+ *res_setting = snow_module_name_setting;
+
return -EINVAL;
+ }
if (snow_module->setup) {
r = snow_module->setup(snow_module_settings, res_setting, res_desc, NULL);
© All Rights Reserved