Skip to content

Commit 83d5d0d

Browse files
committed
cleanup: Remove useless parentheses.
1 parent fe7b467 commit 83d5d0d

File tree

8 files changed

+44
-48
lines changed

8 files changed

+44
-48
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
7e3bf0d47ff9440c7dd629b721b19846171c08b68762c043d6ce04b1b73ad8e0 /usr/local/bin/tox-bootstrapd
1+
35800dfd68ba005a6884d7fcf1d5a76614d7afa3d53a7bf12c6fd6398afa48fd /usr/local/bin/tox-bootstrapd

toxcore/DHT.c

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1505,29 +1505,33 @@ static int handle_sendnodes_ipv6(void *object, IP_Port source, const uint8_t *pa
15051505
/*----------------------------------------------------------------------------------*/
15061506
/*------------------------END of packet handling functions--------------------------*/
15071507

1508+
static void dht_friend_lock(DHT_Friend *const dht_friend, dht_ip_cb *ip_callback,
1509+
void *data, int32_t number, uint16_t *lock_count)
1510+
{
1511+
const uint16_t lock_num = dht_friend->lock_count;
1512+
++dht_friend->lock_count;
1513+
dht_friend->callbacks[lock_num].ip_callback = ip_callback;
1514+
dht_friend->callbacks[lock_num].data = data;
1515+
dht_friend->callbacks[lock_num].number = number;
1516+
1517+
if (lock_count) {
1518+
*lock_count = lock_num + 1;
1519+
}
1520+
}
1521+
15081522
int dht_addfriend(DHT *dht, const uint8_t *public_key, dht_ip_cb *ip_callback,
15091523
void *data, int32_t number, uint16_t *lock_count)
15101524
{
15111525
const uint32_t friend_num = index_of_friend_pk(dht->friends_list, dht->num_friends, public_key);
15121526

1513-
uint16_t lock_num;
1514-
15151527
if (friend_num != UINT32_MAX) { /* Is friend already in DHT? */
15161528
DHT_Friend *const dht_friend = &dht->friends_list[friend_num];
15171529

15181530
if (dht_friend->lock_count == DHT_FRIEND_MAX_LOCKS) {
15191531
return -1;
15201532
}
15211533

1522-
lock_num = dht_friend->lock_count;
1523-
++dht_friend->lock_count;
1524-
dht_friend->callbacks[lock_num].ip_callback = ip_callback;
1525-
dht_friend->callbacks[lock_num].data = data;
1526-
dht_friend->callbacks[lock_num].number = number;
1527-
1528-
if (lock_count) {
1529-
*lock_count = lock_num + 1;
1530-
}
1534+
dht_friend_lock(dht_friend, ip_callback, data, number, lock_count);
15311535

15321536
return 0;
15331537
}
@@ -1546,15 +1550,7 @@ int dht_addfriend(DHT *dht, const uint8_t *public_key, dht_ip_cb *ip_callback,
15461550
dht_friend->nat.nat_ping_id = random_u64();
15471551
++dht->num_friends;
15481552

1549-
lock_num = dht_friend->lock_count;
1550-
++dht_friend->lock_count;
1551-
dht_friend->callbacks[lock_num].ip_callback = ip_callback;
1552-
dht_friend->callbacks[lock_num].data = data;
1553-
dht_friend->callbacks[lock_num].number = number;
1554-
1555-
if (lock_count) {
1556-
*lock_count = lock_num + 1;
1557-
}
1553+
dht_friend_lock(dht_friend, ip_callback, data, number, lock_count);
15581554

15591555
dht_friend->num_to_bootstrap = get_close_nodes(dht, dht_friend->public_key, dht_friend->to_bootstrap, net_family_unspec,
15601556
1);
@@ -1595,7 +1591,7 @@ int dht_delfriend(DHT *dht, const uint8_t *public_key, uint16_t lock_count)
15951591
return 0;
15961592
}
15971593

1598-
DHT_Friend *const temp = (DHT_Friend *)realloc(dht->friends_list, sizeof(DHT_Friend) * (dht->num_friends));
1594+
DHT_Friend *const temp = (DHT_Friend *)realloc(dht->friends_list, sizeof(DHT_Friend) * dht->num_friends);
15991595

16001596
if (temp == nullptr) {
16011597
return -1;

toxcore/Messenger.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2195,7 +2195,7 @@ static int m_handle_packet(void *object, int i, const uint8_t *temp, uint16_t le
21952195
uint8_t type = packet_id - PACKET_ID_MESSAGE;
21962196

21972197
if (m->friend_message) {
2198-
(*m->friend_message)(m, i, type, message_terminated, message_length, userdata);
2198+
m->friend_message(m, i, type, message_terminated, message_length, userdata);
21992199
}
22002200

22012201
break;
@@ -2207,7 +2207,7 @@ static int m_handle_packet(void *object, int i, const uint8_t *temp, uint16_t le
22072207
}
22082208

22092209
if (m->conference_invite) {
2210-
(*m->conference_invite)(m, i, data, data_length, userdata);
2210+
m->conference_invite(m, i, data, data_length, userdata);
22112211
}
22122212

22132213
break;
@@ -2269,8 +2269,8 @@ static int m_handle_packet(void *object, int i, const uint8_t *temp, uint16_t le
22692269
real_filenumber <<= 16;
22702270

22712271
if (m->file_sendrequest) {
2272-
(*m->file_sendrequest)(m, i, real_filenumber, file_type, filesize, filename, filename_length,
2273-
userdata);
2272+
m->file_sendrequest(m, i, real_filenumber, file_type, filesize, filename, filename_length,
2273+
userdata);
22742274
}
22752275

22762276
break;
@@ -2327,7 +2327,7 @@ static int m_handle_packet(void *object, int i, const uint8_t *temp, uint16_t le
23272327
uint32_t real_filenumber = filenumber;
23282328
real_filenumber += 1;
23292329
real_filenumber <<= 16;
2330-
uint16_t file_data_length = (data_length - 1);
2330+
uint16_t file_data_length = data_length - 1;
23312331
const uint8_t *file_data;
23322332

23332333
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
23422342
}
23432343

23442344
if (m->file_filedata) {
2345-
(*m->file_filedata)(m, i, real_filenumber, position, file_data, file_data_length, userdata);
2345+
m->file_filedata(m, i, real_filenumber, position, file_data, file_data_length, userdata);
23462346
}
23472347

23482348
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
23542354

23552355
/* Full file received. */
23562356
if (m->file_filedata) {
2357-
(*m->file_filedata)(m, i, real_filenumber, position, file_data, file_data_length, userdata);
2357+
m->file_filedata(m, i, real_filenumber, position, file_data, file_data_length, userdata);
23582358
}
23592359
}
23602360

@@ -2372,7 +2372,7 @@ static int m_handle_packet(void *object, int i, const uint8_t *temp, uint16_t le
23722372
}
23732373

23742374
if (m->msi_packet) {
2375-
(*m->msi_packet)(m, i, data, data_length, m->msi_packet_userdata);
2375+
m->msi_packet(m, i, data, data_length, m->msi_packet_userdata);
23762376
}
23772377

23782378
break;
@@ -2453,7 +2453,7 @@ static void connection_status_callback(Messenger *m, void *userdata)
24532453

24542454
if (conn_status != m->last_connection_status) {
24552455
if (m->core_connection_change) {
2456-
(*m->core_connection_change)(m, conn_status, userdata);
2456+
m->core_connection_change(m, conn_status, userdata);
24572457
}
24582458

24592459
m->last_connection_status = conn_status;

toxcore/TCP_connection.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ int get_random_tcp_onion_conn_number(TCP_Connections *tcp_c)
377377
const uint32_t r = random_u32();
378378

379379
for (uint32_t i = 0; i < tcp_c->tcp_connections_length; ++i) {
380-
uint32_t index = ((i + r) % tcp_c->tcp_connections_length);
380+
uint32_t index = (i + r) % tcp_c->tcp_connections_length;
381381

382382
if (tcp_c->tcp_connections[index].onion && tcp_c->tcp_connections[index].status == TCP_CONN_CONNECTED) {
383383
return index;

toxcore/group.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ static bool add_to_closest(Group_c *g, const uint8_t *real_pk, const uint8_t *te
298298

299299
comp_val = calculate_comp_value(real_pk, g->real_pk);
300300

301-
for (unsigned int i = (DESIRED_CLOSEST / 2); i < DESIRED_CLOSEST; ++i) {
301+
for (unsigned int i = DESIRED_CLOSEST / 2; i < DESIRED_CLOSEST; ++i) {
302302
uint64_t comp = calculate_comp_value(g->closest_peers[i].real_pk, g->real_pk);
303303

304304
if (comp > comp_val && comp > comp_d) {
@@ -486,7 +486,7 @@ static bool delete_frozen(Group_c *g, uint32_t frozen_index)
486486
g->frozen[frozen_index] = g->frozen[g->numfrozen];
487487
}
488488

489-
Group_Peer *const frozen_temp = (Group_Peer *)realloc(g->frozen, sizeof(Group_Peer) * (g->numfrozen));
489+
Group_Peer *const frozen_temp = (Group_Peer *)realloc(g->frozen, sizeof(Group_Peer) * g->numfrozen);
490490

491491
if (frozen_temp == nullptr) {
492492
return false;
@@ -731,7 +731,7 @@ static bool delpeer(Group_Chats *g_c, uint32_t groupnumber, int peer_index, void
731731
g->group[peer_index] = g->group[g->numpeers];
732732
}
733733

734-
Group_Peer *temp = (Group_Peer *)realloc(g->group, sizeof(Group_Peer) * (g->numpeers));
734+
Group_Peer *temp = (Group_Peer *)realloc(g->group, sizeof(Group_Peer) * g->numpeers);
735735

736736
if (temp == nullptr) {
737737
return false;
@@ -1549,7 +1549,7 @@ static bool send_invite_response(Group_Chats *g_c, int groupnumber, uint32_t fri
15491549
return false;
15501550
}
15511551

1552-
const bool member = (g->status == GROUPCHAT_STATUS_CONNECTED);
1552+
const bool member = g->status == GROUPCHAT_STATUS_CONNECTED;
15531553

15541554
VLA(uint8_t, response, member ? INVITE_MEMBER_PACKET_SIZE : INVITE_ACCEPT_PACKET_SIZE);
15551555
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
19341934

19351935
case INVITE_ACCEPT_ID:
19361936
case INVITE_MEMBER_ID: {
1937-
const bool member = (data[0] == INVITE_MEMBER_ID);
1937+
const bool member = data[0] == INVITE_MEMBER_ID;
19381938

19391939
if (length != (member ? INVITE_MEMBER_PACKET_SIZE : INVITE_ACCEPT_PACKET_SIZE)) {
19401940
return;
@@ -2551,7 +2551,7 @@ int send_group_lossy_packet(const Group_Chats *g_c, uint32_t groupnumber, const
25512551

25522552
static Message_Info *find_message_slot_or_reject(uint32_t message_number, uint8_t message_id, Group_Peer *peer)
25532553
{
2554-
const bool ignore_older = (message_id == GROUP_MESSAGE_NAME_ID || message_id == GROUP_MESSAGE_TITLE_ID);
2554+
const bool ignore_older = message_id == GROUP_MESSAGE_NAME_ID || message_id == GROUP_MESSAGE_TITLE_ID;
25552555

25562556
Message_Info *i;
25572557

toxcore/list.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ static int find(const BS_List *list, const uint8_t *data)
7474
return list_index(i);
7575
}
7676

77-
delta = (delta) / 2;
77+
delta = delta / 2;
7878

7979
if (delta == 0) {
8080
delta = 1;
@@ -90,7 +90,7 @@ static int find(const BS_List *list, const uint8_t *data)
9090
// move up
9191
i -= delta;
9292

93-
delta = (delta) / 2;
93+
delta = delta / 2;
9494

9595
if (delta == 0) {
9696
delta = 1;

toxcore/net_crypto.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2510,8 +2510,8 @@ static void send_crypto_packets(Net_Crypto *c)
25102510

25112511
if (conn->status == CRYPTO_CONN_ESTABLISHED) {
25122512
if (conn->packet_recv_rate > CRYPTO_PACKET_MIN_RATE) {
2513-
double request_packet_interval = (REQUEST_PACKETS_COMPARE_CONSTANT / ((num_packets_array(
2514-
&conn->recv_array) + 1.0) / (conn->packet_recv_rate + 1.0)));
2513+
double request_packet_interval = REQUEST_PACKETS_COMPARE_CONSTANT / ((num_packets_array(
2514+
&conn->recv_array) + 1.0) / (conn->packet_recv_rate + 1.0));
25152515

25162516
double request_packet_interval2 = ((CRYPTO_PACKET_MIN_RATE / conn->packet_recv_rate) *
25172517
(double)CRYPTO_SEND_PACKET_INTERVAL) + (double)PACKET_COUNTER_AVERAGE_INTERVAL;
@@ -2581,7 +2581,7 @@ static void send_crypto_packets(Net_Crypto *c)
25812581

25822582
// TODO(irungentoo): use real delay
25832583
unsigned int delay = (unsigned int)(((double)conn->rtt_time / PACKET_COUNTER_AVERAGE_INTERVAL) + 0.5);
2584-
unsigned int packets_set_rem_array = (CONGESTION_LAST_SENT_ARRAY_SIZE - CONGESTION_QUEUE_ARRAY_SIZE);
2584+
unsigned int packets_set_rem_array = CONGESTION_LAST_SENT_ARRAY_SIZE - CONGESTION_QUEUE_ARRAY_SIZE;
25852585

25862586
if (delay > packets_set_rem_array) {
25872587
delay = packets_set_rem_array;
@@ -2603,17 +2603,17 @@ static void send_crypto_packets(Net_Crypto *c)
26032603

26042604
/* if queue is too big only allow resending packets. */
26052605
uint32_t npackets = num_packets_array(&conn->send_array);
2606-
double min_speed = 1000.0 * (((double)(total_sent)) / ((double)(CONGESTION_QUEUE_ARRAY_SIZE) *
2606+
double min_speed = 1000.0 * (((double)total_sent) / ((double)CONGESTION_QUEUE_ARRAY_SIZE *
26072607
PACKET_COUNTER_AVERAGE_INTERVAL));
26082608

2609-
double min_speed_request = 1000.0 * (((double)(total_sent + total_resent)) / ((double)(
2610-
CONGESTION_QUEUE_ARRAY_SIZE) * PACKET_COUNTER_AVERAGE_INTERVAL));
2609+
double min_speed_request = 1000.0 * (((double)(total_sent + total_resent)) / (
2610+
(double)CONGESTION_QUEUE_ARRAY_SIZE * PACKET_COUNTER_AVERAGE_INTERVAL));
26112611

26122612
if (min_speed < CRYPTO_PACKET_MIN_RATE) {
26132613
min_speed = CRYPTO_PACKET_MIN_RATE;
26142614
}
26152615

2616-
double send_array_ratio = (((double)npackets) / min_speed);
2616+
double send_array_ratio = (double)npackets / min_speed;
26172617

26182618
// TODO(irungentoo): Improve formula?
26192619
if (send_array_ratio > SEND_QUEUE_RATIO && CRYPTO_MIN_QUEUE_LENGTH < npackets) {

toxcore/onion.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ static int handle_send_2(void *object, IP_Port source, const uint8_t *packet, ui
480480

481481
uint8_t data[ONION_MAX_PACKET_SIZE];
482482
memcpy(data, plain + SIZE_IPPORT, len - SIZE_IPPORT);
483-
uint16_t data_len = (len - SIZE_IPPORT);
483+
uint16_t data_len = len - SIZE_IPPORT;
484484
uint8_t *ret_part = data + (len - SIZE_IPPORT);
485485
random_nonce(ret_part);
486486
uint8_t ret_data[RETURN_2 + SIZE_IPPORT];

0 commit comments

Comments
 (0)