summaryrefslogtreecommitdiff
path: root/core/fpdfapi
diff options
context:
space:
mode:
authorWei Li <weili@chromium.org>2016-03-21 11:20:44 -0700
committerWei Li <weili@chromium.org>2016-03-21 11:20:44 -0700
commitd4e8f1222ca17b57ac74019b2fc3706e1192645c (patch)
tree0dd5e1627fd684205631f875cbf5946178177766 /core/fpdfapi
parent34fa8d90ae2f60fae219e4dbeff14c053d2e8eef (diff)
downloadpdfium-d4e8f1222ca17b57ac74019b2fc3706e1192645c.tar.xz
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 .
Diffstat (limited to 'core/fpdfapi')
-rw-r--r--core/fpdfapi/fpdf_edit/fpdf_edit_doc.cpp5
-rw-r--r--core/fpdfapi/fpdf_font/fpdf_font_cid.cpp3
-rw-r--r--core/fpdfapi/fpdf_page/cpdf_page.cpp7
-rw-r--r--core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp14
-rw-r--r--core/fpdfapi/fpdf_parser/cpdf_parser.cpp5
-rw-r--r--core/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp6
-rw-r--r--core/fpdfapi/fpdf_render/fpdf_render_text.cpp9
7 files changed, 27 insertions, 22 deletions
diff --git a/core/fpdfapi/fpdf_edit/fpdf_edit_doc.cpp b/core/fpdfapi/fpdf_edit/fpdf_edit_doc.cpp
index 42315dad53..2fddf10a78 100644
--- a/core/fpdfapi/fpdf_edit/fpdf_edit_doc.cpp
+++ b/core/fpdfapi/fpdf_edit/fpdf_edit_doc.cpp
@@ -924,7 +924,7 @@ CPDF_Font* CPDF_Document::AddFont(CFX_Font* pFont, int charset, FX_BOOL bVert) {
pFontDict = new CPDF_Dictionary;
CFX_ByteString cmap;
CFX_ByteString ordering;
- int supplement;
+ int supplement = 0;
CPDF_Array* pWidthArray = new CPDF_Array;
switch (charset) {
case FXFONT_CHINESEBIG5_CHARSET:
@@ -936,7 +936,8 @@ CPDF_Font* CPDF_Document::AddFont(CFX_Font* pFont, int charset, FX_BOOL bVert) {
break;
case FXFONT_GB2312_CHARSET:
cmap = bVert ? "GBK-EUC-V" : "GBK-EUC-H";
- ordering = "GB1", supplement = 2;
+ ordering = "GB1";
+ supplement = 2;
pWidthArray->AddInteger(7716);
_InsertWidthArray1(pFont, pEncoding.get(), 0x20, 0x20, pWidthArray);
pWidthArray->AddInteger(814);
diff --git a/core/fpdfapi/fpdf_font/fpdf_font_cid.cpp b/core/fpdfapi/fpdf_font/fpdf_font_cid.cpp
index 1295c624ad..f370b86049 100644
--- a/core/fpdfapi/fpdf_font/fpdf_font_cid.cpp
+++ b/core/fpdfapi/fpdf_font/fpdf_font_cid.cpp
@@ -1584,7 +1584,8 @@ void CPDF_CIDFont::LoadMetricsArray(CPDF_Array* pArray,
int nElements) {
int width_status = 0;
int iCurElement = 0;
- int first_code = 0, last_code;
+ int first_code = 0;
+ int last_code = 0;
FX_DWORD count = pArray->GetCount();
for (FX_DWORD i = 0; i < count; i++) {
CPDF_Object* pObj = pArray->GetElementValue(i);
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<FX_DWORD>(-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<FX_DWORD>(-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);
diff --git a/core/fpdfapi/fpdf_parser/cpdf_parser.cpp b/core/fpdfapi/fpdf_parser/cpdf_parser.cpp
index c9b8583d16..3ee53e6cf9 100644
--- a/core/fpdfapi/fpdf_parser/cpdf_parser.cpp
+++ b/core/fpdfapi/fpdf_parser/cpdf_parser.cpp
@@ -1538,9 +1538,8 @@ CPDF_Parser::Error CPDF_Parser::StartAsyncParse(IFX_FileRead* pFileAccess) {
FX_FILESIZE dwFirstXRefOffset = m_pSyntax->SavePos();
FX_BOOL bXRefRebuilt = FALSE;
- FX_BOOL bLoadV4 = FALSE;
- if (!(bLoadV4 = LoadCrossRefV4(dwFirstXRefOffset, 0, FALSE)) &&
- !LoadCrossRefV5(&dwFirstXRefOffset, TRUE)) {
+ FX_BOOL bLoadV4 = LoadCrossRefV4(dwFirstXRefOffset, 0, FALSE);
+ if (!bLoadV4 && !LoadCrossRefV5(&dwFirstXRefOffset, TRUE)) {
if (!RebuildCrossRef())
return FORMAT_ERROR;
diff --git a/core/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp b/core/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp
index f7fc3099fc..c91e99b9cb 100644
--- a/core/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp
+++ b/core/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp
@@ -177,14 +177,14 @@ FX_DWORD RunLengthDecode(const uint8_t* src_buf,
old = dest_size;
dest_size += src_buf[i] + 1;
if (dest_size < old) {
- return (FX_DWORD)-1;
+ return static_cast<FX_DWORD>(-1);
}
i += src_buf[i] + 2;
} else if (src_buf[i] > 128) {
old = dest_size;
dest_size += 257 - src_buf[i];
if (dest_size < old) {
- return (FX_DWORD)-1;
+ return static_cast<FX_DWORD>(-1);
}
i += 2;
} else {
@@ -192,7 +192,7 @@ FX_DWORD RunLengthDecode(const uint8_t* src_buf,
}
}
if (dest_size >= _STREAM_MAX_SIZE_) {
- return -1;
+ return static_cast<FX_DWORD>(-1);
}
dest_buf = FX_Alloc(uint8_t, dest_size);
i = 0;
diff --git a/core/fpdfapi/fpdf_render/fpdf_render_text.cpp b/core/fpdfapi/fpdf_render/fpdf_render_text.cpp
index fe72bb3aee..6741d1a70b 100644
--- a/core/fpdfapi/fpdf_render/fpdf_render_text.cpp
+++ b/core/fpdfapi/fpdf_render/fpdf_render_text.cpp
@@ -140,12 +140,12 @@ CFX_GlyphBitmap* CPDF_Type3Cache::RenderGlyph(CPDF_Type3Glyphs* pSize,
text_matrix.Set(pMatrix->a, pMatrix->b, pMatrix->c, pMatrix->d, 0, 0);
image_matrix.Concat(text_matrix);
CFX_DIBitmap* pResBitmap = NULL;
- int left, top;
+ int left = 0;
+ int top = 0;
if (FXSYS_fabs(image_matrix.b) < FXSYS_fabs(image_matrix.a) / 100 &&
FXSYS_fabs(image_matrix.c) < FXSYS_fabs(image_matrix.d) / 100) {
- int top_line, bottom_line;
- top_line = _DetectFirstLastScan(pBitmap, TRUE);
- bottom_line = _DetectFirstLastScan(pBitmap, FALSE);
+ int top_line = _DetectFirstLastScan(pBitmap, TRUE);
+ int bottom_line = _DetectFirstLastScan(pBitmap, FALSE);
if (top_line == 0 && bottom_line == pBitmap->GetHeight() - 1) {
FX_FLOAT top_y = image_matrix.d + image_matrix.f;
FX_FLOAT bottom_y = image_matrix.f;
@@ -167,7 +167,6 @@ CFX_GlyphBitmap* CPDF_Type3Cache::RenderGlyph(CPDF_Type3Glyphs* pSize,
} else {
left = FXSYS_round(image_matrix.e);
}
- } else {
}
}
if (!pResBitmap) {