validate_fn(): remove now-unused defaults and from_setconf.

These arguments were only used by options_validate, and are now
ignored even there.
This commit is contained in:
Nick Mathewson 2019-10-22 13:52:40 -04:00
parent 91413e04b4
commit 697d99e504
6 changed files with 10 additions and 26 deletions

View File

@ -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, static void config_maybe_load_geoip_files_(const or_options_t *options,
const or_options_t *old_options); const or_options_t *old_options);
static int options_validate_cb(void *old_options, void *options, static int options_validate_cb(void *old_options, void *options,
void *default_options, char **msg);
int from_setconf, char **msg);
static void cleanup_protocol_warning_severity_level(void); static void cleanup_protocol_warning_severity_level(void);
static void set_protocol_warning_severity_level(int warning_severity); static void set_protocol_warning_severity_level(int warning_severity);
static void options_clear_cb(const config_mgr_t *mgr, void *opts); 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) #define RECOMMENDED_MIN_CIRCUIT_BUILD_TIMEOUT (10)
static int static int
options_validate_cb(void *old_options, void *options, void *default_options, options_validate_cb(void *old_options, void *options, char **msg)
int from_setconf, char **msg)
{ {
in_option_validation = 1; in_option_validation = 1;
int rv = options_validate(old_options, options, default_options, int rv = options_validate(old_options, options, NULL, 0, msg);
from_setconf, msg);
in_option_validation = 0; in_option_validation = 0;
return rv; return rv;
} }

View File

@ -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(or_state_t *state, char **msg);
static int or_state_validate_cb(void *old_options, void *options, static int or_state_validate_cb(void *old_options,
void *default_options, void *options, char **msg);
int from_setconf, char **msg);
/** Magic value for or_state_t. */ /** Magic value for or_state_t. */
#define OR_STATE_MAGIC 0x57A73f57 #define OR_STATE_MAGIC 0x57A73f57
@ -269,13 +268,10 @@ validate_transports_in_state(or_state_t *state)
} }
static int static int
or_state_validate_cb(void *old_state, void *state, void *default_state, or_state_validate_cb(void *old_state, void *state, char **msg)
int from_setconf, char **msg)
{ {
/* We don't use these; only options do. Still, we need to match that /* We don't use these; only options do. Still, we need to match that
* signature. */ * signature. */
(void) from_setconf;
(void) default_state;
(void) old_state; (void) old_state;
return or_state_validate(state, msg); return or_state_validate(state, msg);

View File

@ -60,8 +60,7 @@ DUMMY_TYPECHECK_INSTANCE(sr_disk_state_t);
#define SR_DISK_STATE_MAGIC 0x98AB1254 #define SR_DISK_STATE_MAGIC 0x98AB1254
static int static int
disk_state_validate_cb(void *old_state, void *state, void *default_state, disk_state_validate_cb(void *old_state, void *state, char **msg);
int from_setconf, char **msg);
/** Array of variables that are saved to disk as a persistent state. */ /** Array of variables that are saved to disk as a persistent state. */
static const config_var_t state_vars[] = { 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). */ /** Validate the disk state (NOP for now). */
static int static int
disk_state_validate_cb(void *old_state, void *state, void *default_state, disk_state_validate_cb(void *old_state, void *state, char **msg)
int from_setconf, char **msg)
{ {
/* We don't use these; only options do. */ /* We don't use these; only options do. */
(void) from_setconf;
(void) default_state;
(void) old_state; (void) old_state;
/* This is called by config_dump which is just before we are about to /* This is called by config_dump which is just before we are about to

View File

@ -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 */ /* XXX use a 1 here so we don't add a new log line while dumping */
if (default_options == NULL) { 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 // LCOV_EXCL_START
log_err(LD_BUG, "Failed to validate default config: %s", msg); log_err(LD_BUG, "Failed to validate default config: %s", msg);
tor_free(msg); tor_free(msg);

View File

@ -70,8 +70,6 @@ typedef struct config_deprecation_t {
*/ */
typedef int (*validate_fn_t)(void *oldval, typedef int (*validate_fn_t)(void *oldval,
void *newval, void *newval,
void *default_val,
int from_setconf,
char **msg_out); char **msg_out);
struct config_mgr_t; struct config_mgr_t;

View File

@ -103,12 +103,9 @@ static config_deprecation_t test_deprecation_notes[] = {
}; };
static int static int
test_validate_cb(void *old_options, void *options, void *default_options, test_validate_cb(void *old_options, void *options, char **msg)
int from_setconf, char **msg)
{ {
(void)old_options; (void)old_options;
(void)default_options;
(void)from_setconf;
(void)msg; (void)msg;
test_struct_t *ts = options; test_struct_t *ts = options;