summaryrefslogtreecommitdiff
path: root/toxcore/TCP_server.c
diff options
context:
space:
mode:
authoriphydf <iphydf@users.noreply.github.com>2016-08-31 20:40:20 +0100
committeriphydf <iphydf@users.noreply.github.com>2016-09-02 11:02:56 +0100
commita9fbdaf46b23db5c598bf33d6bc5c4555b06e674 (patch)
treee7894501bd010d9904fe0069fc1b8121d2da4040 /toxcore/TCP_server.c
parent6f42eadc54e81be50b7a817c72b0cf4d7ec5feb4 (diff)
Do not use `else` after `return`.
http://llvm.org/docs/CodingStandards.html#use-early-exits-and-continue-to-simplify-code
Diffstat (limited to 'toxcore/TCP_server.c')
-rw-r--r--toxcore/TCP_server.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/toxcore/TCP_server.c b/toxcore/TCP_server.c
index d689e817..81f884d8 100644
--- a/toxcore/TCP_server.c
+++ b/toxcore/TCP_server.c
@@ -325,7 +325,6 @@ static int send_pending_data_nonpriority(TCP_Secure_Connection *con)
325 325
326 con->last_packet_sent += len; 326 con->last_packet_sent += len;
327 return -1; 327 return -1;
328
329} 328}
330 329
331/* return 0 if pending data was sent completely 330/* return 0 if pending data was sent completely
@@ -620,9 +619,9 @@ static int handle_TCP_routing_req(TCP_Server *TCP_server, uint32_t con_id, const
620 if (public_key_cmp(public_key, con->connections[i].public_key) == 0) { 619 if (public_key_cmp(public_key, con->connections[i].public_key) == 0) {
621 if (send_routing_response(con, i + NUM_RESERVED_PORTS, public_key) == -1) { 620 if (send_routing_response(con, i + NUM_RESERVED_PORTS, public_key) == -1) {
622 return -1; 621 return -1;
623 } else {
624 return 0;
625 } 622 }
623
624 return 0;
626 } 625 }
627 } else if (index == (uint32_t)~0) { 626 } else if (index == (uint32_t)~0) {
628 index = i; 627 index = i;
@@ -737,9 +736,9 @@ static int rm_connection_index(TCP_Server *TCP_server, TCP_Secure_Connection *co
737 con->connections[con_number].other_id = 0; 736 con->connections[con_number].other_id = 0;
738 con->connections[con_number].status = 0; 737 con->connections[con_number].status = 0;
739 return 0; 738 return 0;
740 } else {
741 return -1;
742 } 739 }
740
741 return -1;
743} 742}
744 743
745static int handle_onion_recv_1(void *object, IP_Port dest, const uint8_t *data, uint16_t length) 744static int handle_onion_recv_1(void *object, IP_Port dest, const uint8_t *data, uint16_t length)
@@ -830,9 +829,9 @@ static int handle_TCP_packet(TCP_Server *TCP_server, uint32_t con_id, const uint
830 } 829 }
831 830
832 return 0; 831 return 0;
833 } else {
834 return -1;
835 } 832 }
833
834 return -1;
836 } 835 }
837 836
838 case TCP_PACKET_OOB_SEND: { 837 case TCP_PACKET_OOB_SEND: {
@@ -1132,12 +1131,14 @@ static int do_unconfirmed(TCP_Server *TCP_server, uint32_t i)
1132 1131
1133 if (len == 0) { 1132 if (len == 0) {
1134 return -1; 1133 return -1;
1135 } else if (len == -1) { 1134 }
1135
1136 if (len == -1) {
1136 kill_TCP_connection(conn); 1137 kill_TCP_connection(conn);
1137 return -1; 1138 return -1;
1138 } else {
1139 return confirm_TCP_connection(TCP_server, conn, packet, len);
1140 } 1139 }
1140
1141 return confirm_TCP_connection(TCP_server, conn, packet, len);
1141} 1142}
1142 1143
1143static void do_confirmed_recv(TCP_Server *TCP_server, uint32_t i) 1144static void do_confirmed_recv(TCP_Server *TCP_server, uint32_t i)