aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2019-10-24 09:16:50 -0400
committerNick Mathewson <nickm@torproject.org>2019-10-24 20:30:32 -0400
commitd17aa0930872e391a19480f65545a029e2359dd7 (patch)
tree7a74dd30ad83995720f7a26866c9fe884ce82f24
parentbd891f517f022ea93a90f0d771bf61842660e978 (diff)
downloadtor-d17aa0930872e391a19480f65545a029e2359dd7.tar.gz
tor-d17aa0930872e391a19480f65545a029e2359dd7.zip
config.c: Turn options_transition_allowed() into a proper callback
-rw-r--r--src/app/config/config.c23
1 files changed, 11 insertions, 12 deletions
diff --git a/src/app/config/config.c b/src/app/config/config.c
index ca8f95f820..1041b6b6a3 100644
--- a/src/app/config/config.c
+++ b/src/app/config/config.c
@@ -823,9 +823,9 @@ static const config_deprecation_t option_deprecation_notes_[] = {
static char *get_windows_conf_root(void);
#endif
static int options_act_reversible(const or_options_t *old_options, char **msg);
-static int options_transition_allowed(const or_options_t *old,
- const or_options_t *new,
- char **msg);
+static int options_check_transition_cb(const void *old,
+ const void *new,
+ char **msg);
static int options_transition_affects_workers(
const or_options_t *old_options, const or_options_t *new_options);
static int options_transition_affects_descriptor(
@@ -877,6 +877,7 @@ static const config_format_t options_format = {
.deprecations = option_deprecation_notes_,
.vars = option_vars_,
.legacy_validate_fn = options_validate_cb,
+ .check_transition_fn = options_check_transition_cb,
.clear_fn = options_clear_cb,
.config_suite_offset = offsetof(or_options_t, subconfigs_),
};
@@ -3240,11 +3241,6 @@ options_validate_and_set(const or_options_t *old_options,
rv = SETOPT_ERR_PARSE;
goto err;
}
-
- if (options_transition_allowed(old_options, new_options, msg_out) < 0) {
- rv = SETOPT_ERR_TRANSITION;
- goto err;
- }
in_option_validation = 0;
if (set_options(new_options, msg_out)) {
@@ -4821,11 +4817,14 @@ opt_streq(const char *s1, const char *s2)
/** Check if any of the previous options have changed but aren't allowed to. */
static int
-options_transition_allowed(const or_options_t *old,
- const or_options_t *new_val,
- char **msg)
+options_check_transition_cb(const void *old_,
+ const void *new_val_,
+ char **msg)
{
- if (!old)
+ const or_options_t *old = old_;
+ const or_options_t *new_val = new_val_;
+
+ if (BUG(!old))
return 0;
#define BAD_CHANGE_TO(opt, how) do { \