From 777391c1cfbd5b289d6c99cb8344018373850690 Mon Sep 17 00:00:00 2001 From: Nikolaos Ftylitakis Date: Sat, 7 Aug 2021 22:52:41 +0300 Subject: [PATCH] added various casts to avoid LGTM warning --- src/CameraImageWrapper.cpp | 2 +- src/zxing/zxing/common/BitMatrix.cpp | 2 +- src/zxing/zxing/common/GreyscaleLuminanceSource.cpp | 2 +- src/zxing/zxing/common/GreyscaleRotatedLuminanceSource.cpp | 4 ++-- src/zxing/zxing/common/HybridBinarizer.cpp | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/CameraImageWrapper.cpp b/src/CameraImageWrapper.cpp index dc3920d..7c408c3 100644 --- a/src/CameraImageWrapper.cpp +++ b/src/CameraImageWrapper.cpp @@ -195,7 +195,7 @@ void CameraImageWrapper::updateImageAsGrayscale(const QImage &origin) const int width = getWidth(); const int height = getHeight(); - imageBytes = QSharedPointer>(new std::vector(height*width)); + imageBytes = QSharedPointer>(new std::vector((size_t)height * (size_t)width)); imageBytesPerRow = QSharedPointer>>>(new std::vector>>(height)); zxing::byte* m = &(*imageBytes)[0]; diff --git a/src/zxing/zxing/common/BitMatrix.cpp b/src/zxing/zxing/common/BitMatrix.cpp index 4930b1b..2724c8b 100644 --- a/src/zxing/zxing/common/BitMatrix.cpp +++ b/src/zxing/zxing/common/BitMatrix.cpp @@ -37,7 +37,7 @@ void BitMatrix::init(int width, int height) { this->width = width; this->height = height; this->rowSize = (width + 31) >> 5; - bits.reset(new std::vector(rowSize * height)); + bits.reset(new std::vector((size_t)rowSize * (size_t)height)); } BitMatrix::BitMatrix(int dimension) { diff --git a/src/zxing/zxing/common/GreyscaleLuminanceSource.cpp b/src/zxing/zxing/common/GreyscaleLuminanceSource.cpp index e3e8547..fe66009 100644 --- a/src/zxing/zxing/common/GreyscaleLuminanceSource.cpp +++ b/src/zxing/zxing/common/GreyscaleLuminanceSource.cpp @@ -64,7 +64,7 @@ QSharedPointer> GreyscaleLuminanceSource::getMatrix() c int size = getWidth() * getHeight(); QSharedPointer> result (new std::vector(size)); for (int row = 0; row < getHeight(); row++) { - memcpy(&(*result)[row * getWidth()], &(*greyData_)[(top_ + row) * dataWidth_ + left_], getWidth()); + memcpy(&(*result)[(size_t)row * (size_t)getWidth()], &(*greyData_)[(top_ + row) * dataWidth_ + left_], getWidth()); } return result; } diff --git a/src/zxing/zxing/common/GreyscaleRotatedLuminanceSource.cpp b/src/zxing/zxing/common/GreyscaleRotatedLuminanceSource.cpp index 0f12519..d43c785 100644 --- a/src/zxing/zxing/common/GreyscaleRotatedLuminanceSource.cpp +++ b/src/zxing/zxing/common/GreyscaleRotatedLuminanceSource.cpp @@ -69,9 +69,9 @@ GreyscaleRotatedLuminanceSource::getRow(int y, QSharedPointer> GreyscaleRotatedLuminanceSource::getMatrix() const { - QSharedPointer> result (new std::vector(getWidth() * getHeight())); + QSharedPointer> result (new std::vector((size_t)getWidth() * (size_t)getHeight())); for (int y = 0; y < getHeight(); y++) { - zxing::byte* row = &(*result)[y * getWidth()]; + zxing::byte* row = &(*result)[(size_t)y * (size_t)getWidth()]; int offset = (left_ * dataWidth_) + (dataWidth_ - 1 - (y + top_)); for (int x = 0; x < getWidth(); x++) { row[x] = (*greyData_)[offset]; diff --git a/src/zxing/zxing/common/HybridBinarizer.cpp b/src/zxing/zxing/common/HybridBinarizer.cpp index 8a0c489..e8ef902 100644 --- a/src/zxing/zxing/common/HybridBinarizer.cpp +++ b/src/zxing/zxing/common/HybridBinarizer.cpp @@ -117,7 +117,7 @@ HybridBinarizer::calculateThresholdForBlock(QSharedPointer> HybridBinarizer::calculateBlackPoints(QSharedPo int height) { const int minDynamicRange = 24; - QSharedPointer> blackPoints (new std::vector(subHeight * subWidth)); + QSharedPointer> blackPoints (new std::vector((size_t)subHeight * (size_t)subWidth)); for (int y = 0; y < subHeight; y++) { int yoffset = y << BLOCK_SIZE_POWER; int maxYOffset = height - BLOCK_SIZE;