tor

The Tor anonymity network
git clone https://git.dasho.dev/tor.git
Log | Files | Refs | README | LICENSE

commit 7ebfa607b238ed909473bb971d1187066d68c56f
parent b3eb4091579e59e4bf311713a3bef0f85137b1b0
Author: Nick Mathewson <nickm@torproject.org>
Date:   Thu, 16 Jul 2020 10:26:43 -0400

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:
Msrc/core/mainloop/connection.c | 4++--
Msrc/core/or/channeltls.c | 4++--
Msrc/core/or/scheduler.c | 2+-
Msrc/core/or/scheduler_kist.c | 2+-
Msrc/feature/control/control_bootstrap.c | 4++--
Msrc/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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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. */