Merge branch 'Exiv2:main' into TestVideoData

This commit is contained in:
Mohamed Ali Chebbi 2023-02-05 00:50:17 +01:00 committed by GitHub
commit 2b2173aafe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 16 additions and 17 deletions

View File

@ -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<size_t>(blockSize * (1 + need / blockSize), size_);
auto data = static_cast<byte*>(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<size_t>(0));
const size_t allow = std::min(rcount, avail);
const auto avail = std::max<size_t>(p_->size_ - p_->idx_, 0);
const auto allow = std::min<size_t>(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<size_t>(remain, blockSize_);
blocksMap_[iBlock].populate(&source[totalRead], allow);
remain -= allow;
totalRead += allow;
@ -1115,7 +1115,7 @@ int RemoteIo::open() {
auto source = reinterpret_cast<byte*>(const_cast<char*>(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<size_t>(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<size_t>(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<size_t>(allow, p_->blockSize_ - startPos);
std::memcpy(&buf[totalRead], &data[startPos], blockR);
totalRead += blockR;
startPos = 0;

View File

@ -1145,7 +1145,7 @@ void Converter::cnvXmpGPSCoord(const char* from, const char* to) {
char sep1 = '\0';
char sep2 = '\0';
value.erase(value.length() - 1);
value.pop_back();
std::istringstream in(value);

View File

@ -264,7 +264,7 @@ void Uri::Decode(Uri& uri) {
Uri Uri::Parse(const std::string& uri) {
Uri result;
if (!uri.length())
if (uri.empty())
return result;
auto uriEnd = uri.end();
@ -320,7 +320,7 @@ Uri Uri::Parse(const std::string& uri) {
auto portEnd = (pathStart != uriEnd) ? pathStart : queryStart;
result.Port = std::string(hostEnd, portEnd);
}
if (!result.Port.length() && result.Protocol == "http")
if (result.Port.empty() && result.Protocol == "http")
result.Port = "80";
// path

View File

@ -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<size_t>(30), data.size())));
<< " | " << Internal::binaryToString(makeSlice(data, 0, std::min<size_t>(30, data.size())));
bLF = true;
}

View File

@ -200,8 +200,8 @@ void JpegBase::readMetadata() {
// the first one (most jpegs only have one anyway). Comments
// are simple single byte ISO-8859-1 strings.
comment_.assign(buf.c_str(2), size - 2);
while (comment_.length() && comment_.at(comment_.length() - 1) == '\0') {
comment_.erase(comment_.length() - 1);
while (!comment_.empty() && comment_.back() == '\0') {
comment_.pop_back();
}
--search;
} else if (marker == app2_ && size >= 13 // prevent out-of-bounds read in memcmp on next line

View File

@ -42,7 +42,7 @@ const auto nullComp = reinterpret_cast<const Exiv2::byte*>("\0\0");
const auto typeExif = reinterpret_cast<const Exiv2::byte*>("eXIf");
const auto typeICCP = reinterpret_cast<const Exiv2::byte*>("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<size_t>(str.size(), buf.size());
return buf.cmpBytes(0, str.data(), minlen) == 0;
}
} // namespace

View File

@ -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<uint16_t>(idx / cfg()->tagStep());
size_t sz = std::min(def.size(tag, cfg()->group_), TiffEntryBase::doSize() - idx);
auto sz = std::min<size_t>(def.size(tag, cfg()->group_), TiffEntryBase::doSize() - idx);
auto tc = TiffCreator::create(tag, cfg()->group_);
auto tp = dynamic_cast<TiffBinaryElement*>(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<uint16_t>(lastDef->idx_ / cfg()->tagStep());
idx = std::max(idx, lastDef->idx_ + lastDef->size(lastTag, cfg()->group_));
idx = std::max<size_t>(idx, lastDef->idx_ + lastDef->size(lastTag, cfg()->group_));
}
return idx;