cppcheck: add const to pointers

Found with constVariablePointer

Signed-off-by: Rosen Penev <rosenp@gmail.com>
main
Rosen Penev 2 years ago
parent f9845b35e7
commit 55fffbb97e

@ -1314,8 +1314,7 @@ byte* RemoteIo::mmap(bool /*isWriteable*/) {
size_t blocks = (p_->size_ + blockSize - 1) / blockSize; size_t blocks = (p_->size_ + blockSize - 1) / blockSize;
bigBlock_ = new byte[blocks * blockSize]; bigBlock_ = new byte[blocks * blockSize];
for (size_t block = 0; block < blocks; block++) { for (size_t block = 0; block < blocks; block++) {
auto p = p_->blocksMap_[block].getData(); if (auto p = p_->blocksMap_[block].getData()) {
if (p) {
size_t nRead = block == (blocks - 1) ? p_->size_ - nRealData : blockSize; size_t nRead = block == (blocks - 1) ? p_->size_ - nRealData : blockSize;
memcpy(bigBlock_ + (block * blockSize), p, nRead); memcpy(bigBlock_ + (block * blockSize), p, nRead);
nRealData += nRead; nRealData += nRead;

@ -106,8 +106,7 @@ void CrwParser::decode(CrwImage* pCrwImage, const byte* pData, size_t size) {
header.decode(*pCrwImage); header.decode(*pCrwImage);
// a hack to get absolute offset of preview image inside CRW structure // a hack to get absolute offset of preview image inside CRW structure
auto preview = header.findComponent(0x2007, 0x0000); if (auto preview = header.findComponent(0x2007, 0x0000)) {
if (preview) {
(pCrwImage->exifData())["Exif.Image2.JPEGInterchangeFormat"] = static_cast<uint32_t>(preview->pData() - pData); (pCrwImage->exifData())["Exif.Image2.JPEGInterchangeFormat"] = static_cast<uint32_t>(preview->pData() - pData);
(pCrwImage->exifData())["Exif.Image2.JPEGInterchangeFormatLength"] = static_cast<uint32_t>(preview->size()); (pCrwImage->exifData())["Exif.Image2.JPEGInterchangeFormatLength"] = static_cast<uint32_t>(preview->size());
} }

@ -208,7 +208,7 @@ uint64_t Image::byteSwap(uint64_t value, bool bSwap) {
return bSwap ? std::byteswap(value) : value; return bSwap ? std::byteswap(value) : value;
#else #else
uint64_t result = 0; uint64_t result = 0;
auto source_value = reinterpret_cast<byte*>(&value); auto source_value = reinterpret_cast<const byte*>(&value);
auto destination_value = reinterpret_cast<byte*>(&result); auto destination_value = reinterpret_cast<byte*>(&result);
for (int i = 0; i < 8; i++) for (int i = 0; i < 8; i++)

@ -1048,7 +1048,7 @@ const Exiv2::Value* getExifValue(Exiv2::Internal::TiffComponent* pRoot, const ui
if (!pRoot) if (!pRoot)
return nullptr; return nullptr;
pRoot->accept(finder); pRoot->accept(finder);
auto te = dynamic_cast<Exiv2::Internal::TiffEntryBase*>(finder.result()); auto te = dynamic_cast<const Exiv2::Internal::TiffEntryBase*>(finder.result());
return (!te || !te->pValue()) ? nullptr : te->pValue(); return (!te || !te->pValue()) ? nullptr : te->pValue();
} }

@ -2127,7 +2127,7 @@ PrimaryGroups TiffParserWorker::findPrimaryGroups(TiffComponent* pSourceDir) {
for (auto imageGroup : imageGroups) { for (auto imageGroup : imageGroups) {
TiffFinder finder(0x00fe, imageGroup); TiffFinder finder(0x00fe, imageGroup);
pSourceDir->accept(finder); pSourceDir->accept(finder);
auto te = dynamic_cast<TiffEntryBase*>(finder.result()); auto te = dynamic_cast<const TiffEntryBase*>(finder.result());
const Value* pV = te ? te->pValue() : nullptr; const Value* pV = te ? te->pValue() : nullptr;
if (pV && pV->typeId() == unsignedLong && pV->count() == 1 && (pV->toInt64() & 1) == 0) { if (pV && pV->typeId() == unsignedLong && pV->count() == 1 && (pV->toInt64() & 1) == 0) {
ret.push_back(te->group()); ret.push_back(te->group());

@ -195,7 +195,7 @@ TiffDecoder::TiffDecoder(ExifData& exifData, IptcData& iptcData, XmpData& xmpDat
// Find camera make by looking for tag 0x010f in IFD0 // Find camera make by looking for tag 0x010f in IFD0
TiffFinder finder(0x010f, IfdId::ifd0Id); TiffFinder finder(0x010f, IfdId::ifd0Id);
pRoot_->accept(finder); pRoot_->accept(finder);
auto te = dynamic_cast<TiffEntryBase*>(finder.result()); auto te = dynamic_cast<const TiffEntryBase*>(finder.result());
if (te && te->pValue()) { if (te && te->pValue()) {
make_ = te->pValue()->toString(); make_ = te->pValue()->toString();
} }
@ -253,8 +253,7 @@ void TiffDecoder::getObjData(const byte*& pData, size_t& size, uint16_t tag, Ifd
} }
TiffFinder finder(tag, group); TiffFinder finder(tag, group);
pRoot_->accept(finder); pRoot_->accept(finder);
auto te = dynamic_cast<TiffEntryBase*>(finder.result()); if (auto te = dynamic_cast<const TiffEntryBase*>(finder.result())) {
if (te) {
pData = te->pData(); pData = te->pData();
size = te->size(); size = te->size();
return; return;
@ -467,7 +466,7 @@ TiffEncoder::TiffEncoder(ExifData& exifData, IptcData& iptcData, XmpData& xmpDat
if (make_.empty() && pRoot_) { if (make_.empty() && pRoot_) {
TiffFinder finder(0x010f, IfdId::ifd0Id); TiffFinder finder(0x010f, IfdId::ifd0Id);
pRoot_->accept(finder); pRoot_->accept(finder);
auto te = dynamic_cast<TiffEntryBase*>(finder.result()); auto te = dynamic_cast<const TiffEntryBase*>(finder.result());
if (te && te->pValue()) { if (te && te->pValue()) {
make_ = te->pValue()->toString(); make_ = te->pValue()->toString();
} }
@ -590,7 +589,7 @@ void TiffEncoder::visitDirectoryNext(TiffDirectory* object) {
} }
uint32_t TiffEncoder::updateDirEntry(byte* buf, ByteOrder byteOrder, TiffComponent* pTiffComponent) { uint32_t TiffEncoder::updateDirEntry(byte* buf, ByteOrder byteOrder, TiffComponent* pTiffComponent) {
auto pTiffEntry = dynamic_cast<TiffEntryBase*>(pTiffComponent); auto pTiffEntry = dynamic_cast<const TiffEntryBase*>(pTiffComponent);
if (!pTiffEntry) if (!pTiffEntry)
return 0; return 0;
us2Data(buf + 2, pTiffEntry->tiffType(), byteOrder); us2Data(buf + 2, pTiffEntry->tiffType(), byteOrder);
@ -847,8 +846,7 @@ void TiffEncoder::encodeImageEntry(TiffImageEntry* object, const Exifdatum* datu
if (pSourceTree_) { if (pSourceTree_) {
TiffFinder finder(object->tag(), object->group()); TiffFinder finder(object->tag(), object->group());
pSourceTree_->accept(finder); pSourceTree_->accept(finder);
auto ti = dynamic_cast<TiffImageEntry*>(finder.result()); if (auto ti = dynamic_cast<const TiffImageEntry*>(finder.result())) {
if (ti) {
object->strips_ = ti->strips_; object->strips_ = ti->strips_;
} }
} }
@ -1014,7 +1012,7 @@ void TiffReader::readDataEntryBase(TiffDataEntryBase* object) {
readTiffEntry(object); readTiffEntry(object);
TiffFinder finder(object->szTag(), object->szGroup()); TiffFinder finder(object->szTag(), object->szGroup());
pRoot_->accept(finder); pRoot_->accept(finder);
auto te = dynamic_cast<TiffEntryBase*>(finder.result()); auto te = dynamic_cast<const TiffEntryBase*>(finder.result());
if (te && te->pValue()) { if (te && te->pValue()) {
object->setStrips(te->pValue(), pData_, size_, baseOffset()); object->setStrips(te->pValue(), pData_, size_, baseOffset());
} }
@ -1187,7 +1185,7 @@ void TiffReader::visitMnEntry(TiffMnEntry* object) {
// Find camera make // Find camera make
TiffFinder finder(0x010f, IfdId::ifd0Id); TiffFinder finder(0x010f, IfdId::ifd0Id);
pRoot_->accept(finder); pRoot_->accept(finder);
auto te = dynamic_cast<TiffEntryBase*>(finder.result()); auto te = dynamic_cast<const TiffEntryBase*>(finder.result());
std::string make; std::string make;
if (te && te->pValue()) { if (te && te->pValue()) {
make = te->pValue()->toString(); make = te->pValue()->toString();
@ -1348,7 +1346,7 @@ void TiffReader::visitBinaryArray(TiffBinaryArray* object) {
// Check duplicates // Check duplicates
TiffFinder finder(object->tag(), object->group()); TiffFinder finder(object->tag(), object->group());
pRoot_->accept(finder); pRoot_->accept(finder);
if (auto te = dynamic_cast<TiffEntryBase*>(finder.result())) { if (auto te = dynamic_cast<const TiffEntryBase*>(finder.result())) {
if (te->idx() != object->idx()) { if (te->idx() != object->idx()) {
#ifndef SUPPRESS_WARNINGS #ifndef SUPPRESS_WARNINGS
EXV_WARNING << "Not decoding duplicate binary array tag 0x" << std::setw(4) << std::setfill('0') << std::hex EXV_WARNING << "Not decoding duplicate binary array tag 0x" << std::setw(4) << std::setfill('0') << std::hex

@ -586,8 +586,8 @@ void WebPImage::decodeChunks(uint32_t filesize) {
// 4 meaningful bytes + 2 padding bytes // 4 meaningful bytes + 2 padding bytes
byte exifLongHeader[] = {0xFF, 0x01, 0xFF, 0xE1, 0x00, 0x00}; byte exifLongHeader[] = {0xFF, 0x01, 0xFF, 0xE1, 0x00, 0x00};
byte exifShortHeader[] = {0x45, 0x78, 0x69, 0x66, 0x00, 0x00}; byte exifShortHeader[] = {0x45, 0x78, 0x69, 0x66, 0x00, 0x00};
byte exifTiffLEHeader[] = {0x49, 0x49, 0x2A}; // "MM*" const byte exifTiffLEHeader[] = {0x49, 0x49, 0x2A}; // "MM*"
byte exifTiffBEHeader[] = {0x4D, 0x4D, 0x00, 0x2A}; // "II\0*" const byte exifTiffBEHeader[] = {0x4D, 0x4D, 0x00, 0x2A}; // "II\0*"
size_t offset = 0; size_t offset = 0;
bool s_header = false; bool s_header = false;
bool le_header = false; bool le_header = false;
@ -727,7 +727,7 @@ bool WebPImage::equalsWebPTag(const Exiv2::DataBuf& buf, const char* str) {
*/ */
void WebPImage::inject_VP8X(BasicIo& iIo, bool has_xmp, bool has_exif, bool has_alpha, bool has_icc, uint32_t width, void WebPImage::inject_VP8X(BasicIo& iIo, bool has_xmp, bool has_exif, bool has_alpha, bool has_icc, uint32_t width,
uint32_t height) const { uint32_t height) const {
byte size[4] = {0x0A, 0x00, 0x00, 0x00}; const byte size[4] = {0x0A, 0x00, 0x00, 0x00};
byte data[10] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; byte data[10] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
iIo.write(reinterpret_cast<const byte*>(WEBP_CHUNK_HEADER_VP8X), WEBP_TAG_SIZE); iIo.write(reinterpret_cast<const byte*>(WEBP_CHUNK_HEADER_VP8X), WEBP_TAG_SIZE);
iIo.write(size, WEBP_TAG_SIZE); iIo.write(size, WEBP_TAG_SIZE);

Loading…
Cancel
Save