summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@pengaru.com>2023-08-30 21:49:40 -0700
committerVito Caputo <vcaputo@pengaru.com>2023-08-30 21:49:40 -0700
commit05f922543a9af7b9210c03559e85dd4a777ca549 (patch)
tree40ce279644aa37613b57361a831e29a383510916
parent2bc500d361af0d2d5ba716bce26aa5130c9e16dc (diff)
modules/sparkler: handle baking errors in sparkler_setup()
More setup_func conversion to returning the failed setting on errors during res_setup baking.
-rw-r--r--src/modules/sparkler/sparkler.c31
1 files changed, 15 insertions, 16 deletions
diff --git a/src/modules/sparkler/sparkler.c b/src/modules/sparkler/sparkler.c
index e37257c..a7d586f 100644
--- a/src/modules/sparkler/sparkler.c
+++ b/src/modules/sparkler/sparkler.c
@@ -117,10 +117,10 @@ til_module_t sparkler_module = {
/* Settings hooks for configurable variables */
static int sparkler_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 *show_bsp_leafs;
- const char *show_bsp_leafs_min_depth;
- const char *show_bsp_matches;
- const char *show_bsp_matches_affected_only;
+ til_setting_t *show_bsp_leafs;
+ til_setting_t *show_bsp_leafs_min_depth;
+ til_setting_t *show_bsp_matches;
+ til_setting_t *show_bsp_matches_affected_only;
const char *values[] = {
"off",
"on",
@@ -128,9 +128,7 @@ static int sparkler_setup(const til_settings_t *settings, til_setting_t **res_se
};
int r;
- /* TODO: return -EINVAL on parse errors? */
-
- r = til_settings_get_and_describe_value(settings,
+ r = til_settings_get_and_describe_setting(settings,
&(til_setting_spec_t){
.name = "Show BSP-tree leaf-node bounding boxes",
.key = "show_bsp_leafs",
@@ -143,7 +141,7 @@ static int sparkler_setup(const til_settings_t *settings, til_setting_t **res_se
if (r)
return r;
- if (!strcasecmp(show_bsp_leafs, "on")) {
+ if (!strcasecmp(show_bsp_leafs->value, "on")) {
const char *depth_values[] = {
"0",
"4",
@@ -153,7 +151,7 @@ static int sparkler_setup(const til_settings_t *settings, til_setting_t **res_se
NULL
};
- r = til_settings_get_and_describe_value(settings,
+ r = til_settings_get_and_describe_setting(settings,
&(til_setting_spec_t){
.name = "Minimum BSP-tree depth for shown leaf-nodes",
.key = "show_bsp_leafs_min_depth",
@@ -167,7 +165,7 @@ static int sparkler_setup(const til_settings_t *settings, til_setting_t **res_se
return r;
}
- r = til_settings_get_and_describe_value(settings,
+ r = til_settings_get_and_describe_setting(settings,
&(til_setting_spec_t){
.name = "Show BSP-tree search broad-phase match candidates",
.key = "show_bsp_matches",
@@ -180,8 +178,8 @@ static int sparkler_setup(const til_settings_t *settings, til_setting_t **res_se
if (r)
return r;
- if (!strcasecmp(show_bsp_matches, "on")) {
- r = til_settings_get_and_describe_value(settings,
+ if (!strcasecmp(show_bsp_matches->value, "on")) {
+ r = til_settings_get_and_describe_setting(settings,
&(til_setting_spec_t){
.name = "Show only narrow-phase affected match results",
.key = "show_bsp_matches_affected_only",
@@ -203,16 +201,17 @@ static int sparkler_setup(const til_settings_t *settings, til_setting_t **res_se
if (!setup)
return -ENOMEM;
- if (!strcasecmp(show_bsp_leafs, "on")) {
+ if (!strcasecmp(show_bsp_leafs->value, "on")) {
setup->show_bsp_leafs = 1;
- sscanf(show_bsp_leafs_min_depth, "%u", &setup->show_bsp_leafs_min_depth);
+ if (sscanf(show_bsp_leafs_min_depth->value, "%u", &setup->show_bsp_leafs_min_depth) != 1)
+ return til_setup_free_with_failed_setting_ret_err(&setup->til_setup, show_bsp_leafs_min_depth, res_setting, -EINVAL);
}
- if (!strcasecmp(show_bsp_matches, "on")) {
+ if (!strcasecmp(show_bsp_matches->value, "on")) {
setup->show_bsp_matches = 1;
- if (!strcasecmp(show_bsp_matches_affected_only, "on"))
+ if (!strcasecmp(show_bsp_matches_affected_only->value, "on"))
setup->show_bsp_matches_affected_only = 1;
}
© All Rights Reserved