diff options
author | Vito Caputo <vcaputo@pengaru.com> | 2023-08-30 21:58:57 -0700 |
---|---|---|
committer | Vito Caputo <vcaputo@pengaru.com> | 2023-08-30 21:58:57 -0700 |
commit | 8e219de4793f426ed28238fe7a945cce98f2f4e9 (patch) | |
tree | 93e203b6ad7174de2d8f3c8402eb368168e989c4 /src/modules | |
parent | 8888e58dd5e1c4de634fa3a93fa7dd3b47c9b97a (diff) |
modules/voronoi: handle baking errors in voronoi_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/voronoi/voronoi.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/modules/voronoi/voronoi.c b/src/modules/voronoi/voronoi.c index e4621ab..0c06c1d 100644 --- a/src/modules/voronoi/voronoi.c +++ b/src/modules/voronoi/voronoi.c @@ -368,7 +368,7 @@ til_module_t voronoi_module = { static int voronoi_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 *n_cells; + til_setting_t *n_cells; const char *n_cells_values[] = { "512", "1024", @@ -379,7 +379,7 @@ static int voronoi_setup(const til_settings_t *settings, til_setting_t **res_set "32768", NULL }; - const char *randomize; + til_setting_t *randomize; const char *bool_values[] = { "off", "on", @@ -387,7 +387,7 @@ static int voronoi_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 = "Voronoi cells quantity", .key = "cells", @@ -402,7 +402,7 @@ static int voronoi_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 = "Constantly randomize cell placement", .key = "randomize", @@ -424,9 +424,10 @@ static int voronoi_setup(const til_settings_t *settings, til_setting_t **res_set if (!setup) return -ENOMEM; - sscanf(n_cells, "%zu", &setup->n_cells); + if (sscanf(n_cells->value, "%zu", &setup->n_cells) != 1) + return til_setup_free_with_failed_setting_ret_err(&setup->til_setup, n_cells, res_setting, -EINVAL); - if (!strcasecmp(randomize, "on")) + if (!strcasecmp(randomize->value, "on")) setup->randomize = 1; *res_setup = &setup->til_setup; |