From d4e8f1222ca17b57ac74019b2fc3706e1192645c Mon Sep 17 00:00:00 2001 From: Wei Li Date: Mon, 21 Mar 2016 11:20:44 -0700 Subject: Re-enable several MSVC warnings Re-enable the following warnings: 4245: signed/unsigned conversion mismatch; 4310: cast may truncate data; 4389: operator on signed/unsigned mismatch; 4701: use potentially uninitialized local variable; 4706: assignment within conditional expression Clean up the code to avoid those warnings. BUG=pdfium:29 R=tsepez@chromium.org Review URL: https://codereview.chromium.org/1801383002 . --- core/fxcodec/codec/fx_codec_jpx_opj.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'core/fxcodec/codec/fx_codec_jpx_opj.cpp') diff --git a/core/fxcodec/codec/fx_codec_jpx_opj.cpp b/core/fxcodec/codec/fx_codec_jpx_opj.cpp index aaa89388b8..a57b93df22 100644 --- a/core/fxcodec/codec/fx_codec_jpx_opj.cpp +++ b/core/fxcodec/codec/fx_codec_jpx_opj.cpp @@ -24,16 +24,17 @@ static void fx_warning_callback(const char* msg, void* client_data) { static void fx_info_callback(const char* msg, void* client_data) { (void)client_data; } + OPJ_SIZE_T opj_read_from_memory(void* p_buffer, OPJ_SIZE_T nb_bytes, void* p_user_data) { DecodeData* srcData = static_cast(p_user_data); if (!srcData || !srcData->src_data || srcData->src_size == 0) { - return -1; + return static_cast(-1); } // Reads at EOF return an error code. if (srcData->offset >= srcData->src_size) { - return -1; + return static_cast(-1); } OPJ_SIZE_T bufferLength = srcData->src_size - srcData->offset; OPJ_SIZE_T readlength = nb_bytes < bufferLength ? nb_bytes : bufferLength; @@ -41,16 +42,17 @@ OPJ_SIZE_T opj_read_from_memory(void* p_buffer, srcData->offset += readlength; return readlength; } + OPJ_SIZE_T opj_write_from_memory(void* p_buffer, OPJ_SIZE_T nb_bytes, void* p_user_data) { DecodeData* srcData = static_cast(p_user_data); if (!srcData || !srcData->src_data || srcData->src_size == 0) { - return -1; + return static_cast(-1); } // Writes at EOF return an error code. if (srcData->offset >= srcData->src_size) { - return -1; + return static_cast(-1); } OPJ_SIZE_T bufferLength = srcData->src_size - srcData->offset; OPJ_SIZE_T writeLength = nb_bytes < bufferLength ? nb_bytes : bufferLength; @@ -58,17 +60,18 @@ OPJ_SIZE_T opj_write_from_memory(void* p_buffer, srcData->offset += writeLength; return writeLength; } + OPJ_OFF_T opj_skip_from_memory(OPJ_OFF_T nb_bytes, void* p_user_data) { DecodeData* srcData = static_cast(p_user_data); if (!srcData || !srcData->src_data || srcData->src_size == 0) { - return -1; + return static_cast(-1); } // Offsets are signed and may indicate a negative skip. Do not support this // because of the strange return convention where either bytes skipped or // -1 is returned. Following that convention, a successful relative seek of // -1 bytes would be required to to give the same result as the error case. if (nb_bytes < 0) { - return -1; + return static_cast(-1); } // FIXME: use std::make_unsigned::type once c++11 lib is OK'd. uint64_t unsignedNbBytes = static_cast(nb_bytes); @@ -89,6 +92,7 @@ OPJ_OFF_T opj_skip_from_memory(OPJ_OFF_T nb_bytes, void* p_user_data) { } return nb_bytes; } + OPJ_BOOL opj_seek_from_memory(OPJ_OFF_T nb_bytes, void* p_user_data) { DecodeData* srcData = static_cast(p_user_data); if (!srcData || !srcData->src_data || srcData->src_size == 0) { -- cgit v1.2.3