summaryrefslogtreecommitdiff
path: root/fxbarcode/qrcode/BC_QRCoderEncoder.cpp
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2017-04-05 18:42:22 -0700
committerChromium commit bot <commit-bot@chromium.org>2017-04-06 01:58:05 +0000
commit1b22880748c3f3b3740699ae4c953a33f65ad10f (patch)
tree57d7155639ea2f19dea22cb08ec3ce0b76bcbf9b /fxbarcode/qrcode/BC_QRCoderEncoder.cpp
parent0b18e1599dc9d07355c4ab6a069de33a536f7ba8 (diff)
downloadpdfium-1b22880748c3f3b3740699ae4c953a33f65ad10f.tar.xz
Change some fxbarcode to use return values.
No caller cares about the exception values anyway. Remove the unused ones. Also use more std::unique_ptr to stop potential leaks. Change-Id: Ic5955fb0d879f55e1c6a005c0204df50246dab19 Reviewed-on: https://pdfium-review.googlesource.com/3715 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'fxbarcode/qrcode/BC_QRCoderEncoder.cpp')
-rw-r--r--fxbarcode/qrcode/BC_QRCoderEncoder.cpp22
1 files changed, 11 insertions, 11 deletions
diff --git a/fxbarcode/qrcode/BC_QRCoderEncoder.cpp b/fxbarcode/qrcode/BC_QRCoderEncoder.cpp
index d74063d3fe..0971caab51 100644
--- a/fxbarcode/qrcode/BC_QRCoderEncoder.cpp
+++ b/fxbarcode/qrcode/BC_QRCoderEncoder.cpp
@@ -171,8 +171,8 @@ bool AppendLengthInfo(int32_t numLetters,
CBC_QRCoderMode* mode,
CBC_QRCoderBitVector* bits) {
int32_t e = BCExceptionNO;
- CBC_QRCoderVersion* qcv = CBC_QRCoderVersion::GetVersionForNumber(version, e);
- if (e != BCExceptionNO)
+ CBC_QRCoderVersion* qcv = CBC_QRCoderVersion::GetVersionForNumber(version);
+ if (!qcv)
return false;
int32_t numBits = mode->GetCharacterCountBits(qcv, e);
if (e != BCExceptionNO)
@@ -214,8 +214,8 @@ void InitQRCode(int32_t numInputBytes,
qrCode->SetMode(mode);
for (int32_t versionNum = 1; versionNum <= kMaxVersion; versionNum++) {
CBC_QRCoderVersion* version =
- CBC_QRCoderVersion::GetVersionForNumber(versionNum, e);
- if (e != BCExceptionNO)
+ CBC_QRCoderVersion::GetVersionForNumber(versionNum);
+ if (!version)
return;
int32_t numBytes = version->GetTotalCodeWords();
CBC_QRCoderECBlocks* ecBlocks = version->GetECBlocksForLevel(ecLevel);
@@ -237,16 +237,14 @@ void InitQRCode(int32_t numInputBytes,
std::unique_ptr<CBC_CommonByteArray> GenerateECBytes(
CBC_CommonByteArray* dataBytes,
- int32_t numEcBytesInBlock,
- int32_t& e) {
+ int32_t numEcBytesInBlock) {
int32_t numDataBytes = dataBytes->Size();
std::vector<int32_t> toEncode(numDataBytes + numEcBytesInBlock);
for (int32_t i = 0; i < numDataBytes; ++i)
toEncode[i] = dataBytes->At(i);
CBC_ReedSolomonEncoder encode(CBC_ReedSolomonGF256::QRCodeField);
encode.Init();
- encode.Encode(&toEncode, numEcBytesInBlock, e);
- if (e != BCExceptionNO)
+ if (!encode.Encode(&toEncode, numEcBytesInBlock))
return nullptr;
auto ecBytes = pdfium::MakeUnique<CBC_CommonByteArray>(numEcBytesInBlock);
for (int32_t i = 0; i < numEcBytesInBlock; ++i)
@@ -543,10 +541,12 @@ void InterleaveWithECBytes(CBC_QRCoderBitVector* bits,
numEcBytesInBlosk);
auto dataBytes = pdfium::MakeUnique<CBC_CommonByteArray>();
dataBytes->Set(bits->GetArray(), dataBytesOffset, numDataBytesInBlock);
- std::unique_ptr<CBC_CommonByteArray> ecBytes(
- GenerateECBytes(dataBytes.get(), numEcBytesInBlosk, e));
- if (e != BCExceptionNO)
+ std::unique_ptr<CBC_CommonByteArray> ecBytes =
+ GenerateECBytes(dataBytes.get(), numEcBytesInBlosk);
+ if (!ecBytes) {
+ e = BCExceptionGeneric;
return;
+ }
maxNumDataBytes = std::max(maxNumDataBytes, dataBytes->Size());
maxNumEcBytes = std::max(maxNumEcBytes, ecBytes->Size());
blocks[i].SetData(std::move(dataBytes), std::move(ecBytes));