Fix some compilation warnings part 1

This commit is contained in:
Spiros
2025-05-31 00:03:17 +03:00
parent e998352834
commit 39c48ba3bd
3 changed files with 12 additions and 9 deletions

View File

@@ -73,9 +73,11 @@ QString AsciiView::hexDump(const QVector<unsigned char> &data) {
QString line; QString line;
line += QString("%1 ").arg(offset, 8, 16, QChar('0')).toUpper(); line += QString("%1 ").arg(offset, 8, 16, QChar('0')).toUpper();
offset += 16; offset += 16;
for (int j = 0; j < 16; ++j) { for (qsizetype j = 0; j < 16; ++j) {
if (i + j < dataSize) { if (i + j < dataSize) {
line += QString("%1 ").arg(static_cast<unsigned char>(data[i + j]), 2, 16, QChar('0')).toUpper(); line += QString("%1 ")
.arg(static_cast<unsigned char>(data[static_cast<int>(i + j)]), 2, 16, QChar('0'))
.toUpper();
} else { } else {
line += " "; line += " ";
} }
@@ -83,8 +85,8 @@ QString AsciiView::hexDump(const QVector<unsigned char> &data) {
} }
line += " "; line += " ";
for (int j = 0; j < 16 && i + j < dataSize; ++j) { for (qsizetype j = 0; j < 16 && i + j < dataSize; ++j) {
unsigned char c = data[i + j]; unsigned char c = data[static_cast<int>(i + j)];
line += (c >= 32 && c <= 126) ? QChar::fromLatin1(static_cast<char>(c)) : QChar('.'); line += (c >= 32 && c <= 126) ? QChar::fromLatin1(static_cast<char>(c)) : QChar('.');
} }
result += line + "\n"; result += line + "\n";

View File

@@ -34,8 +34,9 @@ QVector<QPair<QString, int>> JsonParser::parse(const QString &json)
} }
qsizetype colonPos = trimmedLine.indexOf(":"); qsizetype colonPos = trimmedLine.indexOf(":");
if (colonPos != -1) { if (colonPos != -1) {
QString key = removeQuotes(trimmedLine.left(colonPos)); int pos = static_cast<int>(colonPos);
QString valueString = trimmedLine.mid(colonPos + 1).trimmed(); QString key = removeQuotes(trimmedLine.left(pos));
QString valueString = trimmedLine.mid(pos + 1).trimmed();
valueString.chop(1); valueString.chop(1);
int value = valueString.toInt(); int value = valueString.toInt();
data.append(qMakePair(key, value)); data.append(qMakePair(key, value));

View File

@@ -115,15 +115,15 @@ QPair<QStringList, QJsonArray> utils::scanDevices(bool initializing)
static const QRegularExpression regex("\\}\\n\\{"); static const QRegularExpression regex("\\}\\n\\{");
while ((endIndex = allDevicesOutput.indexOf(regex, startIndex)) != -1) { while ((endIndex = allDevicesOutput.indexOf(regex, static_cast<int>(startIndex))) != -1) {
++endIndex; ++endIndex;
QString jsonFragment = allDevicesOutput.mid(startIndex, endIndex - startIndex); QString jsonFragment = allDevicesOutput.mid(static_cast<int>(startIndex), static_cast<int>(endIndex - startIndex));
deviceOutputs.append(jsonFragment); deviceOutputs.append(jsonFragment);
startIndex = endIndex; startIndex = endIndex;
} }
if (startIndex < allDevicesOutput.size()) { if (startIndex < allDevicesOutput.size()) {
QString jsonFragment = allDevicesOutput.mid(startIndex); QString jsonFragment = allDevicesOutput.mid(static_cast<int>(startIndex));
deviceOutputs.append(jsonFragment); deviceOutputs.append(jsonFragment);
} }