fix wide lines, use more locals.

This commit is contained in:
Nick Mathewson 2016-02-08 08:31:31 -05:00
parent c30be5a82d
commit d004f06830
2 changed files with 16 additions and 13 deletions

View File

@ -3103,7 +3103,7 @@ dirserv_get_routerdescs(smartlist_t *descs_out, const char *key,
DSR_HEX|DSR_SORT_UNIQ);
SMARTLIST_FOREACH_BEGIN(digests, const char *, d) {
if (router_digest_is_me(d)) {
/* calling router_get_my_routerinfo() to make sure desc_routerinfo exists */
/* calling router_get_my_routerinfo() to make sure it exists */
const routerinfo_t *ri = router_get_my_routerinfo();
if (ri)
smartlist_add(descs_out, (void*) &(ri->cache_info));

View File

@ -1739,7 +1739,8 @@ router_upload_dir_desc_to_dirservers(int force)
int
router_compare_to_my_exit_policy(const tor_addr_t *addr, uint16_t port)
{
if (!router_get_my_routerinfo()) /* make sure desc_routerinfo exists */
routerinfo_t *me = router_get_my_routerinfo();
if (!me) /* make sure routerinfo exists */
return -1;
/* make sure it's resolved to something. this way we can't get a
@ -1747,20 +1748,21 @@ router_compare_to_my_exit_policy(const tor_addr_t *addr, uint16_t port)
if (tor_addr_is_null(addr))
return -1;
/* look at router_get_my_routerinfo()->exit_policy for both the v4 and the v6
* policies. The exit_policy field in router_get_my_routerinfo() is a bit unusual,
* in that it contains IPv6 and IPv6 entries. We don't want to look
* at router_get_my_routerinfo()->ipv6_exit_policy, since that's a port summary. */
/* look at router_get_my_routerinfo()->exit_policy for both the v4 and the
* v6 policies. The exit_policy field in router_get_my_routerinfo() is a
* bit unusual, in that it contains IPv6 and IPv6 entries. We don't want to
* look at router_get_my_routerinfo()->ipv6_exit_policy, since that's a port
* summary. */
if ((tor_addr_family(addr) == AF_INET ||
tor_addr_family(addr) == AF_INET6)) {
return compare_tor_addr_to_addr_policy(addr, port,
router_get_my_routerinfo()->exit_policy) != ADDR_POLICY_ACCEPTED;
me->exit_policy) != ADDR_POLICY_ACCEPTED;
#if 0
} else if (tor_addr_family(addr) == AF_INET6) {
return get_options()->IPv6Exit &&
desc_routerinfo->ipv6_exit_policy &&
compare_tor_addr_to_short_policy(addr, port,
desc_routerinfo->ipv6_exit_policy) != ADDR_POLICY_ACCEPTED;
me->ipv6_exit_policy) != ADDR_POLICY_ACCEPTED;
#endif
} else {
return -1;
@ -1772,7 +1774,7 @@ router_compare_to_my_exit_policy(const tor_addr_t *addr, uint16_t port)
MOCK_IMPL(int,
router_my_exit_policy_is_reject_star,(void))
{
if (!router_get_my_routerinfo()) /* make sure desc_routerinfo exists */
if (!router_get_my_routerinfo()) /* make sure routerinfo exists */
return -1;
return router_get_my_routerinfo()->policy_is_reject_star;
@ -1834,12 +1836,13 @@ const char *
router_get_my_descriptor(void)
{
const char *body;
if (!router_get_my_routerinfo())
routerinfo_t *me = router_get_my_routerinfo();
if (! me)
return NULL;
tor_assert(router_get_my_routerinfo()->cache_info.saved_location == SAVED_NOWHERE);
body = signed_descriptor_get_body(&router_get_my_routerinfo()->cache_info);
tor_assert(me->cache_info.saved_location == SAVED_NOWHERE);
body = signed_descriptor_get_body(&me->cache_info);
/* Make sure this is nul-terminated. */
tor_assert(!body[router_get_my_routerinfo()->cache_info.signed_descriptor_len]);
tor_assert(!body[me->cache_info.signed_descriptor_len]);
log_debug(LD_GENERAL,"my desc is '%s'", body);
return body;
}