# HG changeset patch # User Benjamin Golinvaux <bgo@osimis.io> # Date 1558074978 -7200 # Node ID 596cfabd72c5dc9851572b00cbb1ec216fbcfc11 # Parent 05881bf99c83bac2f9c6b1b95add0ce12e30787d Fixed a couple of truncation warnings diff -r 05881bf99c83 -r 596cfabd72c5 Core/Compression/GzipCompressor.cpp --- a/Core/Compression/GzipCompressor.cpp Thu May 16 12:31:47 2019 +0200 +++ b/Core/Compression/GzipCompressor.cpp Fri May 17 08:36:18 2019 +0200 @@ -91,7 +91,9 @@ const void* uncompressed, size_t uncompressedSize) { - uLongf compressedSize = compressBound(uncompressedSize) + 1024 /* security margin */; + uLongf compressedSize = compressBound(static_cast<uLong>(uncompressedSize)) + + 1024 /* security margin */; + if (compressedSize == 0) { compressedSize = 1; diff -r 05881bf99c83 -r 596cfabd72c5 Core/Compression/ZlibCompressor.cpp --- a/Core/Compression/ZlibCompressor.cpp Thu May 16 12:31:47 2019 +0200 +++ b/Core/Compression/ZlibCompressor.cpp Fri May 17 08:36:18 2019 +0200 @@ -53,7 +53,8 @@ return; } - uLongf compressedSize = compressBound(uncompressedSize) + 1024 /* security margin */; + uLongf compressedSize = compressBound(static_cast<uLong>(uncompressedSize)) + + 1024 /* security margin */; if (compressedSize == 0) { compressedSize = 1; @@ -74,7 +75,7 @@ int error = compress2(target, &compressedSize, const_cast<Bytef *>(static_cast<const Bytef *>(uncompressed)), - uncompressedSize, + static_cast<uLong>(uncompressedSize), GetCompressionLevel()); if (error != Z_OK) @@ -137,7 +138,7 @@ (reinterpret_cast<uint8_t*>(&uncompressed[0]), &tmp, reinterpret_cast<const uint8_t*>(compressed) + sizeof(uint64_t), - compressedSize - sizeof(uint64_t)); + static_cast<uLong>(compressedSize - sizeof(uint64_t))); if (error != Z_OK) { diff -r 05881bf99c83 -r 596cfabd72c5 Core/Images/JpegReader.cpp --- a/Core/Images/JpegReader.cpp Thu May 16 12:31:47 2019 +0200 +++ b/Core/Images/JpegReader.cpp Fri May 17 08:36:18 2019 +0200 @@ -161,12 +161,15 @@ { jpeg_destroy_decompress(&cinfo); throw OrthancException(ErrorCode_InternalError, - "Error during JPEG decoding: " + jerr.GetMessage()); + "Error during JPEG decoding: " + jerr.GetMessage()); } // Below this line, we are under the scope of a "setjmp" jpeg_create_decompress(&cinfo); - jpeg_mem_src(&cinfo, const_cast<unsigned char*>(reinterpret_cast<const unsigned char*>(buffer)), size); + jpeg_mem_src(&cinfo, + const_cast<unsigned char*>( + reinterpret_cast<const unsigned char*>(buffer)), + static_cast<unsigned long>(size)); try { diff -r 05881bf99c83 -r 596cfabd72c5 Core/MetricsRegistry.cpp --- a/Core/MetricsRegistry.cpp Thu May 16 12:31:47 2019 +0200 +++ b/Core/MetricsRegistry.cpp Fri May 17 08:36:18 2019 +0200 @@ -322,7 +322,8 @@ if (active_) { boost::posix_time::time_duration diff = GetNow() - start_; - registry_.SetValue(name_, diff.total_milliseconds(), type_); + registry_.SetValue( + name_, static_cast<float>(diff.total_milliseconds()), type_); } } }