config validation: make the "old_options" argument const.

We can't do this with the "options" argument yet, since several
places in the code change those right now.
This commit is contained in:
Nick Mathewson 2019-10-22 14:16:23 -04:00
parent 3656fdae98
commit 6bc2b41e54
6 changed files with 12 additions and 11 deletions

View File

@ -843,7 +843,7 @@ static int parse_outbound_addresses(or_options_t *options, int validate_only,
char **msg);
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,
static int options_validate_cb(const void *old_options, void *options,
char **msg);
static void cleanup_protocol_warning_severity_level(void);
static void set_protocol_warning_severity_level(int warning_severity);
@ -1227,7 +1227,8 @@ add_default_fallback_dir_servers,(void))
* user if we changed any dangerous ones.
*/
static int
validate_dir_servers(or_options_t *options, or_options_t *old_options)
validate_dir_servers(const or_options_t *options,
const or_options_t *old_options)
{
config_line_t *cl;
@ -3230,7 +3231,7 @@ compute_publishserverdescriptor(or_options_t *options)
#define RECOMMENDED_MIN_CIRCUIT_BUILD_TIMEOUT (10)
static int
options_validate_cb(void *old_options, void *options, char **msg)
options_validate_cb(const void *old_options, void *options, char **msg)
{
in_option_validation = 1;
int rv = options_validate(old_options, options, msg);
@ -3430,7 +3431,7 @@ options_validate_single_onion(or_options_t *options, char **msg)
* On error, tor_strdup an error explanation into *<b>msg</b>.
*/
STATIC int
options_validate(or_options_t *old_options, or_options_t *options,
options_validate(const or_options_t *old_options, or_options_t *options,
char **msg)
{
config_line_t *cl;

View File

@ -277,7 +277,7 @@ STATIC void port_cfg_free_(port_cfg_t *port);
STATIC void or_options_free_(or_options_t *options);
STATIC int options_validate_single_onion(or_options_t *options,
char **msg);
STATIC int options_validate(or_options_t *old_options,
STATIC int options_validate(const or_options_t *old_options,
or_options_t *options,
char **msg);
STATIC int parse_transport_line(const or_options_t *options,

View File

@ -141,7 +141,7 @@ 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,
static int or_state_validate_cb(const void *old_options,
void *options, char **msg);
/** Magic value for or_state_t. */
@ -268,7 +268,7 @@ validate_transports_in_state(or_state_t *state)
}
static int
or_state_validate_cb(void *old_state, void *state, char **msg)
or_state_validate_cb(const void *old_state, void *state, char **msg)
{
/* We don't use these; only options do. Still, we need to match that
* signature. */

View File

@ -60,7 +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, char **msg);
disk_state_validate_cb(const 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[] = {
@ -344,7 +344,7 @@ 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, char **msg)
disk_state_validate_cb(const void *old_state, void *state, char **msg)
{
/* We don't use these; only options do. */
(void) old_state;

View File

@ -68,7 +68,7 @@ typedef struct config_deprecation_t {
* config_dump(); later in our refactoring, it will be cleaned up and used
* more generally.
*/
typedef int (*validate_fn_t)(void *oldval,
typedef int (*validate_fn_t)(const void *oldval,
void *newval,
char **msg_out);

View File

@ -103,7 +103,7 @@ static config_deprecation_t test_deprecation_notes[] = {
};
static int
test_validate_cb(void *old_options, void *options, char **msg)
test_validate_cb(const void *old_options, void *options, char **msg)
{
(void)old_options;
(void)msg;