Use size_t in more places in fxbarcode.

Change-Id: Ibed68449c0ac39fa5a97be6dd4922a24b35d46b9
Reviewed-on: https://pdfium-review.googlesource.com/c/46030
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
diff --git a/fxbarcode/cbc_ean13.cpp b/fxbarcode/cbc_ean13.cpp
index 0c30b38..b038f81 100644
--- a/fxbarcode/cbc_ean13.cpp
+++ b/fxbarcode/cbc_ean13.cpp
@@ -34,18 +34,18 @@
 WideString CBC_EAN13::Preprocess(const WideStringView& contents) {
   auto* pWriter = GetOnedEAN13Writer();
   WideString encodeContents = pWriter->FilterContents(contents);
-  int32_t length = encodeContents.GetLength();
+  size_t length = encodeContents.GetLength();
   if (length <= 12) {
-    for (int32_t i = 0; i < 12 - length; i++)
-      encodeContents = wchar_t('0') + encodeContents;
+    for (size_t i = 0; i < 12 - length; i++)
+      encodeContents.InsertAtFront(L'0');
 
     ByteString byteString = encodeContents.ToUTF8();
     int32_t checksum = pWriter->CalcChecksum(byteString);
     byteString += checksum + '0';
     encodeContents = WideString::FromUTF8(byteString.AsStringView());
-  }
-  if (length > 13)
+  } else {
     encodeContents = encodeContents.Left(13);
+  }
 
   return encodeContents;
 }
diff --git a/fxbarcode/cbc_ean8.cpp b/fxbarcode/cbc_ean8.cpp
index ee3e14b..d74a712 100644
--- a/fxbarcode/cbc_ean8.cpp
+++ b/fxbarcode/cbc_ean8.cpp
@@ -33,17 +33,17 @@
 WideString CBC_EAN8::Preprocess(const WideStringView& contents) {
   auto* pWriter = GetOnedEAN8Writer();
   WideString encodeContents = pWriter->FilterContents(contents);
-  int32_t length = encodeContents.GetLength();
+  size_t length = encodeContents.GetLength();
   if (length <= 7) {
-    for (int32_t i = 0; i < 7 - length; i++)
+    for (size_t i = 0; i < 7 - length; i++)
       encodeContents = L'0' + encodeContents;
 
     ByteString byteString = encodeContents.ToUTF8();
     int32_t checksum = pWriter->CalcChecksum(byteString);
     encodeContents += L'0' + checksum;
-  }
-  if (length > 8)
+  } else {
     encodeContents = encodeContents.Left(8);
+  }
 
   return encodeContents;
 }
diff --git a/fxbarcode/cbc_upca.cpp b/fxbarcode/cbc_upca.cpp
index 369e6e2..77c4c49 100644
--- a/fxbarcode/cbc_upca.cpp
+++ b/fxbarcode/cbc_upca.cpp
@@ -33,18 +33,18 @@
 WideString CBC_UPCA::Preprocess(const WideStringView& contents) {
   CBC_OnedUPCAWriter* pWriter = GetOnedUPCAWriter();
   WideString encodeContents = pWriter->FilterContents(contents);
-  int32_t length = encodeContents.GetLength();
+  size_t length = encodeContents.GetLength();
   if (length <= 11) {
-    for (int32_t i = 0; i < 11 - length; i++)
+    for (size_t i = 0; i < 11 - length; i++)
       encodeContents = L'0' + encodeContents;
 
     ByteString byteString = encodeContents.ToUTF8();
     int32_t checksum = pWriter->CalcChecksum(byteString);
     byteString += '0' + checksum;
     encodeContents = WideString::FromUTF8(byteString.AsStringView());
-  }
-  if (length > 12)
+  } else {
     encodeContents = encodeContents.Left(12);
+  }
 
   return encodeContents;
 }
diff --git a/fxbarcode/datamatrix/BC_Base256Encoder.cpp b/fxbarcode/datamatrix/BC_Base256Encoder.cpp
index 922e1ef..9938b3e 100644
--- a/fxbarcode/datamatrix/BC_Base256Encoder.cpp
+++ b/fxbarcode/datamatrix/BC_Base256Encoder.cpp
@@ -62,7 +62,7 @@
       break;
     }
   }
-  int32_t dataCount = buffer.GetLength() - 1;
+  size_t dataCount = buffer.GetLength() - 1;
   char buf[128];
   FXSYS_itoa(dataCount, buf, 10);
   buffer.SetAt(0, static_cast<wchar_t>(*buf) - '0');
diff --git a/fxbarcode/datamatrix/BC_C40Encoder.cpp b/fxbarcode/datamatrix/BC_C40Encoder.cpp
index 9f1c8f0..983e46b 100644
--- a/fxbarcode/datamatrix/BC_C40Encoder.cpp
+++ b/fxbarcode/datamatrix/BC_C40Encoder.cpp
@@ -61,7 +61,7 @@
     if (lastCharSize <= 0)
       return false;
 
-    int32_t unwritten = (buffer.GetLength() / 3) * 2;
+    size_t unwritten = (buffer.GetLength() / 3) * 2;
     int32_t curCodewordCount = context->getCodewordCount() + unwritten;
     if (!context->UpdateSymbolInfo(curCodewordCount))
       return false;
@@ -84,7 +84,7 @@
       }
       break;
     }
-    int32_t count = buffer.GetLength();
+    size_t count = buffer.GetLength();
     if ((count % 3) == 0) {
       int32_t newMode = CBC_HighLevelEncoder::lookAheadTest(
           context->m_msg, context->m_pos, getEncodingMode());
@@ -105,8 +105,8 @@
 
 bool CBC_C40Encoder::HandleEOD(CBC_EncoderContext* context,
                                WideString* buffer) {
-  int32_t unwritten = (buffer->GetLength() / 3) * 2;
-  int32_t rest = buffer->GetLength() % 3;
+  size_t unwritten = (buffer->GetLength() / 3) * 2;
+  size_t rest = buffer->GetLength() % 3;
   int32_t curCodewordCount = context->getCodewordCount() + unwritten;
   if (!context->UpdateSymbolInfo(curCodewordCount))
     return false;
@@ -189,11 +189,13 @@
 int32_t CBC_C40Encoder::BacktrackOneCharacter(CBC_EncoderContext* context,
                                               WideString* buffer,
                                               int32_t lastCharSize) {
+  ASSERT(lastCharSize >= 0);
+
   if (context->m_pos < 1)
     return -1;
 
-  int32_t count = buffer->GetLength();
-  if (count < lastCharSize)
+  size_t count = buffer->GetLength();
+  if (count < static_cast<size_t>(lastCharSize))
     return -1;
 
   buffer->Delete(count - lastCharSize, lastCharSize);
diff --git a/fxbarcode/datamatrix/BC_DataMatrixSymbolInfo144.cpp b/fxbarcode/datamatrix/BC_DataMatrixSymbolInfo144.cpp
index 46af38d..682d095 100644
--- a/fxbarcode/datamatrix/BC_DataMatrixSymbolInfo144.cpp
+++ b/fxbarcode/datamatrix/BC_DataMatrixSymbolInfo144.cpp
@@ -29,6 +29,6 @@
 
 CBC_DataMatrixSymbolInfo144::~CBC_DataMatrixSymbolInfo144() {}
 
-int32_t CBC_DataMatrixSymbolInfo144::getInterleavedBlockCount() const {
+size_t CBC_DataMatrixSymbolInfo144::getInterleavedBlockCount() const {
   return 10;
 }
diff --git a/fxbarcode/datamatrix/BC_DataMatrixSymbolInfo144.h b/fxbarcode/datamatrix/BC_DataMatrixSymbolInfo144.h
index 45c30b6..2f44557 100644
--- a/fxbarcode/datamatrix/BC_DataMatrixSymbolInfo144.h
+++ b/fxbarcode/datamatrix/BC_DataMatrixSymbolInfo144.h
@@ -14,7 +14,8 @@
   CBC_DataMatrixSymbolInfo144();
   ~CBC_DataMatrixSymbolInfo144() override;
 
-  int32_t getInterleavedBlockCount() const override;
+  // CBC_SymbolInfo:
+  size_t getInterleavedBlockCount() const override;
 };
 
 #endif  // FXBARCODE_DATAMATRIX_BC_DATAMATRIXSYMBOLINFO144_H_
diff --git a/fxbarcode/datamatrix/BC_EdifactEncoder.cpp b/fxbarcode/datamatrix/BC_EdifactEncoder.cpp
index a596992..0a6c7dc 100644
--- a/fxbarcode/datamatrix/BC_EdifactEncoder.cpp
+++ b/fxbarcode/datamatrix/BC_EdifactEncoder.cpp
@@ -51,7 +51,7 @@
 }
 
 bool HandleEOD(CBC_EncoderContext* context, const WideString& buffer) {
-  int32_t count = buffer.GetLength();
+  size_t count = buffer.GetLength();
   if (count == 0)
     return true;
   if (count > 4)
@@ -132,7 +132,7 @@
       return false;
 
     context->m_pos++;
-    int32_t count = buffer.GetLength();
+    size_t count = buffer.GetLength();
     if (count >= 4) {
       WideString encoded = EncodeToEdifactCodewords(buffer, 0);
       if (encoded.IsEmpty())
diff --git a/fxbarcode/datamatrix/BC_EncoderContext.cpp b/fxbarcode/datamatrix/BC_EncoderContext.cpp
index 48cf62a..87fcb09 100644
--- a/fxbarcode/datamatrix/BC_EncoderContext.cpp
+++ b/fxbarcode/datamatrix/BC_EncoderContext.cpp
@@ -66,18 +66,23 @@
 void CBC_EncoderContext::writeCodeword(wchar_t codeword) {
   m_codewords += codeword;
 }
+
 size_t CBC_EncoderContext::getCodewordCount() {
   return m_codewords.GetLength();
 }
+
 void CBC_EncoderContext::signalEncoderChange(int32_t encoding) {
   m_newEncoding = encoding;
 }
+
 void CBC_EncoderContext::resetEncoderSignal() {
   m_newEncoding = -1;
 }
+
 bool CBC_EncoderContext::hasMoreCharacters() {
   return m_pos < getTotalMessageCharCount();
 }
+
 size_t CBC_EncoderContext::getRemainingCharacters() {
   return getTotalMessageCharCount() - m_pos;
 }
@@ -86,7 +91,7 @@
   return UpdateSymbolInfo(getCodewordCount());
 }
 
-bool CBC_EncoderContext::UpdateSymbolInfo(int32_t len) {
+bool CBC_EncoderContext::UpdateSymbolInfo(size_t len) {
   if (!m_symbolInfo || len > m_symbolInfo->dataCapacity()) {
     m_symbolInfo = CBC_SymbolInfo::Lookup(len, m_bAllowRectangular);
     if (!m_symbolInfo)
diff --git a/fxbarcode/datamatrix/BC_EncoderContext.h b/fxbarcode/datamatrix/BC_EncoderContext.h
index 13f0037..a6ee8e6 100644
--- a/fxbarcode/datamatrix/BC_EncoderContext.h
+++ b/fxbarcode/datamatrix/BC_EncoderContext.h
@@ -30,7 +30,7 @@
   bool hasMoreCharacters();
   size_t getRemainingCharacters();
   bool UpdateSymbolInfo();
-  bool UpdateSymbolInfo(int32_t len);
+  bool UpdateSymbolInfo(size_t len);
   void resetSymbolInfo();
 
   bool HasCharactersOutsideISO88591Encoding() const {
diff --git a/fxbarcode/datamatrix/BC_ErrorCorrection.cpp b/fxbarcode/datamatrix/BC_ErrorCorrection.cpp
index 52fe6ba..ae1f487 100644
--- a/fxbarcode/datamatrix/BC_ErrorCorrection.cpp
+++ b/fxbarcode/datamatrix/BC_ErrorCorrection.cpp
@@ -160,13 +160,11 @@
 
 WideString CBC_ErrorCorrection::EncodeECC200(const WideString& codewords,
                                              const CBC_SymbolInfo* symbolInfo) {
-  if (pdfium::base::checked_cast<int32_t>(codewords.GetLength()) !=
-      symbolInfo->dataCapacity()) {
+  if (codewords.GetLength() != symbolInfo->dataCapacity())
     return WideString();
-  }
-  WideString sb;
-  sb += codewords;
-  int32_t blockCount = symbolInfo->getInterleavedBlockCount();
+
+  WideString sb = codewords;
+  size_t blockCount = symbolInfo->getInterleavedBlockCount();
   if (blockCount == 1) {
     WideString ecc = CreateECCBlock(codewords, symbolInfo->errorCodewords());
     if (ecc.IsEmpty())
@@ -176,7 +174,7 @@
     std::vector<int32_t> dataSizes(blockCount);
     std::vector<int32_t> errorSizes(blockCount);
     std::vector<int32_t> startPos(blockCount);
-    for (int32_t i = 0; i < blockCount; i++) {
+    for (size_t i = 0; i < blockCount; i++) {
       dataSizes[i] = symbolInfo->getDataLengthForInterleavedBlock(i + 1);
       errorSizes[i] = symbolInfo->getErrorLengthForInterleavedBlock(i + 1);
       startPos[i] = 0;
@@ -184,18 +182,19 @@
         startPos[i] = startPos[i - 1] + dataSizes[i];
       }
     }
-    for (int32_t block = 0; block < blockCount; block++) {
+    for (size_t block = 0; block < blockCount; block++) {
       WideString temp;
-      for (int32_t d = block; d < symbolInfo->dataCapacity(); d += blockCount) {
-        temp += (wchar_t)codewords[d];
-      }
+      for (size_t d = block; d < symbolInfo->dataCapacity(); d += blockCount)
+        temp += static_cast<wchar_t>(codewords[d]);
+
       WideString ecc = CreateECCBlock(temp, errorSizes[block]);
       if (ecc.IsEmpty())
         return WideString();
-      int32_t pos = 0;
-      for (int32_t l = block; l < errorSizes[block] * blockCount;
-           l += blockCount) {
-        sb.SetAt(symbolInfo->dataCapacity() + l, ecc[pos++]);
+
+      size_t pos = 0;
+      for (size_t i = block; i < errorSizes[block] * blockCount;
+           i += blockCount) {
+        sb.SetAt(symbolInfo->dataCapacity() + i, ecc[pos++]);
       }
     }
   }
diff --git a/fxbarcode/datamatrix/BC_HighLevelEncoder.cpp b/fxbarcode/datamatrix/BC_HighLevelEncoder.cpp
index 6c24262..866ef80 100644
--- a/fxbarcode/datamatrix/BC_HighLevelEncoder.cpp
+++ b/fxbarcode/datamatrix/BC_HighLevelEncoder.cpp
@@ -99,11 +99,11 @@
       context.resetEncoderSignal();
     }
   }
-  int32_t len = context.m_codewords.GetLength();
+  size_t len = context.m_codewords.GetLength();
   if (!context.UpdateSymbolInfo())
     return WideString();
 
-  int32_t capacity = context.m_symbolInfo->dataCapacity();
+  size_t capacity = context.m_symbolInfo->dataCapacity();
   if (len < capacity) {
     if (encodingMode != ASCII_ENCODATION &&
         encodingMode != BASE256_ENCODATION) {
@@ -111,14 +111,12 @@
     }
   }
   WideString codewords = context.m_codewords;
-  if (pdfium::base::checked_cast<int32_t>(codewords.GetLength()) < capacity)
+  if (codewords.GetLength() < capacity)
     codewords += PAD;
 
-  while (pdfium::base::checked_cast<int32_t>(codewords.GetLength()) <
-         capacity) {
-    codewords += (randomize253State(
-        PAD, pdfium::base::checked_cast<int32_t>(codewords.GetLength()) + 1));
-  }
+  while (codewords.GetLength() < capacity)
+    codewords += randomize253State(PAD, codewords.GetLength() + 1);
+
   ASSERT(!codewords.IsEmpty());
   return codewords;
 }
@@ -262,10 +260,11 @@
 bool CBC_HighLevelEncoder::isExtendedASCII(wchar_t ch) {
   return ch >= 128 && ch <= 255;
 }
+
 int32_t CBC_HighLevelEncoder::determineConsecutiveDigitCount(WideString msg,
                                                              int32_t startpos) {
   int32_t count = 0;
-  int32_t len = msg.GetLength();
+  int32_t len = pdfium::base::checked_cast<int32_t>(msg.GetLength());
   int32_t idx = startpos;
   if (idx < len) {
     wchar_t ch = msg[idx];
@@ -284,9 +283,10 @@
                                                 int32_t codewordPosition) {
   int32_t pseudoRandom = ((149 * codewordPosition) % 253) + 1;
   int32_t tempVariable = ch + pseudoRandom;
-  return tempVariable <= 254 ? (wchar_t)tempVariable
-                             : (wchar_t)(tempVariable - 254);
+  return tempVariable <= 254 ? static_cast<wchar_t>(tempVariable)
+                             : static_cast<wchar_t>(tempVariable - 254);
 }
+
 int32_t CBC_HighLevelEncoder::findMinimums(std::vector<float>& charCounts,
                                            std::vector<int32_t>& intCharCounts,
                                            int32_t min,
diff --git a/fxbarcode/datamatrix/BC_SymbolInfo.cpp b/fxbarcode/datamatrix/BC_SymbolInfo.cpp
index 92f0f97..c47a6f0 100644
--- a/fxbarcode/datamatrix/BC_SymbolInfo.cpp
+++ b/fxbarcode/datamatrix/BC_SymbolInfo.cpp
@@ -78,8 +78,8 @@
   }
 }
 
-CBC_SymbolInfo::CBC_SymbolInfo(int32_t dataCapacity,
-                               int32_t errorCodewords,
+CBC_SymbolInfo::CBC_SymbolInfo(size_t dataCapacity,
+                               size_t errorCodewords,
                                int32_t matrixWidth,
                                int32_t matrixHeight,
                                int32_t dataRegions)
@@ -91,8 +91,8 @@
                      dataCapacity,
                      errorCodewords) {}
 
-CBC_SymbolInfo::CBC_SymbolInfo(int32_t dataCapacity,
-                               int32_t errorCodewords,
+CBC_SymbolInfo::CBC_SymbolInfo(size_t dataCapacity,
+                               size_t errorCodewords,
                                int32_t matrixWidth,
                                int32_t matrixHeight,
                                int32_t dataRegions,
@@ -109,7 +109,7 @@
 
 CBC_SymbolInfo::~CBC_SymbolInfo() = default;
 
-const CBC_SymbolInfo* CBC_SymbolInfo::Lookup(int32_t iDataCodewords,
+const CBC_SymbolInfo* CBC_SymbolInfo::Lookup(size_t iDataCodewords,
                                              bool bAllowRectangular) {
   for (size_t i = 0; i < kSymbolsCount; i++) {
     CBC_SymbolInfo* symbol = g_symbols[i];
@@ -174,11 +174,11 @@
   return getSymbolDataHeight() + (getVerticalDataRegions() * 2);
 }
 
-int32_t CBC_SymbolInfo::getCodewordCount() const {
+size_t CBC_SymbolInfo::getCodewordCount() const {
   return m_dataCapacity + m_errorCodewords;
 }
 
-int32_t CBC_SymbolInfo::getInterleavedBlockCount() const {
+size_t CBC_SymbolInfo::getInterleavedBlockCount() const {
   return m_dataCapacity / m_rsBlockData;
 }
 
diff --git a/fxbarcode/datamatrix/BC_SymbolInfo.h b/fxbarcode/datamatrix/BC_SymbolInfo.h
index 4655cb7..bad6d3b 100644
--- a/fxbarcode/datamatrix/BC_SymbolInfo.h
+++ b/fxbarcode/datamatrix/BC_SymbolInfo.h
@@ -12,8 +12,8 @@
 
 class CBC_SymbolInfo {
  public:
-  CBC_SymbolInfo(int32_t dataCapacity,
-                 int32_t errorCodewords,
+  CBC_SymbolInfo(size_t dataCapacity,
+                 size_t errorCodewords,
                  int32_t matrixWidth,
                  int32_t matrixHeight,
                  int32_t dataRegions);
@@ -22,26 +22,26 @@
   static void Initialize();
   static void Finalize();
   static void overrideSymbolSet(CBC_SymbolInfo* override);
-  static const CBC_SymbolInfo* Lookup(int32_t iDataCodewords,
+  static const CBC_SymbolInfo* Lookup(size_t iDataCodewords,
                                       bool bAllowRectangular);
 
   int32_t getSymbolDataWidth() const;
   int32_t getSymbolDataHeight() const;
   int32_t getSymbolWidth() const;
   int32_t getSymbolHeight() const;
-  int32_t getCodewordCount() const;
-  virtual int32_t getInterleavedBlockCount() const;
+  size_t getCodewordCount() const;
+  virtual size_t getInterleavedBlockCount() const;
   int32_t getDataLengthForInterleavedBlock(int32_t index) const;
   int32_t getErrorLengthForInterleavedBlock(int32_t index) const;
 
-  int32_t dataCapacity() const { return m_dataCapacity; }
-  int32_t errorCodewords() const { return m_errorCodewords; }
+  size_t dataCapacity() const { return m_dataCapacity; }
+  size_t errorCodewords() const { return m_errorCodewords; }
   int32_t matrixWidth() const { return m_matrixWidth; }
   int32_t matrixHeight() const { return m_matrixHeight; }
 
  protected:
-  CBC_SymbolInfo(int32_t dataCapacity,
-                 int32_t errorCodewords,
+  CBC_SymbolInfo(size_t dataCapacity,
+                 size_t errorCodewords,
                  int32_t matrixWidth,
                  int32_t matrixHeight,
                  int32_t dataRegions,
@@ -53,8 +53,8 @@
   int32_t getVerticalDataRegions() const;
 
   const bool m_rectangular;
-  const int32_t m_dataCapacity;
-  const int32_t m_errorCodewords;
+  const size_t m_dataCapacity;
+  const size_t m_errorCodewords;
   const int32_t m_matrixWidth;
   const int32_t m_matrixHeight;
   const int32_t m_dataRegions;
diff --git a/fxbarcode/datamatrix/BC_X12Encoder.cpp b/fxbarcode/datamatrix/BC_X12Encoder.cpp
index 0267f20..e9516a3 100644
--- a/fxbarcode/datamatrix/BC_X12Encoder.cpp
+++ b/fxbarcode/datamatrix/BC_X12Encoder.cpp
@@ -46,7 +46,7 @@
     if (EncodeChar(c, &buffer) <= 0)
       return false;
 
-    int32_t count = buffer.GetLength();
+    size_t count = buffer.GetLength();
     if ((count % 3) == 0) {
       WriteNextTriplet(context, &buffer);
       int32_t newMode = CBC_HighLevelEncoder::lookAheadTest(
@@ -67,7 +67,7 @@
 
   int32_t available =
       context->m_symbolInfo->dataCapacity() - context->getCodewordCount();
-  int32_t count = buffer->GetLength();
+  size_t count = buffer->GetLength();
   if (count == 2) {
     context->writeCodeword(CBC_HighLevelEncoder::X12_UNLATCH);
     context->m_pos -= 2;
diff --git a/fxbarcode/oned/BC_OneDimWriter.cpp b/fxbarcode/oned/BC_OneDimWriter.cpp
index a282765..54f44a3 100644
--- a/fxbarcode/oned/BC_OneDimWriter.cpp
+++ b/fxbarcode/oned/BC_OneDimWriter.cpp
@@ -186,8 +186,7 @@
     return false;
 
   ByteString str = FX_UTF8Encode(contents);
-  int32_t iLen = str.GetLength();
-  std::vector<FXTEXT_CHARPOS> charpos(iLen);
+  std::vector<FXTEXT_CHARPOS> charpos(str.GetLength());
   float charsLen = 0;
   float geWidth = 0;
   if (m_locTextLoc == BC_TEXT_LOC_ABOVEEMBED ||
diff --git a/fxbarcode/oned/BC_OnedEAN13Writer.cpp b/fxbarcode/oned/BC_OnedEAN13Writer.cpp
index d35a281..297908a 100644
--- a/fxbarcode/oned/BC_OnedEAN13Writer.cpp
+++ b/fxbarcode/oned/BC_OnedEAN13Writer.cpp
@@ -134,8 +134,8 @@
   int32_t leftPadding = 7 * multiple;
   int32_t leftPosition = 3 * multiple + leftPadding;
   ByteString str = FX_UTF8Encode(contents);
-  int32_t iLen = str.GetLength();
-  std::vector<FXTEXT_CHARPOS> charpos(iLen);
+  size_t length = str.GetLength();
+  std::vector<FXTEXT_CHARPOS> charpos(length);
   int32_t iFontSize = (int32_t)fabs(m_fFontSize);
   int32_t iTextHeight = iFontSize + 1;
   ByteString tempStr = str.Mid(1, 6);
@@ -163,7 +163,7 @@
   device->FillRect(re, m_backgroundColor);
 
   float blank = 0.0;
-  iLen = tempStr.GetLength();
+  length = tempStr.GetLength();
   strWidth = (int32_t)(strWidth * m_outputHScale);
 
   CalcTextInfo(tempStr, &charpos[1], m_pFont.Get(), (float)strWidth, iFontSize,
@@ -174,12 +174,12 @@
                               (float)(m_Height - iTextHeight) + iFontSize);
     if (matrix)
       affine_matrix1.Concat(*matrix);
-    device->DrawNormalText(iLen, &charpos[1], m_pFont.Get(),
+    device->DrawNormalText(length, &charpos[1], m_pFont.Get(),
                            static_cast<float>(iFontSize), &affine_matrix1,
                            m_fontColor, FXTEXT_CLEARTYPE);
   }
   tempStr = str.Mid(7, 6);
-  iLen = tempStr.GetLength();
+  length = tempStr.GetLength();
   CalcTextInfo(tempStr, &charpos[7], m_pFont.Get(), (float)strWidth, iFontSize,
                blank);
   {
@@ -189,12 +189,12 @@
         (float)(m_Height - iTextHeight + iFontSize));
     if (matrix)
       affine_matrix1.Concat(*matrix);
-    device->DrawNormalText(iLen, &charpos[7], m_pFont.Get(),
+    device->DrawNormalText(length, &charpos[7], m_pFont.Get(),
                            static_cast<float>(iFontSize), &affine_matrix1,
                            m_fontColor, FXTEXT_CLEARTYPE);
   }
   tempStr = str.Left(1);
-  iLen = tempStr.GetLength();
+  length = tempStr.GetLength();
   strWidth = multiple * 7;
   strWidth = (int32_t)(strWidth * m_outputHScale);
 
@@ -205,7 +205,7 @@
                               (float)(m_Height - iTextHeight + iFontSize));
     if (matrix)
       affine_matrix1.Concat(*matrix);
-    device->DrawNormalText(iLen, charpos.data(), m_pFont.Get(),
+    device->DrawNormalText(length, charpos.data(), m_pFont.Get(),
                            static_cast<float>(iFontSize), &affine_matrix1,
                            m_fontColor, FXTEXT_CLEARTYPE);
   }
diff --git a/fxbarcode/oned/BC_OnedUPCAWriter.cpp b/fxbarcode/oned/BC_OnedUPCAWriter.cpp
index 6d72377..9e7400a 100644
--- a/fxbarcode/oned/BC_OnedUPCAWriter.cpp
+++ b/fxbarcode/oned/BC_OnedUPCAWriter.cpp
@@ -113,13 +113,13 @@
   int32_t leftPadding = 7 * multiple;
   int32_t leftPosition = 10 * multiple + leftPadding;
   ByteString str = FX_UTF8Encode(contents);
-  int32_t iLen = str.GetLength();
-  std::vector<FXTEXT_CHARPOS> charpos(iLen);
+  size_t length = str.GetLength();
+  std::vector<FXTEXT_CHARPOS> charpos(length);
   ByteString tempStr = str.Mid(1, 5);
   float strWidth = (float)35 * multiple;
   float blank = 0.0;
 
-  iLen = tempStr.GetLength();
+  length = tempStr.GetLength();
   int32_t iFontSize = (int32_t)fabs(m_fFontSize);
   int32_t iTextHeight = iFontSize + 1;
 
@@ -161,12 +161,12 @@
                               (float)(m_Height - iTextHeight + iFontSize));
     if (matrix)
       affine_matrix1.Concat(*matrix);
-    device->DrawNormalText(iLen, &charpos[1], m_pFont.Get(),
+    device->DrawNormalText(length, &charpos[1], m_pFont.Get(),
                            static_cast<float>(iFontSize), &affine_matrix1,
                            m_fontColor, FXTEXT_CLEARTYPE);
   }
   tempStr = str.Mid(6, 5);
-  iLen = tempStr.GetLength();
+  length = tempStr.GetLength();
   CalcTextInfo(tempStr, &charpos[6], m_pFont.Get(), strWidth, iFontSize, blank);
   {
     CFX_Matrix affine_matrix1(
@@ -175,12 +175,12 @@
         (float)(m_Height - iTextHeight + iFontSize));
     if (matrix)
       affine_matrix1.Concat(*matrix);
-    device->DrawNormalText(iLen, &charpos[6], m_pFont.Get(),
+    device->DrawNormalText(length, &charpos[6], m_pFont.Get(),
                            static_cast<float>(iFontSize), &affine_matrix1,
                            m_fontColor, FXTEXT_CLEARTYPE);
   }
   tempStr = str.Left(1);
-  iLen = tempStr.GetLength();
+  length = tempStr.GetLength();
   strWidth = (float)multiple * 7;
   strWidth = strWidth * m_outputHScale;
 
@@ -191,12 +191,12 @@
                               (float)(m_Height - iTextHeight + iFontSize));
     if (matrix)
       affine_matrix1.Concat(*matrix);
-    device->DrawNormalText(iLen, charpos.data(), m_pFont.Get(),
+    device->DrawNormalText(length, charpos.data(), m_pFont.Get(),
                            static_cast<float>(iFontSize), &affine_matrix1,
                            m_fontColor, FXTEXT_CLEARTYPE);
   }
   tempStr = str.Mid(11, 1);
-  iLen = tempStr.GetLength();
+  length = tempStr.GetLength();
   CalcTextInfo(tempStr, &charpos[11], m_pFont.Get(), strWidth, iFontSize,
                blank);
   {
@@ -206,7 +206,7 @@
         (float)(m_Height - iTextHeight + iFontSize));
     if (matrix)
       affine_matrix1.Concat(*matrix);
-    device->DrawNormalText(iLen, &charpos[11], m_pFont.Get(),
+    device->DrawNormalText(length, &charpos[11], m_pFont.Get(),
                            static_cast<float>(iFontSize), &affine_matrix1,
                            m_fontColor, FXTEXT_CLEARTYPE);
   }
diff --git a/fxbarcode/pdf417/BC_PDF417.cpp b/fxbarcode/pdf417/BC_PDF417.cpp
index 8441808..a6d4c20 100644
--- a/fxbarcode/pdf417/BC_PDF417.cpp
+++ b/fxbarcode/pdf417/BC_PDF417.cpp
@@ -370,7 +370,7 @@
   if (!high_level.has_value())
     return false;
 
-  int32_t sourceCodeWords = high_level.value().GetLength();
+  size_t sourceCodeWords = high_level.value().GetLength();
   std::vector<int32_t> dimensions =
       determineDimensions(sourceCodeWords, errorCorrectionCodeWords);
   if (dimensions.size() != 2)
@@ -484,7 +484,7 @@
 }
 
 std::vector<int32_t> CBC_PDF417::determineDimensions(
-    int32_t sourceCodeWords,
+    size_t sourceCodeWords,
     int32_t errorCorrectionCodeWords) const {
   std::vector<int32_t> dimensions;
   float ratio = 0.0f;
diff --git a/fxbarcode/pdf417/BC_PDF417.h b/fxbarcode/pdf417/BC_PDF417.h
index 270c46e..4dabcb3 100644
--- a/fxbarcode/pdf417/BC_PDF417.h
+++ b/fxbarcode/pdf417/BC_PDF417.h
@@ -46,7 +46,7 @@
                       int32_t errorCorrectionLevel,
                       CBC_BarcodeMatrix* logic);
   std::vector<int32_t> determineDimensions(
-      int32_t sourceCodeWords,
+      size_t sourceCodeWords,
       int32_t errorCorrectionCodeWords) const;
 
   std::unique_ptr<CBC_BarcodeMatrix> m_barcodeMatrix;
diff --git a/fxbarcode/pdf417/BC_PDF417ErrorCorrection.cpp b/fxbarcode/pdf417/BC_PDF417ErrorCorrection.cpp
index 4ca40ef..074e8c4 100644
--- a/fxbarcode/pdf417/BC_PDF417ErrorCorrection.cpp
+++ b/fxbarcode/pdf417/BC_PDF417ErrorCorrection.cpp
@@ -143,8 +143,8 @@
     return false;
 
   std::vector<wchar_t> ech(k);
-  int32_t sld = dataCodewords.GetLength();
-  for (int32_t i = 0; i < sld; i++) {
+  size_t sld = dataCodewords.GetLength();
+  for (size_t i = 0; i < sld; i++) {
     int32_t t1 = (dataCodewords[i] + ech[k - 1]) % 929;
     int32_t t2;
     int32_t t3;
diff --git a/fxbarcode/qrcode/BC_QRCoderEncoder.cpp b/fxbarcode/qrcode/BC_QRCoderEncoder.cpp
index 6992c77..9bc7a7d 100644
--- a/fxbarcode/qrcode/BC_QRCoderEncoder.cpp
+++ b/fxbarcode/qrcode/BC_QRCoderEncoder.cpp
@@ -66,8 +66,8 @@
 }
 
 bool AppendNumericBytes(const ByteString& content, CBC_QRCoderBitVector* bits) {
-  int32_t length = content.GetLength();
-  int32_t i = 0;
+  size_t length = content.GetLength();
+  size_t i = 0;
   while (i < length) {
     int32_t num1 = content[i] - '0';
     if (i + 2 < length) {
@@ -89,8 +89,8 @@
 
 bool AppendAlphaNumericBytes(const ByteString& content,
                              CBC_QRCoderBitVector* bits) {
-  int32_t length = content.GetLength();
-  int32_t i = 0;
+  size_t length = content.GetLength();
+  size_t i = 0;
   while (i < length) {
     int32_t code1 = GetAlphaNumericCode(content[i]);
     if (code1 == -1)
@@ -112,9 +112,9 @@
 }
 
 bool AppendGBKBytes(const ByteString& content, CBC_QRCoderBitVector* bits) {
-  int32_t length = content.GetLength();
+  size_t length = content.GetLength();
   uint32_t value = 0;
-  for (int32_t i = 0; i < length; i += 2) {
+  for (size_t i = 0; i < length; i += 2) {
     value = (uint32_t)(content[i] << 8 | content[i + 1]);
     if (value <= 0xAAFE && value >= 0xA1A1)
       value -= 0xA1A1;