diff options
author | aunsane <aunsane@gmail.com> | 2018-08-17 00:29:59 +0300 |
---|---|---|
committer | aunsane <aunsane@gmail.com> | 2018-08-18 13:08:40 +0300 |
commit | 22196f3cad4751f964c56da518bb57ab0e64ae97 (patch) | |
tree | 9830ac73ecd5047aaa4ae0f67139b14cb9f8c4d2 /protocols/Tox/libtox/src/toxcore/TCP_connection.c | |
parent | 28d0e917496ecfd681e8cd3e3032519867993f9b (diff) |
Tox: libtox updated to v0.2.6
Diffstat (limited to 'protocols/Tox/libtox/src/toxcore/TCP_connection.c')
-rw-r--r-- | protocols/Tox/libtox/src/toxcore/TCP_connection.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/protocols/Tox/libtox/src/toxcore/TCP_connection.c b/protocols/Tox/libtox/src/toxcore/TCP_connection.c index 2d2dd47028..6763328da4 100644 --- a/protocols/Tox/libtox/src/toxcore/TCP_connection.c +++ b/protocols/Tox/libtox/src/toxcore/TCP_connection.c @@ -371,10 +371,10 @@ int send_packet_tcp_connection(TCP_Connections *tcp_c, int connections_number, c */ int get_random_tcp_onion_conn_number(TCP_Connections *tcp_c) { - unsigned int i, r = rand(); + const uint32_t r = random_u32(); - for (i = 0; i < tcp_c->tcp_connections_length; ++i) { - unsigned int index = ((i + r) % tcp_c->tcp_connections_length); + for (uint32_t i = 0; i < tcp_c->tcp_connections_length; ++i) { + uint32_t index = ((i + r) % tcp_c->tcp_connections_length); if (tcp_c->tcp_connections[index].onion && tcp_c->tcp_connections[index].status == TCP_CONN_CONNECTED) { return index; @@ -1283,11 +1283,12 @@ unsigned int tcp_connection_to_online_tcp_relays(TCP_Connections *tcp_c, int con * return number of relays copied to tcp_relays on success. * return 0 on failure. */ -unsigned int tcp_copy_connected_relays(TCP_Connections *tcp_c, Node_format *tcp_relays, uint16_t max_num) +uint32_t tcp_copy_connected_relays(TCP_Connections *tcp_c, Node_format *tcp_relays, uint16_t max_num) { - unsigned int i, copied = 0, r = rand(); + const uint32_t r = random_u32(); + uint32_t copied = 0; - for (i = 0; (i < tcp_c->tcp_connections_length) && (copied < max_num); ++i) { + for (uint32_t i = 0; (i < tcp_c->tcp_connections_length) && (copied < max_num); ++i) { TCP_con *tcp_con = get_tcp_connection(tcp_c, (i + r) % tcp_c->tcp_connections_length); if (!tcp_con) { |