From 973479d1ac4e7f030f770a21512cdbbf6520489c Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Sat, 13 Sep 2014 07:57:45 -0700 Subject: [PATCH] fix warning in ByteCountCoded<> --- libraries/shared/src/ByteCountCoding.h | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/libraries/shared/src/ByteCountCoding.h b/libraries/shared/src/ByteCountCoding.h index ada7e7a4cb..a05ec2be3b 100644 --- a/libraries/shared/src/ByteCountCoding.h +++ b/libraries/shared/src/ByteCountCoding.h @@ -59,23 +59,15 @@ template inline QByteArray& operator>>(QByteArray& in, ByteCountCode template inline QByteArray ByteCountCoded::encode() const { QByteArray output; - //qDebug() << "data="; - //outputBufferBits((const unsigned char*)&data, sizeof(data)); - - T totalBits = sizeof(data) * BITS_IN_BYTE; - //qDebug() << "totalBits=" << totalBits; - T valueBits = totalBits; + int totalBits = sizeof(data) * BITS_IN_BYTE; + int valueBits = totalBits; bool firstValueFound = false; T temp = data; T lastBitMask = (T)(1) << (totalBits - 1); - //qDebug() << "lastBitMask="; - //outputBufferBits((const unsigned char*)&lastBitMask, sizeof(lastBitMask)); - // determine the number of bits that the value takes - for (int bitAt = 0; bitAt < totalBits; bitAt++) { + for (size_t bitAt = 0; bitAt < totalBits; bitAt++) { T bitValue = (temp & lastBitMask) == lastBitMask; - //qDebug() << "bitValue[" << bitAt <<"]=" << bitValue; if (!firstValueFound) { if (bitValue == 0) { valueBits--; @@ -85,17 +77,12 @@ template inline QByteArray ByteCountCoded::encode() const { } temp = temp << 1; } - //qDebug() << "valueBits=" << valueBits; // calculate the number of total bytes, including our header // BITS_IN_BYTE-1 because we need to code the number of bytes in the header // + 1 because we always take at least 1 byte, even if number of bits is less than a bytes worth - int numberOfBytes = (valueBits / (BITS_IN_BYTE - 1)) + 1; - //qDebug() << "numberOfBytes=" << numberOfBytes; + size_t numberOfBytes = (valueBits / (BITS_IN_BYTE - 1)) + 1; - //int numberOfBits = numberOfBytes + valueBits; - //qDebug() << "numberOfBits=" << numberOfBits; - output.fill(0, numberOfBytes); // next pack the number of header bits in, the first N-1 to be set to 1, the last to be set to 0