diff options
author | Vito Caputo <vcaputo@pengaru.com> | 2023-08-30 21:52:24 -0700 |
---|---|---|
committer | Vito Caputo <vcaputo@pengaru.com> | 2023-08-30 21:52:24 -0700 |
commit | f86cb4f483da1a0ea89b1d7be7983e427b6d4465 (patch) | |
tree | 9993c8cb732f4407f2c223580bc6d28ed876f2dd | |
parent | fa04bbe8d098d503dca6335f695a67fc561f4072 (diff) |
modules/strobe: handle baking errors in strobe_setup()
More setup_func conversion to returning the failed setting on
errors during res_setup baking.
-rw-r--r-- | src/modules/strobe/strobe.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/modules/strobe/strobe.c b/src/modules/strobe/strobe.c index e8dba3c..b12c0fe 100644 --- a/src/modules/strobe/strobe.c +++ b/src/modules/strobe/strobe.c @@ -159,7 +159,7 @@ til_module_t strobe_module = { static int strobe_setup(const til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc, til_setup_t **res_setup) { - const char *hz; + til_setting_t *hz; const char *hz_values[] = { "60", "50", @@ -173,7 +173,7 @@ static int strobe_setup(const til_settings_t *settings, til_setting_t **res_sett }; int r; - r = til_settings_get_and_describe_value(settings, + r = til_settings_get_and_describe_setting(settings, &(til_setting_spec_t){ .name = "Strobe frequency in hz", .key = "hz", @@ -195,7 +195,8 @@ static int strobe_setup(const til_settings_t *settings, til_setting_t **res_sett if (!setup) return -ENOMEM; - sscanf(hz, "%f", &setup->hz); + if (sscanf(hz->value, "%f", &setup->hz) != 1) + return til_setup_free_with_failed_setting_ret_err(&setup->til_setup, hz, res_setting, -EINVAL); *res_setup = &setup->til_setup; } |