summaryrefslogtreecommitdiff
path: root/toxcore/onion_client.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/onion_client.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/onion_client.c')
-rw-r--r--toxcore/onion_client.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/toxcore/onion_client.c b/toxcore/onion_client.c
index 9d573240..851a0ee1 100644
--- a/toxcore/onion_client.c
+++ b/toxcore/onion_client.c
@@ -341,7 +341,9 @@ static int send_onion_packet_tcp_udp(const Onion_Client *onion_c, const Onion_Pa
341 } 341 }
342 342
343 return 0; 343 return 0;
344 } else if (path->ip_port1.ip.family == TCP_FAMILY) { 344 }
345
346 if (path->ip_port1.ip.family == TCP_FAMILY) {
345 uint8_t packet[ONION_MAX_PACKET_SIZE]; 347 uint8_t packet[ONION_MAX_PACKET_SIZE];
346 int len = create_onion_packet_tcp(packet, sizeof(packet), path, dest, data, length); 348 int len = create_onion_packet_tcp(packet, sizeof(packet), path, dest, data, length);
347 349
@@ -350,9 +352,9 @@ static int send_onion_packet_tcp_udp(const Onion_Client *onion_c, const Onion_Pa
350 } 352 }
351 353
352 return send_tcp_onion_request(onion_c->c, path->ip_port1.ip.ip4.uint32, packet, len); 354 return send_tcp_onion_request(onion_c->c, path->ip_port1.ip.ip4.uint32, packet, len);
353 } else {
354 return -1;
355 } 355 }
356
357 return -1;
356} 358}
357 359
358/* Creates a sendback for use in an announce request. 360/* Creates a sendback for use in an announce request.
@@ -453,7 +455,6 @@ static int client_send_announce_request(Onion_Client *onion_c, uint32_t num, IP_
453 if (num == 0) { 455 if (num == 0) {
454 len = create_announce_request(request, sizeof(request), dest_pubkey, onion_c->c->self_public_key, 456 len = create_announce_request(request, sizeof(request), dest_pubkey, onion_c->c->self_public_key,
455 onion_c->c->self_secret_key, ping_id, onion_c->c->self_public_key, onion_c->temp_public_key, sendback); 457 onion_c->c->self_secret_key, ping_id, onion_c->c->self_public_key, onion_c->temp_public_key, sendback);
456
457 } else { 458 } else {
458 len = create_announce_request(request, sizeof(request), dest_pubkey, onion_c->friends_list[num - 1].temp_public_key, 459 len = create_announce_request(request, sizeof(request), dest_pubkey, onion_c->friends_list[num - 1].temp_public_key,
459 onion_c->friends_list[num - 1].temp_secret_key, ping_id, onion_c->friends_list[num - 1].real_public_key, zero_ping_id, 460 onion_c->friends_list[num - 1].temp_secret_key, ping_id, onion_c->friends_list[num - 1].real_public_key, zero_ping_id,
@@ -520,7 +521,6 @@ static int client_add_to_list(Onion_Client *onion_c, uint32_t num, const uint8_t
520 if (is_stored == 1 && public_key_cmp(pingid_or_key, onion_c->temp_public_key) != 0) { 521 if (is_stored == 1 && public_key_cmp(pingid_or_key, onion_c->temp_public_key) != 0) {
521 is_stored = 0; 522 is_stored = 0;
522 } 523 }
523
524 } else { 524 } else {
525 if (is_stored >= 2) { 525 if (is_stored >= 2) {
526 return -1; 526 return -1;
@@ -841,7 +841,9 @@ static int handle_tcp_onion(void *object, const uint8_t *data, uint16_t length,
841 841
842 if (data[0] == NET_PACKET_ANNOUNCE_RESPONSE) { 842 if (data[0] == NET_PACKET_ANNOUNCE_RESPONSE) {
843 return handle_announce_response(object, ip_port, data, length, userdata); 843 return handle_announce_response(object, ip_port, data, length, userdata);
844 } else if (data[0] == NET_PACKET_ONION_DATA_RESPONSE) { 844 }
845
846 if (data[0] == NET_PACKET_ONION_DATA_RESPONSE) {
845 return handle_data_response(object, ip_port, data, length, userdata); 847 return handle_data_response(object, ip_port, data, length, userdata);
846 } 848 }
847 849
@@ -1418,7 +1420,6 @@ static void do_friend(Onion_Client *onion_c, uint16_t friendnum)
1418 onion_c->friends_list[friendnum].last_dht_pk_dht_sent = unix_time(); 1420 onion_c->friends_list[friendnum].last_dht_pk_dht_sent = unix_time();
1419 } 1421 }
1420 } 1422 }
1421
1422 } 1423 }
1423} 1424}
1424 1425
@@ -1541,9 +1542,9 @@ unsigned int onion_connection_status(const Onion_Client *onion_c)
1541 if (onion_c->onion_connected >= ONION_CONNECTION_SECONDS) { 1542 if (onion_c->onion_connected >= ONION_CONNECTION_SECONDS) {
1542 if (onion_c->UDP_connected) { 1543 if (onion_c->UDP_connected) {
1543 return 2; 1544 return 2;
1544 } else {
1545 return 1;
1546 } 1545 }
1546
1547 return 1;
1547 } 1548 }
1548 1549
1549 return 0; 1550 return 0;
@@ -1566,7 +1567,6 @@ void do_onion_client(Onion_Client *onion_c)
1566 if (onion_c->onion_connected < ONION_CONNECTION_SECONDS * 2) { 1567 if (onion_c->onion_connected < ONION_CONNECTION_SECONDS * 2) {
1567 ++onion_c->onion_connected; 1568 ++onion_c->onion_connected;
1568 } 1569 }
1569
1570 } else { 1570 } else {
1571 populate_path_nodes_tcp(onion_c); 1571 populate_path_nodes_tcp(onion_c);
1572 1572