From 48bd200acbf4b4d8f3fa241373477b3a21001d17 Mon Sep 17 00:00:00 2001 From: iphydf Date: Tue, 5 May 2020 22:28:59 +0100 Subject: refactor: Disallow multiple initialised declarators per decl. We no longer allow: ```c int a = 0, b = 0; int a[3], b[3]; int a, *b; ``` But we do still allow (for now): ```c int a, b; ``` --- toxcore/net_crypto.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'toxcore/net_crypto.c') diff --git a/toxcore/net_crypto.c b/toxcore/net_crypto.c index f57886a8..3ed46a99 100644 --- a/toxcore/net_crypto.c +++ b/toxcore/net_crypto.c @@ -617,7 +617,8 @@ static IP_Port return_ip_port_connection(Net_Crypto *c, int crypt_connection_id) } const uint64_t current_time = mono_time_get(c->mono_time); - bool v6 = 0, v4 = 0; + bool v6 = 0; + bool v4 = 0; if ((UDP_DIRECT_TIMEOUT + conn->direct_lastrecv_timev4) > current_time) { v4 = 1; @@ -932,9 +933,9 @@ static int generate_request_packet(const Logger *log, uint8_t *data, uint16_t le return cur_len; } - uint32_t i, n = 1; + uint32_t n = 1; - for (i = recv_array->buffer_start; i != recv_array->buffer_end; ++i) { + for (uint32_t i = recv_array->buffer_start; i != recv_array->buffer_end; ++i) { uint32_t num = i % CRYPTO_PACKET_BUFFER_SIZE; if (!recv_array->buffer[num]) { @@ -1290,9 +1291,10 @@ static int send_requested_packets(Net_Crypto *c, int crypt_connection_id, uint32 } const uint64_t temp_time = current_time_monotonic(c->mono_time); - uint32_t i, num_sent = 0, array_size = num_packets_array(&conn->send_array); + const uint32_t array_size = num_packets_array(&conn->send_array); + uint32_t num_sent = 0; - for (i = 0; i < array_size; ++i) { + for (uint32_t i = 0; i < array_size; ++i) { Packet_Data *dt; const uint32_t packet_num = i + conn->send_array.buffer_start; const int ret = get_data_pointer(c->log, &conn->send_array, &dt, packet_num); @@ -2586,7 +2588,8 @@ static void send_crypto_packets(Net_Crypto *c) /* When switching from TCP to UDP, don't change the packet send rate for CONGESTION_EVENT_TIMEOUT ms. */ if (!(direct_connected && conn->last_tcp_sent + CONGESTION_EVENT_TIMEOUT > temp_time)) { - long signed int total_sent = 0, total_resent = 0; + long signed int total_sent = 0; + long signed int total_resent = 0; // TODO(irungentoo): use real delay unsigned int delay = (unsigned int)((conn->rtt_time / PACKET_COUNTER_AVERAGE_INTERVAL) + 0.5); -- cgit v1.2.3