scan-build: when logging a path length, check build_state.

Throughout circuituse, when we log about a circuit, we log its
desired path length from build_state. scan-build is irrationally
concerned that build_state might be NULL.
This commit is contained in:
Nick Mathewson 2014-04-18 20:40:34 -04:00
parent 7106492571
commit 7cd9520ba9

View File

@ -537,7 +537,9 @@ circuit_expire_building(void)
"%d guards are live.", "%d guards are live.",
TO_ORIGIN_CIRCUIT(victim)->global_identifier, TO_ORIGIN_CIRCUIT(victim)->global_identifier,
circuit_purpose_to_string(victim->purpose), circuit_purpose_to_string(victim->purpose),
TO_ORIGIN_CIRCUIT(victim)->build_state->desired_path_len, TO_ORIGIN_CIRCUIT(victim)->build_state ?
TO_ORIGIN_CIRCUIT(victim)->build_state->desired_path_len :
-1,
circuit_state_to_string(victim->state), circuit_state_to_string(victim->state),
channel_state_to_string(victim->n_chan->state), channel_state_to_string(victim->n_chan->state),
num_live_entry_guards(0)); num_live_entry_guards(0));
@ -561,7 +563,9 @@ circuit_expire_building(void)
"anyway. %d guards are live.", "anyway. %d guards are live.",
TO_ORIGIN_CIRCUIT(victim)->global_identifier, TO_ORIGIN_CIRCUIT(victim)->global_identifier,
circuit_purpose_to_string(victim->purpose), circuit_purpose_to_string(victim->purpose),
TO_ORIGIN_CIRCUIT(victim)->build_state->desired_path_len, TO_ORIGIN_CIRCUIT(victim)->build_state ?
TO_ORIGIN_CIRCUIT(victim)->build_state->desired_path_len :
-1,
circuit_state_to_string(victim->state), circuit_state_to_string(victim->state),
channel_state_to_string(victim->n_chan->state), channel_state_to_string(victim->n_chan->state),
(long)build_close_ms, (long)build_close_ms,
@ -707,7 +711,8 @@ circuit_expire_building(void)
* and we have tried to send an INTRODUCE1 cell specifying it. * and we have tried to send an INTRODUCE1 cell specifying it.
* Thus, if the pending_final_cpath field *is* NULL, then we * Thus, if the pending_final_cpath field *is* NULL, then we
* want to not spare it. */ * want to not spare it. */
if (TO_ORIGIN_CIRCUIT(victim)->build_state->pending_final_cpath == if (TO_ORIGIN_CIRCUIT(victim)->build_state &&
TO_ORIGIN_CIRCUIT(victim)->build_state->pending_final_cpath ==
NULL) NULL)
break; break;
/* fallthrough! */ /* fallthrough! */
@ -753,7 +758,9 @@ circuit_expire_building(void)
TO_ORIGIN_CIRCUIT(victim)->has_opened, TO_ORIGIN_CIRCUIT(victim)->has_opened,
victim->state, circuit_state_to_string(victim->state), victim->state, circuit_state_to_string(victim->state),
victim->purpose, victim->purpose,
TO_ORIGIN_CIRCUIT(victim)->build_state->desired_path_len); TO_ORIGIN_CIRCUIT(victim)->build_state ?
TO_ORIGIN_CIRCUIT(victim)->build_state->desired_path_len :
-1);
else else
log_info(LD_CIRC, log_info(LD_CIRC,
"Abandoning circ %u %u (state %d,%d:%s, purpose %d, len %d)", "Abandoning circ %u %u (state %d,%d:%s, purpose %d, len %d)",
@ -762,7 +769,9 @@ circuit_expire_building(void)
TO_ORIGIN_CIRCUIT(victim)->has_opened, TO_ORIGIN_CIRCUIT(victim)->has_opened,
victim->state, victim->state,
circuit_state_to_string(victim->state), victim->purpose, circuit_state_to_string(victim->state), victim->purpose,
TO_ORIGIN_CIRCUIT(victim)->build_state->desired_path_len); TO_ORIGIN_CIRCUIT(victim)->build_state ?
TO_ORIGIN_CIRCUIT(victim)->build_state->desired_path_len :
-1);
circuit_log_path(LOG_INFO,LD_CIRC,TO_ORIGIN_CIRCUIT(victim)); circuit_log_path(LOG_INFO,LD_CIRC,TO_ORIGIN_CIRCUIT(victim));
if (victim->purpose == CIRCUIT_PURPOSE_C_MEASURE_TIMEOUT) if (victim->purpose == CIRCUIT_PURPOSE_C_MEASURE_TIMEOUT)