aboutsummaryrefslogtreecommitdiff
path: root/src/app
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2019-09-05 11:48:23 -0400
committerNick Mathewson <nickm@torproject.org>2019-09-05 11:32:32 -0400
commit22e7d33735805799a31949a58f64ce634e47477f (patch)
treed8a7c041448326f5a267d106b4851038b9b4227b /src/app
parent545c21e23dcb2c73ab9d9f33e2ea6906a230b4b5 (diff)
downloadtor-22e7d33735805799a31949a58f64ce634e47477f.tar.gz
tor-22e7d33735805799a31949a58f64ce634e47477f.zip
config: replace config_var_is_cumulative with is_replaced_on_set()
This change replaces the higher-level property check to match our intended flag factoring.
Diffstat (limited to 'src/app')
-rw-r--r--src/app/config/confparse.c17
-rw-r--r--src/app/config/confparse.h1
2 files changed, 12 insertions, 6 deletions
diff --git a/src/app/config/confparse.c b/src/app/config/confparse.c
index 0e941bab6c..633fc4f8ba 100644
--- a/src/app/config/confparse.c
+++ b/src/app/config/confparse.c
@@ -511,11 +511,17 @@ config_count_options(const config_mgr_t *mgr)
return smartlist_len(mgr->all_vars);
}
-bool
-config_var_is_cumulative(const config_var_t *var)
+/**
+ * Return true if assigning a value to <b>var</b> replaces the previous
+ * value. Return false if assigning a value to <b>var</b> appends
+ * to the previous value.
+ **/
+static bool
+config_var_is_replaced_on_set(const config_var_t *var)
{
- return struct_var_is_cumulative(&var->member);
+ return ! struct_var_is_cumulative(&var->member);
}
+
bool
config_var_is_settable(const config_var_t *var)
{
@@ -650,7 +656,8 @@ config_assign_line(const config_mgr_t *mgr, void *options,
if (!strlen(c->value)) {
/* reset or clear it, then return */
if (!clear_first) {
- if (config_var_is_cumulative(cvar) && c->command != CONFIG_LINE_CLEAR) {
+ if (! config_var_is_replaced_on_set(cvar) &&
+ c->command != CONFIG_LINE_CLEAR) {
/* We got an empty linelist from the torrc or command line.
As a special case, call this an error. Warn and ignore. */
log_warn(LD_CONFIG,
@@ -671,7 +678,7 @@ config_assign_line(const config_mgr_t *mgr, void *options,
// LCOV_EXCL_STOP
}
- if (options_seen && ! config_var_is_cumulative(cvar)) {
+ if (options_seen && config_var_is_replaced_on_set(cvar)) {
/* We're tracking which options we've seen, and this option is not
* supposed to occur more than once. */
tor_assert(var_index >= 0);
diff --git a/src/app/config/confparse.h b/src/app/config/confparse.h
index 6a7a567273..7edbbe3c09 100644
--- a/src/app/config/confparse.h
+++ b/src/app/config/confparse.h
@@ -189,7 +189,6 @@ const char *config_expand_abbrev(const config_mgr_t *mgr,
int command_line, int warn_obsolete);
void warn_deprecated_option(const char *what, const char *why);
-bool config_var_is_cumulative(const config_var_t *var);
bool config_var_is_settable(const config_var_t *var);
bool config_var_is_contained(const config_var_t *var);
bool config_var_is_invisible(const config_var_t *var);