summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorweili <weili@chromium.org>2016-05-16 13:53:42 -0700
committerCommit bot <commit-bot@chromium.org>2016-05-16 13:53:42 -0700
commit3cc01f2ba255f4b7584668ee2b8e5ed97792c26d (patch)
tree6a207d8910696ef1c28ef60a855ae266f81067cd
parentc6450bb06b69528406a2a261c70c4ea769965a8d (diff)
downloadpdfium-3cc01f2ba255f4b7584668ee2b8e5ed97792c26d.tar.xz
Fix the code that causes warnings
These are the left or newly added code which causes compilation warnings of "signed and unsigned comparison". Need to fix them before I re-enable the warning flag. BUG=pdfium:29 Review-Url: https://codereview.chromium.org/1986533002
-rw-r--r--core/fpdfapi/fpdf_parser/cpdf_array_unittest.cpp2
-rw-r--r--core/fpdfapi/fpdf_parser/cpdf_document.cpp4
-rw-r--r--core/fxcrt/fx_basic_wstring.cpp3
-rw-r--r--core/fxcrt/fx_basic_wstring_unittest.cpp8
-rw-r--r--core/fxge/win32/fx_win32_gdipext.cpp4
-rw-r--r--fpdfsdk/fpdfview_embeddertest.cpp12
-rw-r--r--xfa/fgas/localization/fgas_locale.cpp24
-rw-r--r--xfa/fgas/xml/fgas_sax.cpp2
-rw-r--r--xfa/fxbarcode/datamatrix/BC_ErrorCorrection.cpp14
-rw-r--r--xfa/fxbarcode/datamatrix/BC_HighLevelEncoder.cpp2
10 files changed, 37 insertions, 38 deletions
diff --git a/core/fpdfapi/fpdf_parser/cpdf_array_unittest.cpp b/core/fpdfapi/fpdf_parser/cpdf_array_unittest.cpp
index 58642a610f..12a36d921a 100644
--- a/core/fpdfapi/fpdf_parser/cpdf_array_unittest.cpp
+++ b/core/fpdfapi/fpdf_parser/cpdf_array_unittest.cpp
@@ -76,7 +76,7 @@ TEST(cpdf_array, InsertAt) {
for (size_t i = 0; i < FX_ArraySize(elems); ++i)
arr->InsertAt(i, new CPDF_Number(elems[i]));
arr->InsertAt(10, new CPDF_Number(10));
- EXPECT_EQ(11, arr->GetCount());
+ EXPECT_EQ(11u, arr->GetCount());
for (size_t i = 0; i < FX_ArraySize(elems); ++i)
EXPECT_EQ(elems[i], arr->GetIntegerAt(i));
for (size_t i = FX_ArraySize(elems); i < 10; ++i)
diff --git a/core/fpdfapi/fpdf_parser/cpdf_document.cpp b/core/fpdfapi/fpdf_parser/cpdf_document.cpp
index 52899eedb3..13d9737b5b 100644
--- a/core/fpdfapi/fpdf_parser/cpdf_document.cpp
+++ b/core/fpdfapi/fpdf_parser/cpdf_document.cpp
@@ -1102,7 +1102,7 @@ CPDF_Font* CPDF_Document::AddWindowsFont(LOGFONTA* pLogFont,
pBaseDict->SetAtName("Encoding", "WinAnsiEncoding");
} else {
flags |= PDFFONT_NONSYMBOLIC;
- int i;
+ size_t i;
for (i = 0; i < FX_ArraySize(g_FX_CharsetUnicodes); ++i) {
if (g_FX_CharsetUnicodes[i].m_Charset == pLogFont->lfCharSet)
break;
@@ -1136,7 +1136,7 @@ CPDF_Font* CPDF_Document::AddWindowsFont(LOGFONTA* pLogFont,
int char_widths[224];
GetCharWidth(hDC, 32, 255, char_widths);
CPDF_Array* pWidths = new CPDF_Array;
- for (int i = 0; i < 224; i++)
+ for (size_t i = 0; i < 224; i++)
pWidths->AddInteger(char_widths[i]);
pBaseDict->SetAt("Widths", pWidths);
diff --git a/core/fxcrt/fx_basic_wstring.cpp b/core/fxcrt/fx_basic_wstring.cpp
index 241c3a6985..ba86823fe2 100644
--- a/core/fxcrt/fx_basic_wstring.cpp
+++ b/core/fxcrt/fx_basic_wstring.cpp
@@ -894,7 +894,8 @@ void CFX_WideString::TrimLeft(const CFX_WideStringC& pTargets) {
FX_STRSIZE pos = 0;
while (pos < len) {
FX_STRSIZE i = 0;
- while (i < pTargets.GetLength() && pTargets[i] != m_pData->m_String[pos]) {
+ while (i < pTargets.GetLength() &&
+ pTargets.CharAt(i) != m_pData->m_String[pos]) {
i++;
}
if (i == pTargets.GetLength()) {
diff --git a/core/fxcrt/fx_basic_wstring_unittest.cpp b/core/fxcrt/fx_basic_wstring_unittest.cpp
index 4b6f4a5800..efd958d8a6 100644
--- a/core/fxcrt/fx_basic_wstring_unittest.cpp
+++ b/core/fxcrt/fx_basic_wstring_unittest.cpp
@@ -691,10 +691,10 @@ TEST(fxcrt, WideStringUTF16LE_Encode) {
TEST(fxcrt, WideStringCOperatorSubscript) {
// CFX_WideStringC includes the NUL terminator for non-empty strings.
CFX_WideStringC abc(L"abc");
- EXPECT_EQ(L'a', abc[0]);
- EXPECT_EQ(L'b', abc[1]);
- EXPECT_EQ(L'c', abc[2]);
- EXPECT_EQ(L'\0', abc[3]);
+ EXPECT_EQ(L'a', abc.CharAt(0));
+ EXPECT_EQ(L'b', abc.CharAt(1));
+ EXPECT_EQ(L'c', abc.CharAt(2));
+ EXPECT_EQ(L'\0', abc.CharAt(3));
}
TEST(fxcrt, WideStringCOperatorLT) {
diff --git a/core/fxge/win32/fx_win32_gdipext.cpp b/core/fxge/win32/fx_win32_gdipext.cpp
index 15f0972bba..eb24410900 100644
--- a/core/fxge/win32/fx_win32_gdipext.cpp
+++ b/core/fxge/win32/fx_win32_gdipext.cpp
@@ -673,7 +673,7 @@ static void OutputImage(GpGraphics* pGraphics,
CGdiplusExt::CGdiplusExt() {
m_hModule = NULL;
m_GdiModule = NULL;
- for (int i = 0; i < sizeof g_GdipFuncNames / sizeof(LPCSTR); i++) {
+ for (size_t i = 0; i < sizeof g_GdipFuncNames / sizeof(LPCSTR); i++) {
m_Functions[i] = NULL;
}
m_pGdiAddFontMemResourceEx = NULL;
@@ -690,7 +690,7 @@ void CGdiplusExt::Load() {
if (!m_hModule) {
return;
}
- for (int i = 0; i < sizeof g_GdipFuncNames / sizeof(LPCSTR); i++) {
+ for (size_t i = 0; i < sizeof g_GdipFuncNames / sizeof(LPCSTR); i++) {
m_Functions[i] = GetProcAddress(m_hModule, g_GdipFuncNames[i]);
if (!m_Functions[i]) {
m_hModule = NULL;
diff --git a/fpdfsdk/fpdfview_embeddertest.cpp b/fpdfsdk/fpdfview_embeddertest.cpp
index 2ccbfd00d3..80b39b5b9c 100644
--- a/fpdfsdk/fpdfview_embeddertest.cpp
+++ b/fpdfsdk/fpdfview_embeddertest.cpp
@@ -56,7 +56,7 @@ TEST_F(FPDFViewEmbeddertest, EmptyDocument) {
EXPECT_EQ(1, FPDF_VIEWERREF_GetNumCopies(document()));
EXPECT_EQ(DuplexUndefined, FPDF_VIEWERREF_GetDuplex(document()));
- EXPECT_EQ(0, FPDF_CountNamedDests(document()));
+ EXPECT_EQ(0u, FPDF_CountNamedDests(document()));
}
TEST_F(FPDFViewEmbeddertest, Page) {
@@ -86,7 +86,7 @@ TEST_F(FPDFViewEmbeddertest, NamedDests) {
buffer_size = 2000000; // Absurdly large, check not used for this case.
dest = FPDF_GetNamedDest(document(), 0, nullptr, &buffer_size);
EXPECT_NE(nullptr, dest);
- EXPECT_EQ(12u, buffer_size);
+ EXPECT_EQ(12, buffer_size);
// Try to retrieve the first item with too small a buffer.
buffer_size = 10;
@@ -99,7 +99,7 @@ TEST_F(FPDFViewEmbeddertest, NamedDests) {
buffer_size = 12;
dest = FPDF_GetNamedDest(document(), 0, fixed_buffer, &buffer_size);
EXPECT_NE(nullptr, dest);
- EXPECT_EQ(12u, buffer_size);
+ EXPECT_EQ(12, buffer_size);
EXPECT_EQ(std::string("F\0i\0r\0s\0t\0\0\0", 12),
std::string(fixed_buffer, buffer_size));
@@ -108,7 +108,7 @@ TEST_F(FPDFViewEmbeddertest, NamedDests) {
buffer_size = sizeof(fixed_buffer);
dest = FPDF_GetNamedDest(document(), 1, fixed_buffer, &buffer_size);
EXPECT_NE(nullptr, dest);
- EXPECT_EQ(10u, buffer_size);
+ EXPECT_EQ(10, buffer_size);
EXPECT_EQ(std::string("N\0e\0x\0t\0\0\0", 10),
std::string(fixed_buffer, buffer_size));
@@ -134,7 +134,7 @@ TEST_F(FPDFViewEmbeddertest, NamedDests) {
buffer_size = sizeof(fixed_buffer);
dest = FPDF_GetNamedDest(document(), 4, fixed_buffer, &buffer_size);
EXPECT_NE(nullptr, dest);
- EXPECT_EQ(30u, buffer_size);
+ EXPECT_EQ(30, buffer_size);
EXPECT_EQ(std::string("F\0i\0r\0s\0t\0A\0l\0t\0e\0r\0n\0a\0t\0e\0\0\0", 30),
std::string(fixed_buffer, buffer_size));
@@ -144,7 +144,7 @@ TEST_F(FPDFViewEmbeddertest, NamedDests) {
buffer_size = sizeof(fixed_buffer);
dest = FPDF_GetNamedDest(document(), 5, fixed_buffer, &buffer_size);
EXPECT_NE(nullptr, dest);
- EXPECT_EQ(28u, buffer_size);
+ EXPECT_EQ(28, buffer_size);
EXPECT_EQ(std::string("L\0a\0s\0t\0A\0l\0t\0e\0r\0n\0a\0t\0e\0\0\0", 28),
std::string(fixed_buffer, buffer_size));
diff --git a/xfa/fgas/localization/fgas_locale.cpp b/xfa/fgas/localization/fgas_locale.cpp
index 851b687c4b..bb4fe93ba3 100644
--- a/xfa/fgas/localization/fgas_locale.cpp
+++ b/xfa/fgas/localization/fgas_locale.cpp
@@ -2304,12 +2304,12 @@ static FX_BOOL FX_ParseLocaleDate(const CFX_WideString& wsDate,
continue;
}
uint32_t dwSymbolNum = 1;
- uint32_t dwSymbol = strf[ccf++];
- while (ccf < lenf && strf[ccf] == dwSymbol) {
+ FX_WCHAR dwCharSymbol = strf[ccf++];
+ while (ccf < lenf && strf[ccf] == dwCharSymbol) {
ccf++;
dwSymbolNum++;
}
- dwSymbol = (dwSymbol << 8) | (dwSymbolNum + '0');
+ uint32_t dwSymbol = (dwCharSymbol << 8) | (dwSymbolNum + '0');
if (dwSymbol == FXBSTR_ID(0, 0, 'D', '1')) {
if (!FX_IsDigit(str[cc])) {
return FALSE;
@@ -2523,12 +2523,12 @@ static FX_BOOL FX_ParseLocaleTime(const CFX_WideString& wsTime,
continue;
}
uint32_t dwSymbolNum = 1;
- uint32_t dwSymbol = strf[ccf++];
- while (ccf < lenf && strf[ccf] == dwSymbol) {
+ FX_WCHAR dwCharSymbol = strf[ccf++];
+ while (ccf < lenf && strf[ccf] == dwCharSymbol) {
ccf++;
dwSymbolNum++;
}
- dwSymbol = (dwSymbol << 8) | (dwSymbolNum + '0');
+ uint32_t dwSymbol = (dwCharSymbol << 8) | (dwSymbolNum + '0');
if (dwSymbol == FXBSTR_ID(0, 0, 'k', '1') ||
dwSymbol == FXBSTR_ID(0, 0, 'H', '1') ||
dwSymbol == FXBSTR_ID(0, 0, 'h', '1') ||
@@ -3952,12 +3952,12 @@ static FX_BOOL FX_DateFormat(const CFX_WideString& wsDatePattern,
continue;
}
uint32_t dwSymbolNum = 1;
- uint32_t dwSymbol = strf[ccf++];
- while (ccf < lenf && strf[ccf] == dwSymbol) {
+ FX_WCHAR dwCharSymbol = strf[ccf++];
+ while (ccf < lenf && strf[ccf] == dwCharSymbol) {
ccf++;
dwSymbolNum++;
}
- dwSymbol = (dwSymbol << 8) | (dwSymbolNum + '0');
+ uint32_t dwSymbol = (dwCharSymbol << 8) | (dwSymbolNum + '0');
if (dwSymbol == FXBSTR_ID(0, 0, 'D', '1')) {
CFX_WideString wsDay;
wsDay.Format(L"%d", day);
@@ -4079,12 +4079,12 @@ static FX_BOOL FX_TimeFormat(const CFX_WideString& wsTimePattern,
continue;
}
uint32_t dwSymbolNum = 1;
- uint32_t dwSymbol = strf[ccf++];
- while (ccf < lenf && strf[ccf] == dwSymbol) {
+ FX_WCHAR dwCharSymbol = strf[ccf++];
+ while (ccf < lenf && strf[ccf] == dwCharSymbol) {
ccf++;
dwSymbolNum++;
}
- dwSymbol = (dwSymbol << 8) | (dwSymbolNum + '0');
+ uint32_t dwSymbol = (dwCharSymbol << 8) | (dwSymbolNum + '0');
if (dwSymbol == FXBSTR_ID(0, 0, 'h', '1')) {
if (wHour > 12) {
wHour -= 12;
diff --git a/xfa/fgas/xml/fgas_sax.cpp b/xfa/fgas/xml/fgas_sax.cpp
index b97aeb0a7c..1128e1184f 100644
--- a/xfa/fgas/xml/fgas_sax.cpp
+++ b/xfa/fgas/xml/fgas_sax.cpp
@@ -32,7 +32,7 @@ FX_BOOL CFX_SAXFile::StartFile(IFX_FileRead* pFile,
if (dwStart >= dwSize) {
return FALSE;
}
- if (dwLen == -1 || dwStart + dwLen > dwSize) {
+ if (dwLen == static_cast<uint32_t>(-1) || dwStart + dwLen > dwSize) {
dwLen = dwSize - dwStart;
}
if (dwLen == 0) {
diff --git a/xfa/fxbarcode/datamatrix/BC_ErrorCorrection.cpp b/xfa/fxbarcode/datamatrix/BC_ErrorCorrection.cpp
index 1c20b7c8a1..8f54353d4a 100644
--- a/xfa/fxbarcode/datamatrix/BC_ErrorCorrection.cpp
+++ b/xfa/fxbarcode/datamatrix/BC_ErrorCorrection.cpp
@@ -172,14 +172,12 @@ CFX_WideString CBC_ErrorCorrection::createECCBlock(CFX_WideString codewords,
int32_t len,
int32_t numECWords,
int32_t& e) {
- int32_t table = -1;
- for (int32_t i = 0; i < sizeof(FACTOR_SETS) / sizeof(int32_t); i++) {
- if (FACTOR_SETS[i] == numECWords) {
- table = i;
- break;
- }
- }
- if (table < 0) {
+ static const size_t kFactorTableNum = sizeof(FACTOR_SETS) / sizeof(int32_t);
+ size_t table = 0;
+ while (table < kFactorTableNum && FACTOR_SETS[table] != numECWords)
+ table++;
+
+ if (table >= kFactorTableNum) {
e = BCExceptionIllegalArgument;
return (FX_WCHAR*)"";
}
diff --git a/xfa/fxbarcode/datamatrix/BC_HighLevelEncoder.cpp b/xfa/fxbarcode/datamatrix/BC_HighLevelEncoder.cpp
index 15f288be63..19672c1b71 100644
--- a/xfa/fxbarcode/datamatrix/BC_HighLevelEncoder.cpp
+++ b/xfa/fxbarcode/datamatrix/BC_HighLevelEncoder.cpp
@@ -158,7 +158,7 @@ int32_t CBC_HighLevelEncoder::lookAheadTest(CFX_WideString msg,
int32_t charsProcessed = 0;
while (TRUE) {
if ((startpos + charsProcessed) == msg.GetLength()) {
- uint32_t min = std::numeric_limits<int32_t>::max();
+ int32_t min = std::numeric_limits<int32_t>::max();
CFX_ByteArray mins;
mins.SetSize(6);
CFX_Int32Array intCharCounts;