Skip to content

Commit 4dd8e6f

Browse files
committed
static analysis fixes
1 parent cc67383 commit 4dd8e6f

File tree

4 files changed

+23
-21
lines changed

4 files changed

+23
-21
lines changed

src/librawspeed/decoders/DngDecoder.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ void DngDecoder::dropUnsuportedChunks(std::vector<const TiffIFD*>* data) {
147147
}
148148
}
149149

150-
void DngDecoder::parseCFA(const TiffIFD* raw, RawImage::frame_ptr_t frame) {
150+
void DngDecoder::parseCFA(const TiffIFD* raw, const RawImage::frame_ptr_t &frame) {
151151

152152
// Check if layout is OK, if present
153153
if (raw->hasEntry(TiffTag::CFALAYOUT) &&
@@ -214,7 +214,7 @@ void DngDecoder::parseCFA(const TiffIFD* raw, RawImage::frame_ptr_t frame) {
214214

215215
DngTilingDescription
216216
DngDecoder::getTilingDescription(const TiffIFD* raw,
217-
RawImage::frame_ptr_t frame) {
217+
const RawImage::frame_ptr_t &frame) {
218218
if (raw->hasEntry(TiffTag::TILEOFFSETS)) {
219219
const uint32_t tilew = raw->getEntry(TiffTag::TILEWIDTH)->getU32();
220220
const uint32_t tileh = raw->getEntry(TiffTag::TILELENGTH)->getU32();
@@ -274,7 +274,7 @@ DngDecoder::getTilingDescription(const TiffIFD* raw,
274274

275275
void DngDecoder::decodeData(const TiffIFD* raw, uint32_t sample_format,
276276
int compression, int bps,
277-
RawImage::frame_ptr_t frame) {
277+
const RawImage::frame_ptr_t &frame) {
278278
if (compression == 8 && sample_format != 3) {
279279
ThrowRDE("Only float format is supported for "
280280
"deflate-compressed data.");
@@ -429,7 +429,7 @@ void DngDecoder::decodeRawInternal() {
429429
}
430430

431431
void DngDecoder::handleMetadata(const TiffIFD* raw, int compression, int bps,
432-
RawImage::frame_ptr_t frame) {
432+
const RawImage::frame_ptr_t &frame) {
433433
// Crop
434434
if (raw->hasEntry(TiffTag::ACTIVEAREA)) {
435435
const TiffEntry* active_area = raw->getEntry(TiffTag::ACTIVEAREA);
@@ -675,7 +675,7 @@ void DngDecoder::checkSupportInternal(const CameraMetaData* meta) {
675675

676676
/* Decodes DNG masked areas into blackareas in the image */
677677
bool DngDecoder::decodeMaskedAreas(const TiffIFD* raw,
678-
RawImage::frame_ptr_t frame) {
678+
const RawImage::frame_ptr_t &frame) {
679679
const TiffEntry* masked = raw->getEntry(TiffTag::MASKEDAREAS);
680680

681681
if (masked->type != TiffDataType::SHORT && masked->type != TiffDataType::LONG)
@@ -718,7 +718,7 @@ bool DngDecoder::decodeMaskedAreas(const TiffIFD* raw,
718718
}
719719

720720
bool DngDecoder::decodeBlackLevels(const TiffIFD* raw,
721-
RawImage::frame_ptr_t frame) {
721+
const RawImage::frame_ptr_t &frame) {
722722
iPoint2D blackdim(1, 1);
723723
if (raw->hasEntry(TiffTag::BLACKLEVELREPEATDIM)) {
724724
const TiffEntry* bleveldim = raw->getEntry(TiffTag::BLACKLEVELREPEATDIM);
@@ -815,7 +815,7 @@ bool DngDecoder::decodeBlackLevels(const TiffIFD* raw,
815815
return true;
816816
}
817817

818-
void DngDecoder::setBlack(const TiffIFD* raw, RawImage::frame_ptr_t frame) {
818+
void DngDecoder::setBlack(const TiffIFD* raw, const RawImage::frame_ptr_t &frame) {
819819

820820
if (raw->hasEntry(TiffTag::MASKEDAREAS) && decodeMaskedAreas(raw, frame))
821821
return;

src/librawspeed/decoders/DngDecoder.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,18 +48,18 @@ class DngDecoder final : public AbstractTiffDecoder {
4848
[[nodiscard]] int getDecoderVersion() const override { return 0; }
4949
bool mFixLjpeg;
5050
static void dropUnsuportedChunks(std::vector<const TiffIFD*>* data);
51-
static void parseCFA(const TiffIFD* raw, RawImage::frame_ptr_t frame);
51+
static void parseCFA(const TiffIFD* raw, const RawImage::frame_ptr_t &frame);
5252
static DngTilingDescription getTilingDescription(const TiffIFD* raw,
53-
RawImage::frame_ptr_t frame);
53+
const RawImage::frame_ptr_t &frame);
5454
void decodeData(const TiffIFD* raw, uint32_t sample_format, int compression,
55-
int bps, RawImage::frame_ptr_t frame);
55+
int bps, const RawImage::frame_ptr_t &frame);
5656
void handleMetadata(const TiffIFD* raw, int compression, int bps,
57-
RawImage::frame_ptr_t frame);
57+
const RawImage::frame_ptr_t &frame);
5858
static bool decodeMaskedAreas(const TiffIFD* raw,
59-
RawImage::frame_ptr_t frame);
59+
const RawImage::frame_ptr_t &frame);
6060
static bool decodeBlackLevels(const TiffIFD* raw,
61-
RawImage::frame_ptr_t frame);
62-
static void setBlack(const TiffIFD* raw, RawImage::frame_ptr_t frame);
61+
const RawImage::frame_ptr_t &frame);
62+
static void setBlack(const TiffIFD* raw, const RawImage::frame_ptr_t &frame);
6363
};
6464

6565
} // namespace rawspeed

src/librawspeed/decoders/RawDecoder.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -277,12 +277,12 @@ void RawDecoder::decodeRaw() {
277277
try {
278278
decodeRawInternal();
279279
/// TODO paralelize?
280-
for (auto raw : mRaw) {
281-
mRaw.get(0)->checkMemIsInitialized();
280+
for (const auto &raw : mRaw) {
281+
raw->checkMemIsInitialized();
282282

283283
if (interpolateBadPixels) {
284-
mRaw.get(0)->fixBadPixels();
285-
mRaw.get(0)->checkMemIsInitialized();
284+
raw->fixBadPixels();
285+
raw->checkMemIsInitialized();
286286
}
287287
}
288288
mRaw.metadata.pixelAspectRatio =

src/utilities/rstest/rstest.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ std::string img_hash(const RawImage& r, bool noSamples) {
165165
APPEND(&oss, "canonical_alias: %s\n", r.metadata.canonical_alias.c_str());
166166
APPEND(&oss, "canonical_id: %s\n", r.metadata.canonical_id.c_str());
167167

168-
for (auto frame : r) {
168+
for (const auto &frame : r) {
169169

170170
APPEND(&oss, "isoSpeed: %d\n", r.metadata.isoSpeed);
171171
APPEND(&oss, "blackLevel: %d\n", frame->blackLevel);
@@ -385,13 +385,14 @@ size_t process(const std::string& filename, const CameraMetaData* metadata,
385385
// write the hash. if force is set, then we are potentially overwriting here
386386
ofstream f(hashfile);
387387
f << img_hash(decoder->mRaw, noSamples);
388-
if (o.dump)
388+
if (o.dump){
389389
for (rawspeed::RawImage::storage_t::size_type i = 0;
390390
i < decoder->mRaw.size(); ++i) {
391391
std::stringstream s;
392392
s << filename << "." << i;
393393
writeImage(decoder->mRaw.get(i).get(), s.str());
394394
}
395+
}
395396
} else {
396397
// do generate the hash string regardless.
397398
std::string h = img_hash(decoder->mRaw, noSamples);
@@ -406,13 +407,14 @@ size_t process(const std::string& filename, const CameraMetaData* metadata,
406407
if (h!= truth) {
407408
ofstream f(filename + ".hash.failed");
408409
f << h;
409-
if (o.dump)
410+
if (o.dump){
410411
for (rawspeed::RawImage::storage_t::size_type i = 0;
411412
i < decoder->mRaw.size(); ++i) {
412413
std::stringstream s;
413414
s << filename << "." << i << ".failed";
414415
writeImage(decoder->mRaw.get(i).get(), s.str());
415416
}
417+
}
416418
throw RstestHashMismatch("hash/metadata mismatch", time);
417419
}
418420
}

0 commit comments

Comments
 (0)