Fix Clazy range-loop-detach warnings
This commit is contained in:
parent
f5f06ae44e
commit
d484ec3ac8
14 changed files with 42 additions and 35 deletions
|
|
@ -58,7 +58,7 @@ void AutoUpdateChecker::start()
|
|||
void AutoUpdateChecker::parseStringToVersionQuad(QString& string, QVector<int>& version)
|
||||
{
|
||||
QStringList list = string.split('.');
|
||||
for (const QString& component : list) {
|
||||
for (const QString& component : std::as_const(list)) {
|
||||
version.append(component.toInt());
|
||||
}
|
||||
}
|
||||
|
|
@ -139,7 +139,7 @@ void AutoUpdateChecker::handleUpdateCheckRequestFinished(QNetworkReply* reply)
|
|||
return;
|
||||
}
|
||||
|
||||
for (QJsonValueRef updateEntry : array) {
|
||||
for (const auto& updateEntry : std::as_const(array)) {
|
||||
if (updateEntry.isObject()) {
|
||||
QJsonObject updateObj = updateEntry.toObject();
|
||||
if (!updateObj.contains("platform") ||
|
||||
|
|
|
|||
|
|
@ -231,17 +231,17 @@ ComputerManager::~ComputerManager()
|
|||
m_MdnsBrowser = nullptr;
|
||||
|
||||
// Interrupt polling
|
||||
for (ComputerPollingEntry* entry : m_PollEntries) {
|
||||
for (ComputerPollingEntry* entry : std::as_const(m_PollEntries)) {
|
||||
entry->interrupt();
|
||||
}
|
||||
|
||||
// Delete all polling entries (and associated threads)
|
||||
for (ComputerPollingEntry* entry : m_PollEntries) {
|
||||
for (ComputerPollingEntry* entry : std::as_const(m_PollEntries)) {
|
||||
delete entry;
|
||||
}
|
||||
|
||||
// Destroy all NvComputer objects now that polling is halted
|
||||
for (NvComputer* computer : m_KnownHosts) {
|
||||
for (NvComputer* computer : std::as_const(m_KnownHosts)) {
|
||||
delete computer;
|
||||
}
|
||||
}
|
||||
|
|
@ -268,7 +268,7 @@ void DelayedFlushThread::run() {
|
|||
|
||||
// Update the last serialized hosts map under the delayed flush mutex
|
||||
m_ComputerManager->m_LastSerializedHosts.clear();
|
||||
for (const NvComputer* computer : m_ComputerManager->m_KnownHosts) {
|
||||
for (const NvComputer* computer : std::as_const(m_ComputerManager->m_KnownHosts)) {
|
||||
// Copy the current state of the NvComputer to allow us to check later if we need
|
||||
// to serialize it again when attribute updates occur.
|
||||
QReadLocker computerLock(&computer->lock);
|
||||
|
|
@ -285,7 +285,7 @@ void DelayedFlushThread::run() {
|
|||
{
|
||||
QReadLocker lock(&m_ComputerManager->m_Lock);
|
||||
int i = 0;
|
||||
for (const NvComputer* computer : m_ComputerManager->m_KnownHosts) {
|
||||
for (const NvComputer* computer : std::as_const(m_ComputerManager->m_KnownHosts)) {
|
||||
settings.setArrayIndex(i++);
|
||||
computer->serialize(settings, false);
|
||||
}
|
||||
|
|
@ -298,7 +298,7 @@ void DelayedFlushThread::run() {
|
|||
{
|
||||
QReadLocker lock(&m_ComputerManager->m_Lock);
|
||||
int i = 0;
|
||||
for (const NvComputer* computer : m_ComputerManager->m_KnownHosts) {
|
||||
for (const NvComputer* computer : std::as_const(m_ComputerManager->m_KnownHosts)) {
|
||||
settings.setArrayIndex(i++);
|
||||
computer->serialize(settings, true);
|
||||
}
|
||||
|
|
@ -424,7 +424,7 @@ void ComputerManager::handleMdnsServiceResolved(MdnsPendingComputer* computer,
|
|||
bool added = false;
|
||||
|
||||
// Add the host using the IPv4 address
|
||||
for (const QHostAddress& address : addresses) {
|
||||
for (const QHostAddress& address : std::as_const(addresses)) {
|
||||
if (address.protocol() == QAbstractSocket::IPv4Protocol) {
|
||||
// NB: We don't just call addNewHost() here with v6Global because the IPv6
|
||||
// address may not be reachable (if the user hasn't installed the IPv6 helper yet
|
||||
|
|
@ -440,7 +440,7 @@ void ComputerManager::handleMdnsServiceResolved(MdnsPendingComputer* computer,
|
|||
|
||||
if (!added) {
|
||||
// If we get here, there wasn't an IPv4 address so we'll do it v6-only
|
||||
for (const QHostAddress& address : addresses) {
|
||||
for (const QHostAddress& address : std::as_const(addresses)) {
|
||||
if (address.protocol() == QAbstractSocket::IPv6Protocol) {
|
||||
// Use a link-local or site-local address for the "local address"
|
||||
if (address.isInSubnet(QHostAddress("fe80::"), 10) ||
|
||||
|
|
@ -569,7 +569,7 @@ void ComputerManager::handleAboutToQuit()
|
|||
|
||||
// Interrupt polling threads immediately, so they
|
||||
// avoid making additional requests while quitting
|
||||
for (ComputerPollingEntry* entry : m_PollEntries) {
|
||||
for (ComputerPollingEntry* entry : std::as_const(m_PollEntries)) {
|
||||
entry->interrupt();
|
||||
}
|
||||
}
|
||||
|
|
@ -721,7 +721,7 @@ void ComputerManager::stopPollingAsync()
|
|||
m_MdnsServer.reset();
|
||||
|
||||
// Interrupt all threads, but don't wait for them to terminate
|
||||
for (ComputerPollingEntry* entry : m_PollEntries) {
|
||||
for (ComputerPollingEntry* entry : std::as_const(m_PollEntries)) {
|
||||
entry->interrupt();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -150,7 +150,7 @@ public:
|
|||
// interrupt() should have taken care of this
|
||||
Q_ASSERT(m_ActiveThread == nullptr);
|
||||
|
||||
for (QThread* thread : m_InactiveList) {
|
||||
for (QThread* thread : std::as_const(m_InactiveList)) {
|
||||
thread->wait();
|
||||
delete thread;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,8 @@ ComputerSeeker::ComputerSeeker(ComputerManager *manager, QString computerName, Q
|
|||
m_TimeoutTimer(new QTimer(this))
|
||||
{
|
||||
// If we know this computer, send a WOL packet to wake it up in case it is asleep.
|
||||
for (NvComputer * computer: m_ComputerManager->getComputers()) {
|
||||
const auto computers = m_ComputerManager->getComputers();
|
||||
for (NvComputer* computer : computers) {
|
||||
if (this->matchComputer(computer)) {
|
||||
computer->wake();
|
||||
}
|
||||
|
|
@ -51,7 +52,8 @@ bool ComputerSeeker::matchComputer(NvComputer *computer) const
|
|||
return true;
|
||||
}
|
||||
|
||||
for (const NvAddress& addr : computer->uniqueAddresses()) {
|
||||
const auto uniqueAddresses = computer->uniqueAddresses();
|
||||
for (const NvAddress& addr : uniqueAddresses) {
|
||||
if (addr.address().toLower() == value || addr.toString().toLower() == value) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -141,7 +141,7 @@ NvComputer::NvComputer(NvHTTP& http, QString serverInfo)
|
|||
QString newMacString = NvHTTP::getXmlString(serverInfo, "mac");
|
||||
if (newMacString != "00:00:00:00:00:00") {
|
||||
QStringList macOctets = newMacString.split(':');
|
||||
for (const QString& macOctet : macOctets) {
|
||||
for (const QString& macOctet : std::as_const(macOctets)) {
|
||||
this->macAddress.append((char) macOctet.toInt(nullptr, 16));
|
||||
}
|
||||
}
|
||||
|
|
@ -254,14 +254,16 @@ bool NvComputer::wake() const
|
|||
// case the host has timed out in ARP entries.
|
||||
QMap<QString, quint16> addressMap;
|
||||
QSet<quint16> basePortSet;
|
||||
for (const NvAddress& addr : uniqueAddresses()) {
|
||||
const auto uniqueHostAddresses = uniqueAddresses();
|
||||
for (const NvAddress& addr : uniqueHostAddresses) {
|
||||
addressMap.insert(addr.address(), addr.port());
|
||||
basePortSet.insert(addr.port());
|
||||
}
|
||||
addressMap.insert("255.255.255.255", 0);
|
||||
|
||||
// Try to broadcast on all available NICs
|
||||
for (const QNetworkInterface& nic : QNetworkInterface::allInterfaces()) {
|
||||
const auto allInterfaces = QNetworkInterface::allInterfaces();
|
||||
for (const QNetworkInterface& nic : allInterfaces) {
|
||||
// Ensure the interface is up and skip the loopback adapter
|
||||
if ((nic.flags() & QNetworkInterface::IsUp) == 0 ||
|
||||
(nic.flags() & QNetworkInterface::IsLoopBack) != 0) {
|
||||
|
|
@ -269,7 +271,8 @@ bool NvComputer::wake() const
|
|||
}
|
||||
|
||||
QHostAddress allNodesMulticast("FF02::1");
|
||||
for (const QNetworkAddressEntry& addr : nic.addressEntries()) {
|
||||
const auto allInterfaceAddresses = nic.addressEntries();
|
||||
for (const QNetworkAddressEntry& addr : allInterfaceAddresses) {
|
||||
// Store the scope ID for this NIC if IPv6 is enabled
|
||||
if (!addr.ip().scopeId().isEmpty()) {
|
||||
allNodesMulticast.setScopeId(addr.ip().scopeId());
|
||||
|
|
@ -375,13 +378,15 @@ NvComputer::ReachabilityType NvComputer::getActiveAddressReachability() const
|
|||
Q_ASSERT(!s.localAddress().isNull());
|
||||
Q_ASSERT(!s.peerAddress().isNull());
|
||||
|
||||
for (const QNetworkInterface& nic : QNetworkInterface::allInterfaces()) {
|
||||
const auto allInterfaces = QNetworkInterface::allInterfaces();
|
||||
for (const QNetworkInterface& nic : allInterfaces) {
|
||||
// Ensure the interface is up
|
||||
if ((nic.flags() & QNetworkInterface::IsUp) == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (const QNetworkAddressEntry& addr : nic.addressEntries()) {
|
||||
const auto allInterfaceAddresses = nic.addressEntries();
|
||||
for (const QNetworkAddressEntry& addr : allInterfaceAddresses) {
|
||||
if (addr.ip() == s.localAddress()) {
|
||||
qInfo() << "Found matching interface:" << nic.humanReadableName() << nic.hardwareAddress() << nic.flags();
|
||||
|
||||
|
|
@ -463,7 +468,7 @@ bool NvComputer::updateAppList(QVector<NvApp> newAppList) {
|
|||
}
|
||||
|
||||
// Propagate client-side attributes to the new app list
|
||||
for (const NvApp& existingApp : appList) {
|
||||
for (const NvApp& existingApp : std::as_const(appList)) {
|
||||
for (NvApp& newApp : newAppList) {
|
||||
if (existingApp.id == newApp.id) {
|
||||
newApp.hidden = existingApp.hidden;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue