diff --git a/toxcore/Lossless_UDP.c b/toxcore/Lossless_UDP.c index ca8ba8e0..01f9ccc2 100644 --- a/toxcore/Lossless_UDP.c +++ b/toxcore/Lossless_UDP.c @@ -480,19 +480,19 @@ uint32_t recvqueue(Lossless_UDP *ludp, int connection_id) } /* return the id of the next packet in the queue. - * return -1 if no packet in queue. + * return ~0 if no packet in queue. */ -char id_packet(Lossless_UDP *ludp, int connection_id) +uint8_t id_packet(Lossless_UDP *ludp, int connection_id) { if (recvqueue(ludp, connection_id) == 0) - return -1; + return ~0; Connection *connection = &tox_array_get(&ludp->connections, connection_id, Connection); if (connection->status != LUDP_NO_CONNECTION) return connection->recvbuffer[connection->successful_read % connection->recvbuffer_length].data[0]; - return -1; + return ~0; } /* return 0 if there is no received data in the buffer. diff --git a/toxcore/Lossless_UDP.h b/toxcore/Lossless_UDP.h index d4d6ec4e..b23d602a 100644 --- a/toxcore/Lossless_UDP.h +++ b/toxcore/Lossless_UDP.h @@ -198,7 +198,7 @@ IP_Port connection_ip(Lossless_UDP *ludp, int connection_id); /* returns the id of the next packet in the queue. * return -1 if no packet in queue. */ -char id_packet(Lossless_UDP *ludp, int connection_id); +uint8_t id_packet(Lossless_UDP *ludp, int connection_id); /* return 0 if there is no received data in the buffer. * return length of received packet if successful. diff --git a/toxcore/net_crypto.c b/toxcore/net_crypto.c index 6b64c1b6..9b0f0443 100644 --- a/toxcore/net_crypto.c +++ b/toxcore/net_crypto.c @@ -753,7 +753,7 @@ static void receive_crypto(Net_Crypto *c) c->crypto_connections[i].status = CRYPTO_CONN_TIMED_OUT; } } else if (id_packet(c->lossless_udp, - c->crypto_connections[i].number) != -1) { + c->crypto_connections[i].number) != (uint8_t)~0) { /* This should not happen, timeout the connection if it does. */ c->crypto_connections[i].status = CRYPTO_CONN_TIMED_OUT; } @@ -782,7 +782,7 @@ static void receive_crypto(Net_Crypto *c) /* This should not happen, timeout the connection if it does. */ c->crypto_connections[i].status = CRYPTO_CONN_TIMED_OUT; } - } else if (id_packet(c->lossless_udp, c->crypto_connections[i].number) != -1) { + } else if (id_packet(c->lossless_udp, c->crypto_connections[i].number) != (uint8_t)~0) { /* This should not happen, timeout the connection if it does. */ c->crypto_connections[i].status = CRYPTO_CONN_TIMED_OUT; }