summaryrefslogtreecommitdiff
path: root/toxcore/DHT.c
diff options
context:
space:
mode:
authorTyler Bunnell <tylerbunnell@gmail.com>2013-09-01 20:42:59 -0600
committerTyler Bunnell <tylerbunnell@gmail.com>2013-09-01 20:42:59 -0600
commitd1c52788c5d4ec5f782df02f6851a74f5dff7da2 (patch)
tree1454c1de8d9c1ae7d3a9b515076437decab5c4dc /toxcore/DHT.c
parent86c748e75552bfc5d57d7ae07d45b440000090d2 (diff)
Fix signed/unsigned comparison warnings
Diffstat (limited to 'toxcore/DHT.c')
-rw-r--r--toxcore/DHT.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/toxcore/DHT.c b/toxcore/DHT.c
index 50bddbd6..94168a69 100644
--- a/toxcore/DHT.c
+++ b/toxcore/DHT.c
@@ -543,7 +543,10 @@ static int sendnodes(DHT *dht, IP_Port ip_port, uint8_t *public_key, uint8_t *cl
543 sizeof(ping_id) + num_nodes * sizeof(Node_format), 543 sizeof(ping_id) + num_nodes * sizeof(Node_format),
544 encrypt ); 544 encrypt );
545 545
546 if (len != sizeof(ping_id) + num_nodes * sizeof(Node_format) + ENCRYPTION_PADDING) 546 if (len == -1)
547 return -1;
548
549 if ((uint32_t)len != sizeof(ping_id) + num_nodes * sizeof(Node_format) + ENCRYPTION_PADDING)
547 return -1; 550 return -1;
548 551
549 data[0] = NET_PACKET_SEND_NODES; 552 data[0] = NET_PACKET_SEND_NODES;
@@ -609,7 +612,10 @@ static int handle_sendnodes(void *object, IP_Port source, uint8_t *packet, uint3
609 packet + 1 + CLIENT_ID_SIZE + crypto_box_NONCEBYTES, 612 packet + 1 + CLIENT_ID_SIZE + crypto_box_NONCEBYTES,
610 sizeof(ping_id) + num_nodes * sizeof(Node_format) + ENCRYPTION_PADDING, plain ); 613 sizeof(ping_id) + num_nodes * sizeof(Node_format) + ENCRYPTION_PADDING, plain );
611 614
612 if (len != sizeof(ping_id) + num_nodes * sizeof(Node_format)) 615 if (len == -1)
616 return -1;
617
618 if ((uint32_t)len != sizeof(ping_id) + num_nodes * sizeof(Node_format))
613 return 1; 619 return 1;
614 620
615 memcpy(&ping_id, plain, sizeof(ping_id)); 621 memcpy(&ping_id, plain, sizeof(ping_id));
@@ -877,7 +883,8 @@ int route_tofriend(DHT *dht, uint8_t *friend_id, uint8_t *packet, uint32_t lengt
877 883
878 /* If ip is not zero and node is good */ 884 /* If ip is not zero and node is good */
879 if (client->ret_ip_port.ip.uint32 != 0 && !is_timeout(temp_time, client->ret_timestamp, BAD_NODE_TIMEOUT)) { 885 if (client->ret_ip_port.ip.uint32 != 0 && !is_timeout(temp_time, client->ret_timestamp, BAD_NODE_TIMEOUT)) {
880 if (sendpacket(dht->c->lossless_udp->net->sock, client->ip_port, packet, length) == length) 886 int retval = sendpacket(dht->c->lossless_udp->net->sock, client->ip_port, packet, length);
887 if (retval != -1 && (uint32_t)retval == length)
881 ++sent; 888 ++sent;
882 } 889 }
883 } 890 }
@@ -916,7 +923,8 @@ static int routeone_tofriend(DHT *dht, uint8_t *friend_id, uint8_t *packet, uint
916 if (n < 1) 923 if (n < 1)
917 return 0; 924 return 0;
918 925
919 if (sendpacket(dht->c->lossless_udp->net->sock, ip_list[rand() % n], packet, length) == length) 926 int retval = sendpacket(dht->c->lossless_udp->net->sock, ip_list[rand() % n], packet, length);
927 if (retval != -1 && (uint32_t)retval == length)
920 return 1; 928 return 1;
921 929
922 return 0; 930 return 0;