summaryrefslogtreecommitdiff
path: root/toxcore/DHT.c
diff options
context:
space:
mode:
authoriphydf <iphydf@users.noreply.github.com>2016-09-12 16:28:23 +0100
committeriphydf <iphydf@users.noreply.github.com>2016-09-12 16:30:00 +0100
commita365bef2aebd324c25da623c45313cc8d0a56b42 (patch)
treeb4bd3e81b32ab369ce15245dc81ce1ad1e53fed8 /toxcore/DHT.c
parent2db31d95fdd62ad0bf9ca02848527201f199b466 (diff)
Remove `else` directly after `return`.
See #78.
Diffstat (limited to 'toxcore/DHT.c')
-rw-r--r--toxcore/DHT.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/toxcore/DHT.c b/toxcore/DHT.c
index 1d9ad54f..f9910b06 100644
--- a/toxcore/DHT.c
+++ b/toxcore/DHT.c
@@ -273,7 +273,9 @@ static int pack_ip_port(uint8_t *data, uint16_t length, const IP_Port *ip_port)
273 memcpy(data + 1, &ip_port->ip.ip4, SIZE_IP4); 273 memcpy(data + 1, &ip_port->ip.ip4, SIZE_IP4);
274 memcpy(data + 1 + SIZE_IP4, &ip_port->port, sizeof(uint16_t)); 274 memcpy(data + 1 + SIZE_IP4, &ip_port->port, sizeof(uint16_t));
275 return size; 275 return size;
276 } else if (ipv6 == 1) { 276 }
277
278 if (ipv6 == 1) {
277 uint32_t size = 1 + SIZE_IP6 + sizeof(uint16_t); 279 uint32_t size = 1 + SIZE_IP6 + sizeof(uint16_t);
278 280
279 if (size > length) { 281 if (size > length) {
@@ -284,9 +286,9 @@ static int pack_ip_port(uint8_t *data, uint16_t length, const IP_Port *ip_port)
284 memcpy(data + 1, &ip_port->ip.ip6, SIZE_IP6); 286 memcpy(data + 1, &ip_port->ip.ip6, SIZE_IP6);
285 memcpy(data + 1 + SIZE_IP6, &ip_port->port, sizeof(uint16_t)); 287 memcpy(data + 1 + SIZE_IP6, &ip_port->port, sizeof(uint16_t));
286 return size; 288 return size;
287 } else {
288 return -1;
289 } 289 }
290
291 return -1;
290} 292}
291 293
292/* Unpack IP_Port structure from data of max size length into ip_port. 294/* Unpack IP_Port structure from data of max size length into ip_port.
@@ -338,7 +340,9 @@ static int unpack_ip_port(IP_Port *ip_port, const uint8_t *data, uint16_t length
338 memcpy(&ip_port->ip.ip4, data + 1, SIZE_IP4); 340 memcpy(&ip_port->ip.ip4, data + 1, SIZE_IP4);
339 memcpy(&ip_port->port, data + 1 + SIZE_IP4, sizeof(uint16_t)); 341 memcpy(&ip_port->port, data + 1 + SIZE_IP4, sizeof(uint16_t));
340 return size; 342 return size;
341 } else if (ipv6 == 1) { 343 }
344
345 if (ipv6 == 1) {
342 uint32_t size = 1 + SIZE_IP6 + sizeof(uint16_t); 346 uint32_t size = 1 + SIZE_IP6 + sizeof(uint16_t);
343 347
344 if (size > length) { 348 if (size > length) {
@@ -349,9 +353,9 @@ static int unpack_ip_port(IP_Port *ip_port, const uint8_t *data, uint16_t length
349 memcpy(&ip_port->ip.ip6, data + 1, SIZE_IP6); 353 memcpy(&ip_port->ip.ip6, data + 1, SIZE_IP6);
350 memcpy(&ip_port->port, data + 1 + SIZE_IP6, sizeof(uint16_t)); 354 memcpy(&ip_port->port, data + 1 + SIZE_IP6, sizeof(uint16_t));
351 return size; 355 return size;
352 } else {
353 return -1;
354 } 356 }
357
358 return -1;
355} 359}
356 360
357/* Pack number of nodes into data of maxlength length. 361/* Pack number of nodes into data of maxlength length.