Fix TTSReader compiler warnings

.. spurious warnings hide real issues.
This commit is contained in:
Mark Liversedge
2021-05-15 12:58:56 +01:00
parent ae2df3a271
commit a4e9b52eeb
2 changed files with 21 additions and 17 deletions

View File

@@ -103,13 +103,13 @@ int getUByte(ByteArray &buffer, int offset) {
return (UByte)(buffer[offset]);
}
int getUShort(ByteArray buffer, int offset) {
int getUShort(ByteArray buffer, size_t offset) {
if((offset + 1) < buffer.size())
return *(unsigned short*)&buffer[offset];
return getUByte(buffer, offset);
}
int getUInt(ByteArray &buffer, int offset) {
int getUInt(ByteArray &buffer, size_t offset) {
if ((offset + 3) < buffer.size()) {
return *(unsigned*)&buffer[offset];
}
@@ -221,9 +221,9 @@ bool decryptData(IntArray &A_0, IntArray &A_1, IntArray &numArray) {
numArray.resize(A_0.size());
int index = 0;
size_t index = 0;
int num1 = 5;
int num2 = -1000;
size_t num2 = -1000;
int e = 0; // set before each block
while (true) {
@@ -381,7 +381,7 @@ void Point::print() const {
//
bool TTSReader::readData(QDataStream &is, ByteArray& buffer, bool copyPre) {
int first = 0;
size_t first = 0;
if (copyPre) {
buffer[0] = pre[0];
buffer[1] = pre[1];
@@ -391,7 +391,7 @@ bool TTSReader::readData(QDataStream &is, ByteArray& buffer, bool copyPre) {
if (buffer.size() != first) {
size_t readSize = buffer.size() - first;
int iBytesRead = is.readRawData((char*)&buffer[first], (int)buffer.size() - first);
size_t iBytesRead = is.readRawData((char*)&buffer[first], (int)buffer.size() - first);
if (iBytesRead != readSize) return false;
}
@@ -612,7 +612,7 @@ bool TTSReader::loadHeaders() {
StringType stringType = StringType::BLOCK;
int fingerprint = 0;
//int fingerprint = 0; // not used
int bytes = 0;
@@ -627,7 +627,7 @@ bool TTSReader::loadHeaders() {
<< getUShort(data, 4) << " " << getUInt(data, 6) << "x"
<< getUInt(data, 10) << "\n";
fingerprint = getUInt(data, 6);
//fingerprint = getUInt(data, 6);
IntArray ia;
iarr(data, ia);
@@ -700,7 +700,7 @@ bool TTSReader::loadHeaders() {
case IMAGE:
DEBUG_LOG << "[image " << blockType << "." << (stringId - 1000) + "]";
//DEBUG_LOG << "[image " << blockType << "." << (stringId - 1000) + "]";
/*
* try { result = currentFile + "." + (imageId++) + ".png";
@@ -722,7 +722,7 @@ bool TTSReader::loadHeaders() {
std::wstring result;
for (int i = 0; i < decrD.size() / 2; i++) {
for (size_t i = 0; i < decrD.size() / 2; i++) {
Char c = (Char)(decrD[2 * i] | (int)decrD[2 * i + 1] << 8);
result.append(1, c);
}
@@ -759,6 +759,7 @@ bool TTSReader::loadHeaders() {
barr(decrD, ba);
blockProcessing(blockType, version, ba);
}
default:
break;
}
}
@@ -806,7 +807,7 @@ bool TTSReader::loadHeaders() {
basis = FrameMap;
} else if (gpsCount >= slopeCount) {
// GpsList basis
for (int i = 0; i < gpsCount; i++) {
for (size_t i = 0; i < gpsCount; i++) {
Point p;
p.setDistanceFromStart(gpsPoints[i].distance);
@@ -819,7 +820,7 @@ bool TTSReader::loadHeaders() {
basis = GPS;
} else {
// slope basis
for (int i = 0; i < slopeCount; i++) {
for (size_t i = 0; i < slopeCount; i++) {
Point p;
p.setDistanceFromStart(programList[i].distance);
@@ -841,11 +842,11 @@ bool TTSReader::loadHeaders() {
DistancePointInterpolator<LinearTwoPointInterpolator> si;
// Interpolate non-basis streams onto points[].
int frameMapIdx = 0;
int gpsIdx = 0;
int slopeIdx = 0;
size_t frameMapIdx = 0;
size_t gpsIdx = 0;
size_t slopeIdx = 0;
for (int i = 0; i < points.size(); i++) {
for (unsigned long i = 0; i < points.size(); i++) {
fHasKM = true;
@@ -989,10 +990,12 @@ void TTSReader::blockProcessing(int blockType, int version, ByteArray &data) {
case VIDEO_INFO:
videoInfo(version, data);
break;
default:
DEBUG_LOG << "Unidentified block type " << blockType << "\n";
break;
}
}

View File

@@ -171,7 +171,7 @@ void inride_BTDeviceInfoToSystemID(const QBluetoothDeviceInfo &devinfo, uint8_t
}
qDebug() << "SystemID: " << hex << systemID[0] << systemID[1] << systemID[2] << systemID[3] << systemID[4] << systemID[5];
qDebug() << "SystemID: " << Qt::hex << systemID[0] << systemID[1] << systemID[2] << systemID[3] << systemID[4] << systemID[5];
}
@@ -232,6 +232,7 @@ alpha_coast alpha(uint32_t interval, uint32_t ticks, uint32_t revs, double speed
int power_for_speed(double kph, double spindown, double alpha, uint32_t revolutions)
{
Q_UNUSED(alpha);
Q_UNUSED(revolutions);
double mph = kph * 0.621371;
double rawPower = (5.244820 * mph) + (0.019168 * (mph * mph * mph));
double dragOffset = 0;