mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2025-02-24 22:58:50 +01:00
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.
This commit is contained in:
parent
545c21e23d
commit
22e7d33735
2 changed files with 12 additions and 6 deletions
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Add table
Reference in a new issue