summaryrefslogtreecommitdiffstats
path: root/src/network/access/qhsts.cpp
diff options
context:
space:
mode:
authorTimur Pocheptsov <timur.pocheptsov@qt.io>2017-10-23 13:58:59 +0200
committerTimur Pocheptsov <timur.pocheptsov@qt.io>2017-10-26 03:56:22 +0000
commit5b9f4a7130fce7fe31ad7a6c916e629e13c9888f (patch)
tree0f2a4db32a8967001e269a2bc0f59fc70b7df53a /src/network/access/qhsts.cpp
parentfb1cf63d778a54965790efa1111184ce577d6d65 (diff)
QHstsCache - do not mix const/non-const iterators
Found by clazy (clazy-strict-iterators). QMap::find returns 'iterator' and this is what we need, since we need to modify the value referenced by this iterator. But QMap::insert only accepts 'const_iterator' and clazy warns about mixed const/non-const iterators (though actually QHstsCache does not have the original problem this check it trying to find). Since we do not share cache and do not want to try detaching on non-const access, we can use std::map which conveniently has 'insert' taking 'iterator' as its first parameter. As a bonus this will also fix another warning from clazy-range-loop check (when iterating over such a non-const map). Change-Id: Id82991cefce33723d177ed04058d15295e9b71d7 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Diffstat (limited to 'src/network/access/qhsts.cpp')
-rw-r--r--src/network/access/qhsts.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/network/access/qhsts.cpp b/src/network/access/qhsts.cpp
index 6a731afc2f..43a8a3663e 100644
--- a/src/network/access/qhsts.cpp
+++ b/src/network/access/qhsts.cpp
@@ -136,7 +136,7 @@ void QHstsCache::updateKnownHost(const QString &host, const QDateTime &expires,
return;
}
- knownHosts.insert(pos, hostName, newPolicy);
+ knownHosts.insert(pos, {hostName, newPolicy});
if (hstsStore)
hstsStore->addToObserved(newPolicy);
return;
@@ -144,8 +144,8 @@ void QHstsCache::updateKnownHost(const QString &host, const QDateTime &expires,
if (newPolicy.isExpired())
knownHosts.erase(pos);
- else if (*pos != newPolicy)
- *pos = std::move(newPolicy);
+ else if (pos->second != newPolicy)
+ pos->second = std::move(newPolicy);
else
return;
@@ -185,13 +185,13 @@ bool QHstsCache::isKnownHost(const QUrl &url) const
while (nameToTest.fragment.size()) {
auto const pos = knownHosts.find(nameToTest);
if (pos != knownHosts.end()) {
- if (pos.value().isExpired()) {
+ if (pos->second.isExpired()) {
knownHosts.erase(pos);
if (hstsStore) {
// Inform our store that this policy has expired.
- hstsStore->addToObserved(pos.value());
+ hstsStore->addToObserved(pos->second);
}
- } else if (!superDomainMatch || pos.value().includesSubDomains()) {
+ } else if (!superDomainMatch || pos->second.includesSubDomains()) {
return true;
}
}
@@ -215,9 +215,9 @@ void QHstsCache::clear()
QVector<QHstsPolicy> QHstsCache::policies() const
{
QVector<QHstsPolicy> values;
- values.reserve(knownHosts.size());
+ values.reserve(int(knownHosts.size()));
for (const auto &host : knownHosts)
- values << host;
+ values << host.second;
return values;
}