Skip to content

Commit

Permalink
Remove else directly after return.
Browse files Browse the repository at this point in the history
  • Loading branch information
iphydf committed Sep 12, 2016
1 parent 2db31d9 commit 3b9bb5d
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions toxcore/DHT.c
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,9 @@ static int pack_ip_port(uint8_t *data, uint16_t length, const IP_Port *ip_port)
memcpy(data + 1, &ip_port->ip.ip4, SIZE_IP4);
memcpy(data + 1 + SIZE_IP4, &ip_port->port, sizeof(uint16_t));
return size;
} else if (ipv6 == 1) {
}

if (ipv6 == 1) {
uint32_t size = 1 + SIZE_IP6 + sizeof(uint16_t);

if (size > length) {
Expand All @@ -284,9 +286,10 @@ static int pack_ip_port(uint8_t *data, uint16_t length, const IP_Port *ip_port)
memcpy(data + 1, &ip_port->ip.ip6, SIZE_IP6);
memcpy(data + 1 + SIZE_IP6, &ip_port->port, sizeof(uint16_t));
return size;
} else {
return -1;
}

return -1;

}

/* Unpack IP_Port structure from data of max size length into ip_port.
Expand Down Expand Up @@ -338,7 +341,9 @@ static int unpack_ip_port(IP_Port *ip_port, const uint8_t *data, uint16_t length
memcpy(&ip_port->ip.ip4, data + 1, SIZE_IP4);
memcpy(&ip_port->port, data + 1 + SIZE_IP4, sizeof(uint16_t));
return size;
} else if (ipv6 == 1) {
}

if (ipv6 == 1) {
uint32_t size = 1 + SIZE_IP6 + sizeof(uint16_t);

if (size > length) {
Expand All @@ -349,9 +354,10 @@ static int unpack_ip_port(IP_Port *ip_port, const uint8_t *data, uint16_t length
memcpy(&ip_port->ip.ip6, data + 1, SIZE_IP6);
memcpy(&ip_port->port, data + 1 + SIZE_IP6, sizeof(uint16_t));
return size;
} else {
return -1;
}

return -1;

}

/* Pack number of nodes into data of maxlength length.
Expand Down

0 comments on commit 3b9bb5d

Please sign in to comment.