From ea284937eaf27709e7a10a0a7b43e0bc91d4aa36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Mon, 23 Oct 2017 15:18:01 +0200 Subject: [PATCH] QNetworkInterface: Use ranged-for in postProcess Use ranged-for loops instead of a normal for-loop with iterators. Change-Id: I13ba2001b7eb0fff1a0d9474f615a81d02af62f0 Reviewed-by: Timur Pocheptsov Reviewed-by: Thiago Macieira Reviewed-by: Edward Welbourne --- src/network/kernel/qnetworkinterface.cpp | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/src/network/kernel/qnetworkinterface.cpp b/src/network/kernel/qnetworkinterface.cpp index 47e0956302..2b83dc2a74 100644 --- a/src/network/kernel/qnetworkinterface.cpp +++ b/src/network/kernel/qnetworkinterface.cpp @@ -59,19 +59,15 @@ static QList postProcess(QList::Iterator it = list.begin(); - const QList::Iterator end = list.end(); - for ( ; it != end; ++it) { - QList::Iterator addr_it = (*it)->addressEntries.begin(); - const QList::Iterator addr_end = (*it)->addressEntries.end(); - for ( ; addr_it != addr_end; ++addr_it) { - if (addr_it->ip().protocol() != QAbstractSocket::IPv4Protocol) + for (QNetworkInterfacePrivate *interface : list) { + for (QNetworkAddressEntry &address : interface->addressEntries) { + if (address.ip().protocol() != QAbstractSocket::IPv4Protocol) continue; - if (!addr_it->netmask().isNull() && addr_it->broadcast().isNull()) { - QHostAddress bcast = addr_it->ip(); - bcast = QHostAddress(bcast.toIPv4Address() | ~addr_it->netmask().toIPv4Address()); - addr_it->setBroadcast(bcast); + if (!address.netmask().isNull() && address.broadcast().isNull()) { + QHostAddress bcast = address.ip(); + bcast = QHostAddress(bcast.toIPv4Address() | ~address.netmask().toIPv4Address()); + address.setBroadcast(bcast); } } }