Small tweaks to 2841 code

- const-ify some transport_t pointers
    - Remove a vestigial argument to parse_bridge_line
    - Make it compile without warnings on my laptop with
      --enable-gcc-warnings
This commit is contained in:
Nick Mathewson 2011-07-02 23:12:32 -04:00
parent 36468ec44b
commit c4b831e92d
5 changed files with 11 additions and 12 deletions

View File

@ -123,7 +123,7 @@ static int onion_append_hop(crypt_path_t **head_ptr, extend_info_t *choice);
static void entry_guards_changed(void); static void entry_guards_changed(void);
static transport_t *transport_get_by_name(const char *name); static const transport_t *transport_get_by_name(const char *name);
static void transport_free(transport_t *transport); static void transport_free(transport_t *transport);
static void bridge_free(bridge_info_t *bridge); static void bridge_free(bridge_info_t *bridge);
@ -4603,7 +4603,7 @@ transport_free(transport_t *transport)
/** Returns the transport in our transport list that has the name <b>name</b>. /** Returns the transport in our transport list that has the name <b>name</b>.
* Else returns NULL. */ * Else returns NULL. */
static transport_t * static const transport_t *
transport_get_by_name(const char *name) transport_get_by_name(const char *name)
{ {
tor_assert(name); tor_assert(name);
@ -4822,7 +4822,7 @@ find_bridge_by_digest(const char *digest)
*/ */
int int
find_transport_by_bridge_addrport(const tor_addr_t *addr, uint16_t port, find_transport_by_bridge_addrport(const tor_addr_t *addr, uint16_t port,
transport_t **transport) const transport_t **transport)
{ {
if (!bridge_list) if (!bridge_list)
return 1; return 1;

View File

@ -143,7 +143,7 @@ void clear_transport_list(void);
int transport_add_from_config(const tor_addr_t *addr, uint16_t port, int transport_add_from_config(const tor_addr_t *addr, uint16_t port,
const char *name, int socks_ver); const char *name, int socks_ver);
int find_transport_by_bridge_addrport(const tor_addr_t *addr, uint16_t port, int find_transport_by_bridge_addrport(const tor_addr_t *addr, uint16_t port,
transport_t **transport); const transport_t **transport);
void validate_pluggable_transports_config(void); void validate_pluggable_transports_config(void);
#endif #endif

View File

@ -570,8 +570,7 @@ static int options_transition_affects_descriptor(or_options_t *old_options,
static int check_nickname_list(const char *lst, const char *name, char **msg); 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(or_options_t *options);
static int parse_bridge_line(const char *line, int validate_only, static int parse_bridge_line(const char *line, int validate_only);
or_options_t *options);
static int parse_client_transport_line(const char *line, int validate_only); static int parse_client_transport_line(const char *line, int validate_only);
static int parse_dir_server_line(const char *line, static int parse_dir_server_line(const char *line,
dirinfo_type_t required_type, dirinfo_type_t required_type,
@ -1223,7 +1222,7 @@ options_act(or_options_t *old_options)
if (options->Bridges) { if (options->Bridges) {
mark_bridge_list(); mark_bridge_list();
for (cl = options->Bridges; cl; cl = cl->next) { for (cl = options->Bridges; cl; cl = cl->next) {
if (parse_bridge_line(cl->value, 0, options)<0) { if (parse_bridge_line(cl->value, 0)<0) {
log_warn(LD_BUG, log_warn(LD_BUG,
"Previously validated Bridge line could not be added!"); "Previously validated Bridge line could not be added!");
return -1; return -1;
@ -3696,7 +3695,7 @@ options_validate(or_options_t *old_options, or_options_t *options,
if (options->Bridges) { if (options->Bridges) {
for (cl = options->Bridges; cl; cl = cl->next) { for (cl = options->Bridges; cl; cl = cl->next) {
if (parse_bridge_line(cl->value, 1, options)<0) if (parse_bridge_line(cl->value, 1)<0)
REJECT("Bridge line did not parse. See logs for details."); REJECT("Bridge line did not parse. See logs for details.");
} }
} }
@ -4579,8 +4578,7 @@ options_init_logs(or_options_t *options, int validate_only)
* <b>validate_only</b> is 0, and the line is well-formed, then add * <b>validate_only</b> is 0, and the line is well-formed, then add
* the bridge described in the line to our internal bridge list. */ * the bridge described in the line to our internal bridge list. */
static int static int
parse_bridge_line(const char *line, int validate_only, parse_bridge_line(const char *line, int validate_only)
or_options_t *options)
{ {
smartlist_t *items = NULL; smartlist_t *items = NULL;
int r; int r;

View File

@ -4130,7 +4130,7 @@ get_proxy_addrport(tor_addr_t *addr, uint16_t *port,
goto done; goto done;
} else if (options->ClientTransportPlugin || } else if (options->ClientTransportPlugin ||
options->Bridges) { options->Bridges) {
transport_t *transport=NULL; const transport_t *transport=NULL;
int r; int r;
r = find_transport_by_bridge_addrport(&conn->addr, conn->port, &transport); r = find_transport_by_bridge_addrport(&conn->addr, conn->port, &transport);
if (r == 0) { /* transport found */ if (r == 0) { /* transport found */
@ -4197,5 +4197,6 @@ proxy_type_to_string(int proxy_type)
case PROXY_NONE: return "NULL"; case PROXY_NONE: return "NULL";
default: tor_assert(0); default: tor_assert(0);
} }
return NULL; /*Unreached*/
} }

View File

@ -336,7 +336,7 @@ connection_or_finished_connecting(or_connection_t *or_conn)
else if (get_options()->Socks5Proxy) else if (get_options()->Socks5Proxy)
proxy_type = PROXY_SOCKS5; proxy_type = PROXY_SOCKS5;
else if (get_options()->ClientTransportPlugin) { else if (get_options()->ClientTransportPlugin) {
transport_t *transport=NULL; const transport_t *transport=NULL;
int r; int r;
r = find_transport_by_bridge_addrport(&conn->addr,conn->port,&transport); r = find_transport_by_bridge_addrport(&conn->addr,conn->port,&transport);
if (r == 0) { if (r == 0) {