summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2017-02-06 09:34:23 -0800
committerChromium commit bot <commit-bot@chromium.org>2017-02-06 17:56:54 +0000
commit3c056ae5599be463216fb1883c710157f019acc2 (patch)
tree69910ca9c32e06600adbe28bb0cdb0dc50245a64
parente5f4f22e4c67f40123bca91c2213223cc5a12ebd (diff)
downloadpdfium-3c056ae5599be463216fb1883c710157f019acc2.tar.xz
Remove redundant tests exposed by inlining macros in fxbarcode
Remove some unused #defines as well. Change-Id: Ie7dc1ae85100eae24f18a3ecd456e3c8d8043a43 Reviewed-on: https://pdfium-review.googlesource.com/2490 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
-rw-r--r--xfa/fxbarcode/common/reedsolomon/BC_ReedSolomon.cpp6
-rw-r--r--xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.cpp9
-rw-r--r--xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.cpp3
-rw-r--r--xfa/fxbarcode/datamatrix/BC_DataMatrixWriter.cpp3
-rw-r--r--xfa/fxbarcode/qrcode/BC_QRCodeWriter.cpp3
-rw-r--r--xfa/fxbarcode/qrcode/BC_QRCoder.cpp3
-rw-r--r--xfa/fxbarcode/qrcode/BC_QRCoderBitVector.cpp12
-rw-r--r--xfa/fxbarcode/qrcode/BC_QRCoderEncoder.cpp170
-rw-r--r--xfa/fxbarcode/qrcode/BC_QRCoderMaskUtil.cpp6
-rw-r--r--xfa/fxbarcode/qrcode/BC_QRCoderMatrixUtil.cpp84
-rw-r--r--xfa/fxbarcode/qrcode/BC_QRCoderMode.cpp10
-rw-r--r--xfa/fxbarcode/qrcode/BC_QRCoderVersion.cpp6
-rw-r--r--xfa/fxbarcode/utils.h4
13 files changed, 113 insertions, 206 deletions
diff --git a/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomon.cpp b/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomon.cpp
index 25b4c852c1..7698890366 100644
--- a/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomon.cpp
+++ b/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomon.cpp
@@ -61,14 +61,12 @@ void CBC_ReedSolomonEncoder::Encode(CFX_ArrayTemplate<int32_t>* toEncode,
int32_t& e) {
if (ecBytes == 0) {
e = BCExceptionNoCorrectionBytes;
- if (e != BCExceptionNO)
- return;
+ return;
}
int32_t dataBytes = toEncode->GetSize() - ecBytes;
if (dataBytes <= 0) {
e = BCExceptionNoDataBytesProvided;
- if (e != BCExceptionNO)
- return;
+ return;
}
CBC_ReedSolomonGF256Poly* generator = BuildGenerator(ecBytes, e);
if (e != BCExceptionNO)
diff --git a/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.cpp b/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.cpp
index 0fe215bd09..ce84d8e08d 100644
--- a/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.cpp
+++ b/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.cpp
@@ -78,8 +78,7 @@ CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256::BuildMonomial(
int32_t& e) {
if (degree < 0) {
e = BCExceptionDegreeIsNegative;
- if (e != BCExceptionNO)
- return nullptr;
+ return nullptr;
}
if (coefficient == 0) {
CBC_ReedSolomonGF256Poly* temp = m_zero->Clone(e);
@@ -108,8 +107,7 @@ int32_t CBC_ReedSolomonGF256::Exp(int32_t a) {
int32_t CBC_ReedSolomonGF256::Log(int32_t a, int32_t& e) {
if (a == 0) {
e = BCExceptionAIsZero;
- if (e != BCExceptionNO)
- return 0;
+ return 0;
}
return m_logTable[a];
}
@@ -117,8 +115,7 @@ int32_t CBC_ReedSolomonGF256::Log(int32_t a, int32_t& e) {
int32_t CBC_ReedSolomonGF256::Inverse(int32_t a, int32_t& e) {
if (a == 0) {
e = BCExceptionAIsZero;
- if (e != BCExceptionNO)
- return 0;
+ return 0;
}
return m_expTable[255 - m_logTable[a]];
}
diff --git a/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.cpp b/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.cpp
index e37d62e112..a0bbc025c4 100644
--- a/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.cpp
+++ b/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.cpp
@@ -42,8 +42,7 @@ void CBC_ReedSolomonGF256Poly::Init(CBC_ReedSolomonGF256* field,
int32_t& e) {
if (!coefficients || coefficients->GetSize() == 0) {
e = BCExceptionCoefficientsSizeIsNull;
- if (e != BCExceptionNO)
- return;
+ return;
}
m_field = field;
int32_t coefficientsLength = coefficients->GetSize();
diff --git a/xfa/fxbarcode/datamatrix/BC_DataMatrixWriter.cpp b/xfa/fxbarcode/datamatrix/BC_DataMatrixWriter.cpp
index 30ec1eef74..f1ce798af0 100644
--- a/xfa/fxbarcode/datamatrix/BC_DataMatrixWriter.cpp
+++ b/xfa/fxbarcode/datamatrix/BC_DataMatrixWriter.cpp
@@ -54,8 +54,7 @@ uint8_t* CBC_DataMatrixWriter::Encode(const CFX_WideString& contents,
int32_t& e) {
if (outWidth < 0 || outHeight < 0) {
e = BCExceptionHeightAndWidthMustBeAtLeast1;
- if (e != BCExceptionNO)
- return nullptr;
+ return nullptr;
}
CBC_SymbolShapeHint::SymbolShapeHint shape =
CBC_SymbolShapeHint::FORCE_SQUARE;
diff --git a/xfa/fxbarcode/qrcode/BC_QRCodeWriter.cpp b/xfa/fxbarcode/qrcode/BC_QRCodeWriter.cpp
index 617dd17ff7..8a6499cbb7 100644
--- a/xfa/fxbarcode/qrcode/BC_QRCodeWriter.cpp
+++ b/xfa/fxbarcode/qrcode/BC_QRCodeWriter.cpp
@@ -85,8 +85,7 @@ uint8_t* CBC_QRCodeWriter::Encode(const CFX_WideString& contents,
break;
default: {
e = BCExceptionUnSupportEclevel;
- if (e != BCExceptionNO)
- return nullptr;
+ return nullptr;
}
}
CBC_QRCoder qr;
diff --git a/xfa/fxbarcode/qrcode/BC_QRCoder.cpp b/xfa/fxbarcode/qrcode/BC_QRCoder.cpp
index bb0001d722..a5c849780d 100644
--- a/xfa/fxbarcode/qrcode/BC_QRCoder.cpp
+++ b/xfa/fxbarcode/qrcode/BC_QRCoder.cpp
@@ -85,8 +85,7 @@ int32_t CBC_QRCoder::At(int32_t x, int32_t y, int32_t& e) {
int32_t value = m_matrix->Get(x, y);
if (!(value == 0 || value == 1)) {
e = BCExceptionValueMustBeEither0or1;
- if (e != BCExceptionNO)
- return 0;
+ return 0;
}
return value;
}
diff --git a/xfa/fxbarcode/qrcode/BC_QRCoderBitVector.cpp b/xfa/fxbarcode/qrcode/BC_QRCoderBitVector.cpp
index bdf73a9841..e4140a87a0 100644
--- a/xfa/fxbarcode/qrcode/BC_QRCoderBitVector.cpp
+++ b/xfa/fxbarcode/qrcode/BC_QRCoderBitVector.cpp
@@ -43,8 +43,7 @@ void CBC_QRCoderBitVector::Clear() {
int32_t CBC_QRCoderBitVector::At(int32_t index, int32_t& e) {
if (index < 0 || index >= m_sizeInBits) {
e = BCExceptionBadIndexException;
- if (e != BCExceptionNO)
- return 0;
+ return 0;
}
int32_t value = m_array[index >> 3] & 0xff;
return (value >> (7 - (index & 0x7))) & 1;
@@ -58,8 +57,7 @@ int32_t CBC_QRCoderBitVector::Size() {
void CBC_QRCoderBitVector::AppendBit(int32_t bit, int32_t& e) {
if (!(bit == 0 || bit == 1)) {
e = BCExceptionBadValueException;
- if (e != BCExceptionNO)
- return;
+ return;
}
int32_t numBitsInLastByte = m_sizeInBits & 0x7;
if (numBitsInLastByte == 0) {
@@ -74,8 +72,7 @@ void CBC_QRCoderBitVector::AppendBits(int32_t value,
int32_t& e) {
if (numBits < 0 || numBits > 32) {
e = BCExceptionBadNumBitsException;
- if (e != BCExceptionNO)
- return;
+ return;
}
int32_t numBitsLeft = numBits;
while (numBitsLeft > 0) {
@@ -107,8 +104,7 @@ void CBC_QRCoderBitVector::AppendBitVector(CBC_QRCoderBitVector* bits,
void CBC_QRCoderBitVector::XOR(CBC_QRCoderBitVector* other, int32_t& e) {
if (m_sizeInBits != other->Size()) {
e = BCExceptioncanNotOperatexorOperator;
- if (e != BCExceptionNO)
- return;
+ return;
}
int32_t sizeInBytes = (m_sizeInBits + 7) >> 3;
for (int32_t i = 0; i < sizeInBytes; ++i) {
diff --git a/xfa/fxbarcode/qrcode/BC_QRCoderEncoder.cpp b/xfa/fxbarcode/qrcode/BC_QRCoderEncoder.cpp
index d8f5f4ed0f..2c262f006b 100644
--- a/xfa/fxbarcode/qrcode/BC_QRCoderEncoder.cpp
+++ b/xfa/fxbarcode/qrcode/BC_QRCoderEncoder.cpp
@@ -139,8 +139,7 @@ void CBC_QRCoderEncoder::AppendDataModeLenghInfo(
return;
} else {
e = BCExceptionUnknown;
- if (e != BCExceptionNO)
- return;
+ return;
}
}
}
@@ -215,48 +214,41 @@ int32_t CBC_QRCoderEncoder::GetSpanByVersion(CBC_QRCoderMode* modeFirst,
CBC_QRCoderMode* modeSecond,
int32_t versionNum,
int32_t& e) {
- if (versionNum == 0) {
+ if (versionNum == 0)
return 0;
- }
- if ((modeFirst == CBC_QRCoderMode::sALPHANUMERIC) &&
- (modeSecond == CBC_QRCoderMode::sBYTE)) {
- if (versionNum >= 1 && versionNum <= 9) {
+
+ if (modeFirst == CBC_QRCoderMode::sALPHANUMERIC &&
+ modeSecond == CBC_QRCoderMode::sBYTE) {
+ if (versionNum >= 1 && versionNum <= 9)
return 11;
- } else if (versionNum >= 10 && versionNum <= 26) {
+ if (versionNum >= 10 && versionNum <= 26)
return 15;
- } else if (versionNum >= 27 && versionNum <= 40) {
+ if (versionNum >= 27 && versionNum <= 40)
return 16;
- } else {
- e = BCExceptionNoSuchVersion;
- if (e != BCExceptionNO)
- return 0;
- }
- } else if ((modeSecond == CBC_QRCoderMode::sALPHANUMERIC) &&
- (modeFirst == CBC_QRCoderMode::sNUMERIC)) {
- if (versionNum >= 1 && versionNum <= 9) {
+ e = BCExceptionNoSuchVersion;
+ return 0;
+ }
+ if (modeSecond == CBC_QRCoderMode::sALPHANUMERIC &&
+ modeFirst == CBC_QRCoderMode::sNUMERIC) {
+ if (versionNum >= 1 && versionNum <= 9)
return 13;
- } else if (versionNum >= 10 && versionNum <= 26) {
+ if (versionNum >= 10 && versionNum <= 26)
return 15;
- } else if (versionNum >= 27 && versionNum <= 40) {
+ if (versionNum >= 27 && versionNum <= 40)
return 17;
- } else {
- e = BCExceptionNoSuchVersion;
- if (e != BCExceptionNO)
- return 0;
- }
- } else if ((modeSecond == CBC_QRCoderMode::sBYTE) &&
- (modeFirst == CBC_QRCoderMode::sNUMERIC)) {
- if (versionNum >= 1 && versionNum <= 9) {
+ e = BCExceptionNoSuchVersion;
+ return 0;
+ }
+ if (modeSecond == CBC_QRCoderMode::sBYTE &&
+ modeFirst == CBC_QRCoderMode::sNUMERIC) {
+ if (versionNum >= 1 && versionNum <= 9)
return 6;
- } else if (versionNum >= 10 && versionNum <= 26) {
+ if (versionNum >= 10 && versionNum <= 26)
return 8;
- } else if (versionNum >= 27 && versionNum <= 40) {
+ if (versionNum >= 27 && versionNum <= 40)
return 9;
- } else {
- e = BCExceptionNoSuchVersion;
- if (e != BCExceptionNO)
- return 0;
- }
+ e = BCExceptionNoSuchVersion;
+ return 0;
}
return -1;
}
@@ -338,18 +330,16 @@ void CBC_QRCoderEncoder::InitQRCode(int32_t numInputBytes,
int32_t numEcBytes = ecBlocks->GetTotalECCodeWords();
int32_t numRSBlocks = ecBlocks->GetNumBlocks();
int32_t numDataBytes = numBytes - numEcBytes;
- if (numDataBytes >= numInputBytes + 3) {
- qrCode->SetVersion(versionNumber);
- qrCode->SetNumTotalBytes(numBytes);
- qrCode->SetNumDataBytes(numDataBytes);
- qrCode->SetNumRSBlocks(numRSBlocks);
- qrCode->SetNumECBytes(numEcBytes);
- qrCode->SetMatrixWidth(version->GetDimensionForVersion());
+ if (numDataBytes < numInputBytes + 3) {
+ e = BCExceptionCannotFindBlockInfo;
return;
}
- e = BCExceptionCannotFindBlockInfo;
- if (e != BCExceptionNO)
- return;
+ qrCode->SetVersion(versionNumber);
+ qrCode->SetNumTotalBytes(numBytes);
+ qrCode->SetNumDataBytes(numDataBytes);
+ qrCode->SetNumRSBlocks(numRSBlocks);
+ qrCode->SetNumECBytes(numEcBytes);
+ qrCode->SetMatrixWidth(version->GetDimensionForVersion());
}
void CBC_QRCoderEncoder::EncodeWithSpecifyVersion(
@@ -397,6 +387,7 @@ void CBC_QRCoderEncoder::EncodeWithSpecifyVersion(
&finalBits, e);
if (e != BCExceptionNO)
return;
+
std::unique_ptr<CBC_CommonByteMatrix> matrix(new CBC_CommonByteMatrix(
qrCode->GetMatrixWidth(), qrCode->GetMatrixWidth()));
matrix->Init();
@@ -404,18 +395,17 @@ void CBC_QRCoderEncoder::EncodeWithSpecifyVersion(
&finalBits, qrCode->GetECLevel(), qrCode->GetVersion(), matrix.get(), e);
if (e != BCExceptionNO)
return;
+
qrCode->SetMaskPattern(maskPattern);
CBC_QRCoderMatrixUtil::BuildMatrix(&finalBits, qrCode->GetECLevel(),
qrCode->GetVersion(),
qrCode->GetMaskPattern(), matrix.get(), e);
if (e != BCExceptionNO)
return;
+
qrCode->SetMatrix(std::move(matrix));
- if (!qrCode->IsValid()) {
+ if (!qrCode->IsValid())
e = BCExceptionInvalidQRCode;
- if (e != BCExceptionNO)
- return;
- }
}
void CBC_QRCoderEncoder::EncodeWithAutoVersion(
@@ -482,6 +472,7 @@ catchException:
&finalBits, e);
if (e != BCExceptionNO)
return;
+
std::unique_ptr<CBC_CommonByteMatrix> matrix(new CBC_CommonByteMatrix(
qrCode->GetMatrixWidth(), qrCode->GetMatrixWidth()));
matrix->Init();
@@ -489,17 +480,16 @@ catchException:
&finalBits, qrCode->GetECLevel(), qrCode->GetVersion(), matrix.get(), e);
if (e != BCExceptionNO)
return;
+
qrCode->SetMaskPattern(maskPattern);
CBC_QRCoderMatrixUtil::BuildMatrix(&finalBits, qrCode->GetECLevel(),
qrCode->GetVersion(),
qrCode->GetMaskPattern(), matrix.get(), e);
if (e != BCExceptionNO)
return qrCode->SetMatrix(std::move(matrix));
- if (!qrCode->IsValid()) {
+
+ if (!qrCode->IsValid())
e = BCExceptionInvalidQRCode;
- if (e != BCExceptionNO)
- return;
- }
}
void CBC_QRCoderEncoder::Encode(const CFX_WideString& content,
@@ -542,6 +532,7 @@ void CBC_QRCoderEncoder::Encode(const CFX_WideString& content,
&finalBits, e);
if (e != BCExceptionNO)
return;
+
std::unique_ptr<CBC_CommonByteMatrix> matrix(new CBC_CommonByteMatrix(
qrCode->GetMatrixWidth(), qrCode->GetMatrixWidth()));
matrix->Init();
@@ -549,17 +540,16 @@ void CBC_QRCoderEncoder::Encode(const CFX_WideString& content,
&finalBits, qrCode->GetECLevel(), qrCode->GetVersion(), matrix.get(), e);
if (e != BCExceptionNO)
return;
+
qrCode->SetMaskPattern(maskPattern);
CBC_QRCoderMatrixUtil::BuildMatrix(&finalBits, qrCode->GetECLevel(),
qrCode->GetVersion(),
qrCode->GetMaskPattern(), matrix.get(), e);
if (e != BCExceptionNO)
return qrCode->SetMatrix(std::move(matrix));
- if (!qrCode->IsValid()) {
+
+ if (!qrCode->IsValid())
e = BCExceptionInvalidQRCode;
- if (e != BCExceptionNO)
- return;
- }
}
void CBC_QRCoderEncoder::TerminateBits(int32_t numDataBytes,
@@ -568,8 +558,7 @@ void CBC_QRCoderEncoder::TerminateBits(int32_t numDataBytes,
int32_t capacity = numDataBytes << 3;
if (bits->Size() > capacity) {
e = BCExceptionDataTooMany;
- if (e != BCExceptionNO)
- return;
+ return;
}
for (int32_t i = 0; i < 4 && bits->Size() < capacity; ++i) {
bits->AppendBit(0, e);
@@ -587,8 +576,7 @@ void CBC_QRCoderEncoder::TerminateBits(int32_t numDataBytes,
}
if (bits->Size() % 8 != 0) {
e = BCExceptionDigitLengthMustBe8;
- if (e != BCExceptionNO)
- return;
+ return;
}
int32_t numPaddingBytes = numDataBytes - bits->sizeInBytes();
for (int32_t k = 0; k < numPaddingBytes; ++k) {
@@ -602,11 +590,8 @@ void CBC_QRCoderEncoder::TerminateBits(int32_t numDataBytes,
return;
}
}
- if (bits->Size() != capacity) {
+ if (bits->Size() != capacity)
e = BCExceptionBitsNotEqualCacity;
- if (e != BCExceptionNO)
- return;
- }
}
int32_t CBC_QRCoderEncoder::ChooseMaskPattern(
@@ -674,31 +659,18 @@ void CBC_QRCoderEncoder::AppendBytes(const CFX_ByteString& content,
CBC_QRCoderBitVector* bits,
CFX_ByteString encoding,
int32_t& e) {
- if (mode == CBC_QRCoderMode::sNUMERIC) {
+ if (mode == CBC_QRCoderMode::sNUMERIC)
AppendNumericBytes(content, bits, e);
- if (e != BCExceptionNO)
- return;
- } else if (mode == CBC_QRCoderMode::sALPHANUMERIC) {
+ else if (mode == CBC_QRCoderMode::sALPHANUMERIC)
AppendAlphaNumericBytes(content, bits, e);
- if (e != BCExceptionNO)
- return;
- } else if (mode == CBC_QRCoderMode::sBYTE) {
+ else if (mode == CBC_QRCoderMode::sBYTE)
Append8BitBytes(content, bits, encoding, e);
- if (e != BCExceptionNO)
- return;
- } else if (mode == CBC_QRCoderMode::sKANJI) {
+ else if (mode == CBC_QRCoderMode::sKANJI)
AppendKanjiBytes(content, bits, e);
- if (e != BCExceptionNO)
- return;
- } else if (mode == CBC_QRCoderMode::sGBK) {
+ else if (mode == CBC_QRCoderMode::sGBK)
AppendGBKBytes(content, bits, e);
- if (e != BCExceptionNO)
- return;
- } else {
+ else
e = BCExceptionUnsupportedMode;
- if (e != BCExceptionNO)
- return;
- }
}
void CBC_QRCoderEncoder::AppendNumericBytes(const CFX_ByteString& content,
@@ -739,15 +711,13 @@ void CBC_QRCoderEncoder::AppendAlphaNumericBytes(const CFX_ByteString& content,
int32_t code1 = GetAlphaNumericCode(content[i]);
if (code1 == -1) {
e = BCExceptionInvalidateCharacter;
- if (e != BCExceptionNO)
- return;
+ return;
}
if (i + 1 < length) {
int32_t code2 = GetAlphaNumericCode(content[i + 1]);
if (code2 == -1) {
e = BCExceptionInvalidateCharacter;
- if (e != BCExceptionNO)
- return;
+ return;
}
bits->AppendBits(code1 * 45 + code2, 11, e);
if (e != BCExceptionNO)
@@ -775,8 +745,7 @@ void CBC_QRCoderEncoder::AppendGBKBytes(const CFX_ByteString& content,
value -= 0xA6A1;
} else {
e = BCExceptionInvalidateCharacter;
- if (e != BCExceptionNO)
- return;
+ return;
}
value = (uint32_t)((value >> 8) * 0x60) + (uint32_t)(value & 0xff);
bits->AppendBits(value, 13, e);
@@ -819,8 +788,7 @@ void CBC_QRCoderEncoder::AppendKanjiBytes(const CFX_ByteString& content,
value -= 0xc140;
} else {
e = BCExceptionInvalidateCharacter;
- if (e != BCExceptionNO)
- return;
+ return;
}
value = (uint32_t)((value >> 8) * 0xc0) + (uint32_t)(value & 0xff);
bits->AppendBits(value, 13, e);
@@ -857,19 +825,14 @@ void CBC_QRCoderEncoder::InitQRCode(int32_t numInputBytes,
}
}
e = BCExceptionCannotFindBlockInfo;
- if (e != BCExceptionNO)
- return;
}
void CBC_QRCoderEncoder::AppendModeInfo(CBC_QRCoderMode* mode,
CBC_QRCoderBitVector* bits,
int32_t& e) {
bits->AppendBits(mode->GetBits(), 4, e);
- if (mode == CBC_QRCoderMode::sGBK) {
+ if (mode == CBC_QRCoderMode::sGBK)
bits->AppendBits(1, 4, e);
- if (e != BCExceptionNO)
- return;
- }
}
void CBC_QRCoderEncoder::AppendLengthInfo(int32_t numLetters,
@@ -892,8 +855,6 @@ void CBC_QRCoderEncoder::AppendLengthInfo(int32_t numLetters,
return;
}
bits->AppendBits(numLetters, numBits, e);
- if (e != BCExceptionNO)
- return;
}
void CBC_QRCoderEncoder::InterleaveWithECBytes(CBC_QRCoderBitVector* bits,
@@ -904,8 +865,7 @@ void CBC_QRCoderEncoder::InterleaveWithECBytes(CBC_QRCoderBitVector* bits,
int32_t& e) {
if (bits->sizeInBytes() != numDataBytes) {
e = BCExceptionBitsBytesNotMatch;
- if (e != BCExceptionNO)
- return;
+ return;
}
int32_t dataBytesOffset = 0;
int32_t maxNumDataBytes = 0;
@@ -932,8 +892,7 @@ void CBC_QRCoderEncoder::InterleaveWithECBytes(CBC_QRCoderBitVector* bits,
}
if (numDataBytes != dataBytesOffset) {
e = BCExceptionBytesNotMatchOffset;
- if (e != BCExceptionNO)
- return;
+ return;
}
for (int32_t x = 0; x < maxNumDataBytes; x++) {
for (int32_t j = 0; j < blocks.GetSize(); j++) {
@@ -958,11 +917,8 @@ void CBC_QRCoderEncoder::InterleaveWithECBytes(CBC_QRCoderBitVector* bits,
for (int32_t k = 0; k < blocks.GetSize(); k++) {
delete blocks[k];
}
- if (numTotalBytes != result->sizeInBytes()) {
+ if (numTotalBytes != result->sizeInBytes())
e = BCExceptionSizeInBytesDiffer;
- if (e != BCExceptionNO)
- return;
- }
}
void CBC_QRCoderEncoder::GetNumDataBytesAndNumECBytesForBlockID(
diff --git a/xfa/fxbarcode/qrcode/BC_QRCoderMaskUtil.cpp b/xfa/fxbarcode/qrcode/BC_QRCoderMaskUtil.cpp
index acc0cc9459..7953701bb2 100644
--- a/xfa/fxbarcode/qrcode/BC_QRCoderMaskUtil.cpp
+++ b/xfa/fxbarcode/qrcode/BC_QRCoderMaskUtil.cpp
@@ -128,8 +128,7 @@ bool CBC_QRCoderMaskUtil::GetDataMaskBit(int32_t maskPattern,
int32_t& e) {
if (!CBC_QRCoder::IsValidMaskPattern(maskPattern)) {
e = (BCExceptionInvalidateMaskPattern);
- if (e != BCExceptionNO)
- return false;
+ return false;
}
int32_t intermediate = 0, temp = 0;
switch (maskPattern) {
@@ -162,8 +161,7 @@ bool CBC_QRCoderMaskUtil::GetDataMaskBit(int32_t maskPattern,
break;
default: {
e = BCExceptionInvalidateMaskPattern;
- if (e != BCExceptionNO)
- return false;
+ return false;
}
}
return intermediate == 0;
diff --git a/xfa/fxbarcode/qrcode/BC_QRCoderMatrixUtil.cpp b/xfa/fxbarcode/qrcode/BC_QRCoderMatrixUtil.cpp
index 757f4ef7f4..d48d81c091 100644
--- a/xfa/fxbarcode/qrcode/BC_QRCoderMatrixUtil.cpp
+++ b/xfa/fxbarcode/qrcode/BC_QRCoderMatrixUtil.cpp
@@ -79,8 +79,7 @@ void CBC_QRCoderMatrixUtil::ClearMatrix(CBC_CommonByteMatrix* matrix,
int32_t& e) {
if (!matrix) {
e = BCExceptionNullPointer;
- if (e != BCExceptionNO)
- return;
+ return;
}
matrix->clear((uint8_t)-1);
}
@@ -93,8 +92,7 @@ void CBC_QRCoderMatrixUtil::BuildMatrix(
int32_t& e) {
if (!matrix) {
e = BCExceptionNullPointer;
- if (e != BCExceptionNO)
- return;
+ return;
}
ClearMatrix(matrix, e);
if (e != BCExceptionNO)
@@ -117,8 +115,7 @@ void CBC_QRCoderMatrixUtil::EmbedBasicPatterns(int32_t version,
int32_t& e) {
if (!matrix) {
e = BCExceptionNullPointer;
- if (e != BCExceptionNO)
- return;
+ return;
}
EmbedPositionDetectionPatternsAndSeparators(matrix, e);
if (e != BCExceptionNO)
@@ -140,8 +137,7 @@ void CBC_QRCoderMatrixUtil::EmbedTypeInfo(
int32_t& e) {
if (!matrix) {
e = BCExceptionNullPointer;
- if (e != BCExceptionNO)
- return;
+ return;
}
CBC_QRCoderBitVector typeInfoBits;
typeInfoBits.Init();
@@ -171,8 +167,7 @@ void CBC_QRCoderMatrixUtil::MaybeEmbedVersionInfo(int32_t version,
int32_t& e) {
if (!matrix) {
e = BCExceptionNullPointer;
- if (e != BCExceptionNO)
- return;
+ return;
}
if (version < 7) {
return;
@@ -200,8 +195,7 @@ void CBC_QRCoderMatrixUtil::EmbedDataBits(CBC_QRCoderBitVector* dataBits,
int32_t& e) {
if (!matrix || !dataBits) {
e = BCExceptionNullPointer;
- if (e != BCExceptionNO)
- return;
+ return;
}
int32_t bitIndex = 0;
int32_t direction = -1;
@@ -265,13 +259,11 @@ void CBC_QRCoderMatrixUtil::MakeTypeInfoBits(
int32_t& e) {
if (!bits) {
e = BCExceptionNullPointer;
- if (e != BCExceptionNO)
- return;
+ return;
}
if (!CBC_QRCoder::IsValidMaskPattern(maskPattern)) {
e = BCExceptionBadMask;
- if (e != BCExceptionNO)
- return;
+ return;
}
int32_t typeInfo = (ecLevel->GetBits() << 3) | maskPattern;
if (e != BCExceptionNO)
@@ -289,33 +281,30 @@ void CBC_QRCoderMatrixUtil::MakeTypeInfoBits(
bits->XOR(&maskBits, e);
if (e != BCExceptionNO)
return;
- if (bits->Size() != 15) {
+ if (bits->Size() != 15)
e = BCExceptionBitSizeNot15;
- if (e != BCExceptionNO)
- return;
- }
}
+
void CBC_QRCoderMatrixUtil::MakeVersionInfoBits(int32_t version,
CBC_QRCoderBitVector* bits,
int32_t& e) {
if (!bits) {
e = BCExceptionNullPointer;
- if (e != BCExceptionNO)
- return;
+ return;
}
bits->AppendBits(version, 6, e);
if (e != BCExceptionNO)
return;
+
int32_t bchCode = CalculateBCHCode(version, VERSION_INFO_POLY);
bits->AppendBits(bchCode, 12, e);
if (e != BCExceptionNO)
return;
- if (bits->Size() != 18) {
+
+ if (bits->Size() != 18)
e = BCExceptionBitSizeNot18;
- if (e != BCExceptionNO)
- return;
- }
}
+
bool CBC_QRCoderMatrixUtil::IsEmpty(int32_t value) {
return (uint8_t)value == 0xff;
}
@@ -323,27 +312,25 @@ bool CBC_QRCoderMatrixUtil::IsValidValue(int32_t value) {
return ((uint8_t)value == 0xff || (uint8_t)value == 0x00 ||
(uint8_t)value == 0x01);
}
+
void CBC_QRCoderMatrixUtil::EmbedTimingPatterns(CBC_CommonByteMatrix* matrix,
int32_t& e) {
if (!matrix) {
e = BCExceptionNullPointer;
- if (e != BCExceptionNO)
- return;
+ return;
}
for (int32_t i = 8; i < matrix->GetWidth() - 8; i++) {
int32_t bit = (i + 1) % 2;
if (!IsValidValue(matrix->Get(i, 6))) {
e = BCExceptionInvalidateImageData;
- if (e != BCExceptionNO)
- return;
+ return;
}
if (IsEmpty(matrix->Get(i, 6))) {
matrix->Set(i, 6, bit);
}
if (!IsValidValue(matrix->Get(6, i))) {
e = BCExceptionInvalidateImageData;
- if (e != BCExceptionNO)
- return;
+ return;
}
if (IsEmpty(matrix->Get(6, i))) {
matrix->Set(6, i, bit);
@@ -355,13 +342,11 @@ void CBC_QRCoderMatrixUtil::EmbedDarkDotAtLeftBottomCorner(
int32_t& e) {
if (!matrix) {
e = BCExceptionNullPointer;
- if (e != BCExceptionNO)
- return;
+ return;
}
if (matrix->Get(8, matrix->GetHeight() - 8) == 0) {
e = BCExceptionHeight_8BeZero;
- if (e != BCExceptionNO)
- return;
+ return;
}
matrix->Set(8, matrix->GetHeight() - 8, 1);
}
@@ -372,14 +357,12 @@ void CBC_QRCoderMatrixUtil::EmbedHorizontalSeparationPattern(
int32_t& e) {
if (!matrix) {
e = BCExceptionNullPointer;
- if (e != BCExceptionNO)
- return;
+ return;
}
for (int32_t x = 0; x < 8; x++) {
if (!IsEmpty(matrix->Get(xStart + x, yStart))) {
e = BCExceptionInvalidateData;
- if (e != BCExceptionNO)
- return;
+ return;
}
matrix->Set(xStart + x, yStart, HORIZONTAL_SEPARATION_PATTERN[0][x]);
}
@@ -391,14 +374,12 @@ void CBC_QRCoderMatrixUtil::EmbedVerticalSeparationPattern(
int32_t& e) {
if (!matrix) {
e = BCExceptionNullPointer;
- if (e != BCExceptionNO)
- return;
+ return;
}
for (int32_t y = 0; y < 7; y++) {
if (!IsEmpty(matrix->Get(xStart, yStart + y))) {
e = BCExceptionInvalidateData;
- if (e != BCExceptionNO)
- return;
+ return;
}
matrix->Set(xStart, yStart + y, VERTICAL_SEPARATION_PATTERN[y][0]);
}
@@ -417,8 +398,7 @@ void CBC_QRCoderMatrixUtil::EmbedPositionAdjustmentPattern(
for (int32_t x = 0; x < 5; x++) {
if (!IsEmpty(matrix->Get(xStart + x, y + yStart))) {
e = BCExceptionInvalidateData;
- if (e != BCExceptionNO)
- return;
+ return;
}
matrix->Set(xStart + x, yStart + y, POSITION_ADJUSTMENT_PATTERN[y][x]);
}
@@ -431,15 +411,13 @@ void CBC_QRCoderMatrixUtil::EmbedPositionDetectionPattern(
int32_t& e) {
if (!matrix) {
e = BCExceptionNullPointer;
- if (e != BCExceptionNO)
- return;
+ return;
}
for (int32_t y = 0; y < 7; y++) {
for (int32_t x = 0; x < 7; x++) {
if (!IsEmpty(matrix->Get(xStart + x, yStart + y))) {
e = BCExceptionInvalidateData;
- if (e != BCExceptionNO)
- return;
+ return;
}
matrix->Set(xStart + x, yStart + y, POSITION_DETECTION_PATTERN[y][x]);
}
@@ -450,8 +428,7 @@ void CBC_QRCoderMatrixUtil::EmbedPositionDetectionPatternsAndSeparators(
int32_t& e) {
if (!matrix) {
e = BCExceptionNullPointer;
- if (e != BCExceptionNO)
- return;
+ return;
}
int32_t pdpWidth = 7;
EmbedPositionDetectionPattern(0, 0, matrix, e);
@@ -493,8 +470,7 @@ void CBC_QRCoderMatrixUtil::MaybeEmbedPositionAdjustmentPatterns(
int32_t& e) {
if (!matrix) {
e = BCExceptionNullPointer;
- if (e != BCExceptionNO)
- return;
+ return;
}
if (version < 2) {
return;
diff --git a/xfa/fxbarcode/qrcode/BC_QRCoderMode.cpp b/xfa/fxbarcode/qrcode/BC_QRCoderMode.cpp
index 87f32edddf..a1283dda93 100644
--- a/xfa/fxbarcode/qrcode/BC_QRCoderMode.cpp
+++ b/xfa/fxbarcode/qrcode/BC_QRCoderMode.cpp
@@ -98,13 +98,10 @@ CBC_QRCoderMode* CBC_QRCoderMode::ForBits(int32_t bits, int32_t& e) {
return sFNC1_SECOND_POSITION;
case 0x0D:
return sGBK;
- default: {
+ default:
e = BCExceptionUnsupportedMode;
- if (e != BCExceptionNO)
- return nullptr;
- }
+ return nullptr;
}
- return nullptr;
}
int32_t CBC_QRCoderMode::GetBits() const {
@@ -119,8 +116,7 @@ int32_t CBC_QRCoderMode::GetCharacterCountBits(CBC_QRCoderVersion* version,
int32_t& e) const {
if (m_characterCountBitsForVersions.empty()) {
e = BCExceptionCharacterNotThisMode;
- if (e != BCExceptionNO)
- return 0;
+ return 0;
}
int32_t number = version->GetVersionNumber();
int32_t offset;
diff --git a/xfa/fxbarcode/qrcode/BC_QRCoderVersion.cpp b/xfa/fxbarcode/qrcode/BC_QRCoderVersion.cpp
index 58516913bc..befdc17a98 100644
--- a/xfa/fxbarcode/qrcode/BC_QRCoderVersion.cpp
+++ b/xfa/fxbarcode/qrcode/BC_QRCoderVersion.cpp
@@ -372,8 +372,7 @@ CBC_QRCoderVersion* CBC_QRCoderVersion::GetProvisionalVersionForDimension(
int32_t& e) {
if ((dimension % 4) != 1) {
e = BCExceptionRead;
- if (e != BCExceptionNO)
- return nullptr;
+ return nullptr;
}
CBC_QRCoderVersion* qcv = GetVersionForNumber((dimension - 17) >> 2, e);
if (e != BCExceptionNO)
@@ -783,8 +782,7 @@ CBC_QRCoderVersion* CBC_QRCoderVersion::GetVersionForNumber(
}
if (versionNumber < 1 || versionNumber > 40) {
e = BCExceptionIllegalArgument;
- if (e != BCExceptionNO)
- return nullptr;
+ return nullptr;
}
return (*VERSION)[versionNumber - 1];
}
diff --git a/xfa/fxbarcode/utils.h b/xfa/fxbarcode/utils.h
index e5f8e9f59f..1cb8d85013 100644
--- a/xfa/fxbarcode/utils.h
+++ b/xfa/fxbarcode/utils.h
@@ -165,9 +165,5 @@ enum BCFORMAT {
#define BCExceptiontNotFoundInstance 104
#define BCExceptionNotFoundInstance 105
#define BCExceptionCannotMetadata 106
-#define TWO_DIGIT_DATA_LENGTH_SIZE 24
-#define THREE_DIGIT_DATA_LENGTH_SIZE 23
-#define THREE_DIGIT_PLUS_DIGIT_DATA_LENGTH_SIZE 57
-#define FOUR_DIGIT_DATA_LENGTH_SIZE 17
#endif // XFA_FXBARCODE_UTILS_H_