diff --git a/cmake/config.h.cmake b/cmake/config.h.cmake index 0bed81c5cc..c42d9ed88e 100644 --- a/cmake/config.h.cmake +++ b/cmake/config.h.cmake @@ -62,10 +62,10 @@ /* Define to the version of this package. */ #cmakedefine EXV_PACKAGE_VERSION "@PROJECT_VERSION@" -#define EXIV2_MAJOR_VERSION (@PROJECT_VERSION_MAJOR@) -#define EXIV2_MINOR_VERSION (@PROJECT_VERSION_MINOR@) -#define EXIV2_PATCH_VERSION (@PROJECT_VERSION_PATCH@) -#define EXIV2_TWEAK_VERSION (@PROJECT_VERSION_TWEAK@) +#define EXIV2_MAJOR_VERSION (@PROJECT_VERSION_MAJOR@U) +#define EXIV2_MINOR_VERSION (@PROJECT_VERSION_MINOR@U) +#define EXIV2_PATCH_VERSION (@PROJECT_VERSION_PATCH@U) +#define EXIV2_TWEAK_VERSION (@PROJECT_VERSION_TWEAK@U) // Definition to enable translation of Nikon lens names. #cmakedefine EXV_HAVE_LENSDATA diff --git a/include/exiv2/version.hpp b/include/exiv2/version.hpp index 86ce9a9832..703c4abb33 100644 --- a/include/exiv2/version.hpp +++ b/include/exiv2/version.hpp @@ -72,9 +72,9 @@ // namespace extensions namespace Exiv2 { /*! - @brief Return the version of %Exiv2 available at runtime as an integer. + @brief Return the version of %Exiv2 available at runtime as a uint32_t. */ -EXIV2API int versionNumber(); +EXIV2API uint32_t versionNumber(); /*! @brief Return the version string Example: "0.25.0" (major.minor.patch) */ @@ -96,7 +96,7 @@ EXIV2API const char* version(); Versions are denoted using a triplet of integers: \em major.minor.patch . The fourth version number is designated a "tweak" an used by Release Candidates */ -EXIV2API bool testVersion(int major, int minor, int patch); +EXIV2API bool testVersion(uint32_t major, uint32_t minor, uint32_t patch); /*! @brief dumpLibraryInfo implements the exiv2 option --version --verbose used by exiv2 test suite to inspect libraries loaded at run-time diff --git a/include/exiv2/webpimage.hpp b/include/exiv2/webpimage.hpp index 5fbc6d6bf8..317e59866e 100644 --- a/include/exiv2/webpimage.hpp +++ b/include/exiv2/webpimage.hpp @@ -70,7 +70,8 @@ class EXIV2API WebPImage : public Image { static bool equalsWebPTag(Exiv2::DataBuf& buf, const char* str); void debugPrintHex(byte* data, size_t size); void decodeChunks(uint32_t filesize); - void inject_VP8X(BasicIo& iIo, bool has_xmp, bool has_exif, bool has_alpha, bool has_icc, int width, int height); + void inject_VP8X(BasicIo& iIo, bool has_xmp, bool has_exif, bool has_alpha, bool has_icc, uint32_t width, + uint32_t height); /* Misc. */ static constexpr byte WEBP_PAD_ODD = 0; static constexpr int WEBP_TAG_SIZE = 0x4; diff --git a/src/types.cpp b/src/types.cpp index 8cb4b6181c..1ec865e462 100644 --- a/src/types.cpp +++ b/src/types.cpp @@ -332,26 +332,26 @@ double getDouble(const byte* buf, ByteOrder byteOrder) { long us2Data(byte* buf, uint16_t s, ByteOrder byteOrder) { if (byteOrder == littleEndian) { - buf[0] = static_cast(s & 0x00ff); - buf[1] = static_cast((s & 0xff00) >> 8); + buf[0] = static_cast(s & 0x00ffU); + buf[1] = static_cast((s & 0xff00U) >> 8); } else { - buf[0] = static_cast((s & 0xff00) >> 8); - buf[1] = static_cast(s & 0x00ff); + buf[0] = static_cast((s & 0xff00U) >> 8); + buf[1] = static_cast(s & 0x00ffU); } return 2; } long ul2Data(byte* buf, uint32_t l, ByteOrder byteOrder) { if (byteOrder == littleEndian) { - buf[0] = static_cast(l & 0x000000ff); - buf[1] = static_cast((l & 0x0000ff00) >> 8); - buf[2] = static_cast((l & 0x00ff0000) >> 16); - buf[3] = static_cast((l & 0xff000000) >> 24); + buf[0] = static_cast(l & 0x000000ffU); + buf[1] = static_cast((l & 0x0000ff00U) >> 8); + buf[2] = static_cast((l & 0x00ff0000U) >> 16); + buf[3] = static_cast((l & 0xff000000U) >> 24); } else { - buf[0] = static_cast((l & 0xff000000) >> 24); - buf[1] = static_cast((l & 0x00ff0000) >> 16); - buf[2] = static_cast((l & 0x0000ff00) >> 8); - buf[3] = static_cast(l & 0x000000ff); + buf[0] = static_cast((l & 0xff000000U) >> 24); + buf[1] = static_cast((l & 0x00ff0000U) >> 16); + buf[2] = static_cast((l & 0x0000ff00U) >> 8); + buf[3] = static_cast(l & 0x000000ffU); } return 4; } @@ -379,26 +379,26 @@ long ur2Data(byte* buf, URational l, ByteOrder byteOrder) { long s2Data(byte* buf, int16_t s, ByteOrder byteOrder) { if (byteOrder == littleEndian) { - buf[0] = static_cast(s & 0x00ff); - buf[1] = static_cast((s & 0xff00) >> 8); + buf[0] = static_cast(s & 0x00ffU); + buf[1] = static_cast((s & 0xff00U) >> 8); } else { - buf[0] = static_cast((s & 0xff00) >> 8); - buf[1] = static_cast(s & 0x00ff); + buf[0] = static_cast((s & 0xff00U) >> 8); + buf[1] = static_cast(s & 0x00ffU); } return 2; } long l2Data(byte* buf, int32_t l, ByteOrder byteOrder) { if (byteOrder == littleEndian) { - buf[0] = static_cast(l & 0x000000ff); - buf[1] = static_cast((l & 0x0000ff00) >> 8); - buf[2] = static_cast((l & 0x00ff0000) >> 16); - buf[3] = static_cast((l & 0xff000000) >> 24); + buf[0] = static_cast(l & 0x000000ffU); + buf[1] = static_cast((l & 0x0000ff00U) >> 8); + buf[2] = static_cast((l & 0x00ff0000U) >> 16); + buf[3] = static_cast((l & 0xff000000U) >> 24); } else { - buf[0] = static_cast((l & 0xff000000) >> 24); - buf[1] = static_cast((l & 0x00ff0000) >> 16); - buf[2] = static_cast((l & 0x0000ff00) >> 8); - buf[3] = static_cast(l & 0x000000ff); + buf[0] = static_cast((l & 0xff000000U) >> 24); + buf[1] = static_cast((l & 0x00ff0000U) >> 16); + buf[2] = static_cast((l & 0x0000ff00U) >> 8); + buf[3] = static_cast(l & 0x000000ffU); } return 4; } diff --git a/src/version.cpp b/src/version.cpp index b3f65f18c3..f719f4b0b5 100644 --- a/src/version.cpp +++ b/src/version.cpp @@ -58,7 +58,7 @@ #endif namespace Exiv2 { -int versionNumber() { +uint32_t versionNumber() { return EXIV2_MAKE_VERSION(EXIV2_MAJOR_VERSION, EXIV2_MINOR_VERSION, EXIV2_PATCH_VERSION); } @@ -78,7 +78,7 @@ const char* version() { return EXV_PACKAGE_VERSION; } -bool testVersion(int major, int minor, int patch) { +bool testVersion(uint32_t major, uint32_t minor, uint32_t patch) { return versionNumber() >= EXIV2_MAKE_VERSION(major, minor, patch); } } // namespace Exiv2 diff --git a/src/webpimage.cpp b/src/webpimage.cpp index 954254a293..c6c804904f 100644 --- a/src/webpimage.cpp +++ b/src/webpimage.cpp @@ -132,8 +132,8 @@ void WebPImage::doWriteMetadata(BasicIo& outIo) { bool has_alpha = false; bool has_icc = iccProfileDefined(); - int width = 0; - int height = 0; + uint32_t width = 0; + uint32_t height = 0; byte size_buff[WEBP_TAG_SIZE]; Blob blob; @@ -244,8 +244,8 @@ void WebPImage::doWriteMetadata(BasicIo& outIo) { // Fetch height - 14 bits wide memcpy(&size_buf_h, payload.c_data(2), 3); - size_buf_h[0] = ((size_buf_h[0] >> 6) & 0x3) | ((size_buf_h[1] & 0x3F) << 0x2); - size_buf_h[1] = ((size_buf_h[1] >> 6) & 0x3) | ((size_buf_h[2] & 0xF) << 0x2); + size_buf_h[0] = ((size_buf_h[0] >> 6) & 0x3) | ((size_buf_h[1] & 0x3FU) << 0x2); + size_buf_h[1] = ((size_buf_h[1] >> 6) & 0x3) | ((size_buf_h[2] & 0xFU) << 0x2); height = Exiv2::getUShort(size_buf_h, littleEndian) + 1; } @@ -567,8 +567,8 @@ void WebPImage::decodeChunks(uint32_t filesize) { // Fetch height memcpy(&size_buf_h, payload.c_data(2), 3); - size_buf_h[0] = ((size_buf_h[0] >> 6) & 0x3) | ((size_buf_h[1] & 0x3F) << 0x2); - size_buf_h[1] = ((size_buf_h[1] >> 6) & 0x3) | ((size_buf_h[2] & 0xF) << 0x2); + size_buf_h[0] = ((size_buf_h[0] >> 6) & 0x3) | ((size_buf_h[1] & 0x3FU) << 0x2); + size_buf_h[1] = ((size_buf_h[1] >> 6) & 0x3) | ((size_buf_h[2] & 0xFU) << 0x2); pixelHeight_ = Exiv2::getUShort(size_buf_h, littleEndian) + 1; } else if (equalsWebPTag(chunkId, WEBP_CHUNK_HEADER_ANMF) && !has_canvas_data) { enforce(size >= 12, Exiv2::ErrorCode::kerCorruptedMetadata); @@ -737,8 +737,8 @@ bool WebPImage::equalsWebPTag(Exiv2::DataBuf& buf, const char* str) { @param has_exif Verify if we have exif data and set required flag @return Returns void */ -void WebPImage::inject_VP8X(BasicIo& iIo, bool has_xmp, bool has_exif, bool has_alpha, bool has_icc, int width, - int height) { +void WebPImage::inject_VP8X(BasicIo& iIo, bool has_xmp, bool has_exif, bool has_alpha, bool has_icc, uint32_t width, + uint32_t height) { byte size[4] = {0x0A, 0x00, 0x00, 0x00}; byte data[10] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; iIo.write(reinterpret_cast(WEBP_CHUNK_HEADER_VP8X), WEBP_TAG_SIZE);