cleanup: Remove useless parentheses.

This commit is contained in:
iphydf 2022-01-06 17:11:39 +00:00
parent fe7b467df4
commit 83d5d0d280
No known key found for this signature in database
GPG Key ID: 3855DBA2D74403C9
8 changed files with 44 additions and 48 deletions

View File

@ -1 +1 @@
7e3bf0d47ff9440c7dd629b721b19846171c08b68762c043d6ce04b1b73ad8e0 /usr/local/bin/tox-bootstrapd
35800dfd68ba005a6884d7fcf1d5a76614d7afa3d53a7bf12c6fd6398afa48fd /usr/local/bin/tox-bootstrapd

View File

@ -1505,13 +1505,25 @@ static int handle_sendnodes_ipv6(void *object, IP_Port source, const uint8_t *pa
/*----------------------------------------------------------------------------------*/
/*------------------------END of packet handling functions--------------------------*/
static void dht_friend_lock(DHT_Friend *const dht_friend, dht_ip_cb *ip_callback,
void *data, int32_t number, uint16_t *lock_count)
{
const uint16_t lock_num = dht_friend->lock_count;
++dht_friend->lock_count;
dht_friend->callbacks[lock_num].ip_callback = ip_callback;
dht_friend->callbacks[lock_num].data = data;
dht_friend->callbacks[lock_num].number = number;
if (lock_count) {
*lock_count = lock_num + 1;
}
}
int dht_addfriend(DHT *dht, const uint8_t *public_key, dht_ip_cb *ip_callback,
void *data, int32_t number, uint16_t *lock_count)
{
const uint32_t friend_num = index_of_friend_pk(dht->friends_list, dht->num_friends, public_key);
uint16_t lock_num;
if (friend_num != UINT32_MAX) { /* Is friend already in DHT? */
DHT_Friend *const dht_friend = &dht->friends_list[friend_num];
@ -1519,15 +1531,7 @@ int dht_addfriend(DHT *dht, const uint8_t *public_key, dht_ip_cb *ip_callback,
return -1;
}
lock_num = dht_friend->lock_count;
++dht_friend->lock_count;
dht_friend->callbacks[lock_num].ip_callback = ip_callback;
dht_friend->callbacks[lock_num].data = data;
dht_friend->callbacks[lock_num].number = number;
if (lock_count) {
*lock_count = lock_num + 1;
}
dht_friend_lock(dht_friend, ip_callback, data, number, lock_count);
return 0;
}
@ -1546,15 +1550,7 @@ int dht_addfriend(DHT *dht, const uint8_t *public_key, dht_ip_cb *ip_callback,
dht_friend->nat.nat_ping_id = random_u64();
++dht->num_friends;
lock_num = dht_friend->lock_count;
++dht_friend->lock_count;
dht_friend->callbacks[lock_num].ip_callback = ip_callback;
dht_friend->callbacks[lock_num].data = data;
dht_friend->callbacks[lock_num].number = number;
if (lock_count) {
*lock_count = lock_num + 1;
}
dht_friend_lock(dht_friend, ip_callback, data, number, lock_count);
dht_friend->num_to_bootstrap = get_close_nodes(dht, dht_friend->public_key, dht_friend->to_bootstrap, net_family_unspec,
1);
@ -1595,7 +1591,7 @@ int dht_delfriend(DHT *dht, const uint8_t *public_key, uint16_t lock_count)
return 0;
}
DHT_Friend *const temp = (DHT_Friend *)realloc(dht->friends_list, sizeof(DHT_Friend) * (dht->num_friends));
DHT_Friend *const temp = (DHT_Friend *)realloc(dht->friends_list, sizeof(DHT_Friend) * dht->num_friends);
if (temp == nullptr) {
return -1;

View File

@ -2195,7 +2195,7 @@ static int m_handle_packet(void *object, int i, const uint8_t *temp, uint16_t le
uint8_t type = packet_id - PACKET_ID_MESSAGE;
if (m->friend_message) {
(*m->friend_message)(m, i, type, message_terminated, message_length, userdata);
m->friend_message(m, i, type, message_terminated, message_length, userdata);
}
break;
@ -2207,7 +2207,7 @@ static int m_handle_packet(void *object, int i, const uint8_t *temp, uint16_t le
}
if (m->conference_invite) {
(*m->conference_invite)(m, i, data, data_length, userdata);
m->conference_invite(m, i, data, data_length, userdata);
}
break;
@ -2269,8 +2269,8 @@ static int m_handle_packet(void *object, int i, const uint8_t *temp, uint16_t le
real_filenumber <<= 16;
if (m->file_sendrequest) {
(*m->file_sendrequest)(m, i, real_filenumber, file_type, filesize, filename, filename_length,
userdata);
m->file_sendrequest(m, i, real_filenumber, file_type, filesize, filename, filename_length,
userdata);
}
break;
@ -2327,7 +2327,7 @@ static int m_handle_packet(void *object, int i, const uint8_t *temp, uint16_t le
uint32_t real_filenumber = filenumber;
real_filenumber += 1;
real_filenumber <<= 16;
uint16_t file_data_length = (data_length - 1);
uint16_t file_data_length = data_length - 1;
const uint8_t *file_data;
if (file_data_length == 0) {
@ -2342,7 +2342,7 @@ static int m_handle_packet(void *object, int i, const uint8_t *temp, uint16_t le
}
if (m->file_filedata) {
(*m->file_filedata)(m, i, real_filenumber, position, file_data, file_data_length, userdata);
m->file_filedata(m, i, real_filenumber, position, file_data, file_data_length, userdata);
}
ft->transferred += file_data_length;
@ -2354,7 +2354,7 @@ static int m_handle_packet(void *object, int i, const uint8_t *temp, uint16_t le
/* Full file received. */
if (m->file_filedata) {
(*m->file_filedata)(m, i, real_filenumber, position, file_data, file_data_length, userdata);
m->file_filedata(m, i, real_filenumber, position, file_data, file_data_length, userdata);
}
}
@ -2372,7 +2372,7 @@ static int m_handle_packet(void *object, int i, const uint8_t *temp, uint16_t le
}
if (m->msi_packet) {
(*m->msi_packet)(m, i, data, data_length, m->msi_packet_userdata);
m->msi_packet(m, i, data, data_length, m->msi_packet_userdata);
}
break;
@ -2453,7 +2453,7 @@ static void connection_status_callback(Messenger *m, void *userdata)
if (conn_status != m->last_connection_status) {
if (m->core_connection_change) {
(*m->core_connection_change)(m, conn_status, userdata);
m->core_connection_change(m, conn_status, userdata);
}
m->last_connection_status = conn_status;

View File

@ -377,7 +377,7 @@ int get_random_tcp_onion_conn_number(TCP_Connections *tcp_c)
const uint32_t r = random_u32();
for (uint32_t i = 0; i < tcp_c->tcp_connections_length; ++i) {
uint32_t index = ((i + r) % tcp_c->tcp_connections_length);
uint32_t index = (i + r) % tcp_c->tcp_connections_length;
if (tcp_c->tcp_connections[index].onion && tcp_c->tcp_connections[index].status == TCP_CONN_CONNECTED) {
return index;

View File

@ -298,7 +298,7 @@ static bool add_to_closest(Group_c *g, const uint8_t *real_pk, const uint8_t *te
comp_val = calculate_comp_value(real_pk, g->real_pk);
for (unsigned int i = (DESIRED_CLOSEST / 2); i < DESIRED_CLOSEST; ++i) {
for (unsigned int i = DESIRED_CLOSEST / 2; i < DESIRED_CLOSEST; ++i) {
uint64_t comp = calculate_comp_value(g->closest_peers[i].real_pk, g->real_pk);
if (comp > comp_val && comp > comp_d) {
@ -486,7 +486,7 @@ static bool delete_frozen(Group_c *g, uint32_t frozen_index)
g->frozen[frozen_index] = g->frozen[g->numfrozen];
}
Group_Peer *const frozen_temp = (Group_Peer *)realloc(g->frozen, sizeof(Group_Peer) * (g->numfrozen));
Group_Peer *const frozen_temp = (Group_Peer *)realloc(g->frozen, sizeof(Group_Peer) * g->numfrozen);
if (frozen_temp == nullptr) {
return false;
@ -731,7 +731,7 @@ static bool delpeer(Group_Chats *g_c, uint32_t groupnumber, int peer_index, void
g->group[peer_index] = g->group[g->numpeers];
}
Group_Peer *temp = (Group_Peer *)realloc(g->group, sizeof(Group_Peer) * (g->numpeers));
Group_Peer *temp = (Group_Peer *)realloc(g->group, sizeof(Group_Peer) * g->numpeers);
if (temp == nullptr) {
return false;
@ -1549,7 +1549,7 @@ static bool send_invite_response(Group_Chats *g_c, int groupnumber, uint32_t fri
return false;
}
const bool member = (g->status == GROUPCHAT_STATUS_CONNECTED);
const bool member = g->status == GROUPCHAT_STATUS_CONNECTED;
VLA(uint8_t, response, member ? INVITE_MEMBER_PACKET_SIZE : INVITE_ACCEPT_PACKET_SIZE);
response[0] = member ? INVITE_MEMBER_ID : INVITE_ACCEPT_ID;
@ -1934,7 +1934,7 @@ static void handle_friend_invite_packet(Messenger *m, uint32_t friendnumber, con
case INVITE_ACCEPT_ID:
case INVITE_MEMBER_ID: {
const bool member = (data[0] == INVITE_MEMBER_ID);
const bool member = data[0] == INVITE_MEMBER_ID;
if (length != (member ? INVITE_MEMBER_PACKET_SIZE : INVITE_ACCEPT_PACKET_SIZE)) {
return;
@ -2551,7 +2551,7 @@ int send_group_lossy_packet(const Group_Chats *g_c, uint32_t groupnumber, const
static Message_Info *find_message_slot_or_reject(uint32_t message_number, uint8_t message_id, Group_Peer *peer)
{
const bool ignore_older = (message_id == GROUP_MESSAGE_NAME_ID || message_id == GROUP_MESSAGE_TITLE_ID);
const bool ignore_older = message_id == GROUP_MESSAGE_NAME_ID || message_id == GROUP_MESSAGE_TITLE_ID;
Message_Info *i;

View File

@ -74,7 +74,7 @@ static int find(const BS_List *list, const uint8_t *data)
return list_index(i);
}
delta = (delta) / 2;
delta = delta / 2;
if (delta == 0) {
delta = 1;
@ -90,7 +90,7 @@ static int find(const BS_List *list, const uint8_t *data)
// move up
i -= delta;
delta = (delta) / 2;
delta = delta / 2;
if (delta == 0) {
delta = 1;

View File

@ -2510,8 +2510,8 @@ static void send_crypto_packets(Net_Crypto *c)
if (conn->status == CRYPTO_CONN_ESTABLISHED) {
if (conn->packet_recv_rate > CRYPTO_PACKET_MIN_RATE) {
double request_packet_interval = (REQUEST_PACKETS_COMPARE_CONSTANT / ((num_packets_array(
&conn->recv_array) + 1.0) / (conn->packet_recv_rate + 1.0)));
double request_packet_interval = REQUEST_PACKETS_COMPARE_CONSTANT / ((num_packets_array(
&conn->recv_array) + 1.0) / (conn->packet_recv_rate + 1.0));
double request_packet_interval2 = ((CRYPTO_PACKET_MIN_RATE / conn->packet_recv_rate) *
(double)CRYPTO_SEND_PACKET_INTERVAL) + (double)PACKET_COUNTER_AVERAGE_INTERVAL;
@ -2581,7 +2581,7 @@ static void send_crypto_packets(Net_Crypto *c)
// TODO(irungentoo): use real delay
unsigned int delay = (unsigned int)(((double)conn->rtt_time / PACKET_COUNTER_AVERAGE_INTERVAL) + 0.5);
unsigned int packets_set_rem_array = (CONGESTION_LAST_SENT_ARRAY_SIZE - CONGESTION_QUEUE_ARRAY_SIZE);
unsigned int packets_set_rem_array = CONGESTION_LAST_SENT_ARRAY_SIZE - CONGESTION_QUEUE_ARRAY_SIZE;
if (delay > packets_set_rem_array) {
delay = packets_set_rem_array;
@ -2603,17 +2603,17 @@ static void send_crypto_packets(Net_Crypto *c)
/* if queue is too big only allow resending packets. */
uint32_t npackets = num_packets_array(&conn->send_array);
double min_speed = 1000.0 * (((double)(total_sent)) / ((double)(CONGESTION_QUEUE_ARRAY_SIZE) *
double min_speed = 1000.0 * (((double)total_sent) / ((double)CONGESTION_QUEUE_ARRAY_SIZE *
PACKET_COUNTER_AVERAGE_INTERVAL));
double min_speed_request = 1000.0 * (((double)(total_sent + total_resent)) / ((double)(
CONGESTION_QUEUE_ARRAY_SIZE) * PACKET_COUNTER_AVERAGE_INTERVAL));
double min_speed_request = 1000.0 * (((double)(total_sent + total_resent)) / (
(double)CONGESTION_QUEUE_ARRAY_SIZE * PACKET_COUNTER_AVERAGE_INTERVAL));
if (min_speed < CRYPTO_PACKET_MIN_RATE) {
min_speed = CRYPTO_PACKET_MIN_RATE;
}
double send_array_ratio = (((double)npackets) / min_speed);
double send_array_ratio = (double)npackets / min_speed;
// TODO(irungentoo): Improve formula?
if (send_array_ratio > SEND_QUEUE_RATIO && CRYPTO_MIN_QUEUE_LENGTH < npackets) {

View File

@ -480,7 +480,7 @@ static int handle_send_2(void *object, IP_Port source, const uint8_t *packet, ui
uint8_t data[ONION_MAX_PACKET_SIZE];
memcpy(data, plain + SIZE_IPPORT, len - SIZE_IPPORT);
uint16_t data_len = (len - SIZE_IPPORT);
uint16_t data_len = len - SIZE_IPPORT;
uint8_t *ret_part = data + (len - SIZE_IPPORT);
random_nonce(ret_part);
uint8_t ret_data[RETURN_2 + SIZE_IPPORT];