summaryrefslogtreecommitdiff
path: root/toxcore/onion_client.c
diff options
context:
space:
mode:
authoriphydf <iphydf@users.noreply.github.com>2018-02-24 20:32:38 +0000
committeriphydf <iphydf@users.noreply.github.com>2018-02-24 20:35:57 +0000
commitafc80922e720f5d2a93bdfb3745da058e5ddf81b (patch)
tree69c00a0d1d6e6217e443dfc8e344af78e6cc8dd0 /toxcore/onion_client.c
parent25debce85074f6f0883905fa496829125ddad713 (diff)
Some minor cleanups suggested by cppcheck.
DETECTED=cppcheck
Diffstat (limited to 'toxcore/onion_client.c')
-rw-r--r--toxcore/onion_client.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/toxcore/onion_client.c b/toxcore/onion_client.c
index 650a3dd3..e6743559 100644
--- a/toxcore/onion_client.c
+++ b/toxcore/onion_client.c
@@ -1551,15 +1551,15 @@ static void do_friend(Onion_Client *onion_c, uint16_t friendnum)
1551 } 1551 }
1552 } 1552 }
1553 1553
1554 unsigned int i, count = 0;
1555 Onion_Node *list_nodes = onion_c->friends_list[friendnum].clients_list;
1556
1557 if (!onion_c->friends_list[friendnum].is_online) { 1554 if (!onion_c->friends_list[friendnum].is_online) {
1555 unsigned int count = 0;
1556 Onion_Node *list_nodes = onion_c->friends_list[friendnum].clients_list;
1557
1558 // ensure we get a response from some node roughly once per 1558 // ensure we get a response from some node roughly once per
1559 // (interval / MAX_ONION_CLIENTS) 1559 // (interval / MAX_ONION_CLIENTS)
1560 bool ping_random = true; 1560 bool ping_random = true;
1561 1561
1562 for (i = 0; i < MAX_ONION_CLIENTS; ++i) { 1562 for (unsigned i = 0; i < MAX_ONION_CLIENTS; ++i) {
1563 if (!(is_timeout(list_nodes[i].timestamp, interval / MAX_ONION_CLIENTS) 1563 if (!(is_timeout(list_nodes[i].timestamp, interval / MAX_ONION_CLIENTS)
1564 && is_timeout(list_nodes[i].last_pinged, ONION_NODE_PING_INTERVAL))) { 1564 && is_timeout(list_nodes[i].last_pinged, ONION_NODE_PING_INTERVAL))) {
1565 ping_random = false; 1565 ping_random = false;
@@ -1567,7 +1567,7 @@ static void do_friend(Onion_Client *onion_c, uint16_t friendnum)
1567 } 1567 }
1568 } 1568 }
1569 1569
1570 for (i = 0; i < MAX_ONION_CLIENTS; ++i) { 1570 for (unsigned i = 0; i < MAX_ONION_CLIENTS; ++i) {
1571 if (onion_node_timed_out(&list_nodes[i])) { 1571 if (onion_node_timed_out(&list_nodes[i])) {
1572 continue; 1572 continue;
1573 } 1573 }
@@ -1800,8 +1800,6 @@ unsigned int onion_connection_status(const Onion_Client *onion_c)
1800 1800
1801void do_onion_client(Onion_Client *onion_c) 1801void do_onion_client(Onion_Client *onion_c)
1802{ 1802{
1803 unsigned int i;
1804
1805 if (onion_c->last_run == unix_time()) { 1803 if (onion_c->last_run == unix_time()) {
1806 return; 1804 return;
1807 } 1805 }
@@ -1833,7 +1831,7 @@ void do_onion_client(Onion_Client *onion_c)
1833 || get_random_tcp_onion_conn_number(nc_get_tcp_c(onion_c->c)) == -1; /* Check if connected to any TCP relays. */ 1831 || get_random_tcp_onion_conn_number(nc_get_tcp_c(onion_c->c)) == -1; /* Check if connected to any TCP relays. */
1834 1832
1835 if (onion_connection_status(onion_c)) { 1833 if (onion_connection_status(onion_c)) {
1836 for (i = 0; i < onion_c->num_friends; ++i) { 1834 for (unsigned i = 0; i < onion_c->num_friends; ++i) {
1837 do_friend(onion_c, i); 1835 do_friend(onion_c, i);
1838 } 1836 }
1839 } 1837 }