Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Remove multi-declarators entirely. #1514

Merged
merged 1 commit into from
May 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion other/bootstrap_daemon/docker/tox-bootstrapd.sha256
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20306177ad19b1b6ad84469331a06d1c5c01f7918a95517105545f76d3c90d82 /usr/local/bin/tox-bootstrapd
087432ee876325273dcb4015083adb88c46a55085a6d00741c6d7a2a385ea40c /usr/local/bin/tox-bootstrapd
6 changes: 4 additions & 2 deletions toxcore/DHT.c
Original file line number Diff line number Diff line change
Expand Up @@ -900,7 +900,8 @@ static bool incorrect_hardening(const IPPTsPng *assoc)

static int cmp_dht_entry(const void *a, const void *b)
{
DHT_Cmp_data cmp1, cmp2;
DHT_Cmp_data cmp1;
DHT_Cmp_data cmp2;
memcpy(&cmp1, a, sizeof(DHT_Cmp_data));
memcpy(&cmp2, b, sizeof(DHT_Cmp_data));
const Client_data entry1 = cmp1.entry;
Expand Down Expand Up @@ -2418,7 +2419,8 @@ static int handle_hardening(void *object, IP_Port source, const uint8_t *source_
return 1;
}

Node_format node, tocheck_node;
Node_format node;
Node_format tocheck_node;
node.ip_port = source;
memcpy(node.public_key, source_pubkey, CRYPTO_PUBLIC_KEY_SIZE);
memcpy(&tocheck_node, packet + 1, sizeof(Node_format));
Expand Down
22 changes: 11 additions & 11 deletions toxcore/Messenger.c
Original file line number Diff line number Diff line change
Expand Up @@ -1047,7 +1047,8 @@ int file_get_id(const Messenger *m, int32_t friendnumber, uint32_t filenumber, u
}

uint32_t temp_filenum;
uint8_t send_receive, file_number;
uint8_t send_receive;
uint8_t file_number;

if (filenumber >= (1 << 16)) {
send_receive = 1;
Expand Down Expand Up @@ -1209,7 +1210,8 @@ int file_control(const Messenger *m, int32_t friendnumber, uint32_t filenumber,
}

uint32_t temp_filenum;
uint8_t send_receive, file_number;
uint8_t send_receive;
uint8_t file_number;

if (filenumber >= (1 << 16)) {
send_receive = 1;
Expand Down Expand Up @@ -2568,9 +2570,9 @@ void do_messenger(Messenger *m, void *userdata)

if (mono_time_get(m->mono_time) > m->lastdump + DUMPING_CLIENTS_FRIENDS_EVERY_N_SECONDS) {
m->lastdump = mono_time_get(m->mono_time);
uint32_t client, last_pinged;
uint32_t last_pinged;

for (client = 0; client < LCLIENT_LIST; ++client) {
for (uint32_t client = 0; client < LCLIENT_LIST; ++client) {
const Client_data *cptr = dht_get_close_client(m->dht, client);
const IPPTsPng *const assocs[] = { &cptr->assoc4, &cptr->assoc6, nullptr };

Expand All @@ -2595,30 +2597,28 @@ void do_messenger(Messenger *m, void *userdata)
}


uint32_t friend_idx, dhtfriend;

/* dht contains additional "friends" (requests) */
uint32_t num_dhtfriends = dht_get_num_friends(m->dht);
VLA(int32_t, m2dht, num_dhtfriends);
VLA(int32_t, dht2m, num_dhtfriends);

for (friend_idx = 0; friend_idx < num_dhtfriends; ++friend_idx) {
for (uint32_t friend_idx = 0; friend_idx < num_dhtfriends; ++friend_idx) {
m2dht[friend_idx] = -1;
dht2m[friend_idx] = -1;

if (friend_idx >= m->numfriends) {
continue;
}

for (dhtfriend = 0; dhtfriend < dht_get_num_friends(m->dht); ++dhtfriend) {
for (uint32_t dhtfriend = 0; dhtfriend < dht_get_num_friends(m->dht); ++dhtfriend) {
if (id_equal(m->friendlist[friend_idx].real_pk, dht_get_friend_public_key(m->dht, dhtfriend))) {
m2dht[friend_idx] = dhtfriend;
break;
}
}
}

for (friend_idx = 0; friend_idx < num_dhtfriends; ++friend_idx) {
for (uint32_t friend_idx = 0; friend_idx < num_dhtfriends; ++friend_idx) {
if (m2dht[friend_idx] >= 0) {
dht2m[m2dht[friend_idx]] = friend_idx;
}
Expand All @@ -2631,7 +2631,7 @@ void do_messenger(Messenger *m, void *userdata)
Friend *msgfptr;
DHT_Friend *dhtfptr;

for (friend_idx = 0; friend_idx < num_dhtfriends; ++friend_idx) {
for (uint32_t friend_idx = 0; friend_idx < num_dhtfriends; ++friend_idx) {
if (dht2m[friend_idx] >= 0) {
msgfptr = &m->friendlist[dht2m[friend_idx]];
} else {
Expand All @@ -2651,7 +2651,7 @@ void do_messenger(Messenger *m, void *userdata)
id_to_string(dht_friend_public_key(dhtfptr), id_str, sizeof(id_str)));
}

for (client = 0; client < MAX_FRIEND_CLIENTS; ++client) {
for (uint32_t client = 0; client < MAX_FRIEND_CLIENTS; ++client) {
const Client_data *cptr = dht_friend_client(dhtfptr, client);
const IPPTsPng *const assocs[] = {&cptr->assoc4, &cptr->assoc6};

Expand Down
7 changes: 5 additions & 2 deletions toxcore/group.c
Original file line number Diff line number Diff line change
Expand Up @@ -1933,7 +1933,8 @@ static void handle_friend_invite_packet(Messenger *m, uint32_t friendnumber, con
return;
}

uint16_t other_groupnum, groupnum;
uint16_t other_groupnum;
uint16_t groupnum;
net_unpack_u16(data + 1, &other_groupnum);
net_unpack_u16(data + 1 + sizeof(uint16_t), &groupnum);

Expand Down Expand Up @@ -2883,7 +2884,9 @@ static int handle_lossy(void *object, int friendcon_id, const uint8_t *data, uin
return -1;
}

uint16_t groupnumber, peer_number, message_number;
uint16_t groupnumber;
uint16_t peer_number;
uint16_t message_number;
memcpy(&groupnumber, data + 1, sizeof(uint16_t));
memcpy(&peer_number, data + 1 + sizeof(uint16_t), sizeof(uint16_t));
memcpy(&message_number, data + 1 + sizeof(uint16_t) * 2, sizeof(uint16_t));
Expand Down
3 changes: 2 additions & 1 deletion toxcore/net_crypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -1512,7 +1512,8 @@ static int handle_data_packet_core(Net_Crypto *c, int crypt_connection_id, const
return -1;
}

uint32_t buffer_start, num;
uint32_t buffer_start;
uint32_t num;
memcpy(&buffer_start, data, sizeof(uint32_t));
memcpy(&num, data + sizeof(uint32_t), sizeof(uint32_t));
buffer_start = net_ntohl(buffer_start);
Expand Down
6 changes: 4 additions & 2 deletions toxcore/network.c
Original file line number Diff line number Diff line change
Expand Up @@ -1532,7 +1532,8 @@ size_t net_unpack_u16(const uint8_t *bytes, uint16_t *v)
size_t net_unpack_u32(const uint8_t *bytes, uint32_t *v)
{
const uint8_t *p = bytes;
uint16_t lo, hi;
uint16_t hi;
uint16_t lo;
p += net_unpack_u16(p, &hi);
p += net_unpack_u16(p, &lo);
*v = ((uint32_t)hi << 16) | lo;
Expand All @@ -1542,7 +1543,8 @@ size_t net_unpack_u32(const uint8_t *bytes, uint32_t *v)
size_t net_unpack_u64(const uint8_t *bytes, uint64_t *v)
{
const uint8_t *p = bytes;
uint32_t lo, hi;
uint32_t hi;
uint32_t lo;
p += net_unpack_u32(p, &hi);
p += net_unpack_u32(p, &lo);
*v = ((uint64_t)hi << 32) | lo;
Expand Down
3 changes: 2 additions & 1 deletion toxcore/onion_announce.c
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,8 @@ typedef struct Cmp_data {

static int cmp_entry(const void *a, const void *b)
{
Cmp_data cmp1, cmp2;
Cmp_data cmp1;
Cmp_data cmp2;
memcpy(&cmp1, a, sizeof(Cmp_data));
memcpy(&cmp2, b, sizeof(Cmp_data));
Onion_Announce_Entry entry1 = cmp1.entry;
Expand Down
3 changes: 2 additions & 1 deletion toxcore/onion_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,8 @@ typedef struct Onion_Client_Cmp_data {

static int onion_client_cmp_entry(const void *a, const void *b)
{
Onion_Client_Cmp_data cmp1, cmp2;
Onion_Client_Cmp_data cmp1;
Onion_Client_Cmp_data cmp2;
memcpy(&cmp1, a, sizeof(Onion_Client_Cmp_data));
memcpy(&cmp2, b, sizeof(Onion_Client_Cmp_data));
Onion_Node entry1 = cmp1.entry;
Expand Down