summaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@pengaru.com>2023-08-30 21:57:01 -0700
committerVito Caputo <vcaputo@pengaru.com>2023-08-30 21:57:01 -0700
commit8888e58dd5e1c4de634fa3a93fa7dd3b47c9b97a (patch)
treede3e37aef4377d5c1dbc3806d1b506a67e659b91 /src/modules
parenta8de0bdf8cf1bac99dd9823db6f353323bd4b40a (diff)
modules/swarm: handle baking errors in swarm_setup()
More setup_func conversion to returning the failed setting on errors during res_setup baking.
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/swarm/swarm.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/modules/swarm/swarm.c b/src/modules/swarm/swarm.c
index 9407168..8cf16d4 100644
--- a/src/modules/swarm/swarm.c
+++ b/src/modules/swarm/swarm.c
@@ -435,10 +435,10 @@ static int swarm_setup(const til_settings_t *settings, til_setting_t **res_setti
"lines",
NULL,
};
- const char *style;
+ til_setting_t *style;
int r;
- r = til_settings_get_and_describe_value(settings,
+ r = til_settings_get_and_describe_setting(settings,
&(til_setting_spec_t){
.name = "Particle drawing style",
.key = "style",
@@ -454,16 +454,22 @@ static int swarm_setup(const til_settings_t *settings, til_setting_t **res_setti
if (res_setup) {
swarm_setup_t *setup;
+ unsigned i;
setup = til_setup_new(settings, sizeof(*setup), NULL, &swarm_module);
if (!setup)
return -ENOMEM;
- for (int i = 0; styles[i]; i++) {
- if (!strcasecmp(styles[i], style))
+ for (i = 0; styles[i]; i++) {
+ if (!strcasecmp(styles[i], style->value)) {
setup->draw_style = i;
+ break;
+ }
}
+ if (!styles[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