summaryrefslogtreecommitdiff
path: root/toxcore/net_crypto.c
diff options
context:
space:
mode:
authoriphydf <iphydf@users.noreply.github.com>2018-06-17 19:10:15 +0000
committeriphydf <iphydf@users.noreply.github.com>2018-06-17 19:10:15 +0000
commita725d7323514db49b3e5dd626445ef2760e51d43 (patch)
tree7675ceb7a40c828181d8961adc8d8547d3f52ad7 /toxcore/net_crypto.c
parent2f80e2206cf33797264916b4e4a1f4be32d9c399 (diff)
Minor cleanup: return early on error condition.
Diffstat (limited to 'toxcore/net_crypto.c')
-rw-r--r--toxcore/net_crypto.c26
1 files changed, 10 insertions, 16 deletions
diff --git a/toxcore/net_crypto.c b/toxcore/net_crypto.c
index eca2f914..ead5a04c 100644
--- a/toxcore/net_crypto.c
+++ b/toxcore/net_crypto.c
@@ -2063,25 +2063,19 @@ int set_direct_ip_port(Net_Crypto *c, int crypt_connection_id, IP_Port ip_port,
2063 return -1; 2063 return -1;
2064 } 2064 }
2065 2065
2066 if (add_ip_port_connection(c, crypt_connection_id, ip_port) == 0) { 2066 if (add_ip_port_connection(c, crypt_connection_id, ip_port) != 0) {
2067 if (connected) { 2067 return -1;
2068 if (net_family_is_ipv4(ip_port.ip.family)) { 2068 }
2069 conn->direct_lastrecv_timev4 = unix_time();
2070 } else {
2071 conn->direct_lastrecv_timev6 = unix_time();
2072 }
2073 } else {
2074 if (net_family_is_ipv4(ip_port.ip.family)) {
2075 conn->direct_lastrecv_timev4 = 0;
2076 } else {
2077 conn->direct_lastrecv_timev6 = 0;
2078 }
2079 }
2080 2069
2081 return 0; 2070 const uint64_t direct_lastrecv_time = connected ? unix_time() : 0;
2071
2072 if (net_family_is_ipv4(ip_port.ip.family)) {
2073 conn->direct_lastrecv_timev4 = direct_lastrecv_time;
2074 } else {
2075 conn->direct_lastrecv_timev6 = direct_lastrecv_time;
2082 } 2076 }
2083 2077
2084 return -1; 2078 return 0;
2085} 2079}
2086 2080
2087 2081