summaryrefslogtreecommitdiffstats
path: root/src/network/ssl
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2016-01-26 14:38:54 +0100
committerMarc Mutz <marc.mutz@kdab.com>2016-05-04 05:21:25 +0000
commitf3af7fce4a9174fb80de22cf650435516c2f3796 (patch)
tree1132b8aad645d9e27b09cf2367866f2c10678061 /src/network/ssl
parent347832d7593e2369f8597bbd06213b80b3087433 (diff)
QtNetwork: eradicate Q_FOREACH loops [rvalues]
... by replacing them with C++11 range-for loops. This is the simplest of the patch series: Q_FOREACH took a copy, so we do, too. Except we don't, since we're just catching the return value that comes out of the function (RVO). We can't feed the rvalues into range-for, because they are non-const and would thus detach. Change-Id: I42c9c44d948ab1512a69d42890187bc3cf2d7e58 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
Diffstat (limited to 'src/network/ssl')
-rw-r--r--src/network/ssl/qsslcertificate_qt.cpp6
-rw-r--r--src/network/ssl/qsslcipher.cpp6
-rw-r--r--src/network/ssl/qsslcontext_openssl.cpp3
-rw-r--r--src/network/ssl/qsslsocket.cpp3
-rw-r--r--src/network/ssl/qsslsocket_openssl.cpp6
5 files changed, 16 insertions, 8 deletions
diff --git a/src/network/ssl/qsslcertificate_qt.cpp b/src/network/ssl/qsslcertificate_qt.cpp
index a351b8ecc7..2535d12044 100644
--- a/src/network/ssl/qsslcertificate_qt.cpp
+++ b/src/network/ssl/qsslcertificate_qt.cpp
@@ -451,7 +451,8 @@ bool QSslCertificatePrivate::parseExtension(const QByteArray &data, QSslCertific
if (!val.read(valElem.value()) || val.type() != QAsn1Element::SequenceType)
return false;
QVariantMap result;
- foreach (const QAsn1Element &el, val.toVector()) {
+ const auto elems = val.toVector();
+ for (const QAsn1Element &el : elems) {
QVector<QAsn1Element> items = el.toVector();
if (items.size() != 2)
return false;
@@ -495,7 +496,8 @@ bool QSslCertificatePrivate::parseExtension(const QByteArray &data, QSslCertific
if (!val.read(valElem.value()) || val.type() != QAsn1Element::SequenceType)
return false;
QVariantMap result;
- foreach (const QAsn1Element &el, val.toVector()) {
+ const auto elems = val.toVector();
+ for (const QAsn1Element &el : elems) {
if (el.type() == 0x80) {
result[QStringLiteral("keyid")] = el.value().toHex();
} else if (el.type() == 0x82) {
diff --git a/src/network/ssl/qsslcipher.cpp b/src/network/ssl/qsslcipher.cpp
index 806a27cd1a..738d521a38 100644
--- a/src/network/ssl/qsslcipher.cpp
+++ b/src/network/ssl/qsslcipher.cpp
@@ -90,7 +90,8 @@ QSslCipher::QSslCipher()
QSslCipher::QSslCipher(const QString &name)
: d(new QSslCipherPrivate)
{
- foreach (const QSslCipher &cipher, QSslConfiguration::supportedCiphers()) {
+ const auto ciphers = QSslConfiguration::supportedCiphers();
+ for (const QSslCipher &cipher : ciphers) {
if (cipher.name() == name) {
*this = cipher;
return;
@@ -111,7 +112,8 @@ QSslCipher::QSslCipher(const QString &name)
QSslCipher::QSslCipher(const QString &name, QSsl::SslProtocol protocol)
: d(new QSslCipherPrivate)
{
- foreach (const QSslCipher &cipher, QSslConfiguration::supportedCiphers()) {
+ const auto ciphers = QSslConfiguration::supportedCiphers();
+ for (const QSslCipher &cipher : ciphers) {
if (cipher.name() == name && cipher.protocol() == protocol) {
*this = cipher;
return;
diff --git a/src/network/ssl/qsslcontext_openssl.cpp b/src/network/ssl/qsslcontext_openssl.cpp
index 011ba33ace..ca296bd179 100644
--- a/src/network/ssl/qsslcontext_openssl.cpp
+++ b/src/network/ssl/qsslcontext_openssl.cpp
@@ -224,7 +224,8 @@ init_context:
const QDateTime now = QDateTime::currentDateTimeUtc();
// Add all our CAs to this store.
- foreach (const QSslCertificate &caCertificate, sslContext->sslConfiguration.caCertificates()) {
+ const auto caCertificates = sslContext->sslConfiguration.caCertificates();
+ for (const QSslCertificate &caCertificate : caCertificates) {
// From https://www.openssl.org/docs/ssl/SSL_CTX_load_verify_locations.html:
//
// If several CA certificates matching the name, key identifier, and
diff --git a/src/network/ssl/qsslsocket.cpp b/src/network/ssl/qsslsocket.cpp
index 35dce23601..a5ee9bf0c1 100644
--- a/src/network/ssl/qsslsocket.cpp
+++ b/src/network/ssl/qsslsocket.cpp
@@ -1249,7 +1249,8 @@ void QSslSocket::setCiphers(const QString &ciphers)
{
Q_D(QSslSocket);
d->configuration.ciphers.clear();
- foreach (const QString &cipherName, ciphers.split(QLatin1Char(':'), QString::SkipEmptyParts)) {
+ const auto cipherNames = ciphers.split(QLatin1Char(':'), QString::SkipEmptyParts);
+ for (const QString &cipherName : cipherNames) {
QSslCipher cipher(cipherName);
if (!cipher.isNull())
d->configuration.ciphers << cipher;
diff --git a/src/network/ssl/qsslsocket_openssl.cpp b/src/network/ssl/qsslsocket_openssl.cpp
index 45caaffe75..c6d63adffc 100644
--- a/src/network/ssl/qsslsocket_openssl.cpp
+++ b/src/network/ssl/qsslsocket_openssl.cpp
@@ -286,7 +286,8 @@ int q_X509Callback(int ok, X509_STORE_CTX *ctx)
qCDebug(lcSsl) << "verification error: dumping bad certificate";
qCDebug(lcSsl) << QSslCertificatePrivate::QSslCertificate_from_X509(q_X509_STORE_CTX_get_current_cert(ctx)).toPem();
qCDebug(lcSsl) << "dumping chain";
- foreach (QSslCertificate cert, QSslSocketBackendPrivate::STACKOFX509_to_QSslCertificates(q_X509_STORE_CTX_get_chain(ctx))) {
+ const auto certs = QSslSocketBackendPrivate::STACKOFX509_to_QSslCertificates(q_X509_STORE_CTX_get_chain(ctx));
+ for (const QSslCertificate &cert : certs) {
qCDebug(lcSsl) << "Issuer:" << "O=" << cert.issuerInfo(QSslCertificate::Organization)
<< "CN=" << cert.issuerInfo(QSslCertificate::CommonName)
<< "L=" << cert.issuerInfo(QSslCertificate::LocalityName)
@@ -1625,7 +1626,8 @@ QList<QSslError> QSslSocketBackendPrivate::verify(const QList<QSslCertificate> &
}
const QDateTime now = QDateTime::currentDateTimeUtc();
- foreach (const QSslCertificate &caCertificate, QSslConfiguration::defaultConfiguration().caCertificates()) {
+ const auto caCertificates = QSslConfiguration::defaultConfiguration().caCertificates();
+ for (const QSslCertificate &caCertificate : caCertificates) {
// From https://www.openssl.org/docs/ssl/SSL_CTX_load_verify_locations.html:
//
// If several CA certificates matching the name, key identifier, and