mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-10 21:23:58 +01:00
Quench gcc's complaints about discarding constness in TO_ORIGIN_CIRCUIT.
This was previously satisfied by using a temporary variable, but there are three other instances in circuitlist.c that gcc is now bothered by, so now introduce a CONST_TO_ORIGIN_CIRCUIT that takes a const circuit_t instead.
This commit is contained in:
parent
cae6388053
commit
88679aa53f
@ -1821,7 +1821,7 @@ circuit_max_queued_cell_age(const circuit_t *c, uint32_t now)
|
||||
age = now - cell->inserted_time;
|
||||
|
||||
if (! CIRCUIT_IS_ORIGIN(c)) {
|
||||
const or_circuit_t *orcirc = TO_OR_CIRCUIT((circuit_t*)c);
|
||||
const or_circuit_t *orcirc = CONST_TO_OR_CIRCUIT(c);
|
||||
if (NULL != (cell = TOR_SIMPLEQ_FIRST(&orcirc->p_chan_cells.head))) {
|
||||
uint32_t age2 = now - cell->inserted_time;
|
||||
if (age2 > age)
|
||||
@ -1863,10 +1863,10 @@ circuit_max_queued_data_age(const circuit_t *c, uint32_t now)
|
||||
{
|
||||
if (CIRCUIT_IS_ORIGIN(c)) {
|
||||
return circuit_get_streams_max_data_age(
|
||||
TO_ORIGIN_CIRCUIT((circuit_t*)c)->p_streams, now);
|
||||
CONST_TO_ORIGIN_CIRCUIT(c)->p_streams, now);
|
||||
} else {
|
||||
return circuit_get_streams_max_data_age(
|
||||
TO_OR_CIRCUIT((circuit_t*)c)->n_streams, now);
|
||||
CONST_TO_OR_CIRCUIT(c)->n_streams, now);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2057,15 +2057,10 @@ assert_circuit_ok(const circuit_t *c)
|
||||
tor_assert(c->purpose >= CIRCUIT_PURPOSE_MIN_ &&
|
||||
c->purpose <= CIRCUIT_PURPOSE_MAX_);
|
||||
|
||||
{
|
||||
/* Having a separate variable for this pleases GCC 4.2 in ways I hope I
|
||||
* never understand. -NM. */
|
||||
circuit_t *nonconst_circ = (circuit_t*) c;
|
||||
if (CIRCUIT_IS_ORIGIN(c))
|
||||
origin_circ = TO_ORIGIN_CIRCUIT(nonconst_circ);
|
||||
else
|
||||
or_circ = TO_OR_CIRCUIT(nonconst_circ);
|
||||
}
|
||||
if (CIRCUIT_IS_ORIGIN(c))
|
||||
origin_circ = CONST_TO_ORIGIN_CIRCUIT(c);
|
||||
else
|
||||
or_circ = CONST_TO_OR_CIRCUIT(c);
|
||||
|
||||
if (c->n_chan) {
|
||||
tor_assert(!c->n_hop);
|
||||
|
13
src/or/or.h
13
src/or/or.h
@ -3231,20 +3231,33 @@ typedef struct or_circuit_rendinfo_s {
|
||||
/** Convert a circuit_t* to a pointer to the enclosing or_circuit_t. Assert
|
||||
* if the cast is impossible. */
|
||||
static or_circuit_t *TO_OR_CIRCUIT(circuit_t *);
|
||||
static const or_circuit_t *CONST_TO_OR_CIRCUIT(const circuit_t *);
|
||||
/** Convert a circuit_t* to a pointer to the enclosing origin_circuit_t.
|
||||
* Assert if the cast is impossible. */
|
||||
static origin_circuit_t *TO_ORIGIN_CIRCUIT(circuit_t *);
|
||||
static const origin_circuit_t *CONST_TO_ORIGIN_CIRCUIT(const circuit_t *);
|
||||
|
||||
static INLINE or_circuit_t *TO_OR_CIRCUIT(circuit_t *x)
|
||||
{
|
||||
tor_assert(x->magic == OR_CIRCUIT_MAGIC);
|
||||
return DOWNCAST(or_circuit_t, x);
|
||||
}
|
||||
static INLINE const or_circuit_t *CONST_TO_OR_CIRCUIT(const circuit_t *x)
|
||||
{
|
||||
tor_assert(x->magic == OR_CIRCUIT_MAGIC);
|
||||
return DOWNCAST(or_circuit_t, x);
|
||||
}
|
||||
static INLINE origin_circuit_t *TO_ORIGIN_CIRCUIT(circuit_t *x)
|
||||
{
|
||||
tor_assert(x->magic == ORIGIN_CIRCUIT_MAGIC);
|
||||
return DOWNCAST(origin_circuit_t, x);
|
||||
}
|
||||
static INLINE const origin_circuit_t *CONST_TO_ORIGIN_CIRCUIT(
|
||||
const circuit_t *x)
|
||||
{
|
||||
tor_assert(x->magic == ORIGIN_CIRCUIT_MAGIC);
|
||||
return DOWNCAST(origin_circuit_t, x);
|
||||
}
|
||||
|
||||
/** Bitfield type: things that we're willing to use invalid routers for. */
|
||||
typedef enum invalid_router_usage_t {
|
||||
|
Loading…
Reference in New Issue
Block a user