summaryrefslogtreecommitdiff
path: root/toxcore/DHT.c
diff options
context:
space:
mode:
authoriphydf <iphydf@users.noreply.github.com>2016-09-13 22:01:45 +0100
committeriphydf <iphydf@users.noreply.github.com>2016-09-13 22:01:45 +0100
commit45d28904b92c825d1ac88be9edae8baabcd4bba1 (patch)
tree7b1b259ba09d35867c141cf072707e6a0891f97a /toxcore/DHT.c
parenta8823830d39bdbde8d4f4f34bfcb26dc4bf79741 (diff)
Use <stdbool.h> and replace _Bool with bool.
This header is a requirement for the public API, therefore is assumed to exist. It is a C99 standard library header, and _Bool is not intended to be used directly, except in legacy code that defines bool (and true/false) itself. We don't use or depend on such code. None of our client code uses or depends on such code. There is no reason to not use bool.
Diffstat (limited to 'toxcore/DHT.c')
-rw-r--r--toxcore/DHT.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/toxcore/DHT.c b/toxcore/DHT.c
index 7e2445b3..e7fd0a9d 100644
--- a/toxcore/DHT.c
+++ b/toxcore/DHT.c
@@ -550,8 +550,8 @@ static int friend_number(const DHT *dht, const uint8_t *public_key)
550 550
551/* Add node to the node list making sure only the nodes closest to cmp_pk are in the list. 551/* Add node to the node list making sure only the nodes closest to cmp_pk are in the list.
552 */ 552 */
553_Bool add_to_list(Node_format *nodes_list, unsigned int length, const uint8_t *pk, IP_Port ip_port, 553bool add_to_list(Node_format *nodes_list, unsigned int length, const uint8_t *pk, IP_Port ip_port,
554 const uint8_t *cmp_pk) 554 const uint8_t *cmp_pk)
555{ 555{
556 uint8_t pk_bak[crypto_box_PUBLICKEYBYTES]; 556 uint8_t pk_bak[crypto_box_PUBLICKEYBYTES];
557 IP_Port ip_port_bak; 557 IP_Port ip_port_bak;
@@ -877,7 +877,7 @@ static int replace_all(Client_data *list,
877 * return -1 on failure. 877 * return -1 on failure.
878 * return 0 on success. 878 * return 0 on success.
879 */ 879 */
880static int add_to_close(DHT *dht, const uint8_t *public_key, IP_Port ip_port, _Bool simulate) 880static int add_to_close(DHT *dht, const uint8_t *public_key, IP_Port ip_port, bool simulate)
881{ 881{
882 unsigned int i; 882 unsigned int i;
883 883
@@ -924,7 +924,7 @@ static int add_to_close(DHT *dht, const uint8_t *public_key, IP_Port ip_port, _B
924 924
925/* Return 1 if node can be added to close list, 0 if it can't. 925/* Return 1 if node can be added to close list, 0 if it can't.
926 */ 926 */
927_Bool node_addable_to_close_list(DHT *dht, const uint8_t *public_key, IP_Port ip_port) 927bool node_addable_to_close_list(DHT *dht, const uint8_t *public_key, IP_Port ip_port)
928{ 928{
929 if (add_to_close(dht, public_key, ip_port, 1) == 0) { 929 if (add_to_close(dht, public_key, ip_port, 1) == 0) {
930 return 1; 930 return 1;
@@ -933,8 +933,8 @@ _Bool node_addable_to_close_list(DHT *dht, const uint8_t *public_key, IP_Port ip
933 return 0; 933 return 0;
934} 934}
935 935
936static _Bool is_pk_in_client_list(Client_data *list, unsigned int client_list_length, const uint8_t *public_key, 936static bool is_pk_in_client_list(Client_data *list, unsigned int client_list_length, const uint8_t *public_key,
937 IP_Port ip_port) 937 IP_Port ip_port)
938{ 938{
939 unsigned int i; 939 unsigned int i;
940 940
@@ -958,7 +958,7 @@ static _Bool is_pk_in_client_list(Client_data *list, unsigned int client_list_le
958 */ 958 */
959static unsigned int ping_node_from_getnodes_ok(DHT *dht, const uint8_t *public_key, IP_Port ip_port) 959static unsigned int ping_node_from_getnodes_ok(DHT *dht, const uint8_t *public_key, IP_Port ip_port)
960{ 960{
961 _Bool ret = 0; 961 bool ret = 0;
962 962
963 if (add_to_close(dht, public_key, ip_port, 1) == 0) { 963 if (add_to_close(dht, public_key, ip_port, 1) == 0) {
964 ret = 1; 964 ret = 1;
@@ -978,7 +978,7 @@ static unsigned int ping_node_from_getnodes_ok(DHT *dht, const uint8_t *public_k
978 unsigned int i; 978 unsigned int i;
979 979
980 for (i = 0; i < dht->num_friends; ++i) { 980 for (i = 0; i < dht->num_friends; ++i) {
981 _Bool store_ok = 0; 981 bool store_ok = 0;
982 982
983 DHT_Friend *friend = &dht->friends_list[i]; 983 DHT_Friend *friend = &dht->friends_list[i];
984 984
@@ -1572,7 +1572,7 @@ int DHT_getfriendip(const DHT *dht, const uint8_t *public_key, IP_Port *ip_port)
1572 1572
1573/* returns number of nodes not in kill-timeout */ 1573/* returns number of nodes not in kill-timeout */
1574static uint8_t do_ping_and_sendnode_requests(DHT *dht, uint64_t *lastgetnode, const uint8_t *public_key, 1574static uint8_t do_ping_and_sendnode_requests(DHT *dht, uint64_t *lastgetnode, const uint8_t *public_key,
1575 Client_data *list, uint32_t list_count, uint32_t *bootstrap_times, _Bool sortable) 1575 Client_data *list, uint32_t list_count, uint32_t *bootstrap_times, bool sortable)
1576{ 1576{
1577 uint32_t i; 1577 uint32_t i;
1578 uint8_t not_kill = 0; 1578 uint8_t not_kill = 0;
@@ -1582,7 +1582,7 @@ static uint8_t do_ping_and_sendnode_requests(DHT *dht, uint64_t *lastgetnode, co
1582 Client_data *client_list[list_count * 2]; 1582 Client_data *client_list[list_count * 2];
1583 IPPTsPng *assoc_list[list_count * 2]; 1583 IPPTsPng *assoc_list[list_count * 2];
1584 unsigned int sort = 0; 1584 unsigned int sort = 0;
1585 _Bool sort_ok = 0; 1585 bool sort_ok = 0;
1586 1586
1587 for (i = 0; i < list_count; i++) { 1587 for (i = 0; i < list_count; i++) {
1588 /* If node is not dead. */ 1588 /* If node is not dead. */