Skip to content

Commit bdff0f0

Browse files
committed
Resolving clang warnings treated as errors
1 parent be38909 commit bdff0f0

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

src/librawspeed/decompressors/PanasonicV8Decompressor.cpp

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,8 @@ void PanasonicV8Decompressor::decompress() const
166166
#pragma omp parallel for num_threads(threadCount) schedule(static) default(none)
167167
#endif
168168
for (uint stripIdx = 0; stripIdx < mParams.horizontalStripCount; ++stripIdx) {
169-
const size_t stripSize = (size_t(mParams.stripBitLengths[stripIdx]) + 7) / 8;
170-
const size_t stripOffset = mParams.stripByteOffsets[stripIdx];
169+
const uint32_t stripSize = (mParams.stripBitLengths[stripIdx] + 7) / 8;
170+
const uint32_t stripOffset = mParams.stripByteOffsets[stripIdx];
171171

172172
// Note: Relying on Buffer to catch OOB access attempts
173173
DataBuffer stripBuffer(mInputFile.getSubView(stripOffset, stripSize), Endianness::big);
@@ -210,7 +210,7 @@ void PanasonicV8Decompressor::decompressStrip(const uint stripIdx, InternalHuffD
210210

211211
// Copy lineBuffer into output buffer.
212212
for (uint linePos = 0; linePos < stripWidth*2; linePos += 4) {
213-
const size_t dstStartCol = stripOutputOffset + linePos / 2;
213+
const uint32_t dstStartCol = stripOutputOffset + linePos / 2;
214214

215215
if (mGammaLUT.empty()) [[likely]] {
216216
outBuffer[row + 0](dstStartCol + 0) = lineBuffer[linePos + 0]; // Top Red
@@ -232,7 +232,7 @@ void PanasonicV8Decompressor::decompressStrip(const uint stripIdx, InternalHuffD
232232
int32_t inline PanasonicV8Decompressor::InternalHuffDecoder::decodeNextDiffValue() {
233233
// Retrieve the difference category, which indicates magnitude of the difference between
234234
// the predicted and actual value.
235-
const uint16_t next16 = mBitPump.peekBits(16);
235+
const uint16_t next16 = uint16_t(mBitPump.peekBits(16));
236236
const auto& [bits, diffCat] = mLUT[next16];
237237
if (diffCat == 0 && bits == 7) ThrowRDE("Huffman decoding encountered an invalid value!");
238238
mBitPump.skipBits(bits); // Skip the bits that encoded the difference category
@@ -299,8 +299,8 @@ void PanasonicV8Decompressor::populateHuffmanLUT(const TiffIFD& ifd) {
299299

300300
for (HuffEntry& entry : huffTable) {
301301
entry.bitcount = stream.getU16(); // Number of bits in symbol
302-
entry.symbol = stream.getU16() << (16U - entry.bitcount);
303-
entry.mask = 0xffffU << (16U - entry.bitcount); // mask of the bits overlapping symbol
302+
entry.symbol = uint16_t(stream.getU16() << (16u - entry.bitcount));
303+
entry.mask = uint16_t(0xffffu << (16u - entry.bitcount)); // mask of the bits overlapping symbol
304304
}
305305

306306
// Cache of Huffman table results for all possible 16-bit values.
@@ -320,6 +320,9 @@ void PanasonicV8Decompressor::populateHuffmanLUT(const TiffIFD& ifd) {
320320
}
321321
}
322322

323+
324+
#pragma GCC diagnostic push
325+
#pragma GCC diagnostic ignored "-Wunreachable-code"
323326
/// Maybe the most complicated part of the entire file format, and seemingly, completely unused.
324327
void PanasonicV8Decompressor::populateGammaLUT(const TiffIFD& ifd) {
325328
// Retrieve encoded gamma curve from tags.
@@ -339,7 +342,8 @@ void PanasonicV8Decompressor::populateGammaLUT(const TiffIFD& ifd) {
339342
if (!gamamPointsAreIdentity || !gammaSlopesAreIdentity) {
340343
// Generate gamma LUT based on retrieved curve.
341344
ThrowRDE("Non-identity gamma curve encountered. Never encountered in any testing samples!");
342-
if (encodedGammaPoints.size() != 6 || encodedGammaSlopes.size() == 6) {
345+
346+
if (encodedGammaPoints.size() != 6 || encodedGammaSlopes.size() != 6) {
343347
ThrowRDE("Gamma curve point and/or slope list is not the expected length of 6");
344348
}
345349

@@ -362,11 +366,10 @@ void PanasonicV8Decompressor::populateGammaLUT(const TiffIFD& ifd) {
362366
[](const GammaPoint& a, const GammaPoint& b) { return a.x <= b.x; });
363367
if (!pointsAreOrdered) {
364368
ThrowRDE("Points in the gamma curve are out of order!");
365-
return;
366369
}
367370

368371
// Evaluates the gamma curve for value x in the piece-wise function segment 'i'
369-
const auto fnGamma = [&](const uint16_t x, const uint i) -> uint16_t {
372+
const auto fnGamma = [&](const uint32_t x, const uint i) -> uint16_t {
370373
assert(i < gammaPoints.size());
371374
const GammaPoint& pt = gammaPoints[i];
372375
const GammaSlope& slope = gammaSlopes[i];
@@ -405,5 +408,7 @@ void PanasonicV8Decompressor::populateGammaLUT(const TiffIFD& ifd) {
405408
}
406409
}
407410

411+
#pragma GCC diagnostic pop
412+
408413

409414
} // namespace rawspeed

0 commit comments

Comments
 (0)