diff options
author | Anony Moose <noMail@nomail.su> | 2013-08-26 20:36:32 +0000 |
---|---|---|
committer | Anony Moose <noMail@nomail.su> | 2013-08-26 20:36:32 +0000 |
commit | fefa2bdea02464cb10ff26e3451e880d5f866de1 (patch) | |
tree | c3bfe9cf8bb801e354c1bc9623ec3d9ae59cfcaa | |
parent | 79f759049bc2dca33e669061dca098e519adfcb7 (diff) |
connection_id can be negative, so it shouldn't be uint32_t.
-rw-r--r-- | testing/misc_tools.h | 2 | ||||
-rw-r--r-- | toxcore/Lossless_UDP.c | 10 | ||||
-rw-r--r-- | toxcore/Lossless_UDP.h | 4 |
3 files changed, 6 insertions, 10 deletions
diff --git a/testing/misc_tools.h b/testing/misc_tools.h index 272cca19..705f4aab 100644 --- a/testing/misc_tools.h +++ b/testing/misc_tools.h | |||
@@ -139,7 +139,7 @@ static inline uint8_t tox_array_push_ptr(tox_array *arr, uint8_t *item) | |||
139 | { | 139 | { |
140 | arr->data = realloc(arr->data, arr->elem_size * (arr->len+1)); | 140 | arr->data = realloc(arr->data, arr->elem_size * (arr->len+1)); |
141 | 141 | ||
142 | if (arr->data == NULL) | 142 | if (arr->data == NULL) /* didn't call tox_array_init() */ |
143 | return 0; | 143 | return 0; |
144 | 144 | ||
145 | if (item != NULL) | 145 | if (item != NULL) |
diff --git a/toxcore/Lossless_UDP.c b/toxcore/Lossless_UDP.c index 8ed25129..73df0e80 100644 --- a/toxcore/Lossless_UDP.c +++ b/toxcore/Lossless_UDP.c | |||
@@ -98,7 +98,7 @@ int new_connection(Lossless_UDP *ludp, IP_Port ip_port) | |||
98 | if (connect != -1) | 98 | if (connect != -1) |
99 | return connect; | 99 | return connect; |
100 | 100 | ||
101 | uint32_t connection_id = -1; | 101 | int connection_id = -1; |
102 | tox_array_for_each(&ludp->connections, Connection, tmp) { | 102 | tox_array_for_each(&ludp->connections, Connection, tmp) { |
103 | if (tmp.status == 0) { | 103 | if (tmp.status == 0) { |
104 | connection_id = tmp_i; | 104 | connection_id = tmp_i; |
@@ -147,7 +147,7 @@ static int new_inconnection(Lossless_UDP *ludp, IP_Port ip_port) | |||
147 | if (getconnection_id(ludp, ip_port) != -1) | 147 | if (getconnection_id(ludp, ip_port) != -1) |
148 | return -1; | 148 | return -1; |
149 | 149 | ||
150 | uint32_t connection_id = -1; | 150 | int connection_id = -1; |
151 | tox_array_for_each(&ludp->connections, Connection, tmp) { | 151 | tox_array_for_each(&ludp->connections, Connection, tmp) { |
152 | if (tmp.status == 0) { | 152 | if (tmp.status == 0) { |
153 | connection_id = tmp_i; | 153 | connection_id = tmp_i; |
@@ -384,7 +384,7 @@ static int send_handshake(Lossless_UDP *ludp, IP_Port ip_port, uint32_t handshak | |||
384 | return sendpacket(ludp->net->sock, ip_port, packet, sizeof(packet)); | 384 | return sendpacket(ludp->net->sock, ip_port, packet, sizeof(packet)); |
385 | } | 385 | } |
386 | 386 | ||
387 | static int send_SYNC(Lossless_UDP *ludp, uint32_t connection_id) | 387 | static int send_SYNC(Lossless_UDP *ludp, int connection_id) |
388 | { | 388 | { |
389 | Connection *connection = &tox_array_get(&ludp->connections, connection_id, Connection); | 389 | Connection *connection = &tox_array_get(&ludp->connections, connection_id, Connection); |
390 | 390 | ||
@@ -413,7 +413,7 @@ static int send_SYNC(Lossless_UDP *ludp, uint32_t connection_id) | |||
413 | 413 | ||
414 | } | 414 | } |
415 | 415 | ||
416 | static int send_data_packet(Lossless_UDP *ludp, uint32_t connection_id, uint32_t packet_num) | 416 | static int send_data_packet(Lossless_UDP *ludp, int connection_id, uint32_t packet_num) |
417 | { | 417 | { |
418 | Connection *connection = &tox_array_get(&ludp->connections, connection_id, Connection); | 418 | Connection *connection = &tox_array_get(&ludp->connections, connection_id, Connection); |
419 | 419 | ||
@@ -428,7 +428,7 @@ static int send_data_packet(Lossless_UDP *ludp, uint32_t connection_id, uint32_t | |||
428 | } | 428 | } |
429 | 429 | ||
430 | /* sends 1 data packet */ | 430 | /* sends 1 data packet */ |
431 | static int send_DATA(Lossless_UDP *ludp, uint32_t connection_id) | 431 | static int send_DATA(Lossless_UDP *ludp, int connection_id) |
432 | { | 432 | { |
433 | Connection *connection = &tox_array_get(&ludp->connections, connection_id, Connection); | 433 | Connection *connection = &tox_array_get(&ludp->connections, connection_id, Connection); |
434 | int ret; | 434 | int ret; |
diff --git a/toxcore/Lossless_UDP.h b/toxcore/Lossless_UDP.h index bd43cb67..ba89c2a1 100644 --- a/toxcore/Lossless_UDP.h +++ b/toxcore/Lossless_UDP.h | |||
@@ -122,10 +122,6 @@ typedef struct { | |||
122 | Networking_Core *net; | 122 | Networking_Core *net; |
123 | 123 | ||
124 | tox_array connections; | 124 | tox_array connections; |
125 | //kk Connection *connections; | ||
126 | |||
127 | //kk uint32_t connections_length; /* Length of connections array */ | ||
128 | //kk uint32_t connections_number; /* Number of connections in connections array */ | ||
129 | 125 | ||
130 | /* table of random numbers used in handshake_id. */ | 126 | /* table of random numbers used in handshake_id. */ |
131 | uint32_t randtable[6][256]; | 127 | uint32_t randtable[6][256]; |