summaryrefslogtreecommitdiff
path: root/toxcore/net_crypto.c
diff options
context:
space:
mode:
Diffstat (limited to 'toxcore/net_crypto.c')
-rw-r--r--toxcore/net_crypto.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/toxcore/net_crypto.c b/toxcore/net_crypto.c
index fb69b768..2851053b 100644
--- a/toxcore/net_crypto.c
+++ b/toxcore/net_crypto.c
@@ -174,23 +174,23 @@ DHT *nc_get_dht(const Net_Crypto *c)
174 return c->dht; 174 return c->dht;
175} 175}
176 176
177static uint8_t crypt_connection_id_not_valid(const Net_Crypto *c, int crypt_connection_id) 177static bool crypt_connection_id_is_valid(const Net_Crypto *c, int crypt_connection_id)
178{ 178{
179 if ((uint32_t)crypt_connection_id >= c->crypto_connections_length) { 179 if ((uint32_t)crypt_connection_id >= c->crypto_connections_length) {
180 return 1; 180 return false;
181 } 181 }
182 182
183 if (c->crypto_connections == nullptr) { 183 if (c->crypto_connections == nullptr) {
184 return 1; 184 return false;
185 } 185 }
186 186
187 const Crypto_Conn_State status = c->crypto_connections[crypt_connection_id].status; 187 const Crypto_Conn_State status = c->crypto_connections[crypt_connection_id].status;
188 188
189 if (status == CRYPTO_CONN_NO_CONNECTION || status == CRYPTO_CONN_FREE) { 189 if (status == CRYPTO_CONN_NO_CONNECTION || status == CRYPTO_CONN_FREE) {
190 return 1; 190 return false;
191 } 191 }
192 192
193 return 0; 193 return true;
194} 194}
195 195
196/* cookie timeout in seconds */ 196/* cookie timeout in seconds */
@@ -555,7 +555,7 @@ static int handle_crypto_handshake(const Net_Crypto *c, uint8_t *nonce, uint8_t
555 555
556static Crypto_Connection *get_crypto_connection(const Net_Crypto *c, int crypt_connection_id) 556static Crypto_Connection *get_crypto_connection(const Net_Crypto *c, int crypt_connection_id)
557{ 557{
558 if (crypt_connection_id_not_valid(c, crypt_connection_id)) { 558 if (!crypt_connection_id_is_valid(c, crypt_connection_id)) {
559 return nullptr; 559 return nullptr;
560 } 560 }
561 561
@@ -1858,7 +1858,7 @@ static int wipe_crypto_connection(Net_Crypto *c, int crypt_connection_id)
1858static int getcryptconnection_id(const Net_Crypto *c, const uint8_t *public_key) 1858static int getcryptconnection_id(const Net_Crypto *c, const uint8_t *public_key)
1859{ 1859{
1860 for (uint32_t i = 0; i < c->crypto_connections_length; ++i) { 1860 for (uint32_t i = 0; i < c->crypto_connections_length; ++i) {
1861 if (crypt_connection_id_not_valid(c, i)) { 1861 if (!crypt_connection_id_is_valid(c, i)) {
1862 continue; 1862 continue;
1863 } 1863 }
1864 1864