Skip to content

Commit

Permalink
Fix some "signed shift" warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinbackhouse committed Jul 5, 2022
1 parent fc0e050 commit b3f2ab5
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 42 deletions.
8 changes: 4 additions & 4 deletions cmake/config.h.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions include/exiv2/version.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
*/
Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion include/exiv2/webpimage.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
48 changes: 24 additions & 24 deletions src/types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<byte>(s & 0x00ff);
buf[1] = static_cast<byte>((s & 0xff00) >> 8);
buf[0] = static_cast<byte>(s & 0x00ffU);
buf[1] = static_cast<byte>((s & 0xff00U) >> 8);
} else {
buf[0] = static_cast<byte>((s & 0xff00) >> 8);
buf[1] = static_cast<byte>(s & 0x00ff);
buf[0] = static_cast<byte>((s & 0xff00U) >> 8);
buf[1] = static_cast<byte>(s & 0x00ffU);
}
return 2;
}

long ul2Data(byte* buf, uint32_t l, ByteOrder byteOrder) {
if (byteOrder == littleEndian) {
buf[0] = static_cast<byte>(l & 0x000000ff);
buf[1] = static_cast<byte>((l & 0x0000ff00) >> 8);
buf[2] = static_cast<byte>((l & 0x00ff0000) >> 16);
buf[3] = static_cast<byte>((l & 0xff000000) >> 24);
buf[0] = static_cast<byte>(l & 0x000000ffU);
buf[1] = static_cast<byte>((l & 0x0000ff00U) >> 8);
buf[2] = static_cast<byte>((l & 0x00ff0000U) >> 16);
buf[3] = static_cast<byte>((l & 0xff000000U) >> 24);
} else {
buf[0] = static_cast<byte>((l & 0xff000000) >> 24);
buf[1] = static_cast<byte>((l & 0x00ff0000) >> 16);
buf[2] = static_cast<byte>((l & 0x0000ff00) >> 8);
buf[3] = static_cast<byte>(l & 0x000000ff);
buf[0] = static_cast<byte>((l & 0xff000000U) >> 24);
buf[1] = static_cast<byte>((l & 0x00ff0000U) >> 16);
buf[2] = static_cast<byte>((l & 0x0000ff00U) >> 8);
buf[3] = static_cast<byte>(l & 0x000000ffU);
}
return 4;
}
Expand Down Expand Up @@ -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<byte>(s & 0x00ff);
buf[1] = static_cast<byte>((s & 0xff00) >> 8);
buf[0] = static_cast<byte>(s & 0x00ffU);
buf[1] = static_cast<byte>((s & 0xff00U) >> 8);
} else {
buf[0] = static_cast<byte>((s & 0xff00) >> 8);
buf[1] = static_cast<byte>(s & 0x00ff);
buf[0] = static_cast<byte>((s & 0xff00U) >> 8);
buf[1] = static_cast<byte>(s & 0x00ffU);
}
return 2;
}

long l2Data(byte* buf, int32_t l, ByteOrder byteOrder) {
if (byteOrder == littleEndian) {
buf[0] = static_cast<byte>(l & 0x000000ff);
buf[1] = static_cast<byte>((l & 0x0000ff00) >> 8);
buf[2] = static_cast<byte>((l & 0x00ff0000) >> 16);
buf[3] = static_cast<byte>((l & 0xff000000) >> 24);
buf[0] = static_cast<byte>(l & 0x000000ffU);
buf[1] = static_cast<byte>((l & 0x0000ff00U) >> 8);
buf[2] = static_cast<byte>((l & 0x00ff0000U) >> 16);
buf[3] = static_cast<byte>((l & 0xff000000U) >> 24);
} else {
buf[0] = static_cast<byte>((l & 0xff000000) >> 24);
buf[1] = static_cast<byte>((l & 0x00ff0000) >> 16);
buf[2] = static_cast<byte>((l & 0x0000ff00) >> 8);
buf[3] = static_cast<byte>(l & 0x000000ff);
buf[0] = static_cast<byte>((l & 0xff000000U) >> 24);
buf[1] = static_cast<byte>((l & 0x00ff0000U) >> 16);
buf[2] = static_cast<byte>((l & 0x0000ff00U) >> 8);
buf[3] = static_cast<byte>(l & 0x000000ffU);
}
return 4;
}
Expand Down
4 changes: 2 additions & 2 deletions src/version.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -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
Expand Down
16 changes: 8 additions & 8 deletions src/webpimage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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<const byte*>(WEBP_CHUNK_HEADER_VP8X), WEBP_TAG_SIZE);
Expand Down

0 comments on commit b3f2ab5

Please sign in to comment.