Skip to content

Commit b3f2ab5

Browse files
Fix some "signed shift" warnings.
1 parent fc0e050 commit b3f2ab5

File tree

6 files changed

+43
-42
lines changed

6 files changed

+43
-42
lines changed

cmake/config.h.cmake

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,10 @@
6262
/* Define to the version of this package. */
6363
#cmakedefine EXV_PACKAGE_VERSION "@PROJECT_VERSION@"
6464

65-
#define EXIV2_MAJOR_VERSION (@PROJECT_VERSION_MAJOR@)
66-
#define EXIV2_MINOR_VERSION (@PROJECT_VERSION_MINOR@)
67-
#define EXIV2_PATCH_VERSION (@PROJECT_VERSION_PATCH@)
68-
#define EXIV2_TWEAK_VERSION (@PROJECT_VERSION_TWEAK@)
65+
#define EXIV2_MAJOR_VERSION (@PROJECT_VERSION_MAJOR@U)
66+
#define EXIV2_MINOR_VERSION (@PROJECT_VERSION_MINOR@U)
67+
#define EXIV2_PATCH_VERSION (@PROJECT_VERSION_PATCH@U)
68+
#define EXIV2_TWEAK_VERSION (@PROJECT_VERSION_TWEAK@U)
6969

7070
// Definition to enable translation of Nikon lens names.
7171
#cmakedefine EXV_HAVE_LENSDATA

include/exiv2/version.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@
7272
// namespace extensions
7373
namespace Exiv2 {
7474
/*!
75-
@brief Return the version of %Exiv2 available at runtime as an integer.
75+
@brief Return the version of %Exiv2 available at runtime as a uint32_t.
7676
*/
77-
EXIV2API int versionNumber();
77+
EXIV2API uint32_t versionNumber();
7878
/*!
7979
@brief Return the version string Example: "0.25.0" (major.minor.patch)
8080
*/
@@ -96,7 +96,7 @@ EXIV2API const char* version();
9696
Versions are denoted using a triplet of integers: \em major.minor.patch .
9797
The fourth version number is designated a "tweak" an used by Release Candidates
9898
*/
99-
EXIV2API bool testVersion(int major, int minor, int patch);
99+
EXIV2API bool testVersion(uint32_t major, uint32_t minor, uint32_t patch);
100100
/*!
101101
@brief dumpLibraryInfo implements the exiv2 option --version --verbose
102102
used by exiv2 test suite to inspect libraries loaded at run-time

include/exiv2/webpimage.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ class EXIV2API WebPImage : public Image {
7070
static bool equalsWebPTag(Exiv2::DataBuf& buf, const char* str);
7171
void debugPrintHex(byte* data, size_t size);
7272
void decodeChunks(uint32_t filesize);
73-
void inject_VP8X(BasicIo& iIo, bool has_xmp, bool has_exif, bool has_alpha, bool has_icc, int width, int height);
73+
void inject_VP8X(BasicIo& iIo, bool has_xmp, bool has_exif, bool has_alpha, bool has_icc, uint32_t width,
74+
uint32_t height);
7475
/* Misc. */
7576
static constexpr byte WEBP_PAD_ODD = 0;
7677
static constexpr int WEBP_TAG_SIZE = 0x4;

src/types.cpp

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -332,26 +332,26 @@ double getDouble(const byte* buf, ByteOrder byteOrder) {
332332

333333
long us2Data(byte* buf, uint16_t s, ByteOrder byteOrder) {
334334
if (byteOrder == littleEndian) {
335-
buf[0] = static_cast<byte>(s & 0x00ff);
336-
buf[1] = static_cast<byte>((s & 0xff00) >> 8);
335+
buf[0] = static_cast<byte>(s & 0x00ffU);
336+
buf[1] = static_cast<byte>((s & 0xff00U) >> 8);
337337
} else {
338-
buf[0] = static_cast<byte>((s & 0xff00) >> 8);
339-
buf[1] = static_cast<byte>(s & 0x00ff);
338+
buf[0] = static_cast<byte>((s & 0xff00U) >> 8);
339+
buf[1] = static_cast<byte>(s & 0x00ffU);
340340
}
341341
return 2;
342342
}
343343

344344
long ul2Data(byte* buf, uint32_t l, ByteOrder byteOrder) {
345345
if (byteOrder == littleEndian) {
346-
buf[0] = static_cast<byte>(l & 0x000000ff);
347-
buf[1] = static_cast<byte>((l & 0x0000ff00) >> 8);
348-
buf[2] = static_cast<byte>((l & 0x00ff0000) >> 16);
349-
buf[3] = static_cast<byte>((l & 0xff000000) >> 24);
346+
buf[0] = static_cast<byte>(l & 0x000000ffU);
347+
buf[1] = static_cast<byte>((l & 0x0000ff00U) >> 8);
348+
buf[2] = static_cast<byte>((l & 0x00ff0000U) >> 16);
349+
buf[3] = static_cast<byte>((l & 0xff000000U) >> 24);
350350
} else {
351-
buf[0] = static_cast<byte>((l & 0xff000000) >> 24);
352-
buf[1] = static_cast<byte>((l & 0x00ff0000) >> 16);
353-
buf[2] = static_cast<byte>((l & 0x0000ff00) >> 8);
354-
buf[3] = static_cast<byte>(l & 0x000000ff);
351+
buf[0] = static_cast<byte>((l & 0xff000000U) >> 24);
352+
buf[1] = static_cast<byte>((l & 0x00ff0000U) >> 16);
353+
buf[2] = static_cast<byte>((l & 0x0000ff00U) >> 8);
354+
buf[3] = static_cast<byte>(l & 0x000000ffU);
355355
}
356356
return 4;
357357
}
@@ -379,26 +379,26 @@ long ur2Data(byte* buf, URational l, ByteOrder byteOrder) {
379379

380380
long s2Data(byte* buf, int16_t s, ByteOrder byteOrder) {
381381
if (byteOrder == littleEndian) {
382-
buf[0] = static_cast<byte>(s & 0x00ff);
383-
buf[1] = static_cast<byte>((s & 0xff00) >> 8);
382+
buf[0] = static_cast<byte>(s & 0x00ffU);
383+
buf[1] = static_cast<byte>((s & 0xff00U) >> 8);
384384
} else {
385-
buf[0] = static_cast<byte>((s & 0xff00) >> 8);
386-
buf[1] = static_cast<byte>(s & 0x00ff);
385+
buf[0] = static_cast<byte>((s & 0xff00U) >> 8);
386+
buf[1] = static_cast<byte>(s & 0x00ffU);
387387
}
388388
return 2;
389389
}
390390

391391
long l2Data(byte* buf, int32_t l, ByteOrder byteOrder) {
392392
if (byteOrder == littleEndian) {
393-
buf[0] = static_cast<byte>(l & 0x000000ff);
394-
buf[1] = static_cast<byte>((l & 0x0000ff00) >> 8);
395-
buf[2] = static_cast<byte>((l & 0x00ff0000) >> 16);
396-
buf[3] = static_cast<byte>((l & 0xff000000) >> 24);
393+
buf[0] = static_cast<byte>(l & 0x000000ffU);
394+
buf[1] = static_cast<byte>((l & 0x0000ff00U) >> 8);
395+
buf[2] = static_cast<byte>((l & 0x00ff0000U) >> 16);
396+
buf[3] = static_cast<byte>((l & 0xff000000U) >> 24);
397397
} else {
398-
buf[0] = static_cast<byte>((l & 0xff000000) >> 24);
399-
buf[1] = static_cast<byte>((l & 0x00ff0000) >> 16);
400-
buf[2] = static_cast<byte>((l & 0x0000ff00) >> 8);
401-
buf[3] = static_cast<byte>(l & 0x000000ff);
398+
buf[0] = static_cast<byte>((l & 0xff000000U) >> 24);
399+
buf[1] = static_cast<byte>((l & 0x00ff0000U) >> 16);
400+
buf[2] = static_cast<byte>((l & 0x0000ff00U) >> 8);
401+
buf[3] = static_cast<byte>(l & 0x000000ffU);
402402
}
403403
return 4;
404404
}

src/version.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
#endif
5959

6060
namespace Exiv2 {
61-
int versionNumber() {
61+
uint32_t versionNumber() {
6262
return EXIV2_MAKE_VERSION(EXIV2_MAJOR_VERSION, EXIV2_MINOR_VERSION, EXIV2_PATCH_VERSION);
6363
}
6464

@@ -78,7 +78,7 @@ const char* version() {
7878
return EXV_PACKAGE_VERSION;
7979
}
8080

81-
bool testVersion(int major, int minor, int patch) {
81+
bool testVersion(uint32_t major, uint32_t minor, uint32_t patch) {
8282
return versionNumber() >= EXIV2_MAKE_VERSION(major, minor, patch);
8383
}
8484
} // namespace Exiv2

src/webpimage.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,8 @@ void WebPImage::doWriteMetadata(BasicIo& outIo) {
132132
bool has_alpha = false;
133133
bool has_icc = iccProfileDefined();
134134

135-
int width = 0;
136-
int height = 0;
135+
uint32_t width = 0;
136+
uint32_t height = 0;
137137

138138
byte size_buff[WEBP_TAG_SIZE];
139139
Blob blob;
@@ -244,8 +244,8 @@ void WebPImage::doWriteMetadata(BasicIo& outIo) {
244244

245245
// Fetch height - 14 bits wide
246246
memcpy(&size_buf_h, payload.c_data(2), 3);
247-
size_buf_h[0] = ((size_buf_h[0] >> 6) & 0x3) | ((size_buf_h[1] & 0x3F) << 0x2);
248-
size_buf_h[1] = ((size_buf_h[1] >> 6) & 0x3) | ((size_buf_h[2] & 0xF) << 0x2);
247+
size_buf_h[0] = ((size_buf_h[0] >> 6) & 0x3) | ((size_buf_h[1] & 0x3FU) << 0x2);
248+
size_buf_h[1] = ((size_buf_h[1] >> 6) & 0x3) | ((size_buf_h[2] & 0xFU) << 0x2);
249249
height = Exiv2::getUShort(size_buf_h, littleEndian) + 1;
250250
}
251251

@@ -567,8 +567,8 @@ void WebPImage::decodeChunks(uint32_t filesize) {
567567

568568
// Fetch height
569569
memcpy(&size_buf_h, payload.c_data(2), 3);
570-
size_buf_h[0] = ((size_buf_h[0] >> 6) & 0x3) | ((size_buf_h[1] & 0x3F) << 0x2);
571-
size_buf_h[1] = ((size_buf_h[1] >> 6) & 0x3) | ((size_buf_h[2] & 0xF) << 0x2);
570+
size_buf_h[0] = ((size_buf_h[0] >> 6) & 0x3) | ((size_buf_h[1] & 0x3FU) << 0x2);
571+
size_buf_h[1] = ((size_buf_h[1] >> 6) & 0x3) | ((size_buf_h[2] & 0xFU) << 0x2);
572572
pixelHeight_ = Exiv2::getUShort(size_buf_h, littleEndian) + 1;
573573
} else if (equalsWebPTag(chunkId, WEBP_CHUNK_HEADER_ANMF) && !has_canvas_data) {
574574
enforce(size >= 12, Exiv2::ErrorCode::kerCorruptedMetadata);
@@ -737,8 +737,8 @@ bool WebPImage::equalsWebPTag(Exiv2::DataBuf& buf, const char* str) {
737737
@param has_exif Verify if we have exif data and set required flag
738738
@return Returns void
739739
*/
740-
void WebPImage::inject_VP8X(BasicIo& iIo, bool has_xmp, bool has_exif, bool has_alpha, bool has_icc, int width,
741-
int height) {
740+
void WebPImage::inject_VP8X(BasicIo& iIo, bool has_xmp, bool has_exif, bool has_alpha, bool has_icc, uint32_t width,
741+
uint32_t height) {
742742
byte size[4] = {0x0A, 0x00, 0x00, 0x00};
743743
byte data[10] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
744744
iIo.write(reinterpret_cast<const byte*>(WEBP_CHUNK_HEADER_VP8X), WEBP_TAG_SIZE);

0 commit comments

Comments
 (0)