Convert remaining files to smartlist_add_strdup

The coccinelle script produced errors with these test files so
convert the remaining cases of smartlist_add to
smartlist_add_strdup by hand.
This commit is contained in:
overcaffeinated 2016-10-27 11:15:57 +01:00
parent 265d5446fa
commit e2577cce0c
4 changed files with 30 additions and 30 deletions

View File

@ -501,13 +501,13 @@ test_container_smartlist_pos(void *arg)
(void) arg;
smartlist_t *sl = smartlist_new();
smartlist_add(sl, tor_strdup("This"));
smartlist_add(sl, tor_strdup("is"));
smartlist_add(sl, tor_strdup("a"));
smartlist_add(sl, tor_strdup("test"));
smartlist_add(sl, tor_strdup("for"));
smartlist_add(sl, tor_strdup("a"));
smartlist_add(sl, tor_strdup("function"));
smartlist_add_strdup(sl, "This");
smartlist_add_strdup(sl, "is");
smartlist_add_strdup(sl, "a");
smartlist_add_strdup(sl, "test");
smartlist_add_strdup(sl, "for");
smartlist_add_strdup(sl, "a");
smartlist_add_strdup(sl, "function");
/* Test string_pos */
tt_int_op(smartlist_string_pos(NULL, "Fred"), ==, -1);
@ -830,7 +830,7 @@ test_container_strmap(void *arg)
found_keys = smartlist_new();
while (!strmap_iter_done(iter)) {
strmap_iter_get(iter,&k,&v);
smartlist_add(found_keys, tor_strdup(k));
smartlist_add_strdup(found_keys, k);
tt_ptr_op(v,OP_EQ, strmap_get(map, k));
if (!strcmp(k, "K2")) {

View File

@ -812,7 +812,7 @@ test_dir_load_routers(void *arg)
#define ADD(str) \
do { \
tt_int_op(0,OP_EQ,router_get_router_hash(str, strlen(str), buf)); \
smartlist_add(wanted, tor_strdup(hex_str(buf, DIGEST_LEN))); \
smartlist_add_strdup(wanted, hex_str(buf, DIGEST_LEN)); \
} while (0)
MOCK(router_get_dl_status_by_descriptor_digest, mock_router_get_dl_status);
@ -932,7 +932,7 @@ test_dir_load_extrainfo(void *arg)
#define ADD(str) \
do { \
tt_int_op(0,OP_EQ,router_get_extrainfo_hash(str, strlen(str), buf)); \
smartlist_add(wanted, tor_strdup(hex_str(buf, DIGEST_LEN))); \
smartlist_add_strdup(wanted, hex_str(buf, DIGEST_LEN)); \
} while (0)
mock_ei_insert_list = smartlist_new();

View File

@ -623,7 +623,7 @@ NS(test_main)(void *arg)
(void)arg;
tgt = routerset_new();
smartlist_add(src->list, tor_strdup("{xx}"));
smartlist_add_strdup(src->list, "{xx}");
routerset_union(tgt, src);
tt_int_op(smartlist_len(tgt->list), OP_NE, 0);
@ -745,7 +745,7 @@ NS(test_main)(void *arg)
tt_int_op(is_empty, OP_NE, 0);
set = routerset_new();
smartlist_add(set->list, tor_strdup("{xx}"));
smartlist_add_strdup(set->list, "{xx}");
is_empty = routerset_is_empty(set);
routerset_free(set);
set = NULL;
@ -1616,7 +1616,7 @@ NS(test_main)(void *arg)
NS_MOCK(node_get_by_nickname);
NS(mock_nickname) = "foo";
smartlist_add(set->list, tor_strdup(NS(mock_nickname)));
smartlist_add_strdup(set->list, NS(mock_nickname));
routerset_get_all_nodes(out, set, NULL, 0);
out_len = smartlist_len(out);
@ -1667,7 +1667,7 @@ NS(test_main)(void *arg)
NS(mock_node).is_running = 0;
NS(mock_nickname) = "foo";
smartlist_add(set->list, tor_strdup(NS(mock_nickname)));
smartlist_add_strdup(set->list, NS(mock_nickname));
routerset_get_all_nodes(out, set, NULL, 1);
out_len = smartlist_len(out);
@ -1766,7 +1766,7 @@ NS(test_main)(void *arg)
NS_MOCK(nodelist_get_list);
smartlist_add(set->country_names, tor_strdup("{xx}"));
smartlist_add_strdup(set->country_names, "{xx}");
NS(mock_smartlist) = smartlist_new();
routerset_get_all_nodes(out, set, NULL, 1);
@ -1813,7 +1813,7 @@ NS(test_main)(void *arg)
NS_MOCK(nodelist_get_list);
smartlist_add(set->country_names, tor_strdup("{xx}"));
smartlist_add_strdup(set->country_names, "{xx}");
NS(mock_smartlist) = smartlist_new();
NS(mock_node).is_running = 0;
smartlist_add(NS(mock_smartlist), (void *)&NS(mock_node));
@ -1985,7 +1985,7 @@ NS(test_main)(void *arg)
int r;
(void)arg;
smartlist_add(b->list, tor_strdup("{xx}"));
smartlist_add_strdup(b->list, "{xx}");
r = routerset_equal(a, b);
routerset_free(a);
routerset_free(b);
@ -2010,9 +2010,9 @@ NS(test_main)(void *arg)
int r;
(void)arg;
smartlist_add(a->list, tor_strdup("{aa}"));
smartlist_add(b->list, tor_strdup("{b1}"));
smartlist_add(b->list, tor_strdup("{b2}"));
smartlist_add_strdup(a->list, "{aa}");
smartlist_add_strdup(b->list, "{b1}");
smartlist_add_strdup(b->list, "{b2}");
r = routerset_equal(a, b);
routerset_free(a);
routerset_free(b);
@ -2037,8 +2037,8 @@ NS(test_main)(void *arg)
int r;
(void)arg;
smartlist_add(a->list, tor_strdup("foo"));
smartlist_add(b->list, tor_strdup("bar"));
smartlist_add_strdup(a->list, "foo");
smartlist_add_strdup(b->list, "bar");
r = routerset_equal(a, b);
routerset_free(a);
routerset_free(b);
@ -2063,8 +2063,8 @@ NS(test_main)(void *arg)
int r;
(void)arg;
smartlist_add(a->list, tor_strdup("foo"));
smartlist_add(b->list, tor_strdup("foo"));
smartlist_add_strdup(a->list, "foo");
smartlist_add_strdup(b->list, "foo");
r = routerset_equal(a, b);
routerset_free(a);
routerset_free(b);

View File

@ -348,12 +348,12 @@ test_sr_commit(void *arg)
/* We'll build a list of values from our commit that our parsing function
* takes from a vote line and see if we can parse it correctly. */
{
smartlist_add(args, tor_strdup("1"));
smartlist_add(args,
tor_strdup(crypto_digest_algorithm_get_name(our_commit->alg)));
smartlist_add(args, tor_strdup(sr_commit_get_rsa_fpr(our_commit)));
smartlist_add(args, tor_strdup(our_commit->encoded_commit));
smartlist_add(args, tor_strdup(our_commit->encoded_reveal));
smartlist_add_strdup(args, "1");
smartlist_add_strdup(args,
crypto_digest_algorithm_get_name(our_commit->alg));
smartlist_add_strdup(args, sr_commit_get_rsa_fpr(our_commit));
smartlist_add_strdup(args, our_commit->encoded_commit);
smartlist_add_strdup(args, our_commit->encoded_reveal);
parsed_commit = sr_parse_commit(args);
tt_assert(parsed_commit);
/* That parsed commit should be _EXACTLY_ like our original commit (we