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/fpdfapi/fpdf_page/cpdf_page.cpp | 7 ++++++- core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp | 14 +++++++------- 2 files changed, 13 insertions(+), 8 deletions(-) (limited to 'core/fpdfapi/fpdf_page') diff --git a/core/fpdfapi/fpdf_page/cpdf_page.cpp b/core/fpdfapi/fpdf_page/cpdf_page.cpp index 0da5452969..2c01cd5573 100644 --- a/core/fpdfapi/fpdf_page/cpdf_page.cpp +++ b/core/fpdfapi/fpdf_page/cpdf_page.cpp @@ -140,7 +140,12 @@ void CPDF_Page::GetDisplayMatrix(CFX_Matrix& matrix, return; } CFX_Matrix display_matrix; - int x0, y0, x1, y1, x2, y2; + int x0 = 0; + int y0 = 0; + int x1 = 0; + int y1 = 0; + int x2 = 0; + int y2 = 0; iRotate %= 4; switch (iRotate) { case 0: diff --git a/core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp b/core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp index c9f05ac5ab..87ed09735a 100644 --- a/core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp +++ b/core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp @@ -41,11 +41,11 @@ CPDF_StreamParser::~CPDF_StreamParser() { } } -FX_DWORD _DecodeAllScanlines(ICodec_ScanlineDecoder* pDecoder, - uint8_t*& dest_buf, - FX_DWORD& dest_size) { +FX_DWORD DecodeAllScanlines(ICodec_ScanlineDecoder* pDecoder, + uint8_t*& dest_buf, + FX_DWORD& dest_size) { if (!pDecoder) { - return (FX_DWORD)-1; + return static_cast(-1); } int ncomps = pDecoder->CountComps(); int bpc = pDecoder->GetBPC(); @@ -54,7 +54,7 @@ FX_DWORD _DecodeAllScanlines(ICodec_ScanlineDecoder* pDecoder, int pitch = (width * ncomps * bpc + 7) / 8; if (height == 0 || pitch > (1 << 30) / height) { delete pDecoder; - return -1; + return static_cast(-1); } dest_buf = FX_Alloc2D(uint8_t, pitch, height); dest_size = pitch * height; // Safe since checked alloc returned. @@ -88,7 +88,7 @@ FX_DWORD PDF_DecodeInlineStream(const uint8_t* src_buf, if (decoder == "CCITTFaxDecode" || decoder == "CCF") { ICodec_ScanlineDecoder* pDecoder = FPDFAPI_CreateFaxDecoder(src_buf, limit, width, height, pParam); - return _DecodeAllScanlines(pDecoder, dest_buf, dest_size); + return DecodeAllScanlines(pDecoder, dest_buf, dest_size); } if (decoder == "ASCII85Decode" || decoder == "A85") { return A85Decode(src_buf, limit, dest_buf, dest_size); @@ -109,7 +109,7 @@ FX_DWORD PDF_DecodeInlineStream(const uint8_t* src_buf, CPDF_ModuleMgr::Get()->GetJpegModule()->CreateDecoder( src_buf, limit, width, height, 0, pParam ? pParam->GetIntegerBy("ColorTransform", 1) : 1); - return _DecodeAllScanlines(pDecoder, dest_buf, dest_size); + return DecodeAllScanlines(pDecoder, dest_buf, dest_size); } if (decoder == "RunLengthDecode" || decoder == "RL") { return RunLengthDecode(src_buf, limit, dest_buf, dest_size); -- cgit v1.2.3