[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [tor/master] Replace config_find_option with a variant that exposes less
commit 7e91d4f57298fc08e4aad8ca90ecfad7cf9de206
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date: Mon Jul 22 15:01:57 2019 -0400
Replace config_find_option with a variant that exposes less
---
src/app/config/config.c | 6 ++----
src/app/config/confparse.c | 14 +++++++-------
src/app/config/confparse.h | 6 +++---
3 files changed, 12 insertions(+), 14 deletions(-)
diff --git a/src/app/config/config.c b/src/app/config/config.c
index 76feed000..444ce481c 100644
--- a/src/app/config/config.c
+++ b/src/app/config/config.c
@@ -2588,8 +2588,7 @@ config_parse_commandline(int argc, char **argv, int ignore_errors,
int
option_is_recognized(const char *key)
{
- const config_var_t *var = config_find_option(get_options_mgr(), key);
- return (var != NULL);
+ return config_find_option_name(get_options_mgr(), key) != NULL;
}
/** Return the canonical name of a configuration option, or NULL
@@ -2597,8 +2596,7 @@ option_is_recognized(const char *key)
const char *
option_get_canonical_name(const char *key)
{
- const config_var_t *var = config_find_option(get_options_mgr(), key);
- return var ? var->member.name : NULL;
+ return config_find_option_name(get_options_mgr(), key);
}
/** Return a canonical list of the options assigned for key.
diff --git a/src/app/config/confparse.c b/src/app/config/confparse.c
index 0964321ad..16fb6dbc5 100644
--- a/src/app/config/confparse.c
+++ b/src/app/config/confparse.c
@@ -288,17 +288,17 @@ config_mgr_find_var(const config_mgr_t *mgr,
return NULL;
}
-/** If <b>key</b> is a configuration option, return the corresponding const
- * config_var_t. Otherwise, if <b>key</b> is a non-standard abbreviation,
- * warn, and return the corresponding const config_var_t. Otherwise return
- * NULL.
+/**
+ * If <b>key</b> is a name or an abbreviation configuration option, return
+ * the corresponding canonical name for it. Warn if the abbreviation is
+ * non-standard. Return NULL if the option does not exist.
*/
-const config_var_t *
-config_find_option(const config_mgr_t *mgr, const char *key)
+const char *
+config_find_option_name(const config_mgr_t *mgr, const char *key)
{
const managed_var_t *mv = config_mgr_find_var(mgr, key, true, NULL);
if (mv)
- return mv->cvar;
+ return mv->cvar->member.name;
else
return NULL;
}
diff --git a/src/app/config/confparse.h b/src/app/config/confparse.h
index a6a2450ae..6e1e8cb3e 100644
--- a/src/app/config/confparse.h
+++ b/src/app/config/confparse.h
@@ -111,9 +111,9 @@ int config_assign(const config_mgr_t *mgr, void *options,
struct config_line_t *list,
unsigned flags, char **msg);
const char *config_find_deprecation(const config_mgr_t *mgr,
- const char *key);
-const config_var_t *config_find_option(const config_mgr_t *mgr,
- const char *key);
+ const char *key);
+const char *config_find_option_name(const config_mgr_t *mgr,
+ const char *key);
const char *config_expand_abbrev(const config_mgr_t *mgr,
const char *option,
int command_line, int warn_obsolete);
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits