diff options
author | Nick Mathewson <nickm@torproject.org> | 2012-01-11 13:44:10 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2012-01-16 15:02:51 -0500 |
commit | edcc9981d8b8894d2ef4e0d617a20d7d99547817 (patch) | |
tree | 44476ecc42282d66930fb659d27fc9ad3c5a74b6 /src/or/networkstatus.c | |
parent | 9c6d913b9e1b84ffcefb2cbd9cfe6f7bd15fc9b3 (diff) | |
download | tor-edcc9981d8b8894d2ef4e0d617a20d7d99547817.tar.gz tor-edcc9981d8b8894d2ef4e0d617a20d7d99547817.zip |
Try to use smartlist_add_asprintf consistently
(To ensure correctness, in every case, make sure that the temporary
variable is deleted, renamed, or lowered in scope, so we can't have
any bugs related to accidentally relying on the no-longer-filled
variable.)
Diffstat (limited to 'src/or/networkstatus.c')
-rw-r--r-- | src/or/networkstatus.c | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/src/or/networkstatus.c b/src/or/networkstatus.c index a835e78b85..0a1fc08bf7 100644 --- a/src/or/networkstatus.c +++ b/src/or/networkstatus.c @@ -598,39 +598,38 @@ networkstatus_check_consensus_signature(networkstatus_t *consensus, hex_str(ds->v3_identity_digest, DIGEST_LEN)); }); { + char *joined; smartlist_t *sl = smartlist_create(); - char *cp; char *tmp = smartlist_join_strings(list_good, " ", 0, NULL); - tor_asprintf(&cp, "A consensus needs %d good signatures from recognized " + smartlist_add_asprintf(sl, + "A consensus needs %d good signatures from recognized " "authorities for us to accept it. This one has %d (%s).", n_required, n_good, tmp); tor_free(tmp); - smartlist_add(sl,cp); if (n_no_signature) { tmp = smartlist_join_strings(list_no_signature, " ", 0, NULL); - tor_asprintf(&cp, "%d (%s) of the authorities we know didn't sign it.", + smartlist_add_asprintf(sl, + "%d (%s) of the authorities we know didn't sign it.", n_no_signature, tmp); tor_free(tmp); - smartlist_add(sl,cp); } if (n_unknown) { - tor_asprintf(&cp, "It has %d signatures from authorities we don't " + smartlist_add_asprintf(sl, + "It has %d signatures from authorities we don't " "recognize.", n_unknown); - smartlist_add(sl,cp); } if (n_bad) { - tor_asprintf(&cp, "%d of the signatures on it didn't verify " + smartlist_add_asprintf(sl, "%d of the signatures on it didn't verify " "correctly.", n_bad); - smartlist_add(sl,cp); } if (n_missing_key) { - tor_asprintf(&cp, "We were unable to check %d of the signatures, " + smartlist_add_asprintf(sl, + "We were unable to check %d of the signatures, " "because we were missing the keys.", n_missing_key); - smartlist_add(sl,cp); } - cp = smartlist_join_strings(sl, " ", 0, NULL); - log(severity, LD_DIR, "%s", cp); - tor_free(cp); + joined = smartlist_join_strings(sl, " ", 0, NULL); + log(severity, LD_DIR, "%s", joined); + tor_free(joined); SMARTLIST_FOREACH(sl, char *, c, tor_free(c)); smartlist_free(sl); } |