[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [tor/master] config: replace config_var_is_cumulative with is_replaced_on_set()
commit 22e7d33735805799a31949a58f64ce634e47477f
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date: Thu Sep 5 11:48:23 2019 -0400
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.
---
src/app/config/confparse.c | 17 ++++++++++++-----
src/app/config/confparse.h | 1 -
2 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/src/app/config/confparse.c b/src/app/config/confparse.c
index 0e941bab6..633fc4f8b 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 6a7a56727..7edbbe3c0 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);
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits