[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [tor/master] remove meaningless checks for chunks==NULL in dirserv stuff
commit 059e33de59030b008193512b58a51be922fffea4
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date: Thu Aug 21 11:01:44 2014 -0400
remove meaningless checks for chunks==NULL in dirserv stuff
Also, make it clearer that chunks cannot be NULL
[CID 1031750, 1031751]
---
src/or/dirserv.c | 9 +++------
src/or/dirvote.c | 10 ++++------
2 files changed, 7 insertions(+), 12 deletions(-)
diff --git a/src/or/dirserv.c b/src/or/dirserv.c
index f33437f..52258e8 100644
--- a/src/or/dirserv.c
+++ b/src/or/dirserv.c
@@ -1959,13 +1959,12 @@ routerstatus_format_entry(const routerstatus_t *rs, const char *version,
char published[ISO_TIME_LEN+1];
char identity64[BASE64_DIGEST_LEN+1];
char digest64[BASE64_DIGEST_LEN+1];
- smartlist_t *chunks = NULL;
+ smartlist_t *chunks = smartlist_new();
format_iso_time(published, rs->published_on);
digest_to_base64(identity64, rs->identity_digest);
digest_to_base64(digest64, rs->descriptor_digest);
- chunks = smartlist_new();
smartlist_add_asprintf(chunks,
"r %s %s %s%s%s %s %d %d\n",
rs->nickname,
@@ -2090,10 +2089,8 @@ routerstatus_format_entry(const routerstatus_t *rs, const char *version,
result = smartlist_join_strings(chunks, "", 0, NULL);
err:
- if (chunks) {
- SMARTLIST_FOREACH(chunks, char *, cp, tor_free(cp));
- smartlist_free(chunks);
- }
+ SMARTLIST_FOREACH(chunks, char *, cp, tor_free(cp));
+ smartlist_free(chunks);
return result;
}
diff --git a/src/or/dirvote.c b/src/or/dirvote.c
index 30f1321..6536b7f 100644
--- a/src/or/dirvote.c
+++ b/src/or/dirvote.c
@@ -64,7 +64,7 @@ STATIC char *
format_networkstatus_vote(crypto_pk_t *private_signing_key,
networkstatus_t *v3_ns)
{
- smartlist_t *chunks;
+ smartlist_t *chunks = smartlist_new();
const char *client_versions = NULL, *server_versions = NULL;
char fingerprint[FINGERPRINT_LEN+1];
char digest[DIGEST_LEN];
@@ -98,7 +98,6 @@ format_networkstatus_vote(crypto_pk_t *private_signing_key,
server_versions_line = tor_strdup("");
}
- chunks = smartlist_new();
{
char published[ISO_TIME_LEN+1];
char va[ISO_TIME_LEN+1];
@@ -230,10 +229,9 @@ format_networkstatus_vote(crypto_pk_t *private_signing_key,
done:
tor_free(client_versions_line);
tor_free(server_versions_line);
- if (chunks) {
- SMARTLIST_FOREACH(chunks, char *, cp, tor_free(cp));
- smartlist_free(chunks);
- }
+
+ SMARTLIST_FOREACH(chunks, char *, cp, tor_free(cp));
+ smartlist_free(chunks);
return status;
}
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits