mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
Avoid multiple for-next expressions.
All for-loops in toxcore are of the form for (<for-init>; <for-cond>; <for-next>) { <body> } `for-init` can be a variable declaration (like `int i = 0`), an assignment (like `i = 0`), or empty. `for-cond` can be any expression. `for-next` can be an assignment or a single increment/decrement expression (like `++i` or `--i`). No other forms are allowed, so e.g. comma expressions in any of these are not allowed (so no `for (i = 0, j = n; ...; ++i, --j)`).
This commit is contained in:
parent
aa63c1330c
commit
7f8b29c346
|
@ -1704,12 +1704,10 @@ static uint8_t do_ping_and_sendnode_requests(DHT *dht, uint64_t *lastgetnode, co
|
|||
/* If node is not dead. */
|
||||
Client_data *client = &list[i];
|
||||
|
||||
IPPTsPng *const assocs[] = { &client->assoc6, &client->assoc4, nullptr };
|
||||
IPPTsPng *const assocs[] = { &client->assoc6, &client->assoc4 };
|
||||
|
||||
uint32_t j = 0;
|
||||
|
||||
for (IPPTsPng * const *it = assocs; *it; ++it, ++j) {
|
||||
IPPTsPng *const assoc = *it;
|
||||
for (uint32_t j = 0; j < sizeof(assocs) / sizeof(assocs[0]); ++j) {
|
||||
IPPTsPng *const assoc = assocs[j];
|
||||
|
||||
if (!is_timeout(assoc->timestamp, KILL_NODE_TIMEOUT)) {
|
||||
sort = 0;
|
||||
|
|
|
@ -2631,10 +2631,11 @@ void do_messenger(Messenger *m, void *userdata)
|
|||
|
||||
for (client = 0; client < LCLIENT_LIST; ++client) {
|
||||
const Client_data *cptr = dht_get_close_client(m->dht, client);
|
||||
const IPPTsPng *assoc = nullptr;
|
||||
uint32_t a;
|
||||
const IPPTsPng *const assocs[] = { &cptr->assoc4, &cptr->assoc4, nullptr };
|
||||
|
||||
for (const IPPTsPng * const *it = assocs; *it; ++it) {
|
||||
const IPPTsPng *const assoc = *it;
|
||||
|
||||
for (a = 0, assoc = &cptr->assoc4; a < 2; ++a, assoc = &cptr->assoc6) {
|
||||
if (ip_isset(&assoc->ip_port.ip)) {
|
||||
last_pinged = m->lastdump - assoc->last_pinged;
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user