Make nodelist_get_list() return a const pointer.

This commit is contained in:
Nick Mathewson 2019-04-26 10:36:49 -04:00
parent efeb101b96
commit 1d44ac9acd
13 changed files with 20 additions and 19 deletions

View File

@ -78,7 +78,7 @@ problem function-size /src/core/or/channeltls.c:channel_tls_process_versions_cel
problem function-size /src/core/or/channeltls.c:channel_tls_process_netinfo_cell() 214
problem function-size /src/core/or/channeltls.c:channel_tls_process_certs_cell() 246
problem function-size /src/core/or/channeltls.c:channel_tls_process_authenticate_cell() 202
problem file-size /src/core/or/circuitbuild.c 3060
problem file-size /src/core/or/circuitbuild.c 3061
problem include-count /src/core/or/circuitbuild.c 53
problem function-size /src/core/or/circuitbuild.c:get_unique_circ_id_by_chan() 128
problem function-size /src/core/or/circuitbuild.c:circuit_extend() 147

View File

@ -1683,7 +1683,8 @@ route_len_for_purpose(uint8_t purpose, extend_info_t *exit_ei)
* to handle the desired path length, return -1.
*/
STATIC int
new_route_len(uint8_t purpose, extend_info_t *exit_ei, smartlist_t *nodes)
new_route_len(uint8_t purpose, extend_info_t *exit_ei,
const smartlist_t *nodes)
{
int routelen;
@ -2345,7 +2346,7 @@ circuit_extend_to_new_exit(origin_circuit_t *circ, extend_info_t *exit_ei)
* particular router. See bug #25885.)
*/
MOCK_IMPL(STATIC int,
count_acceptable_nodes, (smartlist_t *nodes, int direct))
count_acceptable_nodes, (const smartlist_t *nodes, int direct))
{
int num=0;

View File

@ -83,8 +83,8 @@ void circuit_upgrade_circuits_from_guard_wait(void);
#ifdef CIRCUITBUILD_PRIVATE
STATIC circid_t get_unique_circ_id_by_chan(channel_t *chan);
STATIC int new_route_len(uint8_t purpose, extend_info_t *exit_ei,
smartlist_t *nodes);
MOCK_DECL(STATIC int, count_acceptable_nodes, (smartlist_t *nodes,
const smartlist_t *nodes);
MOCK_DECL(STATIC int, count_acceptable_nodes, (const smartlist_t *nodes,
int direct));
STATIC int onion_extend_cpath(origin_circuit_t *circ);

View File

@ -239,7 +239,7 @@ dirserv_compute_performance_thresholds(digestmap_t *omit_as_sybil)
uint32_t *uptimes, *bandwidths_kb, *bandwidths_excluding_exits_kb;
long *tks;
double *mtbfs, *wfus;
smartlist_t *nodelist;
const smartlist_t *nodelist;
time_t now = time(NULL);
const or_options_t *options = get_options();

View File

@ -944,7 +944,7 @@ nodelist_ensure_freshness(networkstatus_t *ns)
/** Return a list of a node_t * for every node we know about. The caller
* MUST NOT modify the list. (You can set and clear flags in the nodes if
* you must, but you must not add or remove nodes.) */
MOCK_IMPL(smartlist_t *,
MOCK_IMPL(const smartlist_t *,
nodelist_get_list,(void))
{
init_nodelist();
@ -1939,7 +1939,7 @@ node_set_country(node_t *node)
void
nodelist_refresh_countries(void)
{
smartlist_t *nodes = nodelist_get_list();
const smartlist_t *nodes = nodelist_get_list();
SMARTLIST_FOREACH(nodes, node_t *, node,
node_set_country(node));
}

View File

@ -101,7 +101,7 @@ const struct curve25519_public_key_t *node_get_curve25519_onion_key(
const node_t *node);
crypto_pk_t *node_get_rsa_onion_key(const node_t *node);
MOCK_DECL(smartlist_t *, nodelist_get_list, (void));
MOCK_DECL(const smartlist_t *, nodelist_get_list, (void));
/* Temporary during transition to multiple addresses. */
void node_get_addr(const node_t *node, tor_addr_t *addr_out);

View File

@ -378,7 +378,7 @@ routerset_get_all_nodes(smartlist_t *out, const routerset_t *routerset,
} else {
/* We need to iterate over the routerlist to get all the ones of the
* right kind. */
smartlist_t *nodes = nodelist_get_list();
const smartlist_t *nodes = nodelist_get_list();
SMARTLIST_FOREACH(nodes, const node_t *, node, {
if (running_only && !node->is_running)
continue;

View File

@ -21,7 +21,7 @@ static smartlist_t dummy_nodes;
static extend_info_t dummy_ei;
static int
mock_count_acceptable_nodes(smartlist_t *nodes, int direct)
mock_count_acceptable_nodes(const smartlist_t *nodes, int direct)
{
(void)nodes;

View File

@ -1546,7 +1546,7 @@ test_current_time(void *arg)
static size_t n_nodelist_get_list = 0;
static smartlist_t *nodes = NULL;
static smartlist_t *
static const smartlist_t *
mock_nodelist_get_list(void)
{
n_nodelist_get_list++;

View File

@ -67,7 +67,7 @@ static networkstatus_t *dummy_consensus = NULL;
static smartlist_t *big_fake_net_nodes = NULL;
static smartlist_t *
static const smartlist_t *
bfn_mock_nodelist_get_list(void)
{
return big_fake_net_nodes;

View File

@ -78,7 +78,7 @@ helper_setup_fake_routerlist(void)
{
int retval;
routerlist_t *our_routerlist = NULL;
smartlist_t *our_nodelist = NULL;
const smartlist_t *our_nodelist = NULL;
/* Read the file that contains our test descriptors. */

View File

@ -275,7 +275,7 @@ test_start_time_of_next_time_period(void *arg)
static void
cleanup_nodelist(void)
{
smartlist_t *nodelist = nodelist_get_list();
const smartlist_t *nodelist = nodelist_get_list();
SMARTLIST_FOREACH_BEGIN(nodelist, node_t *, node) {
tor_free(node->md);
node->md = NULL;

View File

@ -1765,7 +1765,7 @@ NS(node_get_by_nickname)(const char *nickname, unsigned flags)
* Structural test for routerset_get_all_nodes, when the nodelist has no nodes.
*/
NS_DECL(smartlist_t *, nodelist_get_list, (void));
NS_DECL(const smartlist_t *, nodelist_get_list, (void));
static smartlist_t *NS(mock_smartlist);
@ -1795,7 +1795,7 @@ NS(test_main)(void *arg)
;
}
smartlist_t *
const smartlist_t *
NS(nodelist_get_list)(void)
{
CALLED(nodelist_get_list)++;
@ -1811,7 +1811,7 @@ NS(nodelist_get_list)(void)
* the running_only flag is set, but the nodes are not running.
*/
NS_DECL(smartlist_t *, nodelist_get_list, (void));
NS_DECL(const smartlist_t *, nodelist_get_list, (void));
static smartlist_t *NS(mock_smartlist);
static node_t NS(mock_node);
@ -1844,7 +1844,7 @@ NS(test_main)(void *arg)
;
}
smartlist_t *
const smartlist_t *
NS(nodelist_get_list)(void)
{
CALLED(nodelist_get_list)++;