[tor-commits] [tor/master] validate_fn(): remove now-unused defaults and from_setconf.

teor at torproject.org teor at torproject.org
Wed Oct 23 13:00:38 UTC 2019


commit 697d99e50411b29eeb82667a870bd10c5efa9509
Author: Nick Mathewson <nickm at torproject.org>
Date:   Tue Oct 22 13:52:40 2019 -0400

    validate_fn(): remove now-unused defaults and from_setconf.
    
    These arguments were only used by options_validate, and are now
    ignored even there.
---
 src/app/config/config.c                   |  9 +++------
 src/app/config/statefile.c                | 10 +++-------
 src/feature/dirauth/shared_random_state.c |  8 ++------
 src/lib/confmgt/confparse.c               |  2 +-
 src/lib/confmgt/confparse.h               |  2 --
 src/test/test_confparse.c                 |  5 +----
 6 files changed, 10 insertions(+), 26 deletions(-)

diff --git a/src/app/config/config.c b/src/app/config/config.c
index 337ae9357..be243a0d8 100644
--- a/src/app/config/config.c
+++ b/src/app/config/config.c
@@ -844,8 +844,7 @@ static int parse_outbound_addresses(or_options_t *options, int validate_only,
 static void config_maybe_load_geoip_files_(const or_options_t *options,
                                            const or_options_t *old_options);
 static int options_validate_cb(void *old_options, void *options,
-                               void *default_options,
-                               int from_setconf, char **msg);
+                               char **msg);
 static void cleanup_protocol_warning_severity_level(void);
 static void set_protocol_warning_severity_level(int warning_severity);
 static void options_clear_cb(const config_mgr_t *mgr, void *opts);
@@ -3231,12 +3230,10 @@ compute_publishserverdescriptor(or_options_t *options)
 #define RECOMMENDED_MIN_CIRCUIT_BUILD_TIMEOUT (10)
 
 static int
-options_validate_cb(void *old_options, void *options, void *default_options,
-                    int from_setconf, char **msg)
+options_validate_cb(void *old_options, void *options, char **msg)
 {
   in_option_validation = 1;
-  int rv = options_validate(old_options, options, default_options,
-                          from_setconf, msg);
+  int rv = options_validate(old_options, options, NULL, 0, msg);
   in_option_validation = 0;
   return rv;
 }
diff --git a/src/app/config/statefile.c b/src/app/config/statefile.c
index 552bd2c44..3653deeee 100644
--- a/src/app/config/statefile.c
+++ b/src/app/config/statefile.c
@@ -141,9 +141,8 @@ static const config_var_t state_vars_[] = {
 
 static int or_state_validate(or_state_t *state, char **msg);
 
-static int or_state_validate_cb(void *old_options, void *options,
-                                void *default_options,
-                                int from_setconf, char **msg);
+static int or_state_validate_cb(void *old_options,
+                                void *options, char **msg);
 
 /** Magic value for or_state_t. */
 #define OR_STATE_MAGIC 0x57A73f57
@@ -269,13 +268,10 @@ validate_transports_in_state(or_state_t *state)
 }
 
 static int
-or_state_validate_cb(void *old_state, void *state, void *default_state,
-                     int from_setconf, char **msg)
+or_state_validate_cb(void *old_state, void *state, char **msg)
 {
   /* We don't use these; only options do. Still, we need to match that
    * signature. */
-  (void) from_setconf;
-  (void) default_state;
   (void) old_state;
 
   return or_state_validate(state, msg);
diff --git a/src/feature/dirauth/shared_random_state.c b/src/feature/dirauth/shared_random_state.c
index 474dcb271..beeb03448 100644
--- a/src/feature/dirauth/shared_random_state.c
+++ b/src/feature/dirauth/shared_random_state.c
@@ -60,8 +60,7 @@ DUMMY_TYPECHECK_INSTANCE(sr_disk_state_t);
 #define SR_DISK_STATE_MAGIC 0x98AB1254
 
 static int
-disk_state_validate_cb(void *old_state, void *state, void *default_state,
-                       int from_setconf, char **msg);
+disk_state_validate_cb(void *old_state, void *state, char **msg);
 
 /** Array of variables that are saved to disk as a persistent state. */
 static const config_var_t state_vars[] = {
@@ -345,12 +344,9 @@ disk_state_validate(const sr_disk_state_t *state)
 
 /** Validate the disk state (NOP for now). */
 static int
-disk_state_validate_cb(void *old_state, void *state, void *default_state,
-                       int from_setconf, char **msg)
+disk_state_validate_cb(void *old_state, void *state, char **msg)
 {
   /* We don't use these; only options do. */
-  (void) from_setconf;
-  (void) default_state;
   (void) old_state;
 
   /* This is called by config_dump which is just before we are about to
diff --git a/src/lib/confmgt/confparse.c b/src/lib/confmgt/confparse.c
index 08e562f65..323c88a31 100644
--- a/src/lib/confmgt/confparse.c
+++ b/src/lib/confmgt/confparse.c
@@ -1166,7 +1166,7 @@ config_dump(const config_mgr_t *mgr, const void *default_options,
 
   /* XXX use a 1 here so we don't add a new log line while dumping */
   if (default_options == NULL) {
-    if (fmt->validate_fn(NULL, defaults_tmp, defaults_tmp, 1, &msg) < 0) {
+    if (fmt->validate_fn(NULL, defaults_tmp, &msg) < 0) {
       // LCOV_EXCL_START
       log_err(LD_BUG, "Failed to validate default config: %s", msg);
       tor_free(msg);
diff --git a/src/lib/confmgt/confparse.h b/src/lib/confmgt/confparse.h
index 2332f6979..628eb8927 100644
--- a/src/lib/confmgt/confparse.h
+++ b/src/lib/confmgt/confparse.h
@@ -70,8 +70,6 @@ typedef struct config_deprecation_t {
  */
 typedef int (*validate_fn_t)(void *oldval,
                              void *newval,
-                             void *default_val,
-                             int from_setconf,
                              char **msg_out);
 
 struct config_mgr_t;
diff --git a/src/test/test_confparse.c b/src/test/test_confparse.c
index 5f29a22c1..cfdcd34c3 100644
--- a/src/test/test_confparse.c
+++ b/src/test/test_confparse.c
@@ -103,12 +103,9 @@ static config_deprecation_t test_deprecation_notes[] = {
 };
 
 static int
-test_validate_cb(void *old_options, void *options, void *default_options,
-                 int from_setconf, char **msg)
+test_validate_cb(void *old_options, void *options, char **msg)
 {
   (void)old_options;
-  (void)default_options;
-  (void)from_setconf;
   (void)msg;
   test_struct_t *ts = options;
 





More information about the tor-commits mailing list