Misc: Fix qsizetype-related narrowing coversions
Task-number: QTBUG-102461 Change-Id: I96757abc50fc45756bc1271a970f819a48021663 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
dda60cf0d1
commit
8a1eb24de8
@ -542,8 +542,8 @@ QString QLibraryInfoPrivate::path(QLibraryInfo::LibraryPath p, UsageMode usageMo
|
||||
ret = v.toString();
|
||||
}
|
||||
|
||||
int startIndex = 0;
|
||||
forever {
|
||||
qsizetype startIndex = 0;
|
||||
while (true) {
|
||||
startIndex = ret.indexOf(u'$', startIndex);
|
||||
if (startIndex < 0)
|
||||
break;
|
||||
@ -553,7 +553,7 @@ QString QLibraryInfoPrivate::path(QLibraryInfo::LibraryPath p, UsageMode usageMo
|
||||
startIndex++;
|
||||
continue;
|
||||
}
|
||||
int endIndex = ret.indexOf(u')', startIndex + 2);
|
||||
qsizetype endIndex = ret.indexOf(u')', startIndex + 2);
|
||||
if (endIndex < 0)
|
||||
break;
|
||||
auto envVarName = QStringView{ret}.mid(startIndex + 2, endIndex - startIndex - 2);
|
||||
|
@ -352,8 +352,7 @@ static QByteArray getEtcFileFirstLine(const char *fileName)
|
||||
return QByteArray();
|
||||
|
||||
const char *ptr = buffer.constData();
|
||||
int eol = buffer.indexOf("\n");
|
||||
return QByteArray(ptr, eol).trimmed();
|
||||
return QByteArray(ptr, buffer.indexOf("\n")).trimmed();
|
||||
}
|
||||
|
||||
static bool readEtcRedHatRelease(QUnixOSVersion &v)
|
||||
@ -368,9 +367,9 @@ static bool readEtcRedHatRelease(QUnixOSVersion &v)
|
||||
v.prettyName = QString::fromLatin1(line);
|
||||
|
||||
const char keyword[] = "release ";
|
||||
int releaseIndex = line.indexOf(keyword);
|
||||
const qsizetype releaseIndex = line.indexOf(keyword);
|
||||
v.productType = QString::fromLatin1(line.mid(0, releaseIndex)).remove(u' ');
|
||||
int spaceIndex = line.indexOf(' ', releaseIndex + strlen(keyword));
|
||||
const qsizetype spaceIndex = line.indexOf(' ', releaseIndex + strlen(keyword));
|
||||
v.productVersion = QString::fromLatin1(line.mid(releaseIndex + strlen(keyword),
|
||||
spaceIndex > -1 ? spaceIndex - releaseIndex - int(strlen(keyword)) : -1));
|
||||
return true;
|
||||
|
@ -1104,7 +1104,7 @@ static bool createDirectoryWithParents(const QByteArray &nativeName, mode_t mode
|
||||
return false;
|
||||
|
||||
// mkdir failed because the parent dir doesn't exist, so try to create it
|
||||
int slash = nativeName.lastIndexOf('/');
|
||||
qsizetype slash = nativeName.lastIndexOf('/');
|
||||
if (slash < 1)
|
||||
return false;
|
||||
|
||||
@ -1147,7 +1147,7 @@ bool QFileSystemEngine::removeDirectory(const QFileSystemEntry &entry, bool remo
|
||||
|
||||
if (removeEmptyParents) {
|
||||
QString dirName = QDir::cleanPath(entry.filePath());
|
||||
for (int oldslash = 0, slash=dirName.size(); slash > 0; oldslash = slash) {
|
||||
for (qsizetype oldslash = 0, slash=dirName.size(); slash > 0; oldslash = slash) {
|
||||
const QByteArray chunk = QFile::encodeName(dirName.left(slash));
|
||||
QT_STATBUF st;
|
||||
if (QT_STAT(chunk.constData(), &st) != -1) {
|
||||
|
@ -67,7 +67,7 @@ int QLoggingRule::pass(QLatin1StringView cat, QtMsgType msgType) const
|
||||
return 0;
|
||||
}
|
||||
|
||||
const int idx = cat.indexOf(category);
|
||||
const qsizetype idx = cat.indexOf(category);
|
||||
if (idx >= 0) {
|
||||
if (flags == MidFilter) {
|
||||
// matches somewhere
|
||||
@ -194,7 +194,7 @@ void QLoggingSettingsParser::parseNextLine(QStringView line)
|
||||
}
|
||||
|
||||
if (m_inRulesSection) {
|
||||
int equalPos = line.indexOf(u'=');
|
||||
const qsizetype equalPos = line.indexOf(u'=');
|
||||
if (equalPos != -1) {
|
||||
if (line.lastIndexOf(u'=') == equalPos) {
|
||||
const auto key = line.left(equalPos).trimmed();
|
||||
|
@ -72,7 +72,7 @@ QProcessEnvironment QProcessEnvironmentPrivate::fromList(const QStringList &list
|
||||
QStringList::ConstIterator it = list.constBegin(),
|
||||
end = list.constEnd();
|
||||
for ( ; it != end; ++it) {
|
||||
int pos = it->indexOf(u'=', 1);
|
||||
const qsizetype pos = it->indexOf(u'=', 1);
|
||||
if (pos < 1)
|
||||
continue;
|
||||
|
||||
|
@ -82,7 +82,7 @@ public:
|
||||
|
||||
inline QStringView next()
|
||||
{
|
||||
int start = m_pos;
|
||||
const qsizetype start = m_pos;
|
||||
while (m_pos < m_len && m_data[m_pos] != m_splitChar)
|
||||
++m_pos;
|
||||
return QStringView(m_data + start, m_pos - start);
|
||||
@ -1478,14 +1478,14 @@ QString QResourceFileEngine::fileName(FileName file) const
|
||||
{
|
||||
Q_D(const QResourceFileEngine);
|
||||
if (file == BaseName) {
|
||||
int slash = d->resource.fileName().lastIndexOf(u'/');
|
||||
const qsizetype slash = d->resource.fileName().lastIndexOf(u'/');
|
||||
if (slash == -1)
|
||||
return d->resource.fileName();
|
||||
return d->resource.fileName().mid(slash + 1);
|
||||
} else if (file == PathName || file == AbsolutePathName) {
|
||||
const QString path = (file == AbsolutePathName) ? d->resource.absoluteFilePath()
|
||||
: d->resource.fileName();
|
||||
const int slash = path.lastIndexOf(u'/');
|
||||
const qsizetype slash = path.lastIndexOf(u'/');
|
||||
if (slash == -1)
|
||||
return ":"_L1;
|
||||
else if (slash <= 1)
|
||||
@ -1495,7 +1495,7 @@ QString QResourceFileEngine::fileName(FileName file) const
|
||||
} else if (file == CanonicalName || file == CanonicalPathName) {
|
||||
const QString absoluteFilePath = d->resource.absoluteFilePath();
|
||||
if (file == CanonicalPathName) {
|
||||
const int slash = absoluteFilePath.lastIndexOf(u'/');
|
||||
const qsizetype slash = absoluteFilePath.lastIndexOf(u'/');
|
||||
if (slash != -1)
|
||||
return absoluteFilePath.left(slash);
|
||||
}
|
||||
|
@ -558,7 +558,7 @@ bool QSettingsPrivate::iniUnescapedKey(QByteArrayView key, QString &result)
|
||||
}
|
||||
|
||||
int numDigits = 2;
|
||||
int firstDigitPos = i + 1;
|
||||
qsizetype firstDigitPos = i + 1;
|
||||
|
||||
ch = decoded.at(i + 1).unicode();
|
||||
if (ch == 'U') {
|
||||
|
@ -230,7 +230,7 @@ QString QMimeType::comment() const
|
||||
const QString comm = d->localeComments.value(lang);
|
||||
if (!comm.isEmpty())
|
||||
return comm;
|
||||
const int pos = lang.indexOf(u'_');
|
||||
const qsizetype pos = lang.indexOf(u'_');
|
||||
if (pos != -1) {
|
||||
// "pt_BR" not found? try just "pt"
|
||||
const QString shortLang = lang.left(pos);
|
||||
@ -269,7 +269,7 @@ QString QMimeType::genericIconName() const
|
||||
// (i.e. "video-x-generic" in the previous example).
|
||||
const QString group = name();
|
||||
QStringView groupRef(group);
|
||||
const int slashindex = groupRef.indexOf(u'/');
|
||||
const qsizetype slashindex = groupRef.indexOf(u'/');
|
||||
if (slashindex != -1)
|
||||
groupRef = groupRef.left(slashindex);
|
||||
return groupRef + "-x-generic"_L1;
|
||||
@ -279,7 +279,7 @@ QString QMimeType::genericIconName() const
|
||||
|
||||
static QString make_default_icon_name_from_mimetype_name(QString iconName)
|
||||
{
|
||||
const int slashindex = iconName.indexOf(u'/');
|
||||
const qsizetype slashindex = iconName.indexOf(u'/');
|
||||
if (slashindex != -1)
|
||||
iconName[slashindex] = u'-';
|
||||
return iconName;
|
||||
|
@ -1252,7 +1252,7 @@ Q_NEVER_INLINE static int ucstricmp8(const char *utf8, const char *utf8end, cons
|
||||
char32_t uc1 = 0;
|
||||
char32_t *output = &uc1;
|
||||
uchar b = *src1++;
|
||||
int res = QUtf8Functions::fromUtf8<QUtf8BaseTraits>(b, output, src1, end1);
|
||||
const qsizetype res = QUtf8Functions::fromUtf8<QUtf8BaseTraits>(b, output, src1, end1);
|
||||
if (res < 0) {
|
||||
// decoding error
|
||||
uc1 = QChar::ReplacementCharacter;
|
||||
|
@ -651,7 +651,7 @@ char16_t *QUtf8::convertToUnicode(char16_t *dst, QByteArrayView in) noexcept
|
||||
|
||||
do {
|
||||
uchar b = *src++;
|
||||
int res = QUtf8Functions::fromUtf8<QUtf8BaseTraits>(b, dst, src, end);
|
||||
const qsizetype res = QUtf8Functions::fromUtf8<QUtf8BaseTraits>(b, dst, src, end);
|
||||
if (res < 0) {
|
||||
// decoding error
|
||||
*dst++ = QChar::ReplacementCharacter;
|
||||
@ -694,7 +694,7 @@ char16_t *QUtf8::convertToUnicode(char16_t *dst, QByteArrayView in, QStringConve
|
||||
if (state->flags & QStringConverter::Flag::ConvertInvalidToNull)
|
||||
replacement = QChar::Null;
|
||||
|
||||
int res;
|
||||
qsizetype res;
|
||||
uchar ch = 0;
|
||||
|
||||
const uchar *src = reinterpret_cast<const uchar *>(in.data());
|
||||
@ -810,7 +810,7 @@ QUtf8::ValidUtf8Result QUtf8::isValidUtf8(QByteArrayView in)
|
||||
|
||||
isValidAscii = false;
|
||||
QUtf8NoOutputTraits::NoOutput output;
|
||||
int res = QUtf8Functions::fromUtf8<QUtf8NoOutputTraits>(b, output, src, end);
|
||||
const qsizetype res = QUtf8Functions::fromUtf8<QUtf8NoOutputTraits>(b, output, src, end);
|
||||
if (res < 0) {
|
||||
// decoding error
|
||||
return { false, false };
|
||||
@ -837,7 +837,7 @@ int QUtf8::compareUtf8(QByteArrayView utf8, QStringView utf16, Qt::CaseSensitivi
|
||||
|
||||
if (uc1 >= 0x80) {
|
||||
char32_t *output = &uc1;
|
||||
int res = QUtf8Functions::fromUtf8<QUtf8BaseTraitsNoAscii>(uc1, output, src1, end1);
|
||||
qsizetype res = QUtf8Functions::fromUtf8<QUtf8BaseTraitsNoAscii>(uc1, output, src1, end1);
|
||||
if (res < 0) {
|
||||
// decoding error
|
||||
uc1 = QChar::ReplacementCharacter;
|
||||
@ -872,7 +872,7 @@ int QUtf8::compareUtf8(QByteArrayView utf8, QLatin1StringView s, Qt::CaseSensiti
|
||||
while (src1 < end1 && src2 < end2) {
|
||||
uchar b = *src1++;
|
||||
char32_t *output = &uc1;
|
||||
int res = QUtf8Functions::fromUtf8<QUtf8BaseTraits>(b, output, src1, end1);
|
||||
const qsizetype res = QUtf8Functions::fromUtf8<QUtf8BaseTraits>(b, output, src1, end1);
|
||||
if (res < 0) {
|
||||
// decoding error
|
||||
uc1 = QChar::ReplacementCharacter;
|
||||
@ -912,7 +912,7 @@ int QUtf8::compareUtf8(QByteArrayView lhs, QByteArrayView rhs, Qt::CaseSensitivi
|
||||
while (src1 < end1 && src2 < end2) {
|
||||
uchar b = *src1++;
|
||||
char32_t *output = &uc1;
|
||||
int res = QUtf8Functions::fromUtf8<QUtf8BaseTraits>(b, output, src1, end1);
|
||||
qsizetype res = QUtf8Functions::fromUtf8<QUtf8BaseTraits>(b, output, src1, end1);
|
||||
if (res < 0) {
|
||||
// decoding error
|
||||
uc1 = QChar::ReplacementCharacter;
|
||||
|
Loading…
Reference in New Issue
Block a user