diff --git a/cpp/QrCode.cpp b/cpp/QrCode.cpp index cd6ff25..8160866 100644 --- a/cpp/QrCode.cpp +++ b/cpp/QrCode.cpp @@ -93,7 +93,7 @@ QrCode QrCode::encodeSegments(const vector &segs, Ecc ecl, bb.appendBits(seg.getNumChars(), seg.getMode().numCharCountBits(version)); bb.insert(bb.end(), seg.getData().begin(), seg.getData().end()); } - if (bb.size() != static_cast(dataUsedBits)) + if (bb.size() != static_cast(dataUsedBits)) throw std::logic_error("Assertion error"); // Add terminator and pad up to a byte if applicable @@ -326,10 +326,10 @@ vector QrCode::addEccAndInterleave(const vector &data) const { // Interleave (not concatenate) the bytes from every block into a single sequence vector result; - for (int i = 0; static_cast(i) < blocks.at(0).size(); i++) { - for (int j = 0; static_cast(j) < blocks.size(); j++) { + for (size_t i = 0; i < blocks.at(0).size(); i++) { + for (size_t j = 0; j < blocks.size(); j++) { // Skip the padding byte in short blocks - if (i != shortBlockLen - blockEccLen || j >= numShortBlocks) + if (i != static_cast(shortBlockLen - blockEccLen) || j >= static_cast(numShortBlocks)) result.push_back(blocks.at(j).at(i)); } } @@ -362,7 +362,7 @@ void QrCode::drawCodewords(const vector &data) { } } } - if (static_cast(i) != data.size() * 8) + if (i != data.size() * 8) throw std::logic_error("Assertion error"); } diff --git a/cpp/QrSegment.cpp b/cpp/QrSegment.cpp index 4dbae22..8d1bde3 100644 --- a/cpp/QrSegment.cpp +++ b/cpp/QrSegment.cpp @@ -60,7 +60,7 @@ const QrSegment::Mode QrSegment::Mode::ECI (0x7, 0, 0, 0); QrSegment QrSegment::makeBytes(const vector &data) { - if (data.size() > INT_MAX) + if (data.size() > static_cast(INT_MAX)) throw std::length_error("Data too long"); BitBuffer bb; for (uint8_t b : data)