Skip to content

Commit

Permalink
qlogging: use qsizetype to fix Wconversion warnings
Browse files Browse the repository at this point in the history
While the strlen() calls don't raise warnings themselves, it seems like
they were artifacts of indexOf() returning int instead of qsizetype.

Task-number: QTBUG-103527
Pick-to: 6.2 6.4
Change-Id: I32fbf69feca38a5977dde084bef9993f24843ccf
Reviewed-by: Mårten Nordheim <[email protected]>
  • Loading branch information
JohannesKauffmann committed Oct 25, 2022
1 parent 4711f07 commit e38a482
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/corelib/global/qlogging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -892,7 +892,7 @@ Q_AUTOTEST_EXPORT QByteArray qCleanupFuncinfo(QByteArray info)
if (info.isEmpty())
return info;

int pos;
qsizetype pos;

// Skip trailing [with XXX] for templates (gcc), but make
// sure to not affect Objective-C message names.
Expand Down Expand Up @@ -939,7 +939,7 @@ Q_AUTOTEST_EXPORT QByteArray qCleanupFuncinfo(QByteArray info)
info.truncate(++pos);

if (info.at(pos - 1) == ')') {
if (info.indexOf(operator_call) == pos - (int)strlen(operator_call))
if (info.indexOf(operator_call) == pos - (qsizetype)strlen(operator_call))
break;

// this function returns a pointer to a function
Expand All @@ -962,19 +962,19 @@ Q_AUTOTEST_EXPORT QByteArray qCleanupFuncinfo(QByteArray info)
if (pos > -1) {
switch (info.at(pos)) {
case ')':
if (info.indexOf(operator_call) == pos - (int)strlen(operator_call) + 1)
if (info.indexOf(operator_call) == pos - (qsizetype)strlen(operator_call) + 1)
pos -= 2;
break;
case '<':
if (info.indexOf(operator_lessThan) == pos - (int)strlen(operator_lessThan) + 1)
if (info.indexOf(operator_lessThan) == pos - (qsizetype)strlen(operator_lessThan) + 1)
--pos;
break;
case '>':
if (info.indexOf(operator_greaterThan) == pos - (int)strlen(operator_greaterThan) + 1)
if (info.indexOf(operator_greaterThan) == pos - (qsizetype)strlen(operator_greaterThan) + 1)
--pos;
break;
case '=': {
int operatorLength = (int)strlen(operator_lessThanEqual);
qsizetype operatorLength = (qsizetype)strlen(operator_lessThanEqual);
if (info.indexOf(operator_lessThanEqual) == pos - operatorLength + 1)
pos -= 2;
else if (info.indexOf(operator_greaterThanEqual) == pos - operatorLength + 1)
Expand Down Expand Up @@ -1018,7 +1018,7 @@ Q_AUTOTEST_EXPORT QByteArray qCleanupFuncinfo(QByteArray info)
break;

// find the matching close
int end = pos;
qsizetype end = pos;
templatecount = 1;
--pos;
while (pos && templatecount) {
Expand Down Expand Up @@ -1181,7 +1181,7 @@ void QMessagePattern::setPattern(const QString &pattern)
tokens[i] = qthreadptrTokenC;
else if (lexeme.startsWith(QLatin1StringView(timeTokenC))) {
tokens[i] = timeTokenC;
int spaceIdx = lexeme.indexOf(QChar::fromLatin1(' '));
qsizetype spaceIdx = lexeme.indexOf(QChar::fromLatin1(' '));
if (spaceIdx > 0)
timeArgs.append(lexeme.mid(spaceIdx + 1, lexeme.size() - spaceIdx - 2));
else
Expand Down

0 comments on commit e38a482

Please sign in to comment.