From 3cc01f2ba255f4b7584668ee2b8e5ed97792c26d Mon Sep 17 00:00:00 2001 From: weili Date: Mon, 16 May 2016 13:53:42 -0700 Subject: 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 --- xfa/fxbarcode/datamatrix/BC_ErrorCorrection.cpp | 14 ++++++-------- xfa/fxbarcode/datamatrix/BC_HighLevelEncoder.cpp | 2 +- 2 files changed, 7 insertions(+), 9 deletions(-) (limited to 'xfa/fxbarcode') 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::max(); + int32_t min = std::numeric_limits::max(); CFX_ByteArray mins; mins.SetSize(6); CFX_Int32Array intCharCounts; -- cgit v1.2.3