Commit 47c8433a authored by Nick Mathewson's avatar Nick Mathewson 🥄
Browse files

Make the get_options() return const

This lets us make a lot of other stuff const, allows the compiler to
generate (slightly) better code, and will make me get slightly fewer
patches from folks who stick mutable stuff into or_options_t.

const: because not every input is an output!
parent 22efe203
......@@ -1459,7 +1459,7 @@ log_unsafe_socks_warning(int socks_protocol, const char *address,
{
static ratelim_t socks_ratelim = RATELIM_INIT(SOCKS_WARN_INTERVAL);
or_options_t *options = get_options();
const or_options_t *options = get_options();
char *m = NULL;
if (! options->WarnUnsafeSocks)
return;
......
......@@ -1948,7 +1948,7 @@ inform_testing_reachability(void)
static INLINE int
should_use_create_fast_for_circuit(origin_circuit_t *circ)
{
or_options_t *options = get_options();
const or_options_t *options = get_options();
tor_assert(circ->cpath);
tor_assert(circ->cpath->extend_info);
......@@ -2083,7 +2083,7 @@ circuit_send_next_onion_skin(origin_circuit_t *circ)
if (circ->build_state->onehop_tunnel)
control_event_bootstrap(BOOTSTRAP_STATUS_REQUESTING_STATUS, 0);
if (!can_complete_circuit && !circ->build_state->onehop_tunnel) {
or_options_t *options = get_options();
const or_options_t *options = get_options();
can_complete_circuit=1;
/* FFFF Log a count of known routers here */
log_notice(LD_GENERAL,
......@@ -2650,7 +2650,7 @@ choose_good_exit_server_general(int need_uptime, int need_capacity)
smartlist_t *connections;
int best_support = -1;
int n_best_support=0;
or_options_t *options = get_options();
const or_options_t *options = get_options();
const smartlist_t *the_nodes;
const node_t *node=NULL;
......@@ -2851,7 +2851,7 @@ static const node_t *
choose_good_exit_server(uint8_t purpose,
int need_uptime, int need_capacity, int is_internal)
{
or_options_t *options = get_options();
const or_options_t *options = get_options();
router_crn_flags_t flags = CRN_NEED_DESC;
if (need_uptime)
flags |= CRN_NEED_UPTIME;
......@@ -2881,7 +2881,7 @@ choose_good_exit_server(uint8_t purpose,
static void
warn_if_last_router_excluded(origin_circuit_t *circ, const extend_info_t *exit)
{
or_options_t *options = get_options();
const or_options_t *options = get_options();
routerset_t *rs = options->ExcludeNodes;
const char *description;
uint8_t purpose = circ->_base.purpose;
......@@ -3095,7 +3095,7 @@ choose_good_middle_server(uint8_t purpose,
const node_t *r, *choice;
crypt_path_t *cpath;
smartlist_t *excluded;
or_options_t *options = get_options();
const or_options_t *options = get_options();
router_crn_flags_t flags = CRN_NEED_DESC;
tor_assert(_CIRCUIT_PURPOSE_MIN <= purpose &&
purpose <= _CIRCUIT_PURPOSE_MAX);
......@@ -3137,7 +3137,7 @@ choose_good_entry_server(uint8_t purpose, cpath_build_state_t *state)
{
const node_t *choice;
smartlist_t *excluded;
or_options_t *options = get_options();
const or_options_t *options = get_options();
router_crn_flags_t flags = CRN_NEED_GUARD|CRN_NEED_DESC;
const node_t *node;
......@@ -3388,7 +3388,8 @@ build_state_get_exit_nickname(cpath_build_state_t *state)
*/
static int
entry_guard_set_status(entry_guard_t *e, const node_t *node,
time_t now, or_options_t *options, const char **reason)
time_t now, const or_options_t *options,
const char **reason)
{
char buf[HEX_DIGEST_LEN+1];
int changed = 0;
......@@ -3471,7 +3472,7 @@ entry_is_live(entry_guard_t *e, int need_uptime, int need_capacity,
int assume_reachable, const char **msg)
{
const node_t *node;
or_options_t *options = get_options();
const or_options_t *options = get_options();
tor_assert(msg);
if (e->bad_since) {
......@@ -3597,7 +3598,7 @@ control_event_guard_deferred(void)
#if 0
int n = 0;
const char *msg;
or_options_t *options = get_options();
const or_options_t *options = get_options();
if (!entry_guards)
return;
SMARTLIST_FOREACH(entry_guards, entry_guard_t *, entry,
......@@ -3665,7 +3666,7 @@ add_an_entry_guard(const node_t *chosen, int reset_status)
/** If the use of entry guards is configured, choose more entry guards
* until we have enough in the list. */
static void
pick_entry_guards(or_options_t *options)
pick_entry_guards(const or_options_t *options)
{
int changed = 0;
......@@ -3798,7 +3799,7 @@ remove_dead_entry_guards(time_t now)
* think that things are unlisted.
*/
void
entry_guards_compute_status(or_options_t *options, time_t now)
entry_guards_compute_status(const or_options_t *options, time_t now)
{
int changed = 0;
digestmap_t *reasons;
......@@ -3988,7 +3989,7 @@ entry_nodes_should_be_added(void)
/** Add all nodes in EntryNodes that aren't currently guard nodes to the list
* of guard nodes, at the front. */
static void
entry_guards_prepend_from_config(or_options_t *options)
entry_guards_prepend_from_config(const or_options_t *options)
{
smartlist_t *entry_nodes, *entry_fps;
smartlist_t *old_entry_guards_on_list, *old_entry_guards_not_on_list;
......@@ -4067,7 +4068,7 @@ entry_guards_prepend_from_config(or_options_t *options)
* list already and we must stick to it.
*/
int
entry_list_is_constrained(or_options_t *options)
entry_list_is_constrained(const or_options_t *options)
{
if (options->EntryNodes)
return 1;
......@@ -4084,7 +4085,7 @@ entry_list_is_constrained(or_options_t *options)
const node_t *
choose_random_entry(cpath_build_state_t *state)
{
or_options_t *options = get_options();
const or_options_t *options = get_options();
smartlist_t *live_entry_guards = smartlist_create();
smartlist_t *exit_family = smartlist_create();
const node_t *chosen_exit =
......@@ -4694,7 +4695,7 @@ static void
launch_direct_bridge_descriptor_fetch(bridge_info_t *bridge)
{
char *address;
or_options_t *options = get_options();
const or_options_t *options = get_options();
if (connection_get_by_type_addr_port_purpose(
CONN_TYPE_DIR, &bridge->addr, bridge->port,
......@@ -4735,7 +4736,7 @@ retry_bridge_descriptor_fetch_directly(const char *digest)
* descriptor, fetch a new copy of its descriptor -- either directly
* from the bridge or via a bridge authority. */
void
fetch_bridge_descriptors(or_options_t *options, time_t now)
fetch_bridge_descriptors(const or_options_t *options, time_t now)
{
int num_bridge_auths = get_n_authorities(BRIDGE_DIRINFO);
int ask_bridge_directly;
......@@ -4929,7 +4930,7 @@ any_pending_bridge_descriptor_fetches(void)
* down. Else return 0. If <b>act</b> is 1, then mark the down guards
* up; else just observe and report. */
static int
entries_retry_helper(or_options_t *options, int act)
entries_retry_helper(const or_options_t *options, int act)
{
const node_t *node;
int any_known = 0;
......@@ -4968,7 +4969,7 @@ entries_retry_helper(or_options_t *options, int act)
/** Do we know any descriptors for our bridges / entrynodes, and are
* all the ones we have descriptors for down? */
int
entries_known_but_down(or_options_t *options)
entries_known_but_down(const or_options_t *options)
{
tor_assert(entry_list_is_constrained(options));
return entries_retry_helper(options, 0);
......@@ -4976,7 +4977,7 @@ entries_known_but_down(or_options_t *options)
/** Mark all down known bridges / entrynodes up. */
void
entries_retry_all(or_options_t *options)
entries_retry_all(const or_options_t *options)
{
tor_assert(entry_list_is_constrained(options));
entries_retry_helper(options, 1);
......
......@@ -51,11 +51,11 @@ void extend_info_free(extend_info_t *info);
const node_t *build_state_get_exit_node(cpath_build_state_t *state);
const char *build_state_get_exit_nickname(cpath_build_state_t *state);
void entry_guards_compute_status(or_options_t *options, time_t now);
void entry_guards_compute_status(const or_options_t *options, time_t now);
int entry_guard_register_connect_status(const char *digest, int succeeded,
int mark_relay_status, time_t now);
void entry_nodes_should_be_added(void);
int entry_list_is_constrained(or_options_t *options);
int entry_list_is_constrained(const or_options_t *options);
const node_t *choose_random_entry(cpath_build_state_t *state);
int entry_guards_parse_state(or_state_t *state, int set, char **msg);
void entry_guards_update_state(or_state_t *state);
......@@ -72,12 +72,12 @@ void learned_router_identity(const tor_addr_t *addr, uint16_t port,
void bridge_add_from_config(const tor_addr_t *addr, uint16_t port,
const char *digest);
void retry_bridge_descriptor_fetch_directly(const char *digest);
void fetch_bridge_descriptors(or_options_t *options, time_t now);
void fetch_bridge_descriptors(const or_options_t *options, time_t now);
void learned_bridge_descriptor(routerinfo_t *ri, int from_cache);
int any_bridge_descriptors_known(void);
int any_pending_bridge_descriptor_fetches(void);
int entries_known_but_down(or_options_t *options);
void entries_retry_all(or_options_t *options);
int entries_known_but_down(const or_options_t *options);
void entries_retry_all(const or_options_t *options);
void entry_guards_free_all(void);
......
......@@ -979,7 +979,7 @@ circuit_find_to_cannibalize(uint8_t purpose, extend_info_t *info,
int need_uptime = (flags & CIRCLAUNCH_NEED_UPTIME) != 0;
int need_capacity = (flags & CIRCLAUNCH_NEED_CAPACITY) != 0;
int internal = (flags & CIRCLAUNCH_IS_INTERNAL) != 0;
or_options_t *options = get_options();
const or_options_t *options = get_options();
/* Make sure we're not trying to create a onehop circ by
* cannibalization. */
......@@ -1098,7 +1098,7 @@ void
circuit_expire_all_dirty_circs(void)
{
circuit_t *circ;
or_options_t *options = get_options();
const or_options_t *options = get_options();
for (circ=global_circuitlist; circ; circ = circ->next) {
if (CIRCUIT_IS_ORIGIN(circ) &&
......
......@@ -635,7 +635,7 @@ void
circuit_build_needed_circs(time_t now)
{
static time_t time_to_new_circuit = 0;
or_options_t *options = get_options();
const or_options_t *options = get_options();
/* launch a new circ for any pending streams that need one */
connection_ap_attach_pending();
......@@ -1207,7 +1207,7 @@ circuit_get_open_circ_or_launch(edge_connection_t *conn,
int check_exit_policy;
int need_uptime, need_internal;
int want_onehop;
or_options_t *options = get_options();
const or_options_t *options = get_options();
tor_assert(conn);
tor_assert(circp);
......@@ -1470,7 +1470,7 @@ link_apconn_to_circ(edge_connection_t *apconn, origin_circuit_t *circ,
/** Return true iff <b>address</b> is matched by one of the entries in
* TrackHostExits. */
int
hostname_in_track_host_exits(or_options_t *options, const char *address)
hostname_in_track_host_exits(const or_options_t *options, const char *address)
{
if (!options->TrackHostExits)
return 0;
......@@ -1494,7 +1494,7 @@ hostname_in_track_host_exits(or_options_t *options, const char *address)
static void
consider_recording_trackhost(edge_connection_t *conn, origin_circuit_t *circ)
{
or_options_t *options = get_options();
const or_options_t *options = get_options();
char *new_address = NULL;
char fp[HEX_DIGEST_LEN+1];
......
......@@ -50,7 +50,8 @@ int connection_ap_handshake_attach_chosen_circuit(edge_connection_t *conn,
crypt_path_t *cpath);
int connection_ap_handshake_attach_circuit(edge_connection_t *conn);
int hostname_in_track_host_exits(or_options_t *options, const char *address);
int hostname_in_track_host_exits(const or_options_t *options,
const char *address);
#endif
......@@ -422,7 +422,7 @@ static config_var_t _option_vars[] = {
/** Override default values with these if the user sets the TestingTorNetwork
* option. */
static config_var_t testing_tor_network_defaults[] = {
static const config_var_t testing_tor_network_defaults[] = {
V(ServerDNSAllowBrokenConfig, BOOL, "1"),
V(DirAllowPrivateAddresses, BOOL, "1"),
V(EnforceDistinctSubnets, BOOL, "0"),
......@@ -546,39 +546,43 @@ static char *get_windows_conf_root(void);
#endif
static void config_line_append(config_line_t **lst,
const char *key, const char *val);
static void option_clear(config_format_t *fmt, or_options_t *options,
config_var_t *var);
static void option_reset(config_format_t *fmt, or_options_t *options,
config_var_t *var, int use_defaults);
static void config_free(config_format_t *fmt, void *options);
static void option_clear(const config_format_t *fmt, or_options_t *options,
const config_var_t *var);
static void option_reset(const config_format_t *fmt, or_options_t *options,
const config_var_t *var, int use_defaults);
static void config_free(const config_format_t *fmt, void *options);
static int config_lines_eq(config_line_t *a, config_line_t *b);
static int option_is_same(config_format_t *fmt,
or_options_t *o1, or_options_t *o2,
static int option_is_same(const config_format_t *fmt,
const or_options_t *o1, const or_options_t *o2,
const char *name);
static or_options_t *options_dup(config_format_t *fmt, or_options_t *old);
static int options_validate(or_options_t *old_options, or_options_t *options,
static or_options_t *options_dup(const config_format_t *fmt,
const or_options_t *old);
static int options_validate(or_options_t *old_options,
or_options_t *options,
int from_setconf, char **msg);
static int options_act_reversible(or_options_t *old_options, char **msg);
static int options_act(or_options_t *old_options);
static int options_transition_allowed(or_options_t *old, or_options_t *new,
static int options_act_reversible(const or_options_t *old_options, char **msg);
static int options_act(const or_options_t *old_options);
static int options_transition_allowed(const or_options_t *old,
const or_options_t *new,
char **msg);
static int options_transition_affects_workers(or_options_t *old_options,
or_options_t *new_options);
static int options_transition_affects_descriptor(or_options_t *old_options,
or_options_t *new_options);
static int options_transition_affects_workers(
const or_options_t *old_options, const or_options_t *new_options);
static int options_transition_affects_descriptor(
const or_options_t *old_options, const or_options_t *new_options);
static int check_nickname_list(const char *lst, const char *name, char **msg);
static void config_register_addressmaps(or_options_t *options);
static void config_register_addressmaps(const or_options_t *options);
static int parse_bridge_line(const char *line, int validate_only);
static int parse_dir_server_line(const char *line,
dirinfo_type_t required_type,
int validate_only);
static int validate_data_directory(or_options_t *options);
static int write_configuration_file(const char *fname, or_options_t *options);
static config_line_t *get_assigned_option(config_format_t *fmt,
void *options, const char *key,
int escape_val);
static void config_init(config_format_t *fmt, void *options);
static int write_configuration_file(const char *fname,
const or_options_t *options);
static config_line_t *get_assigned_option(const config_format_t *fmt,
const void *options, const char *key,
int escape_val);
static void config_init(const config_format_t *fmt, void *options);
static int or_state_validate(or_state_t *old_options, or_state_t *options,
int from_setconf, char **msg);
static int or_state_load(void);
......@@ -617,7 +621,7 @@ static config_var_t state_extra_var = {
};
/** Configuration format for or_state_t. */
static config_format_t state_format = {
static const config_format_t state_format = {
sizeof(or_state_t),
OR_STATE_MAGIC,
STRUCT_OFFSET(or_state_t, _magic),
......@@ -651,7 +655,7 @@ get_dirportfrontpage(void)
/** Allocate an empty configuration object of a given format type. */
static void *
config_alloc(config_format_t *fmt)
config_alloc(const config_format_t *fmt)
{
void *opts = tor_malloc_zero(fmt->size);
*(uint32_t*)STRUCT_VAR_P(opts, fmt->magic_offset) = fmt->magic;
......@@ -661,12 +665,19 @@ config_alloc(config_format_t *fmt)
/** Return the currently configured options. */
or_options_t *
get_options(void)
get_options_mutable(void)
{
tor_assert(global_options);
return global_options;
}
/** Returns the currently configured options */
const or_options_t *
get_options(void)
{
return get_options_mutable();
}
/** Change the current global options to contain <b>new_val</b> instead of
* their current value; take action based on the new value; free the old value
* as necessary. Returns 0 on success, -1 on failure.
......@@ -903,8 +914,8 @@ validate_dir_authorities(or_options_t *options, or_options_t *old_options)
* as appropriate.
*/
static int
consider_adding_dir_authorities(or_options_t *options,
or_options_t *old_options)
consider_adding_dir_authorities(const or_options_t *options,
const or_options_t *old_options)
{
config_line_t *cl;
int need_to_update =
......@@ -958,12 +969,12 @@ consider_adding_dir_authorities(or_options_t *options,
* Return 0 if all goes well, return -1 if things went badly.
*/
static int
options_act_reversible(or_options_t *old_options, char **msg)
options_act_reversible(const or_options_t *old_options, char **msg)
{
smartlist_t *new_listeners = smartlist_create();
smartlist_t *replaced_listeners = smartlist_create();
static int libevent_initialized = 0;
or_options_t *options = get_options();
or_options_t *options = get_options_mutable();
int running_tor = options->command == CMD_RUN_TOR;
int set_conn_limit = 0;
int r = -1;
......@@ -1056,7 +1067,7 @@ options_act_reversible(or_options_t *old_options, char **msg)
/* No need to roll back, since you can't change the value. */
}
if (directory_caches_v2_dir_info(options)) {
if (directory_caches_v2_dir_info(options)) {
size_t len = strlen(options->DataDirectory)+32;
char *fn = tor_malloc(len);
tor_snprintf(fn, len, "%s"PATH_SEPARATOR"cached-status",
......@@ -1132,7 +1143,7 @@ options_act_reversible(or_options_t *old_options, char **msg)
/** If we need to have a GEOIP ip-to-country map to run with our configured
* options, return 1 and set *<b>reason_out</b> to a description of why. */
int
options_need_geoip_info(or_options_t *options, const char **reason_out)
options_need_geoip_info(const or_options_t *options, const char **reason_out)
{
int bridge_usage =
options->BridgeRelay && options->BridgeRecordUsageByCountry;
......@@ -1157,7 +1168,7 @@ options_need_geoip_info(or_options_t *options, const char **reason_out)
/** Return the bandwidthrate that we are going to report to the authorities
* based on the config options. */
uint32_t
get_effective_bwrate(or_options_t *options)
get_effective_bwrate(const or_options_t *options)
{
uint64_t bw = options->BandwidthRate;
if (bw > options->MaxAdvertisedBandwidth)
......@@ -1171,7 +1182,7 @@ get_effective_bwrate(or_options_t *options)
/** Return the bandwidthburst that we are going to report to the authorities
* based on the config options. */
uint32_t
get_effective_bwburst(or_options_t *options)
get_effective_bwburst(const or_options_t *options)
{
uint64_t bw = options->BandwidthBurst;
if (options->RelayBandwidthBurst > 0 && bw > options->RelayBandwidthBurst)
......@@ -1190,10 +1201,10 @@ get_effective_bwburst(or_options_t *options)
* here yet. Some is still in do_hup() and other places.
*/
static int
options_act(or_options_t *old_options)
options_act(const or_options_t *old_options)
{
config_line_t *cl;
or_options_t *options = get_options();
or_options_t *options = get_options_mutable();
int running_tor = options->command == CMD_RUN_TOR;
char *msg;
const int transition_affects_workers =
......@@ -1550,7 +1561,7 @@ options_act(or_options_t *old_options)
* apply abbreviations that work for the config file and the command line.
* If <b>warn_obsolete</b> is set, warn about deprecated names. */
static const char *
expand_abbrev(config_format_t *fmt, const char *option, int command_line,
expand_abbrev(const config_format_t *fmt, const char *option, int command_line,
int warn_obsolete)
{
int i;
......@@ -1710,12 +1721,9 @@ config_free_lines(config_line_t *front)
}
}
/** If <b>key</b> is a configuration option, return the corresponding
* config_var_t. Otherwise, if <b>key</b> is a non-standard abbreviation,
* warn, and return the corresponding config_var_t. Otherwise return NULL.
*/
/** As config_find_option, but return a non-const pointer. */
static config_var_t *
config_find_option(config_format_t *fmt, const char *key)
config_find_option_mutable(config_format_t *fmt, const char *key)
{
int i;
size_t keylen = strlen(key);
......@@ -1740,9 +1748,20 @@ config_find_option(config_format_t *fmt, const char *key)
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.
*/
static const config_var_t *
config_find_option(const config_format_t *fmt, const char *key)
{
return config_find_option_mutable((config_format_t*)fmt, key);
}
/** Return the number of option entries in <b>fmt</b>. */
static int
config_count_options(config_format_t *fmt)
config_count_options(const config_format_t *fmt)
{
int i;
for (i=0; fmt->vars[i].name; ++i)
......@@ -1760,11 +1779,11 @@ config_count_options(config_format_t *fmt)
* Called from config_assign_line() and option_reset().
*/
static int
config_assign_value(config_format_t *fmt, or_options_t *options,
config_assign_value(const config_format_t *fmt, or_options_t *options,
config_line_t *c, char **msg)
{
int i, ok;
config_var_t *var;
const config_var_t *var;
void *lvalue;
CHECK(fmt, options);
......@@ -1926,11 +1945,11 @@ config_assign_value(config_format_t *fmt, or_options_t *options,
* Called from config_assign().
*/
static int
config_assign_line(config_format_t *fmt, or_options_t *options,
config_assign_line(const config_format_t *fmt, or_options_t *options,
config_line_t *c, int use_defaults,
int clear_first, bitarray_t *options_seen, char **msg)
{
config_var_t *var;
const config_var_t *var;
CHECK(fmt, options);
......@@ -1991,10 +2010,10 @@ config_assign_line(config_format_t *fmt, or_options_t *options,
/** Restore the option named <b>key</b> in options to its default value.
* Called from config_assign(). */
static void
config_reset_line(config_format_t *fmt, or_options_t *options,
config_reset_line(const config_format_t *fmt, or_options_t *options,
const char *key, int use_defaults)
{
config_var_t *var;
const config_var_t *var;
CHECK(fmt, options);
......@@ -2009,7 +2028,7 @@ config_reset_line(config_format_t *fmt, or_options_t *options,
int
option_is_recognized(const char *key)
{
config_var_t *var = config_find_option(&options_format, key);
const config_var_t *var = config_find_option(&options_format, key);
return (var != NULL);
}
......@@ -2018,14 +2037,14 @@ option_is_recognized(const char *key)
const char *
option_get_canonical_name(const char *key)
{
config_var_t *var = config_find_option(&options_format, key);
const config_var_t *var = config_find_option(&options_format, key);
return var ? var->name : NULL;
}
/** Return a canonical list of the options assigned for key.
*/
config_line_t *
option_get_assignment(or_options_t *options, const char *key)
option_get_assignment(const or_options_t *options, const char *key)
{
return get_assigned_option(&options_format, options, key, 1);
}
......@@ -2078,10 +2097,10 @@ config_lines_dup(const config_line_t *inp)
* value needs to be quoted before it's put in a config file, quote and
* escape that value. Return NULL if no such key exists. */
static config_line_t *
get_assigned_option(config_format_t *fmt, void *options,
get_assigned_option(const config_format_t *fmt, const void *options,
const char *key, int escape_val)
{
config_var_t *var;
const config_var_t *var;
const void *value;
config_line_t *result;
tor_assert(options && key);
......@@ -2263,7 +2282,7 @@ options_trial_assign() calls config_assign(1, 1)
returns.
*/
static int
config_assign(config_format_t *fmt, void *options, config_line_t *list,
config_assign(const config_format_t *fmt, void *options, config_line_t *list,
int use_defaults, int clear_first, char **msg)
{
config_line_t *p;
......@@ -2325,7 +2344,7 @@ options_trial_assign(config_line_t *list, int use_defaults,
return r;
}
if (options_validate(get_options(), trial_options, 1, msg) < 0) {
if (options_validate(get_options_mutable(), trial_options, 1, msg) < 0) {
config_free(&options_format, trial_options);
return SETOPT_ERR_PARSE; /*XXX make this a separate return value. */
}
......@@ -2347,7 +2366,8 @@ options_trial_assign(config_line_t *list, int use_defaults,
/** Reset config option <b>var</b> to 0, 0.0, NULL, or the equivalent.
* Called from option_reset() and config_free(). */
static void
option_clear(config_format_t *fmt, or_options_t *options, config_var_t *var)
option_clear(const config_format_t *fmt, or_options_t *options,
const const config_var_t *var)
{
void *lvalue = STRUCT_VAR_P(options, var->var_offset);
(void)fmt; /* unused */
......@@ -2405,8 +2425,8 @@ option_clear(config_format_t *fmt, or_options_t *options, config_var_t *var)
* <b>use_defaults</b>, set it to its default value.
* Called by config_init() and option_reset_line() and option_assign_line(). */
static void
option_reset(config_format_t *fmt, or_options_t *options,
config_var_t *var, int use_defaults)
option_reset(const config_format_t *fmt, or_options_t *options,
const config_var_t *var, int use_defaults)
{
config_line_t *c;
char *msg = NULL;
......@@ -2446,7 +2466,7 @@ list_torrc_options(void)
int i;
smartlist_t *lines = smartlist_create();
for (i = 0; _option_vars[i].name; ++i) {
config_var_t *var = &_option_vars[i];
const config_var_t *var = &_option_vars[i];