summaryrefslogtreecommitdiff
path: root/toxcore/DHT.c
diff options
context:
space:
mode:
authorirungentoo <irungentoo@gmail.com>2013-09-02 09:55:37 -0400
committerirungentoo <irungentoo@gmail.com>2013-09-02 09:55:37 -0400
commit52336565612207fdb2d2068989da936b5b83ceeb (patch)
treec1c3c9ceb9c09d6d4a42d13aba294e53453d5b30 /toxcore/DHT.c
parent36a3b02f63aedeeb09105832ba75252bc06b8598 (diff)
Properly fixed signed/unsigned comparisons.
Diffstat (limited to 'toxcore/DHT.c')
-rw-r--r--toxcore/DHT.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/toxcore/DHT.c b/toxcore/DHT.c
index 9d5be369..4ed437bb 100644
--- a/toxcore/DHT.c
+++ b/toxcore/DHT.c
@@ -544,9 +544,9 @@ static int sendnodes(DHT *dht, IP_Port ip_port, uint8_t *public_key, uint8_t *cl
544 encrypt ); 544 encrypt );
545 545
546 if (len == -1) 546 if (len == -1)
547 return -1; 547 return -1;
548 548
549 if ((uint32_t)len != sizeof(ping_id) + num_nodes * sizeof(Node_format) + ENCRYPTION_PADDING) 549 if ((unsigned int)len != sizeof(ping_id) + num_nodes * sizeof(Node_format) + ENCRYPTION_PADDING)
550 return -1; 550 return -1;
551 551
552 data[0] = NET_PACKET_SEND_NODES; 552 data[0] = NET_PACKET_SEND_NODES;
@@ -612,10 +612,7 @@ static int handle_sendnodes(void *object, IP_Port source, uint8_t *packet, uint3
612 packet + 1 + CLIENT_ID_SIZE + crypto_box_NONCEBYTES, 612 packet + 1 + CLIENT_ID_SIZE + crypto_box_NONCEBYTES,
613 sizeof(ping_id) + num_nodes * sizeof(Node_format) + ENCRYPTION_PADDING, plain ); 613 sizeof(ping_id) + num_nodes * sizeof(Node_format) + ENCRYPTION_PADDING, plain );
614 614
615 if (len == -1) 615 if ((unsigned int)len != sizeof(ping_id) + num_nodes * sizeof(Node_format))
616 return -1;
617
618 if ((uint32_t)len != sizeof(ping_id) + num_nodes * sizeof(Node_format))
619 return 1; 616 return 1;
620 617
621 memcpy(&ping_id, plain, sizeof(ping_id)); 618 memcpy(&ping_id, plain, sizeof(ping_id));
@@ -883,8 +880,9 @@ int route_tofriend(DHT *dht, uint8_t *friend_id, uint8_t *packet, uint32_t lengt
883 880
884 /* If ip is not zero and node is good */ 881 /* If ip is not zero and node is good */
885 if (client->ret_ip_port.ip.uint32 != 0 && !is_timeout(temp_time, client->ret_timestamp, BAD_NODE_TIMEOUT)) { 882 if (client->ret_ip_port.ip.uint32 != 0 && !is_timeout(temp_time, client->ret_timestamp, BAD_NODE_TIMEOUT)) {
886 int retval = sendpacket(dht->c->lossless_udp->net->sock, client->ip_port, packet, length); 883 int retval = sendpacket(dht->c->lossless_udp->net->sock, client->ip_port, packet, length);
887 if (retval != -1 && (uint32_t)retval == length) 884
885 if ((unsigned int)retval == length)
888 ++sent; 886 ++sent;
889 } 887 }
890 } 888 }
@@ -924,7 +922,8 @@ static int routeone_tofriend(DHT *dht, uint8_t *friend_id, uint8_t *packet, uint
924 return 0; 922 return 0;
925 923
926 int retval = sendpacket(dht->c->lossless_udp->net->sock, ip_list[rand() % n], packet, length); 924 int retval = sendpacket(dht->c->lossless_udp->net->sock, ip_list[rand() % n], packet, length);
927 if (retval != -1 && (uint32_t)retval == length) 925
926 if ((unsigned int)retval == length)
928 return 1; 927 return 1;
929 928
930 return 0; 929 return 0;