[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [tor/master] addr: Use false/true with relay_find_addr_to_publish()
commit 0b89eba7d55839c4b746bbe5efd8fe1531592bf7
Author: David Goulet <dgoulet@xxxxxxxxxxxxxx>
Date: Thu Jul 16 09:26:58 2020 -0400
addr: Use false/true with relay_find_addr_to_publish()
Previous development introduced the error of using 0/1 for a boolean
parameter. Fix that everywhere
Related #40025
Signed-off-by: David Goulet <dgoulet@xxxxxxxxxxxxxx>
---
src/feature/client/transports.c | 4 ++--
src/feature/relay/router.c | 6 ++++--
src/test/test_relay.c | 12 ++++++------
3 files changed, 12 insertions(+), 10 deletions(-)
diff --git a/src/feature/client/transports.c b/src/feature/client/transports.c
index ecc952e2ac..8a0694449a 100644
--- a/src/feature/client/transports.c
+++ b/src/feature/client/transports.c
@@ -1652,10 +1652,10 @@ pt_get_extra_info_descriptor_string(void)
tor_addr_t addr;
/* Attempt to find the IPv4 and then attempt to find the IPv6 if we
* can't find it. */
- bool found = relay_find_addr_to_publish(get_options(), AF_INET, 0,
+ bool found = relay_find_addr_to_publish(get_options(), AF_INET, false,
&addr);
if (!found) {
- found = relay_find_addr_to_publish(get_options(), AF_INET6, 0,
+ found = relay_find_addr_to_publish(get_options(), AF_INET6, false,
&addr);
}
if (!found) {
diff --git a/src/feature/relay/router.c b/src/feature/relay/router.c
index 2d79a9ba4d..039aeb7343 100644
--- a/src/feature/relay/router.c
+++ b/src/feature/relay/router.c
@@ -2040,8 +2040,10 @@ router_build_fresh_unsigned_routerinfo,(routerinfo_t **ri_out))
/* Find our resolved address both IPv4 and IPv6. In case the address is not
* found, the object is set to an UNSPEC address. */
- bool have_v4 = relay_find_addr_to_publish(options, AF_INET, 0, &ipv4_addr);
- bool have_v6 = relay_find_addr_to_publish(options, AF_INET6, 0, &ipv6_addr);
+ bool have_v4 = relay_find_addr_to_publish(options, AF_INET, false,
+ &ipv4_addr);
+ bool have_v6 = relay_find_addr_to_publish(options, AF_INET6, false,
+ &ipv6_addr);
/* Tor requires a relay to have an IPv4 so bail if we can't find it. */
if (!have_v4) {
diff --git a/src/test/test_relay.c b/src/test/test_relay.c
index af48eb5a44..5ea35b6ad0 100644
--- a/src/test/test_relay.c
+++ b/src/test/test_relay.c
@@ -316,11 +316,11 @@ test_find_addr_to_publish(void *arg)
tt_assert(tor_addr_eq(&ipv6_addr, &cache_addr));
/* 1. Address located in the resolved cache. */
- ret = relay_find_addr_to_publish(&options, AF_INET, 1, &cache_addr);
+ ret = relay_find_addr_to_publish(&options, AF_INET, true, &cache_addr);
tt_assert(ret);
tt_assert(tor_addr_eq(&ipv4_addr, &cache_addr));
- ret = relay_find_addr_to_publish(&options, AF_INET6, 1, &cache_addr);
+ ret = relay_find_addr_to_publish(&options, AF_INET6, true, &cache_addr);
tt_assert(ret);
tt_assert(tor_addr_eq(&ipv6_addr, &cache_addr));
resolved_addr_reset_last(AF_INET);
@@ -330,21 +330,21 @@ test_find_addr_to_publish(void *arg)
* the find_my_address() code path because that is extensively tested in
* another unit tests. */
resolved_addr_set_suggested(&ipv4_addr);
- ret = relay_find_addr_to_publish(&options, AF_INET, 1, &cache_addr);
+ ret = relay_find_addr_to_publish(&options, AF_INET, true, &cache_addr);
tt_assert(ret);
tt_assert(tor_addr_eq(&ipv4_addr, &cache_addr));
resolved_addr_set_suggested(&ipv6_addr);
- ret = relay_find_addr_to_publish(&options, AF_INET6, 1, &cache_addr);
+ ret = relay_find_addr_to_publish(&options, AF_INET6, true, &cache_addr);
tt_assert(ret);
tt_assert(tor_addr_eq(&ipv6_addr, &cache_addr));
resolve_addr_reset_suggested(AF_INET);
resolve_addr_reset_suggested(AF_INET6);
/* 3. No IP anywhere. */
- ret = relay_find_addr_to_publish(&options, AF_INET, 1, &cache_addr);
+ ret = relay_find_addr_to_publish(&options, AF_INET, true, &cache_addr);
tt_assert(!ret);
- ret = relay_find_addr_to_publish(&options, AF_INET6, 1, &cache_addr);
+ ret = relay_find_addr_to_publish(&options, AF_INET6, true, &cache_addr);
tt_assert(!ret);
done:
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits