From ca95edc6bd09735134cc0e0e10225d340384d6f1 Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Thu, 9 Mar 2023 17:53:44 -0800 Subject: [PATCH] random fixes Signed-off-by: Rosen Penev --- app/actions.cpp | 10 +--------- app/actions.hpp | 4 ++++ include/exiv2/bmffimage.hpp | 5 ++++- include/exiv2/psdimage.hpp | 2 +- src/asfvideo.cpp | 2 +- src/bmffimage.cpp | 2 +- src/fujimn_int.cpp | 10 +++++----- src/futils.cpp | 4 ++-- src/iptc.cpp | 13 ++----------- src/makernote_int.cpp | 2 +- src/matroskavideo.cpp | 2 +- src/pentaxmn_int.cpp | 12 ++++++------ src/pngimage.cpp | 4 ++-- src/quicktimevideo.cpp | 6 +++--- src/samsungmn_int.cpp | 8 ++++---- src/tiffcomposite_int.hpp | 8 -------- src/xmp.cpp | 2 +- unitTests/test_asfvideo.cpp | 2 +- unitTests/test_matroskavideo.cpp | 2 +- unitTests/test_riffVideo.cpp | 2 +- 20 files changed, 42 insertions(+), 60 deletions(-) diff --git a/app/actions.cpp b/app/actions.cpp index 835ea83f..70e570f3 100644 --- a/app/actions.cpp +++ b/app/actions.cpp @@ -172,7 +172,7 @@ Task::UniquePtr TaskFactory::create(TaskType type) { return nullptr; } -int setModeAndPrintStructure(Exiv2::PrintStructureOption option, const std::string& path, bool binary) { +static int setModeAndPrintStructure(Exiv2::PrintStructureOption option, const std::string& path, bool binary) { int result = 0; if (binary && option == Exiv2::kpsIccProfile) { std::stringstream output(std::stringstream::out | std::stringstream::binary); @@ -1815,14 +1815,6 @@ int metacopy(const std::string& source, const std::string& tgt, Exiv2::ImageType return rc; } // metacopy -// Defined outside of the function so that Exiv2::find() can see it -struct String { - const char* s_; - bool operator==(const char* s) const { - return 0 == strcmp(s_, s); - } -}; - void replace(std::string& text, const std::string& searchText, const std::string& replaceText) { std::string::size_type index = 0; while ((index = text.find(searchText, index)) != std::string::npos) { diff --git a/app/actions.hpp b/app/actions.hpp index 60f3cfa8..2349ccc1 100644 --- a/app/actions.hpp +++ b/app/actions.hpp @@ -59,6 +59,10 @@ class Task { //! Virtual destructor. virtual ~Task() = default; + Task() = default; + Task(const Task&) = default; + Task& operator=(const Task&) = default; + //! Virtual copy construction. virtual UniquePtr clone() const = 0; diff --git a/include/exiv2/bmffimage.hpp b/include/exiv2/bmffimage.hpp index 971c3b25..df91095c 100644 --- a/include/exiv2/bmffimage.hpp +++ b/include/exiv2/bmffimage.hpp @@ -19,8 +19,11 @@ EXIV2API bool enableBMFF(bool enable = true); #ifdef EXV_ENABLE_BMFF namespace Exiv2 { struct Iloc { - explicit Iloc(uint32_t ID = 0, uint32_t start = 0, uint32_t length = 0) : ID_(ID), start_(start), length_(length){}; + explicit Iloc(uint32_t ID = 0, uint32_t start = 0, uint32_t length = 0) : ID_(ID), start_(start), length_(length) { + } virtual ~Iloc() = default; + Iloc(const Iloc&) = default; + Iloc& operator=(const Iloc&) = default; uint32_t ID_; uint32_t start_; diff --git a/include/exiv2/psdimage.hpp b/include/exiv2/psdimage.hpp index c3a5d5f8..4d082444 100644 --- a/include/exiv2/psdimage.hpp +++ b/include/exiv2/psdimage.hpp @@ -70,7 +70,7 @@ class EXIV2API PsdImage : public Image { /*! @brief Provides the main implementation of writeMetadata() by writing all buffered metadata to the provided BasicIo. - @param oIo BasicIo instance to write to (a temporary location). + @param outIo BasicIo instance to write to (a temporary location). @return 4 if opening or writing to the associated BasicIo fails */ diff --git a/src/asfvideo.cpp b/src/asfvideo.cpp index 9c2a30b9..029de53c 100644 --- a/src/asfvideo.cpp +++ b/src/asfvideo.cpp @@ -200,7 +200,7 @@ const std::map GUIDReferenceTags = { @param buf Exiv2 byte buffer @return Returns true if the buffer data is equivalent to Header GUID. */ -bool isASFType(const byte buf[]) { +static bool isASFType(const byte buf[]) { return Header == AsfVideo::GUIDTag(buf); } diff --git a/src/bmffimage.cpp b/src/bmffimage.cpp index af94c208..159fd161 100644 --- a/src/bmffimage.cpp +++ b/src/bmffimage.cpp @@ -441,7 +441,7 @@ uint64_t BmffImage::boxHandler(std::ostream& out /* = std::cout*/, Exiv2::PrintS } // save data for post-processing in meta box if (offset && ldata && ID != unknownID_) { - ilocs_[ID] = Iloc(ID, offset, ldata); + ilocs_[ID] = Iloc{ID, offset, ldata}; } } } diff --git a/src/fujimn_int.cpp b/src/fujimn_int.cpp index 28fbb6e6..0c029ebe 100644 --- a/src/fujimn_int.cpp +++ b/src/fujimn_int.cpp @@ -76,7 +76,7 @@ constexpr TagDetails fujiTone[] = {{0, N_("Normal")}, {80, N_("Medium High constexpr TagDetails fujiContrast[] = {{0, N_("Normal")}, {256, N_("High")}, {768, N_("Low")}}; //! WhiteBalanceFineTune, tag 0x100a -std::ostream& printFujiWhiteBalanceFineTune(std::ostream& os, const Value& value, const ExifData*) { +static std::ostream& printFujiWhiteBalanceFineTune(std::ostream& os, const Value& value, const ExifData*) { if (value.typeId() == signedLong && value.size() == 8) { auto longValue = dynamic_cast(value); if (longValue.toInt64(0) % 20 == 0 && longValue.toInt64(1) % 20 == 0) { @@ -186,7 +186,7 @@ constexpr TagDetails fujiSHTone[] = {{-64, N_("+4")}, {-56, N_("+3.5")}, {-48, N {32, N_("-2")}}; //! DigitalZoom, tag 0x1044 -std::ostream& printFujiDigitalZoom(std::ostream& os, const Value& value, const ExifData*) { +static std::ostream& printFujiDigitalZoom(std::ostream& os, const Value& value, const ExifData*) { if (value.typeId() == unsignedLong && value.size() == 4) { os << (value.toFloat() / 8); } @@ -208,7 +208,7 @@ constexpr TagDetails fujiCropMode[] = { }; //! MonochromaticColor, tag 0x1049 and 0x104b -std::ostream& printFujiMonochromaticColor(std::ostream& os, const Value& value, const ExifData*) { +static std::ostream& printFujiMonochromaticColor(std::ostream& os, const Value& value, const ExifData*) { if (value.size() == 1) { auto v = static_cast(value.toInt64()); os << (v > 0 ? "+" : "") << static_cast(v); @@ -235,7 +235,7 @@ constexpr TagDetails fujiDriveSettingByte1[] = { {0, N_("Single")}, {1, N_("Continuous Low")}, {2, N_("Continuous High")}}; //! DriveSetting, tag 0x1103 -std::ostream& printFujiDriveSetting(std::ostream& os, const Value& value, const ExifData*) { +static std::ostream& printFujiDriveSetting(std::ostream& os, const Value& value, const ExifData*) { auto byte1 = value.toInt64() & 0xff; auto byte2 = (value.toInt64() >> 8) & 0xff; auto byte3 = (value.toInt64() >> 16) & 0xff; @@ -331,7 +331,7 @@ constexpr TagDetails fujiDRangePriorityFixed[] = {{1, N_("Weak")}, {2, N_("Stron constexpr TagDetails fujiFaceElementType[] = {{1, N_("Face")}, {2, N_("Left Eye")}, {3, N_("Right Eye")}}; //! FaceElementType, tag 0x4203 -std::ostream& printFujiFaceElementTypes(std::ostream& os, const Value& value, const ExifData*) { +static std::ostream& printFujiFaceElementTypes(std::ostream& os, const Value& value, const ExifData*) { if (value.typeId() == asciiString || value.typeId() == unsignedShort) { auto elements = value.count(); diff --git a/src/futils.cpp b/src/futils.cpp index 65ab8354..465aaa9a 100644 --- a/src/futils.cpp +++ b/src/futils.cpp @@ -76,13 +76,13 @@ std::string getEnv(int env_var) { } /// @brief Convert an integer value to its hex character. -char to_hex(char code) { +static char to_hex(char code) { static const char hex[] = "0123456789abcdef"; return hex[code & 15]; } /// @brief Convert a hex character to its integer value. -char from_hex(char ch) { +static char from_hex(char ch) { return isdigit(ch) ? ch - '0' : static_cast(tolower(ch)) - 'a' + 10; } diff --git a/src/iptc.cpp b/src/iptc.cpp index 9d8e19c7..72e423e4 100644 --- a/src/iptc.cpp +++ b/src/iptc.cpp @@ -419,16 +419,6 @@ int IptcParser::decode(IptcData& iptcData, const byte* pData, size_t size) { return 0; } // IptcParser::decode -/*! - @brief Compare two iptc items by record. Return true if the record of - lhs is less than that of rhs. - - This is a helper function for IptcParser::encode(). - */ -bool cmpIptcdataByRecord(const Iptcdatum& lhs, const Iptcdatum& rhs) { - return lhs.record() < rhs.record(); -} - DataBuf IptcParser::encode(const IptcData& iptcData) { if (iptcData.empty()) return {}; @@ -439,7 +429,8 @@ DataBuf IptcParser::encode(const IptcData& iptcData) { // Copy the iptc data sets and sort them by record but preserve the order of datasets IptcMetadata sortedIptcData; std::copy(iptcData.begin(), iptcData.end(), std::back_inserter(sortedIptcData)); - std::stable_sort(sortedIptcData.begin(), sortedIptcData.end(), cmpIptcdataByRecord); + std::stable_sort(sortedIptcData.begin(), sortedIptcData.end(), + [](const auto& l, const auto& r) { return l.record() < r.record(); }); for (const auto& iter : sortedIptcData) { // marker, record Id, dataset num diff --git a/src/makernote_int.cpp b/src/makernote_int.cpp index 525838b4..9943221e 100644 --- a/src/makernote_int.cpp +++ b/src/makernote_int.cpp @@ -858,7 +858,7 @@ struct NikonArrayIdx { uint32_t start_; //!< Start of the encrypted data }; -#define NA ((uint32_t)-1) +#define NA std::numeric_limits::max() //! Nikon binary array version lookup table constexpr NikonArrayIdx nikonArrayIdx[] = { diff --git a/src/matroskavideo.cpp b/src/matroskavideo.cpp index d1287107..3c20bcae 100644 --- a/src/matroskavideo.cpp +++ b/src/matroskavideo.cpp @@ -584,7 +584,7 @@ const MatroskaTag streamRate[] = { bytes are used to calculate the rest of the Tag. Returns Tag Value. */ -[[nodiscard]] size_t returnTagValue(const byte* buf, size_t size) { +[[nodiscard]] static size_t returnTagValue(const byte* buf, size_t size) { enforce(size > 0 && size <= 8, Exiv2::ErrorCode::kerCorruptedMetadata); size_t b0 = buf[0] & (0xff >> size); diff --git a/src/pentaxmn_int.cpp b/src/pentaxmn_int.cpp index ab3942a8..1dce5a23 100644 --- a/src/pentaxmn_int.cpp +++ b/src/pentaxmn_int.cpp @@ -1076,7 +1076,7 @@ static ExifData::const_iterator findLensInfo(const ExifData* metadata) { } //! resolveLens0x32c print lens in human format -std::ostream& resolveLens0x32c(std::ostream& os, const Value& value, const ExifData* metadata) { +static std::ostream& resolveLens0x32c(std::ostream& os, const Value& value, const ExifData* metadata) { try { unsigned long index = 0; @@ -1102,7 +1102,7 @@ std::ostream& resolveLens0x32c(std::ostream& os, const Value& value, const ExifD // #816 begin //! resolveLens0x3ff print lens in human format -std::ostream& resolveLens0x3ff(std::ostream& os, const Value& value, const ExifData* metadata) +static std::ostream& resolveLens0x3ff(std::ostream& os, const Value& value, const ExifData* metadata) // ---------------------------------------------------------------------- { try { @@ -1165,7 +1165,7 @@ std::ostream& resolveLens0x3ff(std::ostream& os, const Value& value, const ExifD // #1155 //! resolveLens0x8ff print lens in human format -std::ostream& resolveLens0x8ff(std::ostream& os, const Value& value, const ExifData* metadata) +static std::ostream& resolveLens0x8ff(std::ostream& os, const Value& value, const ExifData* metadata) // ---------------------------------------------------------------------- { try { @@ -1192,7 +1192,7 @@ std::ostream& resolveLens0x8ff(std::ostream& os, const Value& value, const ExifD // #1155 //! resolveLens0x319 print lens in human format -std::ostream& resolveLens0x319(std::ostream& os, const Value& value, const ExifData* metadata) +static std::ostream& resolveLens0x319(std::ostream& os, const Value& value, const ExifData* metadata) // ---------------------------------------------------------------------- { try { @@ -1225,7 +1225,7 @@ std::ostream& resolveLens0x319(std::ostream& os, const Value& value, const ExifD } //! resolveLensType print lens in human format -std::ostream& resolveLensType(std::ostream& os, const Value& value, const ExifData* metadata) { +static std::ostream& resolveLensType(std::ostream& os, const Value& value, const ExifData* metadata) { return EXV_PRINT_COMBITAG_MULTI(pentaxLensType, 2, 1, 2)(os, value, metadata); } @@ -1247,7 +1247,7 @@ constexpr LensIdFct lensIdFct[] = { }; //! A lens id and a pretty-print function for special treatment of the id. -std::ostream& printLensType(std::ostream& os, const Value& value, const ExifData* metadata) { +static std::ostream& printLensType(std::ostream& os, const Value& value, const ExifData* metadata) { // #1034 const std::string undefined("undefined"); const std::string section("pentax"); diff --git a/src/pngimage.cpp b/src/pngimage.cpp index 2a291938..4f7bd6ea 100644 --- a/src/pngimage.cpp +++ b/src/pngimage.cpp @@ -173,7 +173,7 @@ static bool tEXtToDataBuf(const byte* bytes, size_t length, DataBuf& result) { return true; } -std::string::size_type findi(const std::string& str, const std::string& substr) { +static std::string::size_type findi(const std::string& str, const std::string& substr) { return str.find(substr); } @@ -374,7 +374,7 @@ void PngImage::printStructure(std::ostream& out, PrintStructureOption option, si } } -void readChunk(DataBuf& buffer, BasicIo& io) { +static void readChunk(DataBuf& buffer, BasicIo& io) { #ifdef EXIV2_DEBUG_MESSAGES std::cout << "Exiv2::PngImage::readMetadata: Position: " << io.tell() << std::endl; #endif diff --git a/src/quicktimevideo.cpp b/src/quicktimevideo.cpp index bb347cd9..99bcfc2c 100644 --- a/src/quicktimevideo.cpp +++ b/src/quicktimevideo.cpp @@ -447,7 +447,7 @@ enum audioDescTags { AudioFormat, AudioVendorID = 4, AudioChannels, AudioSampleR @param str char* Pointer to string @return Returns true if the buffer value is equal to string. */ -bool equalsQTimeTag(Exiv2::DataBuf& buf, const char* str) { +static bool equalsQTimeTag(Exiv2::DataBuf& buf, const char* str) { for (int i = 0; i < 4; ++i) if (tolower(buf.data()[i]) != tolower(str[i])) return false; @@ -460,7 +460,7 @@ bool equalsQTimeTag(Exiv2::DataBuf& buf, const char* str) { @param buf Data buffer that will contain Tag to compare @return Returns true, if Tag is found in the ignoreList[] */ -bool ignoreList(Exiv2::DataBuf& buf) { +static bool ignoreList(Exiv2::DataBuf& buf) { const char ignoreList[13][5] = { "mdat", "edts", "junk", "iods", "alis", "stsc", "stsz", "stco", "ctts", "stss", "skip", "wide", "cmvd", }; @@ -479,7 +479,7 @@ bool ignoreList(Exiv2::DataBuf& buf) { @param buf Data buffer that will contain Tag to compare @return Returns true, if Tag is found in the ignoreList[] */ -bool dataIgnoreList(Exiv2::DataBuf& buf) { +static bool dataIgnoreList(Exiv2::DataBuf& buf) { const char ignoreList[8][5] = { "moov", "mdia", "minf", "dinf", "alis", "stbl", "cmov", "meta", }; diff --git a/src/samsungmn_int.cpp b/src/samsungmn_int.cpp index b8a76104..27178a88 100644 --- a/src/samsungmn_int.cpp +++ b/src/samsungmn_int.cpp @@ -41,7 +41,7 @@ constexpr TagDetails samsung2ColorSpace[] = {{0, N_("sRGB")}, {1, N_("Adobe RGB" constexpr TagDetails samsung2SmartRange[] = {{0, N_("Off")}, {1, N_("On")}}; //! Print the camera temperature -std::ostream& printCameraTemperature(std::ostream& os, const Value& value, const ExifData*) { +static std::ostream& printCameraTemperature(std::ostream& os, const Value& value, const ExifData*) { if (value.count() != 1 || value.typeId() != signedRational) { return os << value; } @@ -49,7 +49,7 @@ std::ostream& printCameraTemperature(std::ostream& os, const Value& value, const } //! Print the 35mm focal length -std::ostream& printFocalLength35(std::ostream& os, const Value& value, const ExifData*) { +static std::ostream& printFocalLength35(std::ostream& os, const Value& value, const ExifData*) { std::ios::fmtflags f(os.flags()); if (value.count() != 1 || value.typeId() != unsignedLong) { return os << value; @@ -145,7 +145,7 @@ constexpr TagDetails samsungPwMode[] = {{0, N_("Standard")}, {1, N_("Vivid")}, {9, N_("Custom1")}, {10, N_("Custom2")}, {11, N_("Custom3")}}; //! Print the PictureWizard Color tag value -std::ostream& printPwColor(std::ostream& os, const Value& value, const ExifData*) { +static std::ostream& printPwColor(std::ostream& os, const Value& value, const ExifData*) { if (value.count() != 1 || value.typeId() != unsignedShort) { return os << value; } @@ -158,7 +158,7 @@ std::ostream& printPwColor(std::ostream& os, const Value& value, const ExifData* } //! Print the tag value minus 4 -std::ostream& printValueMinus4(std::ostream& os, const Value& value, const ExifData*) { +static std::ostream& printValueMinus4(std::ostream& os, const Value& value, const ExifData*) { if (value.count() != 1 || value.typeId() != unsignedShort) { return os << value; } diff --git a/src/tiffcomposite_int.hpp b/src/tiffcomposite_int.hpp index 2353353b..64911a25 100644 --- a/src/tiffcomposite_int.hpp +++ b/src/tiffcomposite_int.hpp @@ -569,8 +569,6 @@ class TiffEntry : public TiffEntryBase { //! Constructor TiffEntry(uint16_t tag, IfdId group) : TiffEntryBase(tag, group) { } - //! Virtual destructor. - ~TiffEntry() override = default; //@} protected: @@ -603,8 +601,6 @@ class TiffDataEntryBase : public TiffEntryBase { TiffDataEntryBase(uint16_t tag, IfdId group, uint16_t szTag, IfdId szGroup) : TiffEntryBase(tag, group), szTag_(szTag), szGroup_(szGroup) { } - //! Virtual destructor. - ~TiffDataEntryBase() override = default; //@} //! @name Manipulators @@ -790,8 +786,6 @@ class TiffSizeEntry : public TiffEntryBase { TiffSizeEntry(uint16_t tag, IfdId group, uint16_t dtTag, IfdId dtGroup) : TiffEntryBase(tag, group), dtTag_(dtTag), dtGroup_(dtGroup) { } - //! Virtual destructor. - ~TiffSizeEntry() override = default; //@} //! @name Accessors @@ -1420,8 +1414,6 @@ class TiffBinaryElement : public TiffEntryBase { //@{ //! Constructor TiffBinaryElement(uint16_t tag, IfdId group); - //! Virtual destructor. - ~TiffBinaryElement() override = default; //@} //! @name Manipulators diff --git a/src/xmp.cpp b/src/xmp.cpp index e94eb425..6b68ea78 100644 --- a/src/xmp.cpp +++ b/src/xmp.cpp @@ -227,7 +227,6 @@ void printNode(const std::string& schemaNs, const std::string& propPath, const s //! Make an XMP key from a schema namespace and property path Exiv2::XmpKey::UniquePtr makeXmpKey(const std::string& schemaNs, const std::string& propPath); -#endif // EXV_HAVE_XMP_TOOLKIT //! Helper class used to serialize critical sections class AutoLock { @@ -248,6 +247,7 @@ class AutoLock { Exiv2::XmpParser::XmpLockFct xmpLockFct_; void* pLockData_; }; +#endif // EXV_HAVE_XMP_TOOLKIT } // namespace // ***************************************************************************** diff --git a/unitTests/test_asfvideo.cpp b/unitTests/test_asfvideo.cpp index 90bcff8c..67c03ee1 100644 --- a/unitTests/test_asfvideo.cpp +++ b/unitTests/test_asfvideo.cpp @@ -52,4 +52,4 @@ TEST(AsfVideo, readMetadata) { auto data = asf.xmpData(); ASSERT_FALSE(data.empty()); ASSERT_EQ(xmpData["Xmp.video.TotalStream"].count(), 4); -} \ No newline at end of file +} diff --git a/unitTests/test_matroskavideo.cpp b/unitTests/test_matroskavideo.cpp index 93781716..0ef3b59b 100644 --- a/unitTests/test_matroskavideo.cpp +++ b/unitTests/test_matroskavideo.cpp @@ -52,4 +52,4 @@ TEST(MatroskaVideo, readMetadata) { auto data = mkv.xmpData(); ASSERT_FALSE(data.empty()); ASSERT_EQ(xmpData["Xmp.video.TotalStream"].count(), 4); -} \ No newline at end of file +} diff --git a/unitTests/test_riffVideo.cpp b/unitTests/test_riffVideo.cpp index 966beaaf..d4ba5089 100644 --- a/unitTests/test_riffVideo.cpp +++ b/unitTests/test_riffVideo.cpp @@ -52,4 +52,4 @@ TEST(RiffVideo, readMetadata) { auto data = riff.xmpData(); ASSERT_FALSE(data.empty()); ASSERT_EQ(xmpData["Xmp.video.TotalStream"].count(), 4); -} \ No newline at end of file +}