diff options
author | iphydf <iphydf@users.noreply.github.com> | 2016-08-31 20:40:20 +0100 |
---|---|---|
committer | iphydf <iphydf@users.noreply.github.com> | 2016-09-02 11:02:56 +0100 |
commit | a9fbdaf46b23db5c598bf33d6bc5c4555b06e674 (patch) | |
tree | e7894501bd010d9904fe0069fc1b8121d2da4040 /toxcore/friend_connection.c | |
parent | 6f42eadc54e81be50b7a817c72b0cf4d7ec5feb4 (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/friend_connection.c')
-rw-r--r-- | toxcore/friend_connection.c | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/toxcore/friend_connection.c b/toxcore/friend_connection.c index 31a7d187..0779fb20 100644 --- a/toxcore/friend_connection.c +++ b/toxcore/friend_connection.c | |||
@@ -269,9 +269,9 @@ static int tcp_relay_node_callback(void *object, uint32_t number, IP_Port ip_por | |||
269 | 269 | ||
270 | if (friend_con->crypt_connection_id != -1) { | 270 | if (friend_con->crypt_connection_id != -1) { |
271 | return friend_add_tcp_relay(fr_c, number, ip_port, public_key); | 271 | return friend_add_tcp_relay(fr_c, number, ip_port, public_key); |
272 | } else { | ||
273 | return add_tcp_relay(fr_c->net_crypto, ip_port, public_key); | ||
274 | } | 272 | } |
273 | |||
274 | return add_tcp_relay(fr_c->net_crypto, ip_port, public_key); | ||
275 | } | 275 | } |
276 | 276 | ||
277 | static int friend_new_connection(Friend_Connections *fr_c, int friendcon_id); | 277 | static int friend_new_connection(Friend_Connections *fr_c, int friendcon_id); |
@@ -411,10 +411,14 @@ static int handle_packet(void *object, int number, uint8_t *data, uint16_t lengt | |||
411 | } | 411 | } |
412 | 412 | ||
413 | return 0; | 413 | return 0; |
414 | } else if (data[0] == PACKET_ID_ALIVE) { | 414 | } |
415 | |||
416 | if (data[0] == PACKET_ID_ALIVE) { | ||
415 | friend_con->ping_lastrecv = unix_time(); | 417 | friend_con->ping_lastrecv = unix_time(); |
416 | return 0; | 418 | return 0; |
417 | } else if (data[0] == PACKET_ID_SHARE_RELAYS) { | 419 | } |
420 | |||
421 | if (data[0] == PACKET_ID_SHARE_RELAYS) { | ||
418 | Node_format nodes[MAX_SHARED_RELAYS]; | 422 | Node_format nodes[MAX_SHARED_RELAYS]; |
419 | int n; | 423 | int n; |
420 | 424 | ||
@@ -795,16 +799,16 @@ int send_friend_request_packet(Friend_Connections *fr_c, int friendcon_id, uint3 | |||
795 | if (friend_con->status == FRIENDCONN_STATUS_CONNECTED) { | 799 | if (friend_con->status == FRIENDCONN_STATUS_CONNECTED) { |
796 | packet[0] = PACKET_ID_FRIEND_REQUESTS; | 800 | packet[0] = PACKET_ID_FRIEND_REQUESTS; |
797 | return write_cryptpacket(fr_c->net_crypto, friend_con->crypt_connection_id, packet, sizeof(packet), 0) != -1; | 801 | return write_cryptpacket(fr_c->net_crypto, friend_con->crypt_connection_id, packet, sizeof(packet), 0) != -1; |
798 | } else { | 802 | } |
799 | packet[0] = CRYPTO_PACKET_FRIEND_REQ; | ||
800 | int num = send_onion_data(fr_c->onion_c, friend_con->onion_friendnum, packet, sizeof(packet)); | ||
801 | 803 | ||
802 | if (num <= 0) { | 804 | packet[0] = CRYPTO_PACKET_FRIEND_REQ; |
803 | return -1; | 805 | int num = send_onion_data(fr_c->onion_c, friend_con->onion_friendnum, packet, sizeof(packet)); |
804 | } | ||
805 | 806 | ||
806 | return num; | 807 | if (num <= 0) { |
808 | return -1; | ||
807 | } | 809 | } |
810 | |||
811 | return num; | ||
808 | } | 812 | } |
809 | 813 | ||
810 | /* Create new friend_connections instance. */ | 814 | /* Create new friend_connections instance. */ |
@@ -867,7 +871,6 @@ void do_friend_connections(Friend_Connections *fr_c) | |||
867 | connect_to_saved_tcp_relays(fr_c, i, (MAX_FRIEND_TCP_CONNECTIONS / 2)); /* Only fill it half up. */ | 871 | connect_to_saved_tcp_relays(fr_c, i, (MAX_FRIEND_TCP_CONNECTIONS / 2)); /* Only fill it half up. */ |
868 | } | 872 | } |
869 | } | 873 | } |
870 | |||
871 | } else if (friend_con->status == FRIENDCONN_STATUS_CONNECTED) { | 874 | } else if (friend_con->status == FRIENDCONN_STATUS_CONNECTED) { |
872 | if (friend_con->ping_lastsent + FRIEND_PING_INTERVAL < temp_time) { | 875 | if (friend_con->ping_lastsent + FRIEND_PING_INTERVAL < temp_time) { |
873 | send_ping(fr_c, i); | 876 | send_ping(fr_c, i); |