diff options
author | Nick Mathewson <nickm@torproject.org> | 2020-07-16 10:26:43 -0400 |
---|---|---|
committer | David Goulet <dgoulet@torproject.org> | 2020-07-16 12:55:06 -0400 |
commit | 7ebfa607b238ed909473bb971d1187066d68c56f (patch) | |
tree | e94ab2e53a0c19164f60e43fc53bee7e85195ab0 /src | |
parent | b3eb4091579e59e4bf311713a3bef0f85137b1b0 (diff) | |
download | tor-7ebfa607b238ed909473bb971d1187066d68c56f.tar.gz tor-7ebfa607b238ed909473bb971d1187066d68c56f.zip |
Use CONST_TO_* macros in more places.
This is an automated commit made with a python script.
After running the automated script, I had to hand-revert the cases where it
made the conversion functions call themselves.
Additionally, I had to edit a variable declaration in control_bootstrap.c so
that the result of a const cast could be put in a const field.
Diffstat (limited to 'src')
-rw-r--r-- | src/core/mainloop/connection.c | 4 | ||||
-rw-r--r-- | src/core/or/channeltls.c | 4 | ||||
-rw-r--r-- | src/core/or/scheduler.c | 2 | ||||
-rw-r--r-- | src/core/or/scheduler_kist.c | 2 | ||||
-rw-r--r-- | src/feature/control/control_bootstrap.c | 4 | ||||
-rw-r--r-- | src/feature/dircommon/directory.c | 2 |
6 files changed, 9 insertions, 9 deletions
diff --git a/src/core/mainloop/connection.c b/src/core/mainloop/connection.c index 20e38ac44b..90fd35b527 100644 --- a/src/core/mainloop/connection.c +++ b/src/core/mainloop/connection.c @@ -433,7 +433,7 @@ connection_describe_peer_internal(const connection_t *conn, address = conn->address ? conn->address : "unix socket"; } else if (conn->type == CONN_TYPE_OR) { /* For OR connections, we have a lot to do. */ - const or_connection_t *or_conn = TO_OR_CONN((connection_t *)conn); + const or_connection_t *or_conn = CONST_TO_OR_CONN(conn); /* we report 'real_addr' as the address we're talking with, if it's set. * * TODO: Eventually we should have 'addr' always mean the address on the @@ -2257,7 +2257,7 @@ connection_connect_log_client_use_ip_version(const connection_t *conn) /* OR conns keep the original address in real_addr, as addr gets overwritten * with the descriptor address */ if (conn->type == CONN_TYPE_OR) { - const or_connection_t *or_conn = TO_OR_CONN((connection_t *)conn); + const or_connection_t *or_conn = CONST_TO_OR_CONN(conn); tor_addr_copy(&real_addr, &or_conn->real_addr); } else if (conn->type == CONN_TYPE_DIR) { tor_addr_copy(&real_addr, &conn->addr); diff --git a/src/core/or/channeltls.c b/src/core/or/channeltls.c index 4a421462cc..90049a7e5c 100644 --- a/src/core/or/channeltls.c +++ b/src/core/or/channeltls.c @@ -538,7 +538,7 @@ static int channel_tls_get_remote_addr_method(const channel_t *chan, tor_addr_t *addr_out) { - const channel_tls_t *tlschan = BASE_CHAN_TO_TLS((channel_t*) chan); + const channel_tls_t *tlschan = CONST_BASE_CHAN_TO_TLS(chan); tor_assert(tlschan); tor_assert(addr_out); @@ -593,7 +593,7 @@ channel_tls_get_transport_name_method(channel_t *chan, char **transport_out) static const char * channel_tls_describe_peer_method(const channel_t *chan) { - const channel_tls_t *tlschan = BASE_CHAN_TO_TLS((channel_t*)chan); + const channel_tls_t *tlschan = CONST_BASE_CHAN_TO_TLS(chan); tor_assert(tlschan); if (tlschan->conn) { diff --git a/src/core/or/scheduler.c b/src/core/or/scheduler.c index 072d78128b..18f11487d9 100644 --- a/src/core/or/scheduler.c +++ b/src/core/or/scheduler.c @@ -713,7 +713,7 @@ scheduler_bug_occurred(const channel_t *chan) if (chan != NULL) { const size_t outbuf_len = - buf_datalen(TO_CONN(BASE_CHAN_TO_TLS((channel_t *) chan)->conn)->outbuf); + buf_datalen(TO_CONN(CONST_BASE_CHAN_TO_TLS(chan)->conn)->outbuf); tor_snprintf(buf, sizeof(buf), "Channel %" PRIu64 " in state %s and scheduler state %s." " Num cells on cmux: %d. Connection outbuf len: %lu.", diff --git a/src/core/or/scheduler_kist.c b/src/core/or/scheduler_kist.c index 5c1922847e..8c6a7bd1d1 100644 --- a/src/core/or/scheduler_kist.c +++ b/src/core/or/scheduler_kist.c @@ -203,7 +203,7 @@ update_socket_info_impl, (socket_table_ent_t *ent)) tor_assert(ent); tor_assert(ent->chan); const tor_socket_t sock = - TO_CONN(BASE_CHAN_TO_TLS((channel_t *) ent->chan)->conn)->s; + TO_CONN(CONST_BASE_CHAN_TO_TLS(ent->chan)->conn)->s; struct tcp_info tcp; socklen_t tcp_info_len = sizeof(tcp); diff --git a/src/feature/control/control_bootstrap.c b/src/feature/control/control_bootstrap.c index fee7612ba2..d4f2adde81 100644 --- a/src/feature/control/control_bootstrap.c +++ b/src/feature/control/control_bootstrap.c @@ -274,7 +274,7 @@ control_event_bootstrap_problem(const char *warn, const char *reason, const char *recommendation = "ignore"; int severity; char *or_id = NULL, *hostaddr = NULL; - or_connection_t *or_conn = NULL; + const or_connection_t *or_conn = NULL; /* bootstrap_percent must not be in "undefined" state here. */ tor_assert(status >= 0); @@ -301,7 +301,7 @@ control_event_bootstrap_problem(const char *warn, const char *reason, if (conn && conn->type == CONN_TYPE_OR) { /* XXX TO_OR_CONN can't deal with const */ - or_conn = TO_OR_CONN((connection_t *)conn); + or_conn = CONST_TO_OR_CONN(conn); or_id = tor_strdup(hex_str(or_conn->identity_digest, DIGEST_LEN)); } else { or_id = tor_strdup("?"); diff --git a/src/feature/dircommon/directory.c b/src/feature/dircommon/directory.c index e92e6480af..b276ac3441 100644 --- a/src/feature/dircommon/directory.c +++ b/src/feature/dircommon/directory.c @@ -233,7 +233,7 @@ connection_dir_is_anonymous(const dir_connection_t *dir_conn) return false; } - edge_conn = TO_EDGE_CONN((connection_t *) linked_conn); + edge_conn = CONST_TO_EDGE_CONN(linked_conn); circ = edge_conn->on_circuit; /* Can't be a circuit we initiated and without a circuit, no channel. */ |