diff options
Diffstat (limited to 'toxcore/TCP_connection.c')
-rw-r--r-- | toxcore/TCP_connection.c | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/toxcore/TCP_connection.c b/toxcore/TCP_connection.c index 3dd8652e..adef3175 100644 --- a/toxcore/TCP_connection.c +++ b/toxcore/TCP_connection.c | |||
@@ -100,44 +100,44 @@ static int realloc_TCP_con(TCP_con **array, size_t num) | |||
100 | } | 100 | } |
101 | 101 | ||
102 | 102 | ||
103 | /* return 1 if the connections_number is not valid. | 103 | /** |
104 | * return 0 if the connections_number is valid. | 104 | * Return true if the connections_number is valid. |
105 | */ | 105 | */ |
106 | static bool connections_number_not_valid(const TCP_Connections *tcp_c, int connections_number) | 106 | static bool connections_number_is_valid(const TCP_Connections *tcp_c, int connections_number) |
107 | { | 107 | { |
108 | if ((unsigned int)connections_number >= tcp_c->connections_length) { | 108 | if ((unsigned int)connections_number >= tcp_c->connections_length) { |
109 | return 1; | 109 | return false; |
110 | } | 110 | } |
111 | 111 | ||
112 | if (tcp_c->connections == nullptr) { | 112 | if (tcp_c->connections == nullptr) { |
113 | return 1; | 113 | return false; |
114 | } | 114 | } |
115 | 115 | ||
116 | if (tcp_c->connections[connections_number].status == TCP_CONN_NONE) { | 116 | if (tcp_c->connections[connections_number].status == TCP_CONN_NONE) { |
117 | return 1; | 117 | return false; |
118 | } | 118 | } |
119 | 119 | ||
120 | return 0; | 120 | return true; |
121 | } | 121 | } |
122 | 122 | ||
123 | /* return 1 if the tcp_connections_number is not valid. | 123 | /** |
124 | * return 0 if the tcp_connections_number is valid. | 124 | * Return true if the tcp_connections_number is valid. |
125 | */ | 125 | */ |
126 | static bool tcp_connections_number_not_valid(const TCP_Connections *tcp_c, int tcp_connections_number) | 126 | static bool tcp_connections_number_is_valid(const TCP_Connections *tcp_c, int tcp_connections_number) |
127 | { | 127 | { |
128 | if ((unsigned int)tcp_connections_number >= tcp_c->tcp_connections_length) { | 128 | if ((unsigned int)tcp_connections_number >= tcp_c->tcp_connections_length) { |
129 | return 1; | 129 | return false; |
130 | } | 130 | } |
131 | 131 | ||
132 | if (tcp_c->tcp_connections == nullptr) { | 132 | if (tcp_c->tcp_connections == nullptr) { |
133 | return 1; | 133 | return false; |
134 | } | 134 | } |
135 | 135 | ||
136 | if (tcp_c->tcp_connections[tcp_connections_number].status == TCP_CONN_NONE) { | 136 | if (tcp_c->tcp_connections[tcp_connections_number].status == TCP_CONN_NONE) { |
137 | return 1; | 137 | return false; |
138 | } | 138 | } |
139 | 139 | ||
140 | return 0; | 140 | return true; |
141 | } | 141 | } |
142 | 142 | ||
143 | /* Create a new empty connection. | 143 | /* Create a new empty connection. |
@@ -199,7 +199,7 @@ static int create_tcp_connection(TCP_Connections *tcp_c) | |||
199 | */ | 199 | */ |
200 | static int wipe_connection(TCP_Connections *tcp_c, int connections_number) | 200 | static int wipe_connection(TCP_Connections *tcp_c, int connections_number) |
201 | { | 201 | { |
202 | if (connections_number_not_valid(tcp_c, connections_number)) { | 202 | if (!connections_number_is_valid(tcp_c, connections_number)) { |
203 | return -1; | 203 | return -1; |
204 | } | 204 | } |
205 | 205 | ||
@@ -227,7 +227,7 @@ static int wipe_connection(TCP_Connections *tcp_c, int connections_number) | |||
227 | */ | 227 | */ |
228 | static int wipe_tcp_connection(TCP_Connections *tcp_c, int tcp_connections_number) | 228 | static int wipe_tcp_connection(TCP_Connections *tcp_c, int tcp_connections_number) |
229 | { | 229 | { |
230 | if (tcp_connections_number_not_valid(tcp_c, tcp_connections_number)) { | 230 | if (!tcp_connections_number_is_valid(tcp_c, tcp_connections_number)) { |
231 | return -1; | 231 | return -1; |
232 | } | 232 | } |
233 | 233 | ||
@@ -250,7 +250,7 @@ static int wipe_tcp_connection(TCP_Connections *tcp_c, int tcp_connections_numbe | |||
250 | 250 | ||
251 | static TCP_Connection_to *get_connection(const TCP_Connections *tcp_c, int connections_number) | 251 | static TCP_Connection_to *get_connection(const TCP_Connections *tcp_c, int connections_number) |
252 | { | 252 | { |
253 | if (connections_number_not_valid(tcp_c, connections_number)) { | 253 | if (!connections_number_is_valid(tcp_c, connections_number)) { |
254 | return nullptr; | 254 | return nullptr; |
255 | } | 255 | } |
256 | 256 | ||
@@ -259,7 +259,7 @@ static TCP_Connection_to *get_connection(const TCP_Connections *tcp_c, int conne | |||
259 | 259 | ||
260 | static TCP_con *get_tcp_connection(const TCP_Connections *tcp_c, int tcp_connections_number) | 260 | static TCP_con *get_tcp_connection(const TCP_Connections *tcp_c, int tcp_connections_number) |
261 | { | 261 | { |
262 | if (tcp_connections_number_not_valid(tcp_c, tcp_connections_number)) { | 262 | if (!tcp_connections_number_is_valid(tcp_c, tcp_connections_number)) { |
263 | return nullptr; | 263 | return nullptr; |
264 | } | 264 | } |
265 | 265 | ||