summaryrefslogtreecommitdiffstats
path: root/src/network
diff options
context:
space:
mode:
authorMårten Nordheim <marten.nordheim@qt.io>2022-06-17 14:49:16 +0200
committerMårten Nordheim <marten.nordheim@qt.io>2022-06-27 14:02:47 +0200
commitf5138d3065c0d1856fcefb067fd44a949883dfde (patch)
tree8775a48306285d491fb933771725282f92a3bdf5 /src/network
parente3ea1d02e6a2cbc63e8ae6fff6ccae49258fe5a2 (diff)
QHttpHeaderParser: fix clang-tidy nags
"use empty instead of checking size" "no else following return" "initialize your variables" Change-Id: I4512471ec15a00f7ac1fccf88a3c87b8aa983ad7 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Diffstat (limited to 'src/network')
-rw-r--r--src/network/access/qhttpheaderparser.cpp15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/network/access/qhttpheaderparser.cpp b/src/network/access/qhttpheaderparser.cpp
index 8ed5592712..debb6e5cc3 100644
--- a/src/network/access/qhttpheaderparser.cpp
+++ b/src/network/access/qhttpheaderparser.cpp
@@ -31,7 +31,7 @@ static bool fieldNameCheck(QByteArrayView name)
|| otherCharacters.contains(c);
};
- return name.size() > 0 && std::all_of(name.begin(), name.end(), fieldNameChar);
+ return !name.empty() && std::all_of(name.begin(), name.end(), fieldNameChar);
}
bool QHttpHeaderParser::parseHeaders(QByteArrayView header)
@@ -43,7 +43,7 @@ bool QHttpHeaderParser::parseHeaders(QByteArrayView header)
return h.startsWith(' ') || h.startsWith('\t');
};
// Headers, if non-empty, start with a non-space and end with a newline:
- if (hSpaceStart(header) || (header.size() && !header.endsWith('\n')))
+ if (hSpaceStart(header) || (!header.empty() && !header.endsWith('\n')))
return false;
while (int tail = header.endsWith("\n\r\n") ? 2 : header.endsWith("\n\n") ? 1 : 0)
@@ -53,10 +53,10 @@ bool QHttpHeaderParser::parseHeaders(QByteArrayView header)
return false;
QList<QPair<QByteArray, QByteArray>> result;
- while (header.size()) {
+ while (!header.empty()) {
const int colon = header.indexOf(':');
if (colon == -1) // if no colon check if empty headers
- return result.size() == 0 && (header == "\n" || header == "\r\n");
+ return result.empty() && (header == "\n" || header == "\r\n");
if (result.size() >= maxFieldCount)
return false;
QByteArrayView name = header.first(colon);
@@ -73,7 +73,7 @@ bool QHttpHeaderParser::parseHeaders(QByteArrayView header)
if (valueSpace < 0)
return false;
line = line.trimmed();
- if (line.size()) {
+ if (!line.empty()) {
if (value.size())
value += ' ' + line.toByteArray();
else
@@ -119,7 +119,7 @@ bool QHttpHeaderParser::parseStatus(QByteArrayView status)
const QByteArrayView code = j > i ? status.sliced(i + 1, j - i - 1)
: status.sliced(i + 1);
- bool ok;
+ bool ok = false;
statusCode = code.toInt(&ok);
reasonPhrase = j > i ? QString::fromLatin1(status.sliced(j + 1))
@@ -148,8 +148,7 @@ QByteArray QHttpHeaderParser::combinedHeaderValue(const QByteArray &name, const
const QList<QByteArray> allValues = headerFieldValues(name);
if (allValues.isEmpty())
return defaultValue;
- else
- return allValues.join(", ");
+ return allValues.join(", ");
}
QList<QByteArray> QHttpHeaderParser::headerFieldValues(const QByteArray &name) const