diff --git a/app/actions.cpp b/app/actions.cpp index 06285aee34..73b275df4e 100644 --- a/app/actions.cpp +++ b/app/actions.cpp @@ -180,7 +180,7 @@ static int setModeAndPrintStructure(Exiv2::PrintStructureOption option, const st std::string str = output.str(); if (result == 0 && !str.empty()) { Exiv2::DataBuf iccProfile(str.size()); - Exiv2::DataBuf ascii(str.size() * 3 + 1); + Exiv2::DataBuf ascii((str.size() * 3) + 1); ascii.write_uint8(str.size() * 3, 0); std::copy(str.begin(), str.end(), iccProfile.begin()); if (Exiv2::base64encode(iccProfile.c_data(), str.size(), reinterpret_cast(ascii.data()), str.size() * 3)) { @@ -1827,7 +1827,7 @@ int renameFile(std::string& newPath, const tm* tm) { auto oldFsPath = fs::path(path); std::string format = Params::instance().format_; std::string filename = p.stem().string(); - std::string basesuffix = ""; + std::string basesuffix; int pos = filename.find('.'); if (pos > 0) basesuffix = filename.substr(filename.find('.')); diff --git a/samples/iptctest.cpp b/samples/iptctest.cpp index 50a1698024..3a1b872e09 100644 --- a/samples/iptctest.cpp +++ b/samples/iptctest.cpp @@ -31,7 +31,7 @@ int main(int argc, char* const argv[]) { std::string line; int num = 0; std::getline(std::cin, line); - while (line.length() && processLine(line, ++num, image->iptcData())) { + while (!line.empty() && processLine(line, ++num, image->iptcData())) { std::getline(std::cin, line); } diff --git a/src/asfvideo.cpp b/src/asfvideo.cpp index 9fa5e089e1..2674cfc9ad 100644 --- a/src/asfvideo.cpp +++ b/src/asfvideo.cpp @@ -50,7 +50,7 @@ AsfVideo::GUIDTag::GUIDTag(const uint8_t* bytes) { std::memcpy(&data1_, bytes, DWORD); std::memcpy(&data2_, bytes + DWORD, WORD); std::memcpy(&data3_, bytes + DWORD + WORD, WORD); - std::copy(bytes + QWORD, bytes + 2 * QWORD, data4_.begin()); + std::copy(bytes + QWORD, bytes + (2 * QWORD), data4_.begin()); if (isBigEndianPlatform()) { data1_ = byteSwap(data1_, true); data2_ = byteSwap(data2_, true); @@ -295,7 +295,7 @@ void AsfVideo::decodeHeader() { uint32_t nb_headers = Exiv2::getULong(nbHeadersBuf.data(), littleEndian); Internal::enforce(nb_headers < std::numeric_limits::max(), Exiv2::ErrorCode::kerCorruptedMetadata); - io_->seekOrThrow(io_->tell() + BYTE * 2, BasicIo::beg, + io_->seekOrThrow(io_->tell() + (BYTE * 2), BasicIo::beg, ErrorCode::kerFailedToReadImageData); // skip two reserved tags for (uint32_t i = 0; i < nb_headers; i++) { decodeBlock(); @@ -346,7 +346,7 @@ void AsfVideo::DegradableJPEGMedia() { height_ = height; xmpData_["Xmp.video.Height"] = height; - io_->seek(io_->tell() + WORD * 3 /*3 Reserved*/, BasicIo::beg); + io_->seek(io_->tell() + (WORD * 3) /*3 Reserved*/, BasicIo::beg); uint32_t interchange_data_length = readWORDTag(io_); io_->seek(io_->tell() + interchange_data_length /*Interchange data*/, BasicIo::beg); diff --git a/src/basicio.cpp b/src/basicio.cpp index ece4d83f24..4c3b5c428f 100644 --- a/src/basicio.cpp +++ b/src/basicio.cpp @@ -11,6 +11,7 @@ #include "image_int.hpp" #include "types.hpp" +#include #include // for remove, rename #include // for alloc, realloc, free #include // std::memcpy @@ -655,8 +656,7 @@ void MemIo::Impl::reserve(size_t wcount) { if (need > size_) { if (need > sizeAlloced_) { blockSize = 2 * sizeAlloced_; - if (blockSize > maxBlockSize) - blockSize = maxBlockSize; + blockSize = std::min(blockSize, maxBlockSize); // Allocate in blocks size_t want = blockSize * (1 + need / blockSize); data_ = static_cast(std::realloc(data_, want)); @@ -1241,7 +1241,7 @@ size_t RemoteIo::read(byte* buf, size_t rcount) { } size_t iBlock = lowBlock; - size_t startPos = p_->idx_ - lowBlock * p_->blockSize_; + size_t startPos = p_->idx_ - (lowBlock * p_->blockSize_); size_t totalRead = 0; do { auto data = p_->blocksMap_[iBlock++].getData(); @@ -1273,7 +1273,7 @@ int RemoteIo::getb() { p_->populateBlocks(expectedBlock, expectedBlock); auto data = p_->blocksMap_[expectedBlock].getData(); - return data[p_->idx_++ - expectedBlock * p_->blockSize_]; + return data[p_->idx_++ - (expectedBlock * p_->blockSize_)]; } void RemoteIo::transfer(BasicIo& src) { @@ -1303,8 +1303,7 @@ int RemoteIo::seek(int64_t offset, Position pos) { // if (newIdx < 0 || newIdx > (long) p_->size_) return 1; p_->idx_ = static_cast(newIdx); p_->eof_ = newIdx > static_cast(p_->size_); - if (p_->idx_ > p_->size_) - p_->idx_ = p_->size_; + p_->idx_ = std::min(p_->idx_, p_->size_); return 0; } @@ -1439,7 +1438,7 @@ void HttpIo::HttpImpl::getDataByRange(size_t lowBlock, size_t highBlock, std::st std::string errors; if (lowBlock != std::numeric_limits::max() && highBlock != std::numeric_limits::max()) { std::stringstream ss; - ss << "Range: bytes=" << lowBlock * blockSize_ << "-" << ((highBlock + 1) * blockSize_ - 1) << "\r\n"; + ss << "Range: bytes=" << lowBlock * blockSize_ << "-" << (((highBlock + 1) * blockSize_) - 1) << "\r\n"; request["header"] = ss.str(); } @@ -1475,7 +1474,7 @@ void HttpIo::HttpImpl::writeRemote(const byte* data, size_t size, size_t from, s request["verb"] = "POST"; // encode base64 - size_t encodeLength = ((size + 2) / 3) * 4 + 1; + size_t encodeLength = (((size + 2) / 3) * 4) + 1; std::vector encodeData(encodeLength); base64encode(data, size, encodeData.data(), encodeLength); // url encode @@ -1618,7 +1617,7 @@ void CurlIo::CurlImpl::getDataByRange(size_t lowBlock, size_t highBlock, std::st if (lowBlock != std::numeric_limits::max() && highBlock != std::numeric_limits::max()) { std::stringstream ss; - ss << lowBlock * blockSize_ << "-" << ((highBlock + 1) * blockSize_ - 1); + ss << lowBlock * blockSize_ << "-" << (((highBlock + 1) * blockSize_) - 1); std::string range = ss.str(); curl_easy_setopt(curl_, CURLOPT_RANGE, range.c_str()); } @@ -1658,7 +1657,7 @@ void CurlIo::CurlImpl::writeRemote(const byte* data, size_t size, size_t from, s curl_easy_setopt(curl_, CURLOPT_SSL_VERIFYPEER, 0L); // encode base64 - size_t encodeLength = ((size + 2) / 3) * 4 + 1; + size_t encodeLength = (((size + 2) / 3) * 4) + 1; std::vector encodeData(encodeLength); base64encode(data, size, encodeData.data(), encodeLength); // url encode diff --git a/src/canonmn_int.cpp b/src/canonmn_int.cpp index e0aac23576..c68c81860f 100644 --- a/src/canonmn_int.cpp +++ b/src/canonmn_int.cpp @@ -2836,9 +2836,8 @@ std::ostream& CanonMakerNote::print0x000c(std::ostream& os, const Value& value, is >> l; return os << std::setw(4) << std::setfill('0') << std::hex << ((l & 0xffff0000) >> 16) << std::setw(5) << std::setfill('0') << std::dec << (l & 0x0000ffff); - } else { - return os << value; } + return os << value; } std::ostream& CanonMakerNote::printCs0x0002(std::ostream& os, const Value& value, const ExifData*) { @@ -3172,7 +3171,7 @@ std::ostream& CanonMakerNote::printSi0x0017(std::ostream& os, const Value& value std::ostringstream oss; oss.copyfmt(os); - os << std::fixed << std::setprecision(2) << value.toInt64() / 8.0 - 6.0; + os << std::fixed << std::setprecision(2) << (value.toInt64() / 8.0) - 6.0; os.copyfmt(oss); return os; } diff --git a/src/casiomn_int.cpp b/src/casiomn_int.cpp index 37776028cc..72f2ebedf3 100644 --- a/src/casiomn_int.cpp +++ b/src/casiomn_int.cpp @@ -169,7 +169,7 @@ std::ostream& CasioMakerNote::print0x0015(std::ostream& os, const Value& value, if (numbers.size() >= 10) { // year - long l = (numbers[0] - 48) * 10 + (numbers[1] - 48); + long l = ((numbers[0] - 48) * 10) + (numbers[1] - 48); if (l < 70) l += 2000; else @@ -470,7 +470,7 @@ std::ostream& Casio2MakerNote::print0x2001(std::ostream& os, const Value& value, if (numbers.size() >= 10) { // year - long l = (numbers[0] - 48) * 10 + (numbers[1] - 48); + long l = ((numbers[0] - 48) * 10) + (numbers[1] - 48); if (l < 70) l += 2000; else diff --git a/src/convert.cpp b/src/convert.cpp index e104e672f4..038fe51e8f 100644 --- a/src/convert.cpp +++ b/src/convert.cpp @@ -24,7 +24,6 @@ #ifdef EXV_HAVE_ICONV #include -#include #elif defined _WIN32 #include #endif @@ -829,7 +828,7 @@ void Converter::cnvExifGPSCoord(const char* from, const char* to) { // Hack: Need Value::toDouble deg[i] = static_cast(z) / d; } - double min = deg[0] * 60.0 + deg[1] + deg[2] / 60.0; + double min = (deg[0] * 60.0) + deg[1] + (deg[2] / 60.0); auto ideg = static_cast(min / 60.0); min -= ideg * 60; std::ostringstream oss; diff --git a/src/crwimage_int.cpp b/src/crwimage_int.cpp index dae684919d..e8457a1283 100644 --- a/src/crwimage_int.cpp +++ b/src/crwimage_int.cpp @@ -6,6 +6,7 @@ #include "error.hpp" #include "i18n.h" // NLS support. +#include #include #include @@ -251,7 +252,7 @@ void CiffDirectory::readDirectory(const byte* pData, size_t size, ByteOrder byte for (uint16_t i = 0; i < count; ++i) { uint16_t tag = getUShort(pData + o, byteOrder); auto m = [this, tag]() -> std::unique_ptr { - if (this->typeId(tag) == TypeId::directory) + if (Exiv2::Internal::CiffDirectory::typeId(tag) == TypeId::directory) return std::make_unique(); return std::make_unique(); }(); @@ -580,7 +581,7 @@ void CiffHeader::remove(uint16_t crwTagId, uint16_t crwDir) const { } // CiffHeader::remove void CiffComponent::remove(CrwDirs& crwDirs, uint16_t crwTagId) { - return doRemove(crwDirs, crwTagId); + doRemove(crwDirs, crwTagId); } // CiffComponent::remove void CiffComponent::doRemove(CrwDirs& /*crwDirs*/, uint16_t /*crwTagId*/) { @@ -672,7 +673,7 @@ void CrwMap::decode0x080a(const CiffComponent& ciffComponent, const CrwMapping* void CrwMap::decodeArray(const CiffComponent& ciffComponent, const CrwMapping* pCrwMapping, Image& image, ByteOrder byteOrder) { if (ciffComponent.typeId() != unsignedShort) { - return decodeBasic(ciffComponent, pCrwMapping, image, byteOrder); + decodeBasic(ciffComponent, pCrwMapping, image, byteOrder); return; } int64_t aperture = 0; @@ -703,7 +704,7 @@ void CrwMap::decodeArray(const CiffComponent& ciffComponent, const CrwMapping* p UShortValue value; if (ifdId == IfdId::canonCsId && c == 23 && component_size >= 52) n = 3; - value.read(ciffComponent.pData() + c * 2, n * 2, byteOrder); + value.read(ciffComponent.pData() + (c * 2), n * 2, byteOrder); image.exifData().add(key, &value); if (ifdId == IfdId::canonSiId && c == 21) aperture = value.toInt64(); @@ -732,7 +733,7 @@ void CrwMap::decodeArray(const CiffComponent& ciffComponent, const CrwMapping* p void CrwMap::decode0x180e(const CiffComponent& ciffComponent, const CrwMapping* pCrwMapping, Image& image, ByteOrder byteOrder) { if (ciffComponent.size() < 8 || ciffComponent.typeId() != unsignedLong) { - return decodeBasic(ciffComponent, pCrwMapping, image, byteOrder); + decodeBasic(ciffComponent, pCrwMapping, image, byteOrder); return; } ULongValue v; v.read(ciffComponent.pData(), 8, byteOrder); @@ -758,7 +759,7 @@ void CrwMap::decode0x180e(const CiffComponent& ciffComponent, const CrwMapping* void CrwMap::decode0x1810(const CiffComponent& ciffComponent, const CrwMapping* pCrwMapping, Image& image, ByteOrder byteOrder) { if (ciffComponent.typeId() != unsignedLong || ciffComponent.size() < 28) { - return decodeBasic(ciffComponent, pCrwMapping, image, byteOrder); + decodeBasic(ciffComponent, pCrwMapping, image, byteOrder); return; } ExifKey key1("Exif.Photo.PixelXDimension"); @@ -997,17 +998,16 @@ DataBuf packIfdId(const ExifData& exifData, IfdId ifdId, ByteOrder byteOrder) { for (auto&& exif : exifData) { if (exif.ifdId() != ifdId) continue; - const uint16_t s = exif.tag() * 2 + static_cast(exif.size()); + const uint16_t s = (exif.tag() * 2) + static_cast(exif.size()); if (s <= size) { - if (len < s) - len = s; + len = std::max(len, s); exif.copy(buf.data(exif.tag() * 2), byteOrder); } else { EXV_ERROR << "packIfdId out-of-bounds error: s = " << std::dec << s << "\n"; } } // Round the size to make it even. - buf.resize(len + len % 2); + buf.resize(len + (len % 2)); return buf; } diff --git a/src/epsimage.cpp b/src/epsimage.cpp index 2e2241b69c..4fdcb0671d 100644 --- a/src/epsimage.cpp +++ b/src/epsimage.cpp @@ -1121,9 +1121,7 @@ bool isEpsType(BasicIo& iIo, bool advance) { // read as many bytes as needed for the longest (DOS) EPS signature size_t bufSize = dosEpsSignature.size(); for (auto&& i : epsFirstLine) { - if (bufSize < i.size()) { - bufSize = i.size(); - } + bufSize = std::max(bufSize, i.size()); } const size_t restore = iIo.tell(); // save DataBuf buf = iIo.read(bufSize); diff --git a/src/helper_functions.cpp b/src/helper_functions.cpp index 6894ab3911..736d2a4b14 100644 --- a/src/helper_functions.cpp +++ b/src/helper_functions.cpp @@ -2,11 +2,12 @@ #include "helper_functions.hpp" +#include "convert.hpp" +#include "enforce.hpp" + #include #include #include -#include "convert.hpp" -#include "enforce.hpp" std::string string_from_unterminated(const char* data, size_t data_length) { if (data_length == 0) { diff --git a/src/helper_functions.hpp b/src/helper_functions.hpp index a7c820e917..0346f621c4 100644 --- a/src/helper_functions.hpp +++ b/src/helper_functions.hpp @@ -3,9 +3,11 @@ #ifndef HELPER_FUNCTIONS_HPP #define HELPER_FUNCTIONS_HPP -#include #include "basicio.hpp" #include "types.hpp" + +#include + /*! @brief Convert a (potentially not null terminated) array into a std::string. diff --git a/src/http.cpp b/src/http.cpp index cec119a1ca..75737dd86f 100644 --- a/src/http.cpp +++ b/src/http.cpp @@ -6,6 +6,7 @@ #include "http.hpp" #include +#include #include #include #include @@ -25,7 +26,6 @@ #include #include #include -#include #define SOCKET_ERROR (-1) #define WSAEWOULDBLOCK EINPROGRESS @@ -226,7 +226,7 @@ int Exiv2::http(Exiv2::Dictionary& request, Exiv2::Dictionary& response, std::st std::to_string(serv_addr.sin_port).c_str(), WSAGetLastError()); } - char buffer[32 * 1024 + 1]; + char buffer[(32 * 1024) + 1]; size_t buff_l = sizeof buffer - 1; //////////////////////////////////// diff --git a/src/image.cpp b/src/image.cpp index e14dba586e..92dc50707e 100644 --- a/src/image.cpp +++ b/src/image.cpp @@ -417,7 +417,7 @@ void Image::printIFDStructure(BasicIo& io, std::ostream& out, Exiv2::PrintStruct // if ( offset > io.size() ) offset = 0; // Denial of service? // #55 and #56 memory allocation crash test/data/POC8 - const size_t allocate64 = size * count + pad + 20; + const size_t allocate64 = (size * count) + pad + 20; if (allocate64 > io.size()) { throw Error(ErrorCode::kerInvalidMalloc); } @@ -436,7 +436,7 @@ void Image::printIFDStructure(BasicIo& io, std::ostream& out, Exiv2::PrintStruct } if (bPrint) { - const size_t address = start + 2 + i * 12; + const size_t address = start + 2 + (i * 12); const std::string offsetString = bOffsetIsPointer ? Internal::stringFormat("%10u", offset) : ""; out << Internal::indent(depth) @@ -455,8 +455,8 @@ void Image::printIFDStructure(BasicIo& io, std::ostream& out, Exiv2::PrintStruct } else if (isRationalType(type)) { for (size_t k = 0; k < kount; k++) { - uint32_t a = byteSwap4(buf, k * size + 0, bSwap); - uint32_t b = byteSwap4(buf, k * size + 4, bSwap); + uint32_t a = byteSwap4(buf, (k * size) + 0, bSwap); + uint32_t b = byteSwap4(buf, (k * size) + 4, bSwap); out << sp << a << "/" << b; sp = " "; } diff --git a/src/jp2image.cpp b/src/jp2image.cpp index 9485a28643..43c1ce338d 100644 --- a/src/jp2image.cpp +++ b/src/jp2image.cpp @@ -713,7 +713,7 @@ void Jp2Image::doWriteMetadata(BasicIo& outIo) { } // Prevent a malicious file from causing a large memory allocation. - Internal::enforce(box.length - 8 <= static_cast(io_->size() - io_->tell()), + Internal::enforce(box.length - 8 <= io_->size() - io_->tell(), ErrorCode::kerCorruptedMetadata); // Read whole box : Box header + Box data (not fixed size - can be null). diff --git a/src/jp2image_int.cpp b/src/jp2image_int.cpp index 97bdfba2a2..cb501a9c81 100644 --- a/src/jp2image_int.cpp +++ b/src/jp2image_int.cpp @@ -21,7 +21,7 @@ bool isValidBoxFileType(const std::vector& boxData) { bool clWithRightBrand = false; for (size_t i = 0; i < N; i++) { - uint32_t compatibilityList = getULong(boxData.data() + 8 + i * 4, bigEndian); + uint32_t compatibilityList = getULong(boxData.data() + 8 + (i * 4), bigEndian); if ((brand == brandJp2 && compatibilityList == brandJp2) || (brand == brandJph && compatibilityList == brandJph)) { clWithRightBrand = true; break; diff --git a/src/jpgimage.cpp b/src/jpgimage.cpp index 81452f45e6..114a3aeaca 100644 --- a/src/jpgimage.cpp +++ b/src/jpgimage.cpp @@ -817,11 +817,11 @@ void JpegBase::doWriteMetadata(BasicIo& outIo) { tmpBuf[0] = 0xff; tmpBuf[1] = app2_; - const size_t chunk_size = 256 * 256 - 40; // leave bytes for marker, header and padding + const size_t chunk_size = (256 * 256) - 40; // leave bytes for marker, header and padding size_t size = iccProfile_.size(); if (size >= 255 * chunk_size) throw Error(ErrorCode::kerTooLargeJpegSegment, "IccProfile"); - const size_t chunks = 1 + (size - 1) / chunk_size; + const size_t chunks = 1 + ((size - 1) / chunk_size); for (size_t chunk = 0; chunk < chunks; chunk++) { size_t bytes = size > chunk_size ? chunk_size : size; // bytes to write size -= bytes; diff --git a/src/nikonmn_int.cpp b/src/nikonmn_int.cpp index 4f1e559797..168b67950c 100644 --- a/src/nikonmn_int.cpp +++ b/src/nikonmn_int.cpp @@ -1759,7 +1759,7 @@ const TagInfo* Nikon3MakerNote::tagListLd4() { } std::ostream& Nikon3MakerNote::printIiIso(std::ostream& os, const Value& value, const ExifData*) { - auto v = std::lround(100.0 * std::pow(2.0, value.toInt64() / 12.0 - 5)); + auto v = std::lround(100.0 * std::pow(2.0, (value.toInt64() / 12.0) - 5)); return os << v; } @@ -1783,8 +1783,7 @@ std::ostream& Nikon3MakerNote::printAf2AreaMode(std::ostream& os, const Value& v if (contrastDetectAF == 0) return EXV_PRINT_TAG(nikonAf2AreaModeContrastDetectAfOff)(os, value, nullptr); - else - return EXV_PRINT_TAG(nikonAf2AreaModeContrastDetectAfOn)(os, value, nullptr); + return EXV_PRINT_TAG(nikonAf2AreaModeContrastDetectAfOn)(os, value, nullptr); } std::ostream& Nikon3MakerNote::print0x0007(std::ostream& os, const Value& value, const ExifData*) { @@ -3898,7 +3897,7 @@ std::ostream& Nikon3MakerNote::printTimeZone(std::ostream& os, const Value& valu oss.copyfmt(os); char sign = value.toInt64() < 0 ? '-' : '+'; long h = static_cast(std::abs(static_cast(value.toFloat() / 60.0F))) % 24; - long min = static_cast(std::abs(static_cast(value.toFloat() - h * 60))) % 60; + long min = static_cast(std::abs(static_cast(value.toFloat() - (h * 60)))) % 60; os << std::fixed << "UTC " << sign << std::setw(2) << std::setfill('0') << h << ":" << std::setw(2) << std::setfill('0') << min; os.copyfmt(oss); @@ -4033,7 +4032,7 @@ std::ostream& Nikon3MakerNote::printApertureLd4(std::ostream& os, const Value& v if (temp == 0) return os << _("n/a"); - double aperture = pow(2.0, value.toInt64() / 384.0 - 1.0); + double aperture = pow(2.0, (value.toInt64() / 384.0) - 1.0); std::ostringstream oss; oss.copyfmt(os); os << std::fixed << std::setprecision(1) << "F" << aperture; diff --git a/src/pentaxmn_int.cpp b/src/pentaxmn_int.cpp index 12033a5cf6..cedd515bb9 100644 --- a/src/pentaxmn_int.cpp +++ b/src/pentaxmn_int.cpp @@ -1258,7 +1258,7 @@ static std::ostream& printLensType(std::ostream& os, const Value& value, const E return os << Internal::readExiv2Config(section, value.toString(), undefined); } - const auto index = value.toUint32(0) * 256 + value.toUint32(1); + const auto index = (value.toUint32(0) * 256) + value.toUint32(1); // std::cout << '\n' << "printLensType value =" << value.toLong() << " index = " << index << '\n'; auto lif = Exiv2::find(lensIdFct, index); diff --git a/src/pgfimage.cpp b/src/pgfimage.cpp index 538b5bd9f4..f9fa43c81b 100644 --- a/src/pgfimage.cpp +++ b/src/pgfimage.cpp @@ -276,7 +276,7 @@ DataBuf PgfImage::readPgfHeaderStructure(BasicIo& iIo, uint32_t& width, uint32_t if (header.read_uint8(12) == 2) // Indexed color image. We pass color table (256 * 3 bytes). { - header.alloc(16 + 256 * 3); + header.alloc(16 + (256 * 3)); bufRead = iIo.read(header.data(16), 256 * 3); if (iIo.error()) diff --git a/src/properties.cpp b/src/properties.cpp index fddf483f59..e1f58f9875 100644 --- a/src/properties.cpp +++ b/src/properties.cpp @@ -5166,11 +5166,11 @@ XmpKey* XmpKey::clone_() const { } std::string XmpKey::key() const { - return std::string(p_->familyName_) + "." + p_->prefix_ + "." + p_->property_; + return std::string(Exiv2::XmpKey::Impl::familyName_) + "." + p_->prefix_ + "." + p_->property_; } const char* XmpKey::familyName() const { - return p_->familyName_; + return Exiv2::XmpKey::Impl::familyName_; } std::string XmpKey::groupName() const { diff --git a/src/quicktimevideo.cpp b/src/quicktimevideo.cpp index 2bc8964f1a..3bc4a408db 100644 --- a/src/quicktimevideo.cpp +++ b/src/quicktimevideo.cpp @@ -1216,7 +1216,7 @@ void QuickTimeVideo::audioDescDecoder() { break; case AudioChannels: xmpData_["Xmp.audio.ChannelType"] = buf.read_uint16(0, bigEndian); - xmpData_["Xmp.audio.BitsPerSample"] = (buf.data()[2] * 256 + buf.data()[3]); + xmpData_["Xmp.audio.BitsPerSample"] = ((buf.data()[2] * 256) + buf.data()[3]); break; case AudioSampleRate: xmpData_["Xmp.audio.SampleRate"] = @@ -1256,7 +1256,7 @@ void QuickTimeVideo::imageDescDecoder() { break; case SourceImageWidth_Height: xmpData_["Xmp.video.SourceImageWidth"] = buf.read_uint16(0, bigEndian); - xmpData_["Xmp.video.SourceImageHeight"] = (buf.data()[2] * 256 + buf.data()[3]); + xmpData_["Xmp.video.SourceImageHeight"] = ((buf.data()[2] * 256) + buf.data()[3]); break; case XResolution: xmpData_["Xmp.video.XResolution"] = diff --git a/src/riffvideo.cpp b/src/riffvideo.cpp index ab978fac16..a4883e36d8 100644 --- a/src/riffvideo.cpp +++ b/src/riffvideo.cpp @@ -494,7 +494,7 @@ void RiffVideo::readAviHeader() { xmpData_["Xmp.video.MaxDataRate"] = readDWORDTag(io_); // MaximumDataRate - io_->seekOrThrow(io_->tell() + DWORD * 2, BasicIo::beg, + io_->seekOrThrow(io_->tell() + (DWORD * 2), BasicIo::beg, ErrorCode::kerFailedToReadImageData); // ignore PaddingGranularity and Flags uint32_t frame_count = readDWORDTag(io_); // TotalNumberOfFrames @@ -513,7 +513,7 @@ void RiffVideo::readAviHeader() { uint32_t height = readDWORDTag(io_); xmpData_["Xmp.video.Height"] = height; - io_->seekOrThrow(io_->tell() + DWORD * 4, BasicIo::beg, + io_->seekOrThrow(io_->tell() + (DWORD * 4), BasicIo::beg, ErrorCode::kerFailedToReadImageData); // TimeScale, DataRate, StartTime, DataLength xmpData_["Xmp.video.AspectRatio"] = getAspectRatio(width, height); @@ -549,7 +549,7 @@ void RiffVideo::readStreamHeader() { xmpData_["Xmp.video.Codec"] = readStringTag(io_); // DataHandler - io_->seekOrThrow(io_->tell() + DWORD * 2 + WORD * 2, BasicIo::beg, + io_->seekOrThrow(io_->tell() + (DWORD * 2) + (WORD * 2), BasicIo::beg, ErrorCode::kerFailedToReadImageData); // dwFlags, wPriority, wLanguage, dwInitialFrames uint32_t divisor = readDWORDTag(io_); // TimeScale @@ -570,7 +570,7 @@ void RiffVideo::readStreamHeader() { xmpData_[(streamType_ == Video) ? "Xmp.video.VideoQuality" : "Xmp.video.StreamQuality"] = readDWORDTag(io_); xmpData_[(streamType_ == Video) ? "Xmp.video.VideoSampleSize" : "Xmp.video.StreamSampleSize"] = readDWORDTag(io_); - io_->seekOrThrow(io_->tell() + DWORD * 2, BasicIo::beg, ErrorCode::kerFailedToReadImageData); + io_->seekOrThrow(io_->tell() + (DWORD * 2), BasicIo::beg, ErrorCode::kerFailedToReadImageData); } void RiffVideo::readStreamFormat(uint64_t size_) { @@ -605,7 +605,7 @@ void RiffVideo::readStreamFormat(uint64_t size_) { #endif if (streamType_ == Video) { - io_->seekOrThrow(io_->tell() + DWORD * 3, BasicIo::beg, + io_->seekOrThrow(io_->tell() + (DWORD * 3), BasicIo::beg, ErrorCode::kerFailedToReadImageData); // ignore biSize, biWidth, biHeight xmpData_["Xmp.video.Planes"] = readWORDTag(io_); xmpData_["Xmp.video.PixelDepth"] = readWORDTag(io_); diff --git a/src/sonymn_int.cpp b/src/sonymn_int.cpp index 07e09cb7a5..9ee78e3a2d 100644 --- a/src/sonymn_int.cpp +++ b/src/sonymn_int.cpp @@ -844,7 +844,7 @@ static auto getMetaVersion(const ExifData* metadata, std::string& val) { if (pos != metadata->end() && pos->typeId() == asciiString) { std::string temp = pos->toString(); - if (temp.length() != 0) { + if (!temp.empty()) { val = temp; return true; } diff --git a/src/tags_int.cpp b/src/tags_int.cpp index f71959c11e..0d305f4d17 100644 --- a/src/tags_int.cpp +++ b/src/tags_int.cpp @@ -2828,7 +2828,7 @@ std::ostream& print0x0007(std::ostream& os, const Value& value, const ExifData*) } std::ostringstream oss; oss.copyfmt(os); - const double t = 3600.0 * value.toInt64(0) + 60.0 * value.toInt64(1) + value.toFloat(2); + const double t = (3600.0 * value.toInt64(0)) + (60.0 * value.toInt64(1)) + value.toFloat(2); enforce(std::isfinite(t), "Non-finite time value"); int p = 0; const double fraction = std::fmod(t, 1); @@ -2841,7 +2841,7 @@ std::ostream& print0x0007(std::ostream& os, const Value& value, const ExifData*) const auto hh = static_cast(std::fmod(hours, 24)); os << std::setw(2) << std::setfill('0') << std::right << hh << ":" << std::setw(2) << std::setfill('0') - << std::right << mm << ":" << std::setw(2 + p * 2) << std::setfill('0') << std::right << std::fixed + << std::right << mm << ":" << std::setw(2 + (p * 2)) << std::setfill('0') << std::right << std::fixed << std::setprecision(p) << ss; os.copyfmt(oss); diff --git a/src/tiffcomposite_int.cpp b/src/tiffcomposite_int.cpp index cfc5cdf2bf..21b691d0c9 100644 --- a/src/tiffcomposite_int.cpp +++ b/src/tiffcomposite_int.cpp @@ -823,7 +823,7 @@ size_t TiffDirectory::doWrite(IoWrapper& ioWrapper, ByteOrder byteOrder, size_t ioWrapper.setTarget(OffsetWriter::cr2RawIfdOffset, offset); } // Size of all directory entries, without values and additional data - const size_t sizeDir = 2 + 12 * compCount + (hasNext_ ? 4 : 0); + const size_t sizeDir = 2 + (12 * compCount) + (hasNext_ ? 4 : 0); // TIFF standard requires IFD entries to be sorted in ascending order by tag. // Not sorting makernote directories sometimes preserves them better. @@ -1276,7 +1276,7 @@ size_t TiffComponent::size() const { size_t TiffDirectory::doSize() const { size_t compCount = count(); // Size of the directory, without values and additional data - size_t len = 2 + 12 * compCount + (hasNext_ ? 4 : 0); + size_t len = 2 + (12 * compCount) + (hasNext_ ? 4 : 0); // Size of IFD values and data for (auto&& component : components_) { if (size_t sv = component->size(); sv > 4) { diff --git a/src/tiffimage_int.hpp b/src/tiffimage_int.hpp index 9c61c6db0e..d4d93625e3 100644 --- a/src/tiffimage_int.hpp +++ b/src/tiffimage_int.hpp @@ -5,11 +5,12 @@ // ***************************************************************************** // included header files -#include #include "image.hpp" #include "tiffcomposite_int.hpp" #include "tifffwd_int.hpp" +#include + // ***************************************************************************** // namespace extensions namespace Exiv2::Internal { diff --git a/src/tiffvisitor_int.cpp b/src/tiffvisitor_int.cpp index c7cc4980da..174930cfde 100644 --- a/src/tiffvisitor_int.cpp +++ b/src/tiffvisitor_int.cpp @@ -497,7 +497,7 @@ void TiffEncoder::encodeIptc() { DataBuf buf; if (rawIptc.size() % 4 != 0) { // Pad the last unsignedLong value with 0s - buf.alloc((rawIptc.size() / 4) * 4 + 4); + buf.alloc(((rawIptc.size() / 4) * 4) + 4); std::move(rawIptc.begin(), rawIptc.end(), buf.begin()); } else { buf = std::move(rawIptc); // Note: This resets rawIptc @@ -1149,7 +1149,7 @@ void TiffReader::visitSubIfd(TiffSubIfd* object) { if (object->group() == IfdId::ifd1Id) maxi = 1; for (uint32_t i = 0; i < object->count(); ++i) { - uint32_t offset = getULong(object->pData() + 4 * i, byteOrder()); + uint32_t offset = getULong(object->pData() + (4 * i), byteOrder()); if (baseOffset() + offset > size_) { #ifndef SUPPRESS_WARNINGS EXV_ERROR << "Directory " << groupName(object->group()) << ", entry 0x" << std::setw(4) << std::setfill('0') diff --git a/src/types.cpp b/src/types.cpp index 8618a0c4db..88381372ed 100644 --- a/src/types.cpp +++ b/src/types.cpp @@ -452,7 +452,7 @@ size_t d2Data(byte* buf, double d, ByteOrder byteOrder) { } void hexdump(std::ostream& os, const byte* buf, size_t len, size_t offset) { - const std::string::size_type pos = 8 + 16 * 3 + 2; + const std::string::size_type pos = 8 + (16 * 3) + 2; const std::string align(pos, ' '); std::ios::fmtflags f(os.flags()); @@ -465,7 +465,7 @@ void hexdump(std::ostream& os, const byte* buf, size_t len, size_t offset) { os << std::setw(2) << std::setfill('0') << std::right << std::hex << static_cast(c) << " "; ss << (static_cast(c) >= 31 && static_cast(c) < 127 ? static_cast(buf[i]) : '.'); } while (++i < len && i % 16 != 0); - std::string::size_type width = 9 + ((i - 1) % 16 + 1) * 3; + std::string::size_type width = 9 + (((i - 1) % 16 + 1) * 3); os << (width > pos ? "" : align.substr(width)) << ss.str() << "\n"; } os << std::dec << std::setfill(' ');