diff options
author | iphydf <iphydf@users.noreply.github.com> | 2018-07-12 17:22:20 +0000 |
---|---|---|
committer | iphydf <iphydf@users.noreply.github.com> | 2018-07-12 20:21:42 +0000 |
commit | beeb9b4335d9ca6f947a52528453753a51f194f3 (patch) | |
tree | 242cad42e2e90ebf5ed04283fd79f42f4e3afa60 /toxcore/DHT.c | |
parent | cbda01021c561bd061cb03a1c1bab58199ac2307 (diff) |
Style fixes in TCP code; remove MIN and PAIR from util.h.
* Moved PAIR to toxav, where it's used (but really this should die).
* Replace most MIN calls with typed `min_*` calls. Didn't replace the
ones where the desired semantics are unclear. Moved the MIN macro to
the one place where it's still used.
* Avoid assignments in `while` loops. Instead, factored out the loop body
into a separate `bool`-returning function.
* Use named types for callbacks (`_cb` types).
* Avoid assignments in `if` conditions.
* Removed `MAKE_REALLOC` and expanded its two calls. We can't have
templates in C, and this fake templating is ugly and hard to analyse
and debug (it expands on a single line).
* Moved epoll system include to the .c file, out of the .h file.
* Avoid assignments in expressions (`a = b = c;`).
* Avoid multiple declarators per struct member declaration.
* Fix naming inconsistencies.
* Replace `net_to_host` macro with function.
Diffstat (limited to 'toxcore/DHT.c')
-rw-r--r-- | toxcore/DHT.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/toxcore/DHT.c b/toxcore/DHT.c index 3fd3829e..01fcfd66 100644 --- a/toxcore/DHT.c +++ b/toxcore/DHT.c | |||
@@ -1192,7 +1192,7 @@ uint32_t addto_lists(DHT *dht, IP_Port ip_port, const uint8_t *public_key) | |||
1192 | uint32_t used = 0; | 1192 | uint32_t used = 0; |
1193 | 1193 | ||
1194 | /* convert IPv4-in-IPv6 to IPv4 */ | 1194 | /* convert IPv4-in-IPv6 to IPv4 */ |
1195 | if (net_family_is_ipv6(ip_port.ip.family) && IPV6_IPV4_IN_V6(ip_port.ip.ip.v6)) { | 1195 | if (net_family_is_ipv6(ip_port.ip.family) && ipv6_ipv4_in_v6(ip_port.ip.ip.v6)) { |
1196 | ip_port.ip.family = net_family_ipv4; | 1196 | ip_port.ip.family = net_family_ipv4; |
1197 | ip_port.ip.ip.v4.uint32 = ip_port.ip.ip.v6.uint32[3]; | 1197 | ip_port.ip.ip.v4.uint32 = ip_port.ip.ip.v6.uint32[3]; |
1198 | } | 1198 | } |
@@ -1272,7 +1272,7 @@ static bool update_client_data(Client_data *array, size_t size, IP_Port ip_port, | |||
1272 | static void returnedip_ports(DHT *dht, IP_Port ip_port, const uint8_t *public_key, const uint8_t *nodepublic_key) | 1272 | static void returnedip_ports(DHT *dht, IP_Port ip_port, const uint8_t *public_key, const uint8_t *nodepublic_key) |
1273 | { | 1273 | { |
1274 | /* convert IPv4-in-IPv6 to IPv4 */ | 1274 | /* convert IPv4-in-IPv6 to IPv4 */ |
1275 | if (net_family_is_ipv6(ip_port.ip.family) && IPV6_IPV4_IN_V6(ip_port.ip.ip.v6)) { | 1275 | if (net_family_is_ipv6(ip_port.ip.family) && ipv6_ipv4_in_v6(ip_port.ip.ip.v6)) { |
1276 | ip_port.ip.family = net_family_ipv4; | 1276 | ip_port.ip.family = net_family_ipv4; |
1277 | ip_port.ip.ip.v4.uint32 = ip_port.ip.ip.v6.uint32[3]; | 1277 | ip_port.ip.ip.v4.uint32 = ip_port.ip.ip.v6.uint32[3]; |
1278 | } | 1278 | } |