diff options
author | Nick Mathewson <nickm@torproject.org> | 2019-11-05 10:18:47 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2019-11-07 07:28:43 -0500 |
commit | 0f0a9bdf332002bb0542dae6bb00e922af5dcf63 (patch) | |
tree | 4a25bc3928f62bd08c49c55ff1345db5fa8b91f6 /src/lib/confmgt/confmgt.c | |
parent | 0d8504e70b0c6ff92f38fc7f4b4c38037d121e69 (diff) | |
download | tor-0f0a9bdf332002bb0542dae6bb00e922af5dcf63.tar.gz tor-0f0a9bdf332002bb0542dae6bb00e922af5dcf63.zip |
Stop using "config_suite_offset=-1" to indicate "no config suite."
Instead, create a separate "has_config_suite" boolean, so that only
top-level formats with config_suites need to declare an offset at
all.
Diffstat (limited to 'src/lib/confmgt/confmgt.c')
-rw-r--r-- | src/lib/confmgt/confmgt.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/lib/confmgt/confmgt.c b/src/lib/confmgt/confmgt.c index 1c1a1595ec..a96c7f96bf 100644 --- a/src/lib/confmgt/confmgt.c +++ b/src/lib/confmgt/confmgt.c @@ -169,9 +169,14 @@ config_mgr_register_fmt(config_mgr_t *mgr, "it had been frozen."); if (object_idx != IDX_TOPLEVEL) { - tor_assertf(fmt->config_suite_offset < 0, + tor_assertf(! fmt->has_config_suite, "Tried to register a toplevel format in a non-toplevel position"); } + if (fmt->config_suite_offset) { + tor_assertf(fmt->has_config_suite, + "config_suite_offset was set, but has_config_suite was not."); + } + tor_assertf(fmt != mgr->toplevel && ! smartlist_contains(mgr->subconfigs, fmt), "Tried to register an already-registered format."); @@ -223,7 +228,7 @@ config_mgr_add_format(config_mgr_t *mgr, static inline config_suite_t ** config_mgr_get_suite_ptr(const config_mgr_t *mgr, void *toplevel) { - if (mgr->toplevel->config_suite_offset < 0) + if (! mgr->toplevel->has_config_suite) return NULL; return STRUCT_VAR_P(toplevel, mgr->toplevel->config_suite_offset); } |