mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-11 05:33:47 +01:00
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.
This commit is contained in:
parent
b3eb409157
commit
7ebfa607b2
@ -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);
|
||||
|
@ -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) {
|
||||
|
@ -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.",
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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("?");
|
||||
|
@ -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. */
|
||||
|
Loading…
Reference in New Issue
Block a user