diff options
author | iphydf <iphydf@users.noreply.github.com> | 2018-08-02 00:25:20 +0000 |
---|---|---|
committer | iphydf <iphydf@users.noreply.github.com> | 2018-08-04 09:04:42 +0000 |
commit | 7f8b29c3465bae5b34999ad417508c2d0f6e6946 (patch) | |
tree | cf15e14621c0f1ef63d586063ce636a5efc90009 /toxcore/Messenger.c | |
parent | aa63c1330c49ee1c4b675037e2e54516950203a2 (diff) |
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)`).
Diffstat (limited to 'toxcore/Messenger.c')
-rw-r--r-- | toxcore/Messenger.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/toxcore/Messenger.c b/toxcore/Messenger.c index c45debed..cfa76172 100644 --- a/toxcore/Messenger.c +++ b/toxcore/Messenger.c | |||
@@ -2631,10 +2631,11 @@ void do_messenger(Messenger *m, void *userdata) | |||
2631 | 2631 | ||
2632 | for (client = 0; client < LCLIENT_LIST; ++client) { | 2632 | for (client = 0; client < LCLIENT_LIST; ++client) { |
2633 | const Client_data *cptr = dht_get_close_client(m->dht, client); | 2633 | const Client_data *cptr = dht_get_close_client(m->dht, client); |
2634 | const IPPTsPng *assoc = nullptr; | 2634 | const IPPTsPng *const assocs[] = { &cptr->assoc4, &cptr->assoc4, nullptr }; |
2635 | uint32_t a; | 2635 | |
2636 | for (const IPPTsPng * const *it = assocs; *it; ++it) { | ||
2637 | const IPPTsPng *const assoc = *it; | ||
2636 | 2638 | ||
2637 | for (a = 0, assoc = &cptr->assoc4; a < 2; ++a, assoc = &cptr->assoc6) { | ||
2638 | if (ip_isset(&assoc->ip_port.ip)) { | 2639 | if (ip_isset(&assoc->ip_port.ip)) { |
2639 | last_pinged = m->lastdump - assoc->last_pinged; | 2640 | last_pinged = m->lastdump - assoc->last_pinged; |
2640 | 2641 | ||