Mercurial > hg > orthanc
changeset 3378:596cfabd72c5
Fixed a couple of truncation warnings
author | Benjamin Golinvaux <bgo@osimis.io> |
---|---|
date | Fri, 17 May 2019 08:36:18 +0200 |
parents | 05881bf99c83 |
children | 974e12006b7d |
files | Core/Compression/GzipCompressor.cpp Core/Compression/ZlibCompressor.cpp Core/Images/JpegReader.cpp Core/MetricsRegistry.cpp |
diffstat | 4 files changed, 14 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- 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;
--- 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) {
--- 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 {
--- 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_); } } }