From 7f8b29c3465bae5b34999ad417508c2d0f6e6946 Mon Sep 17 00:00:00 2001 From: iphydf Date: Thu, 2 Aug 2018 00:25:20 +0000 Subject: Avoid multiple for-next expressions. All for-loops in toxcore are of the form for (; ; ) { } `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)`). --- toxcore/DHT.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'toxcore/DHT.c') diff --git a/toxcore/DHT.c b/toxcore/DHT.c index 01fcfd66..543ee191 100644 --- a/toxcore/DHT.c +++ b/toxcore/DHT.c @@ -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 }; - - uint32_t j = 0; + IPPTsPng *const assocs[] = { &client->assoc6, &client->assoc4 }; - 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; -- cgit v1.2.3