summaryrefslogtreecommitdiffstats
path: root/src/network/kernel/qnetworkinterface.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/network/kernel/qnetworkinterface.cpp')
-rw-r--r--src/network/kernel/qnetworkinterface.cpp41
1 files changed, 18 insertions, 23 deletions
diff --git a/src/network/kernel/qnetworkinterface.cpp b/src/network/kernel/qnetworkinterface.cpp
index 3857ff87b9..2b83dc2a74 100644
--- a/src/network/kernel/qnetworkinterface.cpp
+++ b/src/network/kernel/qnetworkinterface.cpp
@@ -59,19 +59,15 @@ static QList<QNetworkInterfacePrivate *> postProcess(QList<QNetworkInterfacePriv
// The math is:
// broadcast = IP | ~netmask
- QList<QNetworkInterfacePrivate *>::Iterator it = list.begin();
- const QList<QNetworkInterfacePrivate *>::Iterator end = list.end();
- for ( ; it != end; ++it) {
- QList<QNetworkAddressEntry>::Iterator addr_it = (*it)->addressEntries.begin();
- const QList<QNetworkAddressEntry>::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);
}
}
}
@@ -91,17 +87,16 @@ QNetworkInterfaceManager::~QNetworkInterfaceManager()
QSharedDataPointer<QNetworkInterfacePrivate> QNetworkInterfaceManager::interfaceFromName(const QString &name)
{
- QList<QSharedDataPointer<QNetworkInterfacePrivate> > interfaceList = allInterfaces();
- QList<QSharedDataPointer<QNetworkInterfacePrivate> >::ConstIterator it = interfaceList.constBegin();
+ const auto interfaceList = allInterfaces();
bool ok;
uint index = name.toUInt(&ok);
- for ( ; it != interfaceList.constEnd(); ++it) {
- if (ok && (*it)->index == int(index))
- return *it;
- else if ((*it)->name == name)
- return *it;
+ for (const auto &interface : interfaceList) {
+ if (ok && interface->index == int(index))
+ return interface;
+ else if (interface->name == name)
+ return interface;
}
return empty;
@@ -109,11 +104,11 @@ QSharedDataPointer<QNetworkInterfacePrivate> QNetworkInterfaceManager::interface
QSharedDataPointer<QNetworkInterfacePrivate> QNetworkInterfaceManager::interfaceFromIndex(int index)
{
- QList<QSharedDataPointer<QNetworkInterfacePrivate> > interfaceList = allInterfaces();
- QList<QSharedDataPointer<QNetworkInterfacePrivate> >::ConstIterator it = interfaceList.constBegin();
- for ( ; it != interfaceList.constEnd(); ++it)
- if ((*it)->index == index)
- return *it;
+ const auto interfaceList = allInterfaces();
+ for (const auto &interface : interfaceList) {
+ if (interface->index == index)
+ return interface;
+ }
return empty;
}