summaryrefslogtreecommitdiff
path: root/src/or
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2017-09-15 16:40:11 -0400
committerNick Mathewson <nickm@torproject.org>2017-09-15 16:40:11 -0400
commit76c33f7ff46df47df0cc880595c4d943d50f019b (patch)
tree11448ec9afd6990160ce6212c020d3c2630448d6 /src/or
parentc1deabd3b0c9e2701696afc80ac8392f0efda2c7 (diff)
parenta28e239b171c1a69fd32b6583bca0559f7116445 (diff)
downloadtor-76c33f7ff46df47df0cc880595c4d943d50f019b.tar.gz
tor-76c33f7ff46df47df0cc880595c4d943d50f019b.zip
Merge branch 'scan-build-032'
Diffstat (limited to 'src/or')
-rw-r--r--src/or/circuitbuild.c6
-rw-r--r--src/or/circuitmux.c10
-rw-r--r--src/or/config.c2
-rw-r--r--src/or/connection.c10
-rw-r--r--src/or/directory.c12
-rw-r--r--src/or/dirvote.c21
-rw-r--r--src/or/parsecommon.c1
-rw-r--r--src/or/rendservice.c18
-rw-r--r--src/or/routerparse.c6
-rw-r--r--src/or/statefile.c2
10 files changed, 42 insertions, 46 deletions
diff --git a/src/or/circuitbuild.c b/src/or/circuitbuild.c
index dea87e5915..aa048f8c31 100644
--- a/src/or/circuitbuild.c
+++ b/src/or/circuitbuild.c
@@ -2422,10 +2422,10 @@ cpath_get_n_hops(crypt_path_t **head_ptr)
}
tmp = *head_ptr;
- if (tmp) {
+ do {
n_hops++;
- tmp = (*head_ptr)->next;
- }
+ tmp = tmp->next;
+ } while (tmp != *head_ptr);
return n_hops;
}
diff --git a/src/or/circuitmux.c b/src/or/circuitmux.c
index 38ab56b6dc..f3b8aecb1b 100644
--- a/src/or/circuitmux.c
+++ b/src/or/circuitmux.c
@@ -261,13 +261,11 @@ circuitmux_move_active_circ_to_tail(circuitmux_t *cmux, circuit_t *circ,
if (circ->n_mux == cmux) {
next_p = &(circ->next_active_on_n_chan);
prev_p = &(circ->prev_active_on_n_chan);
- direction = CELL_DIRECTION_OUT;
} else {
or_circ = TO_OR_CIRCUIT(circ);
tor_assert(or_circ->p_mux == cmux);
next_p = &(or_circ->next_active_on_p_chan);
prev_p = &(or_circ->prev_active_on_p_chan);
- direction = CELL_DIRECTION_IN;
}
}
tor_assert(next_p);
@@ -1655,7 +1653,6 @@ circuitmux_assert_okay_pass_one(circuitmux_t *cmux)
circid_t circ_id;
circuit_t *circ;
or_circuit_t *or_circ;
- unsigned int circ_is_active;
circuit_t **next_p, **prev_p;
unsigned int n_circuits, n_active_circuits, n_cells;
@@ -1679,8 +1676,6 @@ circuitmux_assert_okay_pass_one(circuitmux_t *cmux)
tor_assert(chan);
circ = circuit_get_by_circid_channel_even_if_marked(circ_id, chan);
tor_assert(circ);
- /* Clear the circ_is_active bit to start */
- circ_is_active = 0;
/* Assert that we know which direction this is going */
tor_assert((*i)->muxinfo.direction == CELL_DIRECTION_OUT ||
@@ -1707,7 +1702,7 @@ circuitmux_assert_okay_pass_one(circuitmux_t *cmux)
* Should this circuit be active? I.e., does the mux know about > 0
* cells on it?
*/
- circ_is_active = ((*i)->muxinfo.cell_count > 0);
+ const int circ_is_active = ((*i)->muxinfo.cell_count > 0);
/* It should be in the linked list iff it's active */
if (circ_is_active) {
@@ -1759,7 +1754,6 @@ circuitmux_assert_okay_pass_two(circuitmux_t *cmux)
circuit_t **next_p, **prev_p;
channel_t *chan;
unsigned int n_active_circuits = 0;
- cell_direction_t direction;
chanid_circid_muxinfo_t search, *hashent = NULL;
tor_assert(cmux);
@@ -1778,7 +1772,7 @@ circuitmux_assert_okay_pass_two(circuitmux_t *cmux)
curr_or_circ = NULL;
next_circ = NULL;
next_p = prev_p = NULL;
- direction = 0;
+ cell_direction_t direction;
/* Figure out if this is n_mux or p_mux */
if (cmux == curr_circ->n_mux) {
diff --git a/src/or/config.c b/src/or/config.c
index af054bd87f..6badb4e68a 100644
--- a/src/or/config.c
+++ b/src/or/config.c
@@ -6120,6 +6120,8 @@ parse_dir_authority_line(const char *line, dirinfo_type_t required_type,
dirinfo_type_t type = 0;
double weight = 1.0;
+ memset(v3_digest, 0, sizeof(v3_digest));
+
items = smartlist_new();
smartlist_split_string(items, line, NULL,
SPLIT_SKIP_SPACE|SPLIT_IGNORE_BLANK, -1);
diff --git a/src/or/connection.c b/src/or/connection.c
index 1b979945bf..dd5cb3480d 100644
--- a/src/or/connection.c
+++ b/src/or/connection.c
@@ -3062,9 +3062,11 @@ connection_buckets_decrement(connection_t *conn, time_t now,
(unsigned long)num_read, (unsigned long)num_written,
conn_type_to_string(conn->type),
conn_state_to_string(conn->type, conn->state));
- if (num_written >= INT_MAX) num_written = 1;
- if (num_read >= INT_MAX) num_read = 1;
- tor_fragile_assert();
+ tor_assert_nonfatal_unreached();
+ if (num_written >= INT_MAX)
+ num_written = 1;
+ if (num_read >= INT_MAX)
+ num_read = 1;
}
record_num_bytes_transferred_impl(conn, now, num_read, num_written);
@@ -3593,10 +3595,8 @@ connection_buf_read_from_socket(connection_t *conn, ssize_t *max_to_read,
connection_start_reading(conn);
}
/* we're already reading, one hopes */
- result = 0;
break;
case TOR_TLS_DONE: /* no data read, so nothing to process */
- result = 0;
break; /* so we call bucket_decrement below */
default:
break;
diff --git a/src/or/directory.c b/src/or/directory.c
index 630524db67..6470723cd8 100644
--- a/src/or/directory.c
+++ b/src/or/directory.c
@@ -3837,7 +3837,6 @@ directory_handle_command_get,(dir_connection_t *conn, const char *headers,
char *url, *url_mem, *header;
time_t if_modified_since = 0;
int zlib_compressed_in_url;
- size_t url_len;
unsigned compression_methods_supported;
/* We ignore the body of a GET request. */
@@ -3868,12 +3867,13 @@ directory_handle_command_get,(dir_connection_t *conn, const char *headers,
log_debug(LD_DIRSERV,"rewritten url as '%s'.", escaped(url));
url_mem = url;
- url_len = strlen(url);
+ {
+ size_t url_len = strlen(url);
- zlib_compressed_in_url = url_len > 2 && !strcmp(url+url_len-2, ".z");
- if (zlib_compressed_in_url) {
- url[url_len-2] = '\0';
- url_len -= 2;
+ zlib_compressed_in_url = url_len > 2 && !strcmp(url+url_len-2, ".z");
+ if (zlib_compressed_in_url) {
+ url[url_len-2] = '\0';
+ }
}
if ((header = http_get_header(headers, "Accept-Encoding: "))) {
diff --git a/src/or/dirvote.c b/src/or/dirvote.c
index c65945fea7..ba0ab7a776 100644
--- a/src/or/dirvote.c
+++ b/src/or/dirvote.c
@@ -541,8 +541,8 @@ compute_routerstatus_consensus(smartlist_t *votes, int consensus_method,
if (cur_n > most_n ||
(cur && cur_n == most_n && cur->status.published_on > most_published)) {
most = cur;
- most_n = cur_n;
- most_published = cur->status.published_on;
+ // most_n = cur_n; // unused after this point.
+ // most_published = cur->status.published_on; // unused after this point.
}
tor_assert(most);
@@ -3993,14 +3993,15 @@ dirvote_format_all_microdesc_vote_lines(const routerinfo_t *ri, time_t now,
while ((ep = entries)) {
char buf[128];
vote_microdesc_hash_t *h;
- dirvote_format_microdesc_vote_line(buf, sizeof(buf), ep->md,
- ep->low, ep->high);
- h = tor_malloc_zero(sizeof(vote_microdesc_hash_t));
- h->microdesc_hash_line = tor_strdup(buf);
- h->next = result;
- result = h;
- ep->md->last_listed = now;
- smartlist_add(microdescriptors_out, ep->md);
+ if (dirvote_format_microdesc_vote_line(buf, sizeof(buf), ep->md,
+ ep->low, ep->high) >= 0) {
+ h = tor_malloc_zero(sizeof(vote_microdesc_hash_t));
+ h->microdesc_hash_line = tor_strdup(buf);
+ h->next = result;
+ result = h;
+ ep->md->last_listed = now;
+ smartlist_add(microdescriptors_out, ep->md);
+ }
entries = ep->next;
tor_free(ep);
}
diff --git a/src/or/parsecommon.c b/src/or/parsecommon.c
index 6b5359303a..6c3dd3100e 100644
--- a/src/or/parsecommon.c
+++ b/src/or/parsecommon.c
@@ -161,6 +161,7 @@ get_token_arguments(memarea_t *area, directory_token_t *tok,
char *cp = mem;
int j = 0;
char *args[MAX_ARGS];
+ memset(args, 0, sizeof(args));
while (*cp) {
if (j == MAX_ARGS)
return -1;
diff --git a/src/or/rendservice.c b/src/or/rendservice.c
index 7127ed1ccd..f67e332b7f 100644
--- a/src/or/rendservice.c
+++ b/src/or/rendservice.c
@@ -696,7 +696,6 @@ rend_config_service(const config_line_t *line_,
* of authorized clients. */
smartlist_t *type_names_split, *clients;
const char *authname;
- int num_clients;
if (service->auth_type != REND_NO_AUTH) {
log_warn(LD_CONFIG, "Got multiple HiddenServiceAuthorizeClient "
"lines for a single service.");
@@ -740,14 +739,15 @@ rend_config_service(const config_line_t *line_,
SMARTLIST_FOREACH(type_names_split, char *, cp, tor_free(cp));
smartlist_free(type_names_split);
/* Remove duplicate client names. */
- num_clients = smartlist_len(clients);
- smartlist_sort_strings(clients);
- smartlist_uniq_strings(clients);
- if (smartlist_len(clients) < num_clients) {
- log_info(LD_CONFIG, "HiddenServiceAuthorizeClient contains %d "
- "duplicate client name(s); removing.",
- num_clients - smartlist_len(clients));
- num_clients = smartlist_len(clients);
+ {
+ int num_clients = smartlist_len(clients);
+ smartlist_sort_strings(clients);
+ smartlist_uniq_strings(clients);
+ if (smartlist_len(clients) < num_clients) {
+ log_info(LD_CONFIG, "HiddenServiceAuthorizeClient contains %d "
+ "duplicate client name(s); removing.",
+ num_clients - smartlist_len(clients));
+ }
}
SMARTLIST_FOREACH_BEGIN(clients, const char *, client_name)
{
diff --git a/src/or/routerparse.c b/src/or/routerparse.c
index 4541781beb..15cdb0bbde 100644
--- a/src/or/routerparse.c
+++ b/src/or/routerparse.c
@@ -2934,7 +2934,7 @@ networkstatus_verify_bw_weights(networkstatus_t *ns, int consensus_method)
}
Wgg /= weight_scale;
- Wgm /= weight_scale;
+ Wgm /= weight_scale; (void) Wgm; // unused from here on.
Wgd /= weight_scale;
Wmg /= weight_scale;
@@ -2942,8 +2942,8 @@ networkstatus_verify_bw_weights(networkstatus_t *ns, int consensus_method)
Wme /= weight_scale;
Wmd /= weight_scale;
- Weg /= weight_scale;
- Wem /= weight_scale;
+ Weg /= weight_scale; (void) Weg; // unused from here on.
+ Wem /= weight_scale; (void) Wem; // unused from here on.
Wee /= weight_scale;
Wed /= weight_scale;
diff --git a/src/or/statefile.c b/src/or/statefile.c
index 18111771da..9647aa8834 100644
--- a/src/or/statefile.c
+++ b/src/or/statefile.c
@@ -659,8 +659,6 @@ save_transport_to_state(const char *transport,
*next = line = tor_malloc_zero(sizeof(config_line_t));
line->key = tor_strdup("TransportProxy");
tor_asprintf(&line->value, "%s %s", transport, fmt_addrport(addr, port));
-
- next = &(line->next);
}
if (!get_options()->AvoidDiskWrites)