summaryrefslogtreecommitdiff
path: root/src/setup.c
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@pengaru.com>2023-07-05 10:42:03 -0700
committerVito Caputo <vcaputo@pengaru.com>2023-07-05 10:42:03 -0700
commit5191d68bb76129cb2a95c62ea18d2ef9ae6605f2 (patch)
treed9ca151ebc0975b85295d747e3494cfbad78e7e3 /src/setup.c
parent759fdd53975646e4c5f9cff5eb0fc0599d9edba9 (diff)
setup: separate res_setup setup_func call
This is just temporary until all the setup_funcs always return a res_setting on -EINVAL. Currently they only cover this requirement when res_setup is NULL...
Diffstat (limited to 'src/setup.c')
-rw-r--r--src/setup.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/setup.c b/src/setup.c
index cf39f08..131c856 100644
--- a/src/setup.c
+++ b/src/setup.c
@@ -21,7 +21,12 @@ int setup_interactively(til_settings_t *settings, int (*setup_func)(const til_se
/* TODO: regex and error handling */
- while ((r = setup_func(settings, &setting, &desc, res_setup)) > 0) {
+ /* until all the setup_funcs guarantee they return the failed setting on -EINVAL w/non-NULL res_setup (finalizing),
+ * this will be done in two steps; this first loop just constructs the settings heirarchy, and if it fails with
+ * -EINVAL we will use the setting for logging. Then after this loop, one last recurrence of setup_func() w/res_setup
+ * actually set. Once all setup_funcs behave well even in res_setup we'll go back to just the loop on setup_func().
+ */
+ while ((r = setup_func(settings, &setting, &desc, NULL)) > 0) {
assert(desc);
additions++;
@@ -170,5 +175,14 @@ _next:
til_setting_desc_free(desc);
}
+ if (r < 0) {
+ if (r == -EINVAL)
+ *res_failed_desc = setting->desc;
+
+ return r;
+ }
+
+ r = setup_func(settings, &setting, &desc, res_setup);
+
return r < 0 ? r : additions;
}
© All Rights Reserved