Get rid of "exceptions" in CBC_SymbolInfo::Lookup().

Lookup() already returns nullptr when the lookup fails.

Change-Id: I831738ab46616d5ffb9aa037e02f4cca4d7e1e3d
Reviewed-on: https://pdfium-review.googlesource.com/c/45766
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
diff --git a/fxbarcode/datamatrix/BC_DataMatrixWriter.cpp b/fxbarcode/datamatrix/BC_DataMatrixWriter.cpp
index 38abed1..550984d 100644
--- a/fxbarcode/datamatrix/BC_DataMatrixWriter.cpp
+++ b/fxbarcode/datamatrix/BC_DataMatrixWriter.cpp
@@ -117,25 +117,25 @@
       CBC_HighLevelEncoder::EncodeHighLevel(contents, ecLevel, false);
   if (!encoded.has_value())
     return nullptr;
-  int32_t e = BCExceptionNO;
-  CBC_SymbolInfo* symbolInfo =
-      CBC_SymbolInfo::lookup(encoded.value().GetLength(), false, e);
-  if (e != BCExceptionNO)
+  CBC_SymbolInfo* pSymbolInfo =
+      CBC_SymbolInfo::Lookup(encoded.value().GetLength(), false);
+  if (!pSymbolInfo)
     return nullptr;
+  int32_t e = BCExceptionNO;
   WideString codewords =
-      CBC_ErrorCorrection::encodeECC200(encoded.value(), symbolInfo, e);
+      CBC_ErrorCorrection::encodeECC200(encoded.value(), pSymbolInfo, e);
   if (e != BCExceptionNO)
     return nullptr;
 
-  int32_t width = symbolInfo->getSymbolDataWidth();
+  int32_t width = pSymbolInfo->getSymbolDataWidth();
   ASSERT(width);
-  int32_t height = symbolInfo->getSymbolDataHeight();
+  int32_t height = pSymbolInfo->getSymbolDataHeight();
   ASSERT(height);
 
   auto placement =
       pdfium::MakeUnique<CBC_DefaultPlacement>(codewords, width, height);
   placement->place();
-  auto bytematrix = encodeLowLevel(placement.get(), symbolInfo);
+  auto bytematrix = encodeLowLevel(placement.get(), pSymbolInfo);
   if (!bytematrix)
     return nullptr;
 
diff --git a/fxbarcode/datamatrix/BC_EncoderContext.cpp b/fxbarcode/datamatrix/BC_EncoderContext.cpp
index f686605..6bd2d3f 100644
--- a/fxbarcode/datamatrix/BC_EncoderContext.cpp
+++ b/fxbarcode/datamatrix/BC_EncoderContext.cpp
@@ -89,9 +89,8 @@
 
 bool CBC_EncoderContext::UpdateSymbolInfo(int32_t len) {
   if (!m_symbolInfo || len > m_symbolInfo->dataCapacity()) {
-    int32_t e = BCExceptionNO;
-    m_symbolInfo = CBC_SymbolInfo::lookup(len, m_bAllowRectangular, e);
-    if (e != BCExceptionNO)
+    m_symbolInfo = CBC_SymbolInfo::Lookup(len, m_bAllowRectangular);
+    if (!m_symbolInfo)
       return false;
   }
   return true;
diff --git a/fxbarcode/datamatrix/BC_SymbolInfo.cpp b/fxbarcode/datamatrix/BC_SymbolInfo.cpp
index f4d99d2..6ef7737 100644
--- a/fxbarcode/datamatrix/BC_SymbolInfo.cpp
+++ b/fxbarcode/datamatrix/BC_SymbolInfo.cpp
@@ -108,20 +108,18 @@
       m_rsBlockData(rsBlockData),
       m_rsBlockError(rsBlockError) {}
 
-CBC_SymbolInfo::~CBC_SymbolInfo() {}
+CBC_SymbolInfo::~CBC_SymbolInfo() = default;
 
-CBC_SymbolInfo* CBC_SymbolInfo::lookup(int32_t dataCodewords,
-                                       bool allowRectangular,
-                                       int32_t& e) {
+CBC_SymbolInfo* CBC_SymbolInfo::Lookup(int32_t iDataCodewords,
+                                       bool bAllowRectangular) {
   for (size_t i = 0; i < kSymbolsCount; i++) {
     CBC_SymbolInfo* symbol = g_symbols[i];
-    if (symbol->m_rectangular && !allowRectangular)
+    if (symbol->m_rectangular && !bAllowRectangular)
       continue;
 
-    if (dataCodewords <= symbol->dataCapacity())
+    if (iDataCodewords <= symbol->dataCapacity())
       return symbol;
   }
-  e = BCExceptionIllegalDataCodewords;
   return nullptr;
 }
 
diff --git a/fxbarcode/datamatrix/BC_SymbolInfo.h b/fxbarcode/datamatrix/BC_SymbolInfo.h
index fe3e24c..75d7149 100644
--- a/fxbarcode/datamatrix/BC_SymbolInfo.h
+++ b/fxbarcode/datamatrix/BC_SymbolInfo.h
@@ -22,9 +22,7 @@
   static void Initialize();
   static void Finalize();
   static void overrideSymbolSet(CBC_SymbolInfo* override);
-  static CBC_SymbolInfo* lookup(int32_t dataCodewords,
-                                bool allowRectangular,
-                                int32_t& e);
+  static CBC_SymbolInfo* Lookup(int32_t iDataCodewords, bool bAllowRectangular);
 
   int32_t getSymbolDataWidth() const;
   int32_t getSymbolDataHeight() const;
diff --git a/fxbarcode/utils.h b/fxbarcode/utils.h
index 64d714e..94e7266 100644
--- a/fxbarcode/utils.h
+++ b/fxbarcode/utils.h
@@ -28,7 +28,6 @@
 #define BCExceptionBadIndexException 52
 #define BCExceptionInvalidateMaskPattern 68
 #define BCExceptionCharacterNotThisMode 75
-#define BCExceptionIllegalDataCodewords 88
 #define BCExceptionGeneric 107
 
 #endif  // FXBARCODE_UTILS_H_