diff --git a/src/basicio.cpp b/src/basicio.cpp index c23a47bc6d..97a481ce28 100644 --- a/src/basicio.cpp +++ b/src/basicio.cpp @@ -660,7 +660,7 @@ void MemIo::Impl::reserve(size_t wcount) { if (!isMalloced_) { // Minimum size for 1st block - size_t size = std::max(blockSize * (1 + need / blockSize), size_); + auto size = std::max(blockSize * (1 + need / blockSize), size_); auto data = static_cast(std::malloc(size)); if (!data) { throw Error(ErrorCode::kerMallocFailed); @@ -828,8 +828,8 @@ DataBuf MemIo::read(size_t rcount) { } size_t MemIo::read(byte* buf, size_t rcount) { - const size_t avail = std::max(p_->size_ - p_->idx_, static_cast(0)); - const size_t allow = std::min(rcount, avail); + const auto avail = std::max(p_->size_ - p_->idx_, 0); + const auto allow = std::min(rcount, avail); if (allow > 0) { std::memcpy(buf, &p_->data_[p_->idx_], allow); } @@ -1077,7 +1077,7 @@ size_t RemoteIo::Impl::populateBlocks(size_t lowBlock, size_t highBlock) { size_t iBlock = (rcount == size_) ? 0 : lowBlock; while (remain) { - size_t allow = std::min(remain, blockSize_); + auto allow = std::min(remain, blockSize_); blocksMap_[iBlock].populate(&source[totalRead], allow); remain -= allow; totalRead += allow; @@ -1115,7 +1115,7 @@ int RemoteIo::open() { auto source = reinterpret_cast(const_cast(data.c_str())); size_t remain = p_->size_, iBlock = 0, totalRead = 0; while (remain) { - size_t allow = std::min(remain, p_->blockSize_); + auto allow = std::min(remain, p_->blockSize_); p_->blocksMap_[iBlock].populate(&source[totalRead], allow); remain -= allow; totalRead += allow; @@ -1240,7 +1240,7 @@ size_t RemoteIo::read(byte* buf, size_t rcount) { return 0; p_->totalRead_ += rcount; - size_t allow = std::min(rcount, (p_->size_ - p_->idx_)); + auto allow = std::min(rcount, (p_->size_ - p_->idx_)); size_t lowBlock = p_->idx_ / p_->blockSize_; size_t highBlock = (p_->idx_ + allow) / p_->blockSize_; @@ -1258,7 +1258,7 @@ size_t RemoteIo::read(byte* buf, size_t rcount) { byte* data = p_->blocksMap_[iBlock++].getData(); if (!data) data = fakeData; - size_t blockR = std::min(allow, p_->blockSize_ - startPos); + auto blockR = std::min(allow, p_->blockSize_ - startPos); std::memcpy(&buf[totalRead], &data[startPos], blockR); totalRead += blockR; startPos = 0; diff --git a/src/jp2image.cpp b/src/jp2image.cpp index e19bfd6665..b721c0d77b 100644 --- a/src/jp2image.cpp +++ b/src/jp2image.cpp @@ -467,8 +467,7 @@ void Jp2Image::printStructure(std::ostream& out, PrintStructureOption option, si io_->read(data.data(), data.size()); if (bPrint) { out << Internal::stringFormat("%8zu | %8u | sub:", address, subBox.length) << toAscii(subBox.type) - << " | " - << Internal::binaryToString(makeSlice(data, 0, std::min(static_cast(30), data.size()))); + << " | " << Internal::binaryToString(makeSlice(data, 0, std::min(30, data.size()))); bLF = true; } diff --git a/src/pngimage.cpp b/src/pngimage.cpp index a4f577ca0e..36d9b3665c 100644 --- a/src/pngimage.cpp +++ b/src/pngimage.cpp @@ -42,7 +42,7 @@ const auto nullComp = reinterpret_cast("\0\0"); const auto typeExif = reinterpret_cast("eXIf"); const auto typeICCP = reinterpret_cast("iCCP"); bool compare(std::string_view str, const Exiv2::DataBuf& buf) { - const auto minlen = std::min(str.size(), buf.size()); + const auto minlen = std::min(str.size(), buf.size()); return buf.cmpBytes(0, str.data(), minlen) == 0; } } // namespace diff --git a/src/tiffcomposite_int.cpp b/src/tiffcomposite_int.cpp index 376e795059..32d29d3a22 100644 --- a/src/tiffcomposite_int.cpp +++ b/src/tiffcomposite_int.cpp @@ -407,7 +407,7 @@ bool TiffBinaryArray::updOrigDataBuf(const byte* pData, size_t size) { size_t TiffBinaryArray::addElement(size_t idx, const ArrayDef& def) { auto tag = static_cast(idx / cfg()->tagStep()); - size_t sz = std::min(def.size(tag, cfg()->group_), TiffEntryBase::doSize() - idx); + auto sz = std::min(def.size(tag, cfg()->group_), TiffEntryBase::doSize() - idx); auto tc = TiffCreator::create(tag, cfg()->group_); auto tp = dynamic_cast(tc.get()); // The assertion typically fails if a component is not configured in @@ -1361,7 +1361,7 @@ size_t TiffBinaryArray::doSize() const { if (cfg()->hasFillers_ && def()) { const ArrayDef* lastDef = def() + defSize() - 1; auto lastTag = static_cast(lastDef->idx_ / cfg()->tagStep()); - idx = std::max(idx, lastDef->idx_ + lastDef->size(lastTag, cfg()->group_)); + idx = std::max(idx, lastDef->idx_ + lastDef->size(lastTag, cfg()->group_)); } return idx;