Skip to content

Commit 39c48ba

Browse files
committed
Fix some compilation warnings part 1
1 parent e998352 commit 39c48ba

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

src/asciiview.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,18 +73,20 @@ QString AsciiView::hexDump(const QVector<unsigned char> &data) {
7373
QString line;
7474
line += QString("%1 ").arg(offset, 8, 16, QChar('0')).toUpper();
7575
offset += 16;
76-
for (int j = 0; j < 16; ++j) {
76+
for (qsizetype j = 0; j < 16; ++j) {
7777
if (i + j < dataSize) {
78-
line += QString("%1 ").arg(static_cast<unsigned char>(data[i + j]), 2, 16, QChar('0')).toUpper();
78+
line += QString("%1 ")
79+
.arg(static_cast<unsigned char>(data[static_cast<int>(i + j)]), 2, 16, QChar('0'))
80+
.toUpper();
7981
} else {
8082
line += " ";
8183
}
8284
if (j == 7) line += " ";
8385
}
8486

8587
line += " ";
86-
for (int j = 0; j < 16 && i + j < dataSize; ++j) {
87-
unsigned char c = data[i + j];
88+
for (qsizetype j = 0; j < 16 && i + j < dataSize; ++j) {
89+
unsigned char c = data[static_cast<int>(i + j)];
8890
line += (c >= 32 && c <= 126) ? QChar::fromLatin1(static_cast<char>(c)) : QChar('.');
8991
}
9092
result += line + "\n";

src/jsonparser.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,9 @@ QVector<QPair<QString, int>> JsonParser::parse(const QString &json)
3434
}
3535
qsizetype colonPos = trimmedLine.indexOf(":");
3636
if (colonPos != -1) {
37-
QString key = removeQuotes(trimmedLine.left(colonPos));
38-
QString valueString = trimmedLine.mid(colonPos + 1).trimmed();
37+
int pos = static_cast<int>(colonPos);
38+
QString key = removeQuotes(trimmedLine.left(pos));
39+
QString valueString = trimmedLine.mid(pos + 1).trimmed();
3940
valueString.chop(1);
4041
int value = valueString.toInt();
4142
data.append(qMakePair(key, value));

src/utils.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,15 +115,15 @@ QPair<QStringList, QJsonArray> utils::scanDevices(bool initializing)
115115

116116
static const QRegularExpression regex("\\}\\n\\{");
117117

118-
while ((endIndex = allDevicesOutput.indexOf(regex, startIndex)) != -1) {
118+
while ((endIndex = allDevicesOutput.indexOf(regex, static_cast<int>(startIndex))) != -1) {
119119
++endIndex;
120-
QString jsonFragment = allDevicesOutput.mid(startIndex, endIndex - startIndex);
120+
QString jsonFragment = allDevicesOutput.mid(static_cast<int>(startIndex), static_cast<int>(endIndex - startIndex));
121121
deviceOutputs.append(jsonFragment);
122122
startIndex = endIndex;
123123
}
124124

125125
if (startIndex < allDevicesOutput.size()) {
126-
QString jsonFragment = allDevicesOutput.mid(startIndex);
126+
QString jsonFragment = allDevicesOutput.mid(static_cast<int>(startIndex));
127127
deviceOutputs.append(jsonFragment);
128128
}
129129

0 commit comments

Comments
 (0)