summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzugz (tox) <mbays+tox@sdf.org>2020-02-28 00:00:00 +0000
committerzugz (tox) <mbays+tox@sdf.org>2020-03-14 00:00:02 +0000
commitc644ef76810f8db61bce3f52d36a1a6a25e47683 (patch)
tree1a4c5ed13f1a3450e3a005746ba6bb0d1af7beaf
parente6714909898d7e5fe6b35b6d109e584e6c5858b0 (diff)
use -1 rather than ~0 in unsigned integer types
Using ~0 involves a bitwise operation on int, so depends on the internal representation of signed integers.
-rwxr-xr-x.travis/cmake-linux7
-rw-r--r--auto_tests/toxav_basic_test.c4
-rw-r--r--auto_tests/toxav_many_test.c8
-rw-r--r--toxcore/DHT.c2
-rw-r--r--toxcore/TCP_client.c6
-rw-r--r--toxcore/TCP_client.h2
-rw-r--r--toxcore/TCP_server.c16
-rw-r--r--toxcore/TCP_server.h2
-rw-r--r--toxcore/group.c4
-rw-r--r--toxcore/net_crypto.c6
-rw-r--r--toxcore/onion_client.c22
11 files changed, 41 insertions, 38 deletions
diff --git a/.travis/cmake-linux b/.travis/cmake-linux
index 9b2a1fae..c0d175f8 100755
--- a/.travis/cmake-linux
+++ b/.travis/cmake-linux
@@ -7,6 +7,7 @@ set -eu
7CACHEDIR="$HOME/cache" 7CACHEDIR="$HOME/cache"
8NPROC=`nproc` 8NPROC=`nproc`
9ASTYLE="$CACHEDIR/astyle/build/gcc/bin/astyle" 9ASTYLE="$CACHEDIR/astyle/build/gcc/bin/astyle"
10ASTYLE_VERSION=3.1
10 11
11install_tool() { 12install_tool() {
12 SLUG="$1" 13 SLUG="$1"
@@ -35,9 +36,10 @@ travis_install() {
35 } 36 }
36 37
37 # Install astyle (version in ubuntu-precise too old). 38 # Install astyle (version in ubuntu-precise too old).
38 [ -f "$ASTYLE" ] || { 39 ([ -f "$ASTYLE" ] && "$ASTYLE" --version | grep "$ASTYLE_VERSION" >/dev/null) || {
39 wget -O ../astyle.tar.gz https://deb.debian.org/debian/pool/main/a/astyle/astyle_3.1.orig.tar.gz 40 wget -O ../astyle.tar.gz "https://deb.debian.org/debian/pool/main/a/astyle/astyle_$ASTYLE_VERSION.orig.tar.gz"
40 tar -xf ../astyle.tar.gz -C "$CACHEDIR" 41 tar -xf ../astyle.tar.gz -C "$CACHEDIR"
42 make -C "$CACHEDIR/astyle/build/gcc" clean
41 make -C "$CACHEDIR/astyle/build/gcc" "-j$NPROC" 43 make -C "$CACHEDIR/astyle/build/gcc" "-j$NPROC"
42 } 44 }
43 45
@@ -77,6 +79,7 @@ travis_script() {
77 # Coverage flags. 79 # Coverage flags.
78 add_flag -fprofile-arcs -ftest-coverage 80 add_flag -fprofile-arcs -ftest-coverage
79 81
82 "$ASTYLE" --version
80 other/astyle/format-source . "$ASTYLE" 83 other/astyle/format-source . "$ASTYLE"
81 84
82 echo "Running TokTok style checker" 85 echo "Running TokTok style checker"
diff --git a/auto_tests/toxav_basic_test.c b/auto_tests/toxav_basic_test.c
index 5c6daefa..89c2918a 100644
--- a/auto_tests/toxav_basic_test.c
+++ b/auto_tests/toxav_basic_test.c
@@ -88,7 +88,7 @@ static void t_accept_friend_request_cb(Tox *m, const uint8_t *public_key, const
88 void *userdata) 88 void *userdata)
89{ 89{
90 if (length == 7 && memcmp("gentoo", data, 7) == 0) { 90 if (length == 7 && memcmp("gentoo", data, 7) == 0) {
91 ck_assert(tox_friend_add_norequest(m, public_key, nullptr) != (uint32_t) ~0); 91 ck_assert(tox_friend_add_norequest(m, public_key, nullptr) != (uint32_t) -1);
92 } 92 }
93} 93}
94 94
@@ -191,7 +191,7 @@ static void test_av_flows(void)
191 tox_bootstrap(Alice, "localhost", dht_port, dht_key, nullptr); 191 tox_bootstrap(Alice, "localhost", dht_port, dht_key, nullptr);
192 tox_bootstrap(Bob, "localhost", dht_port, dht_key, nullptr); 192 tox_bootstrap(Bob, "localhost", dht_port, dht_key, nullptr);
193 193
194 ck_assert(tox_friend_add(Bob, address, (const uint8_t *)"gentoo", 7, nullptr) != (uint32_t) ~0); 194 ck_assert(tox_friend_add(Bob, address, (const uint8_t *)"gentoo", 7, nullptr) != (uint32_t) -1);
195 195
196 uint8_t off = 1; 196 uint8_t off = 1;
197 197
diff --git a/auto_tests/toxav_many_test.c b/auto_tests/toxav_many_test.c
index c8b14022..76417366 100644
--- a/auto_tests/toxav_many_test.c
+++ b/auto_tests/toxav_many_test.c
@@ -72,7 +72,7 @@ static void t_accept_friend_request_cb(Tox *m, const uint8_t *public_key, const
72 void *userdata) 72 void *userdata)
73{ 73{
74 if (length == 7 && memcmp("gentoo", data, 7) == 0) { 74 if (length == 7 && memcmp("gentoo", data, 7) == 0) {
75 ck_assert(tox_friend_add_norequest(m, public_key, nullptr) != (uint32_t) ~0); 75 ck_assert(tox_friend_add_norequest(m, public_key, nullptr) != (uint32_t) -1);
76 } 76 }
77} 77}
78 78
@@ -180,9 +180,9 @@ static void test_av_three_calls(void)
180 tox_bootstrap(Bobs[1], "localhost", dht_port, dht_key, nullptr); 180 tox_bootstrap(Bobs[1], "localhost", dht_port, dht_key, nullptr);
181 tox_bootstrap(Bobs[2], "localhost", dht_port, dht_key, nullptr); 181 tox_bootstrap(Bobs[2], "localhost", dht_port, dht_key, nullptr);
182 182
183 ck_assert(tox_friend_add(Bobs[0], address, (const uint8_t *)"gentoo", 7, nullptr) != (uint32_t) ~0); 183 ck_assert(tox_friend_add(Bobs[0], address, (const uint8_t *)"gentoo", 7, nullptr) != (uint32_t) -1);
184 ck_assert(tox_friend_add(Bobs[1], address, (const uint8_t *)"gentoo", 7, nullptr) != (uint32_t) ~0); 184 ck_assert(tox_friend_add(Bobs[1], address, (const uint8_t *)"gentoo", 7, nullptr) != (uint32_t) -1);
185 ck_assert(tox_friend_add(Bobs[2], address, (const uint8_t *)"gentoo", 7, nullptr) != (uint32_t) ~0); 185 ck_assert(tox_friend_add(Bobs[2], address, (const uint8_t *)"gentoo", 7, nullptr) != (uint32_t) -1);
186 186
187 uint8_t off = 1; 187 uint8_t off = 1;
188 188
diff --git a/toxcore/DHT.c b/toxcore/DHT.c
index 79925552..8603b9c0 100644
--- a/toxcore/DHT.c
+++ b/toxcore/DHT.c
@@ -247,7 +247,7 @@ static unsigned int bit_by_bit_cmp(const uint8_t *pk1, const uint8_t *pk2)
247void get_shared_key(const Mono_Time *mono_time, Shared_Keys *shared_keys, uint8_t *shared_key, 247void get_shared_key(const Mono_Time *mono_time, Shared_Keys *shared_keys, uint8_t *shared_key,
248 const uint8_t *secret_key, const uint8_t *public_key) 248 const uint8_t *secret_key, const uint8_t *public_key)
249{ 249{
250 uint32_t num = ~0; 250 uint32_t num = -1;
251 uint32_t curr = 0; 251 uint32_t curr = 0;
252 252
253 for (uint32_t i = 0; i < MAX_KEYS_PER_SLOT; ++i) { 253 for (uint32_t i = 0; i < MAX_KEYS_PER_SLOT; ++i) {
diff --git a/toxcore/TCP_client.c b/toxcore/TCP_client.c
index 6eae8408..1fae897f 100644
--- a/toxcore/TCP_client.c
+++ b/toxcore/TCP_client.c
@@ -555,7 +555,7 @@ int send_oob_packet(TCP_Client_Connection *con, const uint8_t *public_key, const
555 555
556/* Set the number that will be used as an argument in the callbacks related to con_id. 556/* Set the number that will be used as an argument in the callbacks related to con_id.
557 * 557 *
558 * When not set by this function, the number is ~0. 558 * When not set by this function, the number is -1.
559 * 559 *
560 * return 0 on success. 560 * return 0 on success.
561 * return -1 on failure. 561 * return -1 on failure.
@@ -785,7 +785,7 @@ static int handle_TCP_client_packet(TCP_Client_Connection *conn, const uint8_t *
785 } 785 }
786 786
787 conn->connections[con_id].status = 1; 787 conn->connections[con_id].status = 1;
788 conn->connections[con_id].number = ~0; 788 conn->connections[con_id].number = -1;
789 memcpy(conn->connections[con_id].public_key, data + 2, CRYPTO_PUBLIC_KEY_SIZE); 789 memcpy(conn->connections[con_id].public_key, data + 2, CRYPTO_PUBLIC_KEY_SIZE);
790 790
791 if (conn->response_callback) { 791 if (conn->response_callback) {
@@ -1038,7 +1038,7 @@ void do_TCP_connection(Mono_Time *mono_time, TCP_Client_Connection *tcp_connecti
1038 1038
1039 if (sizeof(data) == len) { 1039 if (sizeof(data) == len) {
1040 if (handle_handshake(tcp_connection, data) == 0) { 1040 if (handle_handshake(tcp_connection, data) == 0) {
1041 tcp_connection->kill_at = ~0; 1041 tcp_connection->kill_at = -1;
1042 tcp_connection->status = TCP_CLIENT_CONFIRMED; 1042 tcp_connection->status = TCP_CLIENT_CONFIRMED;
1043 } else { 1043 } else {
1044 tcp_connection->kill_at = 0; 1044 tcp_connection->kill_at = 0;
diff --git a/toxcore/TCP_client.h b/toxcore/TCP_client.h
index 9d43d642..6a9bf8e2 100644
--- a/toxcore/TCP_client.h
+++ b/toxcore/TCP_client.h
@@ -103,7 +103,7 @@ int send_disconnect_request(TCP_Client_Connection *con, uint8_t con_id);
103 103
104/* Set the number that will be used as an argument in the callbacks related to con_id. 104/* Set the number that will be used as an argument in the callbacks related to con_id.
105 * 105 *
106 * When not set by this function, the number is ~0. 106 * When not set by this function, the number is -1.
107 * 107 *
108 * return 0 on success. 108 * return 0 on success.
109 * return -1 on failure. 109 * return -1 on failure.
diff --git a/toxcore/TCP_server.c b/toxcore/TCP_server.c
index 23b95940..086fe3d3 100644
--- a/toxcore/TCP_server.c
+++ b/toxcore/TCP_server.c
@@ -288,7 +288,7 @@ static int del_accepted(TCP_Server *tcp_server, int index)
288 * 288 *
289 * return length on success 289 * return length on success
290 * return 0 if nothing has been read from socket. 290 * return 0 if nothing has been read from socket.
291 * return ~0 on failure. 291 * return -1 on failure.
292 */ 292 */
293uint16_t read_TCP_length(Socket sock) 293uint16_t read_TCP_length(Socket sock)
294{ 294{
@@ -306,7 +306,7 @@ uint16_t read_TCP_length(Socket sock)
306 length = net_ntohs(length); 306 length = net_ntohs(length);
307 307
308 if (length > MAX_PACKET_SIZE) { 308 if (length > MAX_PACKET_SIZE) {
309 return ~0; 309 return -1;
310 } 310 }
311 311
312 return length; 312 return length;
@@ -348,7 +348,7 @@ int read_packet_TCP_secure_connection(Socket sock, uint16_t *next_packet_length,
348 if (*next_packet_length == 0) { 348 if (*next_packet_length == 0) {
349 uint16_t len = read_TCP_length(sock); 349 uint16_t len = read_TCP_length(sock);
350 350
351 if (len == (uint16_t)~0) { 351 if (len == (uint16_t) -1) {
352 return -1; 352 return -1;
353 } 353 }
354 354
@@ -684,7 +684,7 @@ static int send_disconnect_notification(TCP_Secure_Connection *con, uint8_t id)
684static int handle_TCP_routing_req(TCP_Server *tcp_server, uint32_t con_id, const uint8_t *public_key) 684static int handle_TCP_routing_req(TCP_Server *tcp_server, uint32_t con_id, const uint8_t *public_key)
685{ 685{
686 uint32_t i; 686 uint32_t i;
687 uint32_t index = ~0; 687 uint32_t index = -1;
688 TCP_Secure_Connection *con = &tcp_server->accepted_connection_array[con_id]; 688 TCP_Secure_Connection *con = &tcp_server->accepted_connection_array[con_id];
689 689
690 /* If person tries to cennect to himself we deny the request*/ 690 /* If person tries to cennect to himself we deny the request*/
@@ -705,12 +705,12 @@ static int handle_TCP_routing_req(TCP_Server *tcp_server, uint32_t con_id, const
705 705
706 return 0; 706 return 0;
707 } 707 }
708 } else if (index == (uint32_t)~0) { 708 } else if (index == (uint32_t) -1) {
709 index = i; 709 index = i;
710 } 710 }
711 } 711 }
712 712
713 if (index == (uint32_t)~0) { 713 if (index == (uint32_t) -1) {
714 if (send_routing_response(con, 0, public_key) == -1) { 714 if (send_routing_response(con, 0, public_key) == -1) {
715 return -1; 715 return -1;
716 } 716 }
@@ -733,7 +733,7 @@ static int handle_TCP_routing_req(TCP_Server *tcp_server, uint32_t con_id, const
733 int other_index = get_TCP_connection_index(tcp_server, public_key); 733 int other_index = get_TCP_connection_index(tcp_server, public_key);
734 734
735 if (other_index != -1) { 735 if (other_index != -1) {
736 uint32_t other_id = ~0; 736 uint32_t other_id = -1;
737 TCP_Secure_Connection *other_conn = &tcp_server->accepted_connection_array[other_index]; 737 TCP_Secure_Connection *other_conn = &tcp_server->accepted_connection_array[other_index];
738 738
739 for (i = 0; i < NUM_CLIENT_CONNECTIONS; ++i) { 739 for (i = 0; i < NUM_CLIENT_CONNECTIONS; ++i) {
@@ -744,7 +744,7 @@ static int handle_TCP_routing_req(TCP_Server *tcp_server, uint32_t con_id, const
744 } 744 }
745 } 745 }
746 746
747 if (other_id != (uint32_t)~0) { 747 if (other_id != (uint32_t) -1) {
748 con->connections[index].status = 2; 748 con->connections[index].status = 2;
749 con->connections[index].index = other_index; 749 con->connections[index].index = other_index;
750 con->connections[index].other_id = other_id; 750 con->connections[index].other_id = other_id;
diff --git a/toxcore/TCP_server.h b/toxcore/TCP_server.h
index 252df9fa..bc159f73 100644
--- a/toxcore/TCP_server.h
+++ b/toxcore/TCP_server.h
@@ -100,7 +100,7 @@ void kill_TCP_server(TCP_Server *tcp_server);
100 * 100 *
101 * return length on success 101 * return length on success
102 * return 0 if nothing has been read from socket. 102 * return 0 if nothing has been read from socket.
103 * return ~0 on failure. 103 * return -1 on failure.
104 */ 104 */
105uint16_t read_TCP_length(Socket sock); 105uint16_t read_TCP_length(Socket sock);
106 106
diff --git a/toxcore/group.c b/toxcore/group.c
index 1761d02d..9ba0c3df 100644
--- a/toxcore/group.c
+++ b/toxcore/group.c
@@ -2457,7 +2457,7 @@ static unsigned int send_lossy_all_close(const Group_Chats *g_c, uint32_t groupn
2457 } 2457 }
2458 2458
2459 unsigned int to_send = 0; 2459 unsigned int to_send = 0;
2460 uint64_t comp_val_old = ~0; 2460 uint64_t comp_val_old = -1;
2461 2461
2462 for (i = 0; i < num_connected_closest; ++i) { 2462 for (i = 0; i < num_connected_closest; ++i) {
2463 uint8_t real_pk[CRYPTO_PUBLIC_KEY_SIZE] = {0}; 2463 uint8_t real_pk[CRYPTO_PUBLIC_KEY_SIZE] = {0};
@@ -2477,7 +2477,7 @@ static unsigned int send_lossy_all_close(const Group_Chats *g_c, uint32_t groupn
2477 } 2477 }
2478 2478
2479 unsigned int to_send_other = 0; 2479 unsigned int to_send_other = 0;
2480 comp_val_old = ~0; 2480 comp_val_old = -1;
2481 2481
2482 for (i = 0; i < num_connected_closest; ++i) { 2482 for (i = 0; i < num_connected_closest; ++i) {
2483 uint8_t real_pk[CRYPTO_PUBLIC_KEY_SIZE] = {0}; 2483 uint8_t real_pk[CRYPTO_PUBLIC_KEY_SIZE] = {0};
diff --git a/toxcore/net_crypto.c b/toxcore/net_crypto.c
index 01dd680e..09ce91ba 100644
--- a/toxcore/net_crypto.c
+++ b/toxcore/net_crypto.c
@@ -1004,7 +1004,7 @@ static int handle_request_packet(Mono_Time *mono_time, const Logger *log, Packet
1004 uint32_t requested = 0; 1004 uint32_t requested = 0;
1005 1005
1006 const uint64_t temp_time = current_time_monotonic(mono_time); 1006 const uint64_t temp_time = current_time_monotonic(mono_time);
1007 uint64_t l_sent_time = ~0; 1007 uint64_t l_sent_time = -1;
1008 1008
1009 for (uint32_t i = send_array->buffer_start; i != send_array->buffer_end; ++i) { 1009 for (uint32_t i = send_array->buffer_start; i != send_array->buffer_end; ++i) {
1010 if (length == 0) { 1010 if (length == 0) {
@@ -2513,7 +2513,7 @@ static void send_crypto_packets(Net_Crypto *c)
2513{ 2513{
2514 const uint64_t temp_time = current_time_monotonic(c->mono_time); 2514 const uint64_t temp_time = current_time_monotonic(c->mono_time);
2515 double total_send_rate = 0; 2515 double total_send_rate = 0;
2516 uint32_t peak_request_packet_interval = ~0; 2516 uint32_t peak_request_packet_interval = -1;
2517 2517
2518 for (uint32_t i = 0; i < c->crypto_connections_length; ++i) { 2518 for (uint32_t i = 0; i < c->crypto_connections_length; ++i) {
2519 Crypto_Connection *conn = get_crypto_connection(c, i); 2519 Crypto_Connection *conn = get_crypto_connection(c, i);
@@ -2722,7 +2722,7 @@ static void send_crypto_packets(Net_Crypto *c)
2722 } 2722 }
2723 } 2723 }
2724 2724
2725 c->current_sleep_time = ~0; 2725 c->current_sleep_time = -1;
2726 uint32_t sleep_time = peak_request_packet_interval; 2726 uint32_t sleep_time = peak_request_packet_interval;
2727 2727
2728 if (c->current_sleep_time > sleep_time) { 2728 if (c->current_sleep_time > sleep_time) {
diff --git a/toxcore/onion_client.c b/toxcore/onion_client.c
index 6dd945b0..b3a54879 100644
--- a/toxcore/onion_client.c
+++ b/toxcore/onion_client.c
@@ -465,7 +465,7 @@ static uint32_t set_path_timeouts(Onion_Client *onion_c, uint32_t num, uint32_t
465 return path_num; 465 return path_num;
466 } 466 }
467 467
468 return ~0; 468 return -1;
469} 469}
470 470
471/* Function to send onion packet via TCP and UDP. 471/* Function to send onion packet via TCP and UDP.
@@ -544,7 +544,7 @@ static int new_sendback(Onion_Client *onion_c, uint32_t num, const uint8_t *publ
544 * ret_pubkey must be at least CRYPTO_PUBLIC_KEY_SIZE big 544 * ret_pubkey must be at least CRYPTO_PUBLIC_KEY_SIZE big
545 * ret_ip_port must be at least 1 big 545 * ret_ip_port must be at least 1 big
546 * 546 *
547 * return ~0 on failure 547 * return -1 on failure
548 * return num (see new_sendback(...)) on success 548 * return num (see new_sendback(...)) on success
549 */ 549 */
550static uint32_t check_sendback(Onion_Client *onion_c, const uint8_t *sendback, uint8_t *ret_pubkey, 550static uint32_t check_sendback(Onion_Client *onion_c, const uint8_t *sendback, uint8_t *ret_pubkey,
@@ -555,7 +555,7 @@ static uint32_t check_sendback(Onion_Client *onion_c, const uint8_t *sendback, u
555 uint8_t data[sizeof(uint32_t) + CRYPTO_PUBLIC_KEY_SIZE + sizeof(IP_Port) + sizeof(uint32_t)]; 555 uint8_t data[sizeof(uint32_t) + CRYPTO_PUBLIC_KEY_SIZE + sizeof(IP_Port) + sizeof(uint32_t)];
556 556
557 if (ping_array_check(onion_c->announce_ping_array, onion_c->mono_time, data, sizeof(data), sback) != sizeof(data)) { 557 if (ping_array_check(onion_c->announce_ping_array, onion_c->mono_time, data, sizeof(data), sback) != sizeof(data)) {
558 return ~0; 558 return -1;
559 } 559 }
560 560
561 memcpy(ret_pubkey, data + sizeof(uint32_t), CRYPTO_PUBLIC_KEY_SIZE); 561 memcpy(ret_pubkey, data + sizeof(uint32_t), CRYPTO_PUBLIC_KEY_SIZE);
@@ -834,7 +834,7 @@ static int client_ping_nodes(Onion_Client *onion_c, uint32_t num, const Node_for
834 } 834 }
835 835
836 if (j == list_length && good_to_ping(onion_c->mono_time, last_pinged, last_pinged_index, nodes[i].public_key)) { 836 if (j == list_length && good_to_ping(onion_c->mono_time, last_pinged, last_pinged_index, nodes[i].public_key)) {
837 client_send_announce_request(onion_c, num, nodes[i].ip_port, nodes[i].public_key, nullptr, ~0); 837 client_send_announce_request(onion_c, num, nodes[i].ip_port, nodes[i].public_key, nullptr, -1);
838 } 838 }
839 } 839 }
840 } 840 }
@@ -1098,7 +1098,7 @@ int send_onion_data(Onion_Client *onion_c, int friend_num, const uint8_t *data,
1098 for (i = 0; i < num_good; ++i) { 1098 for (i = 0; i < num_good; ++i) {
1099 Onion_Path path; 1099 Onion_Path path;
1100 1100
1101 if (random_path(onion_c, &onion_c->onion_paths_friends, ~0, &path) == -1) { 1101 if (random_path(onion_c, &onion_c->onion_paths_friends, -1, &path) == -1) {
1102 continue; 1102 continue;
1103 } 1103 }
1104 1104
@@ -1303,7 +1303,7 @@ int onion_addfriend(Onion_Client *onion_c, const uint8_t *public_key)
1303 return num; 1303 return num;
1304 } 1304 }
1305 1305
1306 unsigned int i, index = ~0; 1306 unsigned int i, index = -1;
1307 1307
1308 for (i = 0; i < onion_c->num_friends; ++i) { 1308 for (i = 0; i < onion_c->num_friends; ++i) {
1309 if (onion_c->friends_list[i].status == 0) { 1309 if (onion_c->friends_list[i].status == 0) {
@@ -1312,7 +1312,7 @@ int onion_addfriend(Onion_Client *onion_c, const uint8_t *public_key)
1312 } 1312 }
1313 } 1313 }
1314 1314
1315 if (index == (uint32_t)~0) { 1315 if (index == (uint32_t) -1) {
1316 if (realloc_onion_friends(onion_c, onion_c->num_friends + 1) == -1) { 1316 if (realloc_onion_friends(onion_c, onion_c->num_friends + 1) == -1) {
1317 return -1; 1317 return -1;
1318 } 1318 }
@@ -1607,7 +1607,7 @@ static void do_friend(Onion_Client *onion_c, uint16_t friendnum)
1607 if (mono_time_is_timeout(onion_c->mono_time, list_nodes[i].last_pinged, interval) 1607 if (mono_time_is_timeout(onion_c->mono_time, list_nodes[i].last_pinged, interval)
1608 || (ping_random && random_u32() % (MAX_ONION_CLIENTS - i) == 0)) { 1608 || (ping_random && random_u32() % (MAX_ONION_CLIENTS - i) == 0)) {
1609 if (client_send_announce_request(onion_c, friendnum + 1, list_nodes[i].ip_port, 1609 if (client_send_announce_request(onion_c, friendnum + 1, list_nodes[i].ip_port,
1610 list_nodes[i].public_key, nullptr, ~0) == 0) { 1610 list_nodes[i].public_key, nullptr, -1) == 0) {
1611 list_nodes[i].last_pinged = mono_time_get(onion_c->mono_time); 1611 list_nodes[i].last_pinged = mono_time_get(onion_c->mono_time);
1612 ++list_nodes[i].unsuccessful_pings; 1612 ++list_nodes[i].unsuccessful_pings;
1613 ping_random = false; 1613 ping_random = false;
@@ -1630,7 +1630,7 @@ static void do_friend(Onion_Client *onion_c, uint16_t friendnum)
1630 for (j = 0; j < n; ++j) { 1630 for (j = 0; j < n; ++j) {
1631 const uint32_t num = random_u32() % num_nodes; 1631 const uint32_t num = random_u32() % num_nodes;
1632 client_send_announce_request(onion_c, friendnum + 1, onion_c->path_nodes[num].ip_port, 1632 client_send_announce_request(onion_c, friendnum + 1, onion_c->path_nodes[num].ip_port,
1633 onion_c->path_nodes[num].public_key, nullptr, ~0); 1633 onion_c->path_nodes[num].public_key, nullptr, -1);
1634 } 1634 }
1635 1635
1636 ++onion_c->friends_list[friendnum].run_count; 1636 ++onion_c->friends_list[friendnum].run_count;
@@ -1723,7 +1723,7 @@ static void do_announce(Onion_Client *onion_c)
1723 if (list_nodes[i].unsuccessful_pings == ONION_NODE_MAX_PINGS - 1 1723 if (list_nodes[i].unsuccessful_pings == ONION_NODE_MAX_PINGS - 1
1724 && mono_time_is_timeout(onion_c->mono_time, list_nodes[i].added_time, TIME_TO_STABLE)) { 1724 && mono_time_is_timeout(onion_c->mono_time, list_nodes[i].added_time, TIME_TO_STABLE)) {
1725 /* Last chance for a long-lived node - try a random path */ 1725 /* Last chance for a long-lived node - try a random path */
1726 path_to_use = ~0; 1726 path_to_use = -1;
1727 } 1727 }
1728 1728
1729 if (client_send_announce_request(onion_c, 0, list_nodes[i].ip_port, list_nodes[i].public_key, 1729 if (client_send_announce_request(onion_c, 0, list_nodes[i].ip_port, list_nodes[i].public_key,
@@ -1751,7 +1751,7 @@ static void do_announce(Onion_Client *onion_c)
1751 if (num_nodes != 0) { 1751 if (num_nodes != 0) {
1752 for (i = 0; i < (MAX_ONION_CLIENTS_ANNOUNCE / 2); ++i) { 1752 for (i = 0; i < (MAX_ONION_CLIENTS_ANNOUNCE / 2); ++i) {
1753 const uint32_t num = random_u32() % num_nodes; 1753 const uint32_t num = random_u32() % num_nodes;
1754 client_send_announce_request(onion_c, 0, path_nodes[num].ip_port, path_nodes[num].public_key, nullptr, ~0); 1754 client_send_announce_request(onion_c, 0, path_nodes[num].ip_port, path_nodes[num].public_key, nullptr, -1);
1755 } 1755 }
1756 } 1756 }
1757 } 1757 }