diff options
author | Nick Mathewson <nickm@torproject.org> | 2016-07-05 14:19:31 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2016-07-28 06:58:44 -0400 |
commit | 47573038736b96e2a353a25ed3c788dcb77d8fcb (patch) | |
tree | 20b95e3228fd153eead07944848c8cd62367d1ed /src/test | |
parent | 1135405c8c6ea315cd035171770a6701edae57f0 (diff) | |
download | tor-47573038736b96e2a353a25ed3c788dcb77d8fcb.tar.gz tor-47573038736b96e2a353a25ed3c788dcb77d8fcb.zip |
Fix all -Wshadow warnings on Linux
This is a partial fix for 18902.
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/bench.c | 9 | ||||
-rw-r--r-- | src/test/test_addr.c | 6 | ||||
-rw-r--r-- | src/test/test_buffers.c | 6 | ||||
-rw-r--r-- | src/test/test_cell_formats.c | 4 | ||||
-rw-r--r-- | src/test/test_containers.c | 24 | ||||
-rw-r--r-- | src/test/test_dir.c | 10 | ||||
-rw-r--r-- | src/test/test_dns.c | 8 | ||||
-rw-r--r-- | src/test/test_microdesc.c | 2 | ||||
-rw-r--r-- | src/test/test_policy.c | 9 | ||||
-rw-r--r-- | src/test/test_pt.c | 12 | ||||
-rw-r--r-- | src/test/test_scheduler.c | 6 | ||||
-rw-r--r-- | src/test/test_util.c | 6 |
12 files changed, 51 insertions, 51 deletions
diff --git a/src/test/bench.c b/src/test/bench.c index 5595988f31..f1cf715f30 100644 --- a/src/test/bench.c +++ b/src/test/bench.c @@ -662,7 +662,6 @@ main(int argc, const char **argv) { int i; int list=0, n_enabled=0; - benchmark_t *b; char *errmsg; or_options_t *options; @@ -672,10 +671,10 @@ main(int argc, const char **argv) if (!strcmp(argv[i], "--list")) { list = 1; } else { - benchmark_t *b = find_benchmark(argv[i]); + benchmark_t *benchmark = find_benchmark(argv[i]); ++n_enabled; - if (b) { - b->enabled = 1; + if (benchmark) { + benchmark->enabled = 1; } else { printf("No such benchmark as %s\n", argv[i]); } @@ -700,7 +699,7 @@ main(int argc, const char **argv) return 1; } - for (b = benchmarks; b->name; ++b) { + for (benchmark_t *b = benchmarks; b->name; ++b) { if (b->enabled || n_enabled == 0) { printf("===== %s =====\n", b->name); if (!list) diff --git a/src/test/test_addr.c b/src/test/test_addr.c index 337bddad6b..dcecb0b7dc 100644 --- a/src/test/test_addr.c +++ b/src/test/test_addr.c @@ -83,12 +83,12 @@ test_addr_basic(void *arg) tt_assert_test_fmt_type(a,b,e1" "#op" "e2,struct in6_addr*, \ (memcmp(val1_->s6_addr, val2_->s6_addr, 16) op 0), \ char *, "%s", \ - { int i; char *cp; \ + { char *cp; \ cp = print_ = tor_malloc(64); \ - for (i=0;i<16;++i) { \ + for (int ii_=0;i<16;++i) { \ tor_snprintf(cp, 3,"%02x", (unsigned)value_->s6_addr[i]);\ cp += 2; \ - if (i != 15) *cp++ = ':'; \ + if (ii_ != 15) *cp++ = ':'; \ } \ }, \ { tor_free(print_); }, \ diff --git a/src/test/test_buffers.c b/src/test/test_buffers.c index 95584d54a8..91db62c1a3 100644 --- a/src/test/test_buffers.c +++ b/src/test/test_buffers.c @@ -178,10 +178,10 @@ test_buffers_basic(void *arg) /* Try adding a string too long for any freelist. */ { - char *cp = tor_malloc_zero(65536); + char *mem = tor_malloc_zero(65536); buf = buf_new(); - write_to_buf(cp, 65536, buf); - tor_free(cp); + write_to_buf(mem, 65536, buf); + tor_free(mem); tt_int_op(buf_datalen(buf), OP_EQ, 65536); buf_free(buf); diff --git a/src/test/test_cell_formats.c b/src/test/test_cell_formats.c index 499a637959..f839a5b72c 100644 --- a/src/test/test_cell_formats.c +++ b/src/test/test_cell_formats.c @@ -882,8 +882,8 @@ test_cfmt_resolved_cells(void *arg) memset(&rh, 0, sizeof(rh)); \ } while (0) #define CLEAR_ADDRS() do { \ - SMARTLIST_FOREACH(addrs, address_ttl_t *, a, \ - address_ttl_free(a); ); \ + SMARTLIST_FOREACH(addrs, address_ttl_t *, aa_, \ + address_ttl_free(aa_); ); \ smartlist_clear(addrs); \ } while (0) #define SET_CELL(s) do { \ diff --git a/src/test/test_containers.c b/src/test/test_containers.c index fd896760c0..d8b82e0661 100644 --- a/src/test/test_containers.c +++ b/src/test/test_containers.c @@ -132,7 +132,7 @@ test_container_smartlist_strings(void *arg) tt_str_op("def",OP_EQ, smartlist_get(sl, 5)); tt_str_op(" ",OP_EQ, smartlist_get(sl, 6)); tt_str_op("ghijk",OP_EQ, smartlist_get(sl, 7)); - SMARTLIST_FOREACH(sl, char *, cp, tor_free(cp)); + SMARTLIST_FOREACH(sl, char *, str, tor_free(str)); smartlist_clear(sl); smartlist_split_string(sl, "a,bbd,cdef", ",", SPLIT_SKIP_SPACE, 0); @@ -149,7 +149,7 @@ test_container_smartlist_strings(void *arg) tt_str_op("bnud",OP_EQ, smartlist_get(sl,6)); tt_str_op("",OP_EQ, smartlist_get(sl,7)); - SMARTLIST_FOREACH(sl, char *, cp, tor_free(cp)); + SMARTLIST_FOREACH(sl, char *, str, tor_free(str)); smartlist_clear(sl); smartlist_split_string(sl, " ab\tc \td ef ", NULL, @@ -165,7 +165,7 @@ test_container_smartlist_strings(void *arg) tt_str_op("ghi",OP_EQ, smartlist_get(sl,4)); tt_str_op("j",OP_EQ, smartlist_get(sl,5)); - SMARTLIST_FOREACH(sl, char *, cp, tor_free(cp)); + SMARTLIST_FOREACH(sl, char *, str, tor_free(str)); smartlist_clear(sl); cp_alloc = smartlist_join_strings(sl, "XY", 0, NULL); @@ -186,7 +186,7 @@ test_container_smartlist_strings(void *arg) tt_int_op(5,OP_EQ, smartlist_len(sl)); tt_str_op("z",OP_EQ, smartlist_get(sl, 3)); tt_str_op("zhasd <> <> bnud<>",OP_EQ, smartlist_get(sl, 4)); - SMARTLIST_FOREACH(sl, char *, cp, tor_free(cp)); + SMARTLIST_FOREACH(sl, char *, str, tor_free(str)); smartlist_clear(sl); smartlist_split_string(sl, "abcd\n", "\n", @@ -198,7 +198,7 @@ test_container_smartlist_strings(void *arg) tt_int_op(2,OP_EQ, smartlist_len(sl)); tt_str_op("efgh",OP_EQ, smartlist_get(sl, 1)); - SMARTLIST_FOREACH(sl, char *, cp, tor_free(cp)); + SMARTLIST_FOREACH(sl, char *, str, tor_free(str)); smartlist_clear(sl); /* Test swapping, shuffling, and sorting. */ @@ -286,7 +286,7 @@ test_container_smartlist_strings(void *arg) tt_str_op(cp_alloc,OP_EQ, "and"); tor_free(cp_alloc); tt_int_op(smartlist_len(sl),OP_EQ, 6); - SMARTLIST_FOREACH(sl, char *, cp, tor_free(cp)); + SMARTLIST_FOREACH(sl, char *, str, tor_free(str)); smartlist_clear(sl); cp_alloc = smartlist_pop_last(sl); tt_ptr_op(cp_alloc,OP_EQ, NULL); @@ -326,7 +326,7 @@ test_container_smartlist_strings(void *arg) tt_assert(!allsame); tt_assert(allin); } - SMARTLIST_FOREACH(sl, char *, cp, tor_free(cp)); + SMARTLIST_FOREACH(sl, char *, str, tor_free(str)); smartlist_clear(sl); /* Test string_remove and remove and join_strings2 */ @@ -348,7 +348,7 @@ test_container_smartlist_strings(void *arg) done: - SMARTLIST_FOREACH(sl, char *, cp, tor_free(cp)); + SMARTLIST_FOREACH(sl, char *, str, tor_free(str)); smartlist_free(sl); tor_free(cp_alloc); } @@ -437,7 +437,7 @@ test_container_smartlist_digests(void *arg) tt_mem_op(smartlist_get(sl, 1),OP_EQ, "AAAAAAAAAAAAAAAAAAAA", DIGEST_LEN); done: - SMARTLIST_FOREACH(sl, char *, cp, tor_free(cp)); + SMARTLIST_FOREACH(sl, char *, str, tor_free(str)); smartlist_free(sl); } @@ -490,7 +490,7 @@ test_container_smartlist_join(void *arg) smartlist_free(sl3); SMARTLIST_FOREACH(sl2, char *, cp, tor_free(cp)); smartlist_free(sl2); - SMARTLIST_FOREACH(sl, char *, cp, tor_free(cp)); + SMARTLIST_FOREACH(sl, char *, str, tor_free(str)); smartlist_free(sl); tor_free(joined); } @@ -528,7 +528,7 @@ test_container_smartlist_pos(void *arg) tt_int_op(smartlist_pos(sl, smartlist_get(sl,6)), ==, 6); done: - SMARTLIST_FOREACH(sl, char *, cp, tor_free(cp)); + SMARTLIST_FOREACH(sl, char *, str, tor_free(str)); smartlist_free(sl); } @@ -1140,7 +1140,7 @@ test_container_smartlist_most_frequent(void *arg) tt_str_op(cp, ==, "def"); /* No tie */ done: - SMARTLIST_FOREACH(sl, char *, cp, tor_free(cp)); + SMARTLIST_FOREACH(sl, char *, str, tor_free(str)); smartlist_free(sl); } diff --git a/src/test/test_dir.c b/src/test/test_dir.c index 8889ccc41b..51a5ecad76 100644 --- a/src/test/test_dir.c +++ b/src/test/test_dir.c @@ -704,8 +704,8 @@ test_dir_parse_router_list(void *arg) "9a651ee03b64325959e8f1b46f2b689b30750b4c"); /* Now tidy up */ - SMARTLIST_FOREACH(dest, routerinfo_t *, ri, routerinfo_free(ri)); - SMARTLIST_FOREACH(invalid, uint8_t *, d, tor_free(d)); + SMARTLIST_FOREACH(dest, routerinfo_t *, rinfo, routerinfo_free(rinfo)); + SMARTLIST_FOREACH(invalid, uint8_t *, dig, tor_free(dig)); smartlist_clear(dest); smartlist_clear(invalid); @@ -741,9 +741,9 @@ test_dir_parse_router_list(void *arg) else SMARTLIST_FOREACH(dest, extrainfo_t *, ei, extrainfo_free(ei)); smartlist_free(dest); - SMARTLIST_FOREACH(invalid, uint8_t *, d, tor_free(d)); + SMARTLIST_FOREACH(invalid, uint8_t *, dig, tor_free(dig)); smartlist_free(invalid); - SMARTLIST_FOREACH(chunks, char *, cp, tor_free(cp)); + SMARTLIST_FOREACH(chunks, char *, chunk, tor_free(chunk)); smartlist_free(chunks); routerinfo_free(ri); if (map) { @@ -1169,7 +1169,7 @@ test_dir_fp_pairs(void *arg) tt_mem_op(pair->second,OP_EQ, "Use AES-256 instead.", DIGEST_LEN); done: - SMARTLIST_FOREACH(sl, fp_pair_t *, pair, tor_free(pair)); + SMARTLIST_FOREACH(sl, fp_pair_t *, pair_to_free, tor_free(pair_to_free)); smartlist_free(sl); } diff --git a/src/test/test_dns.c b/src/test/test_dns.c index 5289ca58ff..8346c0a33f 100644 --- a/src/test/test_dns.c +++ b/src/test/test_dns.c @@ -52,7 +52,7 @@ NS(test_main)(void *arg) static int resolve_retval = 0; static int resolve_made_conn_pending = 0; static char *resolved_name = NULL; -static cached_resolve_t *cache_entry = NULL; +static cached_resolve_t *cache_entry_mock = NULL; static int n_fake_impl = 0; @@ -85,8 +85,8 @@ NS(dns_resolve_impl)(edge_connection_t *exitconn, int is_resolve, if (hostname_out && resolved_name) *hostname_out = tor_strdup(resolved_name); - if (resolve_out && cache_entry) - *resolve_out = cache_entry; + if (resolve_out && cache_entry_mock) + *resolve_out = cache_entry_mock; n_fake_impl++; @@ -213,7 +213,7 @@ NS(test_main)(void *arg) exitconn->on_circuit = &(on_circuit->base_); - cache_entry = fake_resolved; + cache_entry_mock = fake_resolved; prev_n_send_resolved_cell_replacement = n_send_resolved_cell_replacement; diff --git a/src/test/test_microdesc.c b/src/test/test_microdesc.c index 2afbdde88a..2ae605b8db 100644 --- a/src/test/test_microdesc.c +++ b/src/test/test_microdesc.c @@ -716,7 +716,7 @@ test_md_parse(void *arg) tt_int_op(md->ipv6_orport, OP_EQ, 9090); done: - SMARTLIST_FOREACH(mds, microdesc_t *, md, microdesc_free(md)); + SMARTLIST_FOREACH(mds, microdesc_t *, mdsc, microdesc_free(mdsc)); smartlist_free(mds); SMARTLIST_FOREACH(invalid, char *, cp, tor_free(cp)); smartlist_free(invalid); diff --git a/src/test/test_policy.c b/src/test/test_policy.c index 14182af86b..58102ea6db 100644 --- a/src/test/test_policy.c +++ b/src/test/test_policy.c @@ -523,18 +523,17 @@ test_policies_general(void *arg) /* Test a too-long policy. */ { - int i; - char *policy = NULL; + char *policy_strng = NULL; smartlist_t *chunks = smartlist_new(); smartlist_add(chunks, tor_strdup("accept ")); for (i=1; i<10000; ++i) smartlist_add_asprintf(chunks, "%d,", i); smartlist_add(chunks, tor_strdup("20000")); - policy = smartlist_join_strings(chunks, "", 0, NULL); + policy_strng = smartlist_join_strings(chunks, "", 0, NULL); SMARTLIST_FOREACH(chunks, char *, ch, tor_free(ch)); smartlist_free(chunks); - short_parsed = parse_short_policy(policy);/* shouldn't be accepted */ - tor_free(policy); + short_parsed = parse_short_policy(policy_strng);/* shouldn't be accepted */ + tor_free(policy_strng); tt_ptr_op(NULL, OP_EQ, short_parsed); } diff --git a/src/test/test_pt.c b/src/test/test_pt.c index ab8447dcd7..e5cdc5f3cd 100644 --- a/src/test/test_pt.c +++ b/src/test/test_pt.c @@ -107,12 +107,12 @@ test_pt_parsing(void *arg) tt_assert(parse_smethod_line(line, mp) == 0); tt_int_op(1, OP_EQ, smartlist_len(mp->transports)); { - const transport_t *transport = smartlist_get(mp->transports, 0); - tt_assert(transport); - tt_str_op(transport->name, OP_EQ, "trebuchet"); - tt_int_op(transport->port, OP_EQ, 9999); - tt_str_op(fmt_addr(&transport->addr), OP_EQ, "127.0.0.1"); - tt_str_op(transport->extra_info_args, OP_EQ, + const transport_t *transport_ = smartlist_get(mp->transports, 0); + tt_assert(transport_); + tt_str_op(transport_->name, OP_EQ, "trebuchet"); + tt_int_op(transport_->port, OP_EQ, 9999); + tt_str_op(fmt_addr(&transport_->addr), OP_EQ, "127.0.0.1"); + tt_str_op(transport_->extra_info_args, OP_EQ, "counterweight=3,sling=snappy"); } reset_mp(mp); diff --git a/src/test/test_scheduler.c b/src/test/test_scheduler.c index 15fbb2d186..f8b5046c70 100644 --- a/src/test/test_scheduler.c +++ b/src/test/test_scheduler.c @@ -150,7 +150,7 @@ channel_flush_some_cells_mock_free_all(void) static void channel_flush_some_cells_mock_set(channel_t *chan, ssize_t num_cells) { - flush_mock_channel_t *flush_mock_ch = NULL; + int found = 0; if (!chan) return; if (num_cells <= 0) return; @@ -166,6 +166,7 @@ channel_flush_some_cells_mock_set(channel_t *chan, ssize_t num_cells) if (flush_mock_ch->chan == chan) { /* Found it */ flush_mock_ch->cells = num_cells; + found = 1; break; } } else { @@ -175,8 +176,9 @@ channel_flush_some_cells_mock_set(channel_t *chan, ssize_t num_cells) } } SMARTLIST_FOREACH_END(flush_mock_ch); - if (!flush_mock_ch) { + if (! found) { /* The loop didn't find it */ + flush_mock_channel_t *flush_mock_ch; flush_mock_ch = tor_malloc_zero(sizeof(*flush_mock_ch)); flush_mock_ch->chan = chan; flush_mock_ch->cells = num_cells; diff --git a/src/test/test_util.c b/src/test/test_util.c index c331a662a5..7cb9311577 100644 --- a/src/test/test_util.c +++ b/src/test/test_util.c @@ -2007,9 +2007,9 @@ test_util_strmisc(void *arg) /* Test hex_str */ { char binary_data[68]; - size_t i; - for (i = 0; i < sizeof(binary_data); ++i) - binary_data[i] = i; + size_t idx; + for (idx = 0; idx < sizeof(binary_data); ++idx) + binary_data[idx] = idx; tt_str_op(hex_str(binary_data, 0),OP_EQ, ""); tt_str_op(hex_str(binary_data, 1),OP_EQ, "00"); tt_str_op(hex_str(binary_data, 17),OP_EQ, |