Get rid of "exceptions" in CBC_QRCoderMode::GetCharacterCountBits(). It already returns 0 on failure. Change-Id: If71ac2722084d294ff9a929cd7092b61a03a1765 Reviewed-on: https://pdfium-review.googlesource.com/c/45768 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
diff --git a/fxbarcode/qrcode/BC_QRCoderEncoder.cpp b/fxbarcode/qrcode/BC_QRCoderEncoder.cpp index 3495edc..6992c77 100644 --- a/fxbarcode/qrcode/BC_QRCoderEncoder.cpp +++ b/fxbarcode/qrcode/BC_QRCoderEncoder.cpp
@@ -166,12 +166,11 @@ int32_t version, CBC_QRCoderMode* mode, CBC_QRCoderBitVector* bits) { - int32_t e = BCExceptionNO; const auto* qcv = CBC_QRCoderVersion::GetVersionForNumber(version); if (!qcv) return false; - int32_t numBits = mode->GetCharacterCountBits(qcv->GetVersionNumber(), e); - if (e != BCExceptionNO) + int32_t numBits = mode->GetCharacterCountBits(qcv->GetVersionNumber()); + if (numBits == 0) return false; if (numBits > ((1 << numBits) - 1)) return true;
diff --git a/fxbarcode/qrcode/BC_QRCoderMode.cpp b/fxbarcode/qrcode/BC_QRCoderMode.cpp index b8e66a4..4039834 100644 --- a/fxbarcode/qrcode/BC_QRCoderMode.cpp +++ b/fxbarcode/qrcode/BC_QRCoderMode.cpp
@@ -83,21 +83,21 @@ return m_name; } -int32_t CBC_QRCoderMode::GetCharacterCountBits(int32_t number, - int32_t& e) const { - if (m_characterCountBitsForVersions.empty()) { - e = BCExceptionCharacterNotThisMode; +int32_t CBC_QRCoderMode::GetCharacterCountBits(int32_t number) const { + if (m_characterCountBitsForVersions.empty()) return 0; - } + int32_t offset; - if (number <= 9) { + if (number <= 9) offset = 0; - } else if (number <= 26) { + else if (number <= 26) offset = 1; - } else { + else offset = 2; - } - return m_characterCountBitsForVersions[offset]; + + int32_t result = m_characterCountBitsForVersions[offset]; + ASSERT(result != 0); + return result; } void CBC_QRCoderMode::Destroy() {
diff --git a/fxbarcode/qrcode/BC_QRCoderMode.h b/fxbarcode/qrcode/BC_QRCoderMode.h index ee78ef9..632d685 100644 --- a/fxbarcode/qrcode/BC_QRCoderMode.h +++ b/fxbarcode/qrcode/BC_QRCoderMode.h
@@ -21,7 +21,7 @@ static void Finalize(); static void Destroy(); - int32_t GetCharacterCountBits(int32_t number, int32_t& e) const; + int32_t GetCharacterCountBits(int32_t number) const; int32_t GetBits() const; ByteString GetName() const;
diff --git a/fxbarcode/utils.h b/fxbarcode/utils.h index 7d41e91..be45e3e 100644 --- a/fxbarcode/utils.h +++ b/fxbarcode/utils.h
@@ -26,7 +26,6 @@ #define BCExceptionIllegalArgument 16 #define BCExceptionValueMustBeEither0or1 50 #define BCExceptionInvalidateMaskPattern 68 -#define BCExceptionCharacterNotThisMode 75 #define BCExceptionGeneric 107 #endif // FXBARCODE_UTILS_H_