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
This diff is collapsed.
......@@ -13,7 +13,8 @@
#define _TOR_CONFIG_H
const char *get_dirportfrontpage(void);
or_options_t *get_options(void);
const or_options_t *get_options(void);
or_options_t *get_options_mutable(void);
int set_options(or_options_t *new_val, char **msg);
void config_free_all(void);
const char *safe_str_client(const char *address);
......@@ -26,21 +27,21 @@ int config_get_lines(const char *string, config_line_t **result);
void config_free_lines(config_line_t *front);
setopt_err_t options_trial_assign(config_line_t *list, int use_defaults,
int clear_first, char **msg);
int resolve_my_address(int warn_severity, or_options_t *options,
int resolve_my_address(int warn_severity, const or_options_t *options,
uint32_t *addr, char **hostname_out);
int is_local_addr(const tor_addr_t *addr) ATTR_PURE;
void options_init(or_options_t *options);
char *options_dump(or_options_t *options, int minimal);
char *options_dump(const or_options_t *options, int minimal);
int options_init_from_torrc(int argc, char **argv);
setopt_err_t options_init_from_string(const char *cf,
int command, const char *command_arg, char **msg);
int option_is_recognized(const char *key);
const char *option_get_canonical_name(const char *key);
config_line_t *option_get_assignment(or_options_t *options,
config_line_t *option_get_assignment(const or_options_t *options,
const char *key);
int options_save_current(void);
const char *get_torrc_fname(void);
char *options_get_datadir_fname2_suffix(or_options_t *options,
char *options_get_datadir_fname2_suffix(const or_options_t *options,
const char *sub1, const char *sub2,
const char *suffix);
#define get_datadir_fname2_suffix(sub1, sub2, suffix) \
......@@ -63,14 +64,15 @@ or_state_t *get_or_state(void);
int did_last_state_file_write_fail(void);
int or_state_save(time_t now);
int options_need_geoip_info(or_options_t *options, const char **reason_out);
int options_need_geoip_info(const or_options_t *options,
const char **reason_out);
int getinfo_helper_config(control_connection_t *conn,
const char *question, char **answer,
const char **errmsg);
const char *tor_get_digests(void);
uint32_t get_effective_bwrate(or_options_t *options);
uint32_t get_effective_bwburst(or_options_t *options);
uint32_t get_effective_bwrate(const or_options_t *options);
uint32_t get_effective_bwburst(const or_options_t *options);
#ifdef CONFIG_PRIVATE
/* Used only by config.c and test.c */
......
......@@ -619,7 +619,7 @@ connection_about_to_close_connection(connection_t *conn)
circuit_n_conn_done(TO_OR_CONN(conn), 0);
/* now mark things down as needed */
if (connection_or_nonopen_was_started_here(or_conn)) {
or_options_t *options = get_options();
const or_options_t *options = get_options();
rep_hist_note_connect_failed(or_conn->identity_digest, now);
entry_guard_register_connect_status(or_conn->identity_digest,0,
!options->HTTPSProxy, now);
......@@ -899,7 +899,7 @@ warn_too_many_conns(void)
/** Check whether we should be willing to open an AF_UNIX socket in
* <b>path</b>. Return 0 if we should go ahead and -1 if we shouldn't. */
static int
check_location_for_unix_socket(or_options_t *options, const char *path)
check_location_for_unix_socket(const or_options_t *options, const char *path)
{
int r = -1;
char *p = tor_strdup(path);
......@@ -1186,7 +1186,7 @@ connection_handle_listener_read(connection_t *conn, int new_type)
struct sockaddr *remote = (struct sockaddr*)addrbuf;
/* length of the remote address. Must be whatever accept() needs. */
socklen_t remotelen = (socklen_t)sizeof(addrbuf);
or_options_t *options = get_options();
const or_options_t *options = get_options();
tor_assert((size_t)remotelen >= sizeof(struct sockaddr_in));
memset(addrbuf, 0, sizeof(addrbuf));
......@@ -1366,7 +1366,7 @@ connection_connect(connection_t *conn, const char *address,
char addrbuf[256];
struct sockaddr *dest_addr;
int dest_addr_len;
or_options_t *options = get_options();
const or_options_t *options = get_options();
int protocol_family;
if (get_n_open_sockets() >= get_options()->_ConnLimit-1) {
......@@ -1489,7 +1489,7 @@ connection_proxy_state_to_string(int state)
int
connection_proxy_connect(connection_t *conn, int type)
{
or_options_t *options;
const or_options_t *options;
tor_assert(conn);
......@@ -2005,7 +2005,7 @@ int
retry_all_listeners(smartlist_t *replaced_conns,
smartlist_t *new_conns)
{
or_options_t *options = get_options();
const or_options_t *options = get_options();
int retval = 0;
const uint16_t old_or_port = router_get_advertised_or_port(options);
const uint16_t old_dir_port = router_get_advertised_dir_port(options, 0);
......@@ -2071,7 +2071,7 @@ retry_all_listeners(smartlist_t *replaced_conns,
static int
connection_is_rate_limited(connection_t *conn)
{
or_options_t *options = get_options();
const or_options_t *options = get_options();
if (conn->linked)
return 0; /* Internal connection */
else if (! options->CountPrivateBandwidth &&
......@@ -2269,7 +2269,7 @@ global_write_bucket_low(connection_t *conn, size_t attempt, int priority)
if (priority == 1) { /* old-style v1 query */
/* Could we handle *two* of these requests within the next two seconds? */
or_options_t *options = get_options();
const or_options_t *options = get_options();
int64_t can_write = (int64_t)smaller_bucket
+ 2*(options->RelayBandwidthRate ? options->RelayBandwidthRate :
options->BandwidthRate);
......@@ -2387,7 +2387,7 @@ connection_consider_empty_write_buckets(connection_t *conn)
void
connection_bucket_init(void)
{
or_options_t *options = get_options();
const or_options_t *options = get_options();
/* start it at max traffic */
global_read_bucket = (int)options->BandwidthBurst;
global_write_bucket = (int)options->BandwidthBurst;
......@@ -2432,7 +2432,7 @@ connection_bucket_refill_helper(int *bucket, int rate, int burst,
void
connection_bucket_refill(int seconds_elapsed, time_t now)
{
or_options_t *options = get_options();
const or_options_t *options = get_options();
smartlist_t *conns = get_connection_array();
int relayrate, relayburst;
......@@ -2552,7 +2552,7 @@ connection_bucket_refill(int seconds_elapsed, time_t now)
void
connection_bucket_init(void)
{
or_options_t *options = get_options();
const or_options_t *options = get_options();
const struct timeval *tick = tor_libevent_get_one_tick_timeout();
struct ev_token_bucket_cfg *bucket_cfg;
......
......@@ -439,7 +439,7 @@ connection_ap_expire_beginning(void)
edge_connection_t *conn;
circuit_t *circ;
time_t now = time(NULL);
or_options_t *options = get_options();
const or_options_t *options = get_options();
int severity;
int cutoff;
int seconds_idle, seconds_since_born;
......@@ -813,7 +813,7 @@ clear_trackexithost_mappings(const char *exitname)
* host is unknown or no longer allowed, or for which the source address
* is no longer in trackexithosts. */
void
addressmap_clear_excluded_trackexithosts(or_options_t *options)
addressmap_clear_excluded_trackexithosts(const or_options_t *options)
{
const routerset_t *allow_nodes = options->ExitNodes;
const routerset_t *exclude_nodes = options->_ExcludeExitNodesUnion;
......@@ -866,7 +866,7 @@ addressmap_clear_excluded_trackexithosts(or_options_t *options)
* no longer allowed by AutomapHostsOnResolve, or for which the
* target address is no longer in the virtual network. */
void
addressmap_clear_invalid_automaps(or_options_t *options)
addressmap_clear_invalid_automaps(const or_options_t *options)
{
int clear_all = !options->AutomapHostsOnResolve;
const smartlist_t *suffixes = options->AutomapHostsSuffixes;
......@@ -1520,7 +1520,7 @@ addressmap_get_mappings(smartlist_t *sl, time_t min_expires,
static int
consider_plaintext_ports(edge_connection_t *conn, uint16_t port)
{
or_options_t *options = get_options();
const or_options_t *options = get_options();
int reject = smartlist_string_num_isin(options->RejectPlaintextPorts, port);
if (smartlist_string_num_isin(options->WarnPlaintextPorts, port)) {
......@@ -1557,7 +1557,7 @@ connection_ap_rewrite_and_attach_if_allowed(edge_connection_t *conn,
origin_circuit_t *circ,
crypt_path_t *cpath)
{
or_options_t *options = get_options();
const or_options_t *options = get_options();
if (options->LeaveStreamsUnattached) {
conn->_base.state = AP_CONN_STATE_CONTROLLER_WAIT;
......@@ -1588,7 +1588,7 @@ connection_ap_handshake_rewrite_and_attach(edge_connection_t *conn,
{
socks_request_t *socks = conn->socks_request;
hostname_type_t addresstype;
or_options_t *options = get_options();
const or_options_t *options = get_options();
struct in_addr addr_tmp;
/* We set this to true if this is an address we should automatically
* remap to a local address in VirtualAddrNetwork */
......@@ -2079,7 +2079,7 @@ connection_ap_handshake_process_socks(edge_connection_t *conn)
{
socks_request_t *socks;
int sockshere;
or_options_t *options = get_options();
const or_options_t *options = get_options();
tor_assert(conn);
tor_assert(conn->_base.type == CONN_TYPE_AP);
......@@ -2703,7 +2703,7 @@ connection_exit_begin_conn(cell_t *cell, circuit_t *circ)
char *address=NULL;
uint16_t port;
or_circuit_t *or_circ = NULL;
or_options_t *options = get_options();
const or_options_t *options = get_options();
assert_circuit_ok(circ);
if (!CIRCUIT_IS_ORIGIN(circ))
......@@ -3104,7 +3104,7 @@ connection_edge_is_rendezvous_stream(edge_connection_t *conn)
int
connection_ap_can_use_exit(edge_connection_t *conn, const node_t *exit)
{
or_options_t *options = get_options();
const or_options_t *options = get_options();
tor_assert(conn);
tor_assert(conn->_base.type == CONN_TYPE_AP);
......
......@@ -63,8 +63,8 @@ int connection_ap_process_transparent(edge_connection_t *conn);
int address_is_invalid_destination(const char *address, int client);
void addressmap_init(void);
void addressmap_clear_excluded_trackexithosts(or_options_t *options);
void addressmap_clear_invalid_automaps(or_options_t *options);
void addressmap_clear_excluded_trackexithosts(const or_options_t *options);
void addressmap_clear_invalid_automaps(const or_options_t *options);
void addressmap_clean(time_t now);
void addressmap_clear_configured(void);
void addressmap_clear_transient(void);
......
......@@ -380,7 +380,7 @@ connection_or_digest_is_known_relay(const char *id_digest)
*/
static void
connection_or_update_token_buckets_helper(or_connection_t *conn, int reset,
or_options_t *options)
const or_options_t *options)
{
int rate, burst; /* per-connection rate limiting params */
if (connection_or_digest_is_known_relay(conn->identity_digest)) {
......@@ -436,7 +436,8 @@ connection_or_update_token_buckets_helper(or_connection_t *conn, int reset,
* Go through all the OR connections and update their token buckets to make
* sure they don't exceed their maximum values. */
void
connection_or_update_token_buckets(smartlist_t *conns, or_options_t *options)
connection_or_update_token_buckets(smartlist_t *conns,
const or_options_t *options)
{
SMARTLIST_FOREACH(conns, connection_t *, conn,
{
......@@ -827,7 +828,7 @@ connection_or_connect(const tor_addr_t *_addr, uint16_t port,
const char *id_digest)
{
or_connection_t *conn;
or_options_t *options = get_options();
const or_options_t *options = get_options();
int socket_error = 0;
int using_proxy = 0;
tor_addr_t addr;
......@@ -1144,7 +1145,7 @@ connection_or_check_valid_tls_handshake(or_connection_t *conn,
char *digest_rcvd_out)
{
crypto_pk_env_t *identity_rcvd=NULL;
or_options_t *options = get_options();
const or_options_t *options = get_options();
int severity = server_mode(options) ? LOG_PROTOCOL_WARN : LOG_WARN;
const char *safe_address =
started_here ? conn->_base.address :
......
......@@ -27,7 +27,7 @@ int connection_or_finished_flushing(or_connection_t *conn);
int connection_or_finished_connecting(or_connection_t *conn);
int connection_or_digest_is_known_relay(const char *id_digest);
void connection_or_update_token_buckets(smartlist_t *conns,
or_options_t *options);
const or_options_t *options);
void connection_or_connect_failed(or_connection_t *conn,
int reason, const char *msg);
......
......@@ -523,7 +523,7 @@ control_ports_write_to_file(void)
{
smartlist_t *lines;
char *joined = NULL;
or_options_t *options = get_options();
const or_options_t *options = get_options();
if (!options->ControlPortWriteToFile)
return;
......@@ -827,7 +827,7 @@ handle_control_getconf(control_connection_t *conn, uint32_t body_len,
smartlist_t *unrecognized = smartlist_create();
char *msg = NULL;
size_t msg_len;
or_options_t *options = get_options();
const or_options_t *options = get_options();
int i, len;
(void) body_len; /* body is NUL-terminated; so we can ignore len. */
......@@ -1070,7 +1070,7 @@ handle_control_authenticate(control_connection_t *conn, uint32_t len,
const char *body)
{
int used_quoted_string = 0;
or_options_t *options = get_options();
const or_options_t *options = get_options();
const char *errstr = NULL;
char *password;
size_t password_len;
......@@ -2849,7 +2849,7 @@ handle_control_protocolinfo(control_connection_t *conn, uint32_t len,
connection_mark_for_close(TO_CONN(conn));
goto done;
} else {
or_options_t *options = get_options();
const or_options_t *options = get_options();
int cookies = options->CookieAuthentication;
char *cfile = get_cookie_file();
char *esc_cfile = esc_for_log(cfile);
......@@ -4021,7 +4021,7 @@ control_event_guard(const char *nickname, const char *digest,
static char *
get_cookie_file(void)
{
or_options_t *options = get_options();
const or_options_t *options = get_options();
if (options->CookieAuthFile && strlen(options->CookieAuthFile)) {
return tor_strdup(options->CookieAuthFile);
} else {
......
......@@ -252,7 +252,7 @@ int
directories_have_accepted_server_descriptor(void)
{
smartlist_t *servers = router_get_trusted_dir_servers();
or_options_t *options = get_options();
const or_options_t *options = get_options();
SMARTLIST_FOREACH(servers, trusted_dir_server_t *, d, {
if ((d->type & options->_PublishServerDescriptor) &&
d->has_accepted_serverdesc) {
......@@ -285,7 +285,7 @@ directory_post_to_dirservers(uint8_t dir_purpose, uint8_t router_purpose,
const char *payload,
size_t payload_len, size_t extrainfo_len)
{
or_options_t *options = get_options();
const or_options_t *options = get_options();
int post_via_tor;