summaryrefslogtreecommitdiff
path: root/src/modules/drizzle
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@pengaru.com>2023-08-30 20:29:08 -0700
committerVito Caputo <vcaputo@pengaru.com>2023-08-30 21:45:13 -0700
commit97f5b943e459d3834a51996fd54c01ba82fe831b (patch)
tree00f73730a0028db305b53dc371d8c01fb91bce87 /src/modules/drizzle
parent918f2eb6f20de6fbdb300bbb7a3d8d829da6fb6d (diff)
modules/drizzle: handle baking errors in drizzle_setup()
More setup_func conversion to returning the failed setting on errors during res_setup baking. Also fixed a bug while here in the style_values error detection; it was misusing nelems() on the array when it's NULL-terminated with a sentinel. But this was only triggered if a user force overrided the setting with the :-prefix syntax, since otherwise the setting had to be in the values set according to the front-end. It was known there'd prolly be bugs when adding that : override prefix support. A lot of the module-local setup baking code has been neglected/bitrotted/carelessly changed over time, depending on front-end values policing to keep things on the rails.
Diffstat (limited to 'src/modules/drizzle')
-rw-r--r--src/modules/drizzle/drizzle.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/modules/drizzle/drizzle.c b/src/modules/drizzle/drizzle.c
index 18ef731..0614632 100644
--- a/src/modules/drizzle/drizzle.c
+++ b/src/modules/drizzle/drizzle.c
@@ -375,8 +375,8 @@ til_module_t drizzle_module = {
static int drizzle_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 *viscosity;
- const char *style;
+ til_setting_t *viscosity;
+ til_setting_t *style;
const char *viscosity_values[] = {
".005",
".01",
@@ -391,7 +391,7 @@ static int drizzle_setup(const til_settings_t *settings, til_setting_t **res_set
};
int r;
- r = til_settings_get_and_describe_value(settings,
+ r = til_settings_get_and_describe_setting(settings,
&(til_setting_spec_t){
.name = "Puddle viscosity",
.key = "viscosity",
@@ -406,7 +406,7 @@ static int drizzle_setup(const til_settings_t *settings, til_setting_t **res_set
if (r)
return r;
- r = til_settings_get_and_describe_value(settings,
+ r = til_settings_get_and_describe_setting(settings,
&(til_setting_spec_t){
.name = "Overlay style",
.key = "style",
@@ -429,18 +429,19 @@ static int drizzle_setup(const til_settings_t *settings, til_setting_t **res_set
if (!setup)
return -ENOMEM;
- sscanf(viscosity, "%f", &setup->viscosity);
+ if (sscanf(viscosity->value, "%f", &setup->viscosity) != 1)
+ return til_setup_free_with_failed_setting_ret_err(&setup->til_setup, viscosity, res_setting, -EINVAL);
/* TODO: til should prolly have a helper for this */
- for (i = 0; i < nelems(style_values); i++) {
- if (!strcasecmp(style_values[i], style)) {
+ for (i = 0; style_values[i]; i++) {
+ if (!strcasecmp(style_values[i], style->value)) {
setup->style = i;
break;
}
}
- if (i >= nelems(style_values))
- return -EINVAL;
+ if (!style_values[i])
+ return til_setup_free_with_failed_setting_ret_err(&setup->til_setup, style, res_setting, -EINVAL);
*res_setup = &setup->til_setup;
}
© All Rights Reserved