From fa04bbe8d098d503dca6335f695a67fc561f4072 Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Wed, 30 Aug 2023 21:51:17 -0700 Subject: modules/stars: handle baking errors in stars_setup() More setup_func conversion to returning the failed setting on errors during res_setup baking. --- src/modules/stars/stars.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/modules/stars/stars.c b/src/modules/stars/stars.c index ef35c4e..1a66ab3 100644 --- a/src/modules/stars/stars.c +++ b/src/modules/stars/stars.c @@ -271,7 +271,7 @@ til_module_t stars_module = { int stars_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 *rot_adj; + til_setting_t *rot_adj; const char *rot_adj_values[] = { ".0", ".00001", @@ -283,7 +283,7 @@ int stars_setup(const til_settings_t *settings, til_setting_t **res_setting, con }; int r; - r = til_settings_get_and_describe_value(settings, + r = til_settings_get_and_describe_setting(settings, &(til_setting_spec_t){ .name = "Rotation rate", .key = "rot_adj", @@ -305,7 +305,8 @@ int stars_setup(const til_settings_t *settings, til_setting_t **res_setting, con if (!setup) return -ENOMEM; - sscanf(rot_adj, "%f", &setup->rot_adj); + if (sscanf(rot_adj->value, "%f", &setup->rot_adj) != 1) + return til_setup_free_with_failed_setting_ret_err(&setup->til_setup, rot_adj, res_setting, -EINVAL); *res_setup = &setup->til_setup; } -- cgit v1.2.3