diff options
author | Nick Mathewson <nickm@torproject.org> | 2009-01-13 14:43:51 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2009-01-13 14:43:51 +0000 |
commit | a33452c40149842fda3ce2a201a722009e7e1456 (patch) | |
tree | 5bc3efc1704b0fb1dafface01fbda1e6a8da6e3b /src | |
parent | c32a4ce6b3ac5d24ff53639d2c00d9864e9bf22c (diff) | |
download | tor-a33452c40149842fda3ce2a201a722009e7e1456.tar.gz tor-a33452c40149842fda3ce2a201a722009e7e1456.zip |
Fix up (I hope) most ot the things that coverity suddenly claimed were REVERSE_INULL. This is what we get for bragging about being down to 0 issues.
svn:r18096
Diffstat (limited to 'src')
-rw-r--r-- | src/common/torgzip.c | 6 | ||||
-rw-r--r-- | src/or/control.c | 47 | ||||
-rw-r--r-- | src/or/routerlist.c | 12 | ||||
-rw-r--r-- | src/or/routerparse.c | 2 | ||||
-rw-r--r-- | src/or/test.c | 27 |
5 files changed, 47 insertions, 47 deletions
diff --git a/src/common/torgzip.c b/src/common/torgzip.c index 180c1e6dfd..f75ef83503 100644 --- a/src/common/torgzip.c +++ b/src/common/torgzip.c @@ -76,14 +76,14 @@ tor_gzip_compress(char **out, size_t *out_len, tor_assert(in); tor_assert(in_len < UINT_MAX); + *out = NULL; + if (method == GZIP_METHOD && !is_gzip_supported()) { /* Old zlib version don't support gzip in deflateInit2 */ log_warn(LD_BUG, "Gzip not supported with zlib %s", ZLIB_VERSION); - return -1; + goto err; } - *out = NULL; - stream = tor_malloc_zero(sizeof(struct z_stream_s)); stream->zalloc = Z_NULL; stream->zfree = Z_NULL; diff --git a/src/or/control.c b/src/or/control.c index 7e8cbfcf6b..0236d1ea88 100644 --- a/src/or/control.c +++ b/src/or/control.c @@ -823,24 +823,21 @@ static int handle_control_getconf(control_connection_t *conn, uint32_t body_len, const char *body) { - smartlist_t *questions = NULL; - smartlist_t *answers = NULL; - smartlist_t *unrecognized = NULL; + smartlist_t *questions = smartlist_create(); + smartlist_t *answers = smartlist_create(); + smartlist_t *unrecognized = smartlist_create(); char *msg = NULL; size_t msg_len; or_options_t *options = get_options(); int i, len; - questions = smartlist_create(); (void) body_len; /* body is nul-terminated; so we can ignore len. */ smartlist_split_string(questions, body, " ", SPLIT_SKIP_SPACE|SPLIT_IGNORE_BLANK, 0); - answers = smartlist_create(); - unrecognized = smartlist_create(); - SMARTLIST_FOREACH(questions, char *, q, + SMARTLIST_FOREACH(questions, const char *, q, { if (!option_is_recognized(q)) { - smartlist_add(unrecognized, q); + smartlist_add(unrecognized, (char*) q); } else { config_line_t *answer = option_get_assignment(options,q); if (!answer) { @@ -886,15 +883,12 @@ handle_control_getconf(control_connection_t *conn, uint32_t body_len, connection_write_str_to_buf("250 OK\r\n", conn); } - if (answers) { - SMARTLIST_FOREACH(answers, char *, cp, tor_free(cp)); - smartlist_free(answers); - } - if (questions) { - SMARTLIST_FOREACH(questions, char *, cp, tor_free(cp)); - smartlist_free(questions); - } + SMARTLIST_FOREACH(answers, char *, cp, tor_free(cp)); + smartlist_free(answers); + SMARTLIST_FOREACH(questions, char *, cp, tor_free(cp)); + smartlist_free(questions); smartlist_free(unrecognized); + tor_free(msg); return 0; @@ -2020,18 +2014,15 @@ static int handle_control_getinfo(control_connection_t *conn, uint32_t len, const char *body) { - smartlist_t *questions = NULL; - smartlist_t *answers = NULL; - smartlist_t *unrecognized = NULL; + smartlist_t *questions = smartlist_create(); + smartlist_t *answers = smartlist_create(); + smartlist_t *unrecognized = smartlist_create(); char *msg = NULL, *ans = NULL; int i; (void) len; /* body is nul-terminated, so it's safe to ignore the length. */ - questions = smartlist_create(); smartlist_split_string(questions, body, " ", SPLIT_SKIP_SPACE|SPLIT_IGNORE_BLANK, 0); - answers = smartlist_create(); - unrecognized = smartlist_create(); SMARTLIST_FOREACH(questions, const char *, q, { if (handle_getinfo_helper(conn, q, &ans) < 0) { @@ -2075,14 +2066,10 @@ handle_control_getinfo(control_connection_t *conn, uint32_t len, connection_write_str_to_buf("250 OK\r\n", conn); done: - if (answers) { - SMARTLIST_FOREACH(answers, char *, cp, tor_free(cp)); - smartlist_free(answers); - } - if (questions) { - SMARTLIST_FOREACH(questions, char *, cp, tor_free(cp)); - smartlist_free(questions); - } + SMARTLIST_FOREACH(answers, char *, cp, tor_free(cp)); + smartlist_free(answers); + SMARTLIST_FOREACH(questions, char *, cp, tor_free(cp)); + smartlist_free(questions); smartlist_free(unrecognized); tor_free(msg); diff --git a/src/or/routerlist.c b/src/or/routerlist.c index b08d506dbe..3706769a46 100644 --- a/src/or/routerlist.c +++ b/src/or/routerlist.c @@ -619,10 +619,14 @@ router_rebuild_store(int flags, desc_store_t *store) int had_any; int force = flags & RRS_FORCE; - if (!force && !router_should_rebuild_store(store)) - return 0; - if (!routerlist) - return 0; + if (!force && !router_should_rebuild_store(store)) { + r = 0; + goto done; + } + if (!routerlist) { + r = 0; + goto done; + } if (store->type == EXTRAINFO_STORE) had_any = !eimap_isempty(routerlist->extra_info_map); diff --git a/src/or/routerparse.c b/src/or/routerparse.c index cef7f73bee..b2df638874 100644 --- a/src/or/routerparse.c +++ b/src/or/routerparse.c @@ -1468,7 +1468,7 @@ extrainfo_parse_entry_from_string(const char *s, const char *end, if (router_get_extrainfo_hash(s, digest) < 0) { log_warn(LD_DIR, "Couldn't compute router hash."); - return NULL; + goto err; } tokens = smartlist_create(); area = memarea_new(); diff --git a/src/or/test.c b/src/or/test.c index 6f28f86f1e..f555d75673 100644 --- a/src/or/test.c +++ b/src/or/test.c @@ -2401,13 +2401,12 @@ _compare_strings_for_pqueue(const void *s1, const void *s2) static void test_util_pqueue(void) { - smartlist_t *sl = NULL; + smartlist_t *sl = smartlist_create(); int (*cmp)(const void *, const void*); #define OK() smartlist_pqueue_assert_ok(sl, cmp) cmp = _compare_strings_for_pqueue; - sl = smartlist_create(); smartlist_pqueue_add(sl, cmp, (char*)"cows"); smartlist_pqueue_add(sl, cmp, (char*)"zebras"); smartlist_pqueue_add(sl, cmp, (char*)"fish"); @@ -2451,8 +2450,8 @@ test_util_pqueue(void) #undef OK done: - if (sl) - smartlist_free(sl); + + smartlist_free(sl); } /** Run unit tests for compression functions */ @@ -3921,17 +3920,16 @@ test_rend_fns(void) char address2[] = "aaaaaaaaaaaaaaaa.onion"; char address3[] = "fooaddress.exit"; char address4[] = "www.torproject.org"; - rend_service_descriptor_t *d1 = NULL, *d2 = NULL; + rend_service_descriptor_t *d1 = + tor_malloc_zero(sizeof(rend_service_descriptor_t)); + rend_service_descriptor_t *d2 = NULL; char *encoded = NULL; size_t len; - crypto_pk_env_t *pk1 = NULL, *pk2 = NULL; time_t now; int i; - pk1 = pk_generate(0); - pk2 = pk_generate(1); + crypto_pk_env_t *pk1 = pk_generate(0), *pk2 = pk_generate(1); /* Test unversioned (v0) descriptor */ - d1 = tor_malloc_zero(sizeof(rend_service_descriptor_t)); d1->pk = crypto_pk_dup_key(pk1); now = time(NULL); d1->timestamp = now; @@ -3967,6 +3965,13 @@ test_rend_fns(void) test_assert(EXIT_HOSTNAME == parse_extended_hostname(address3)); test_assert(NORMAL_HOSTNAME == parse_extended_hostname(address4)); + crypto_free_pk_env(pk1); + crypto_free_pk_env(pk2); + pk1 = pk2 = NULL; + rend_service_descriptor_free(d1); + rend_service_descriptor_free(d2); + d1 = d2 = NULL; + done: if (pk1) crypto_free_pk_env(pk1); @@ -4530,6 +4535,10 @@ test_rend_fns_v2(void) test_eq(gen_info->port, par_info->port); } + rend_service_descriptor_free(parsed); + rend_service_descriptor_free(generated); + parsed = generated = NULL; + done: if (descs) { for (i = 0; i < smartlist_len(descs); i++) |