diff options
author | weili <weili@chromium.org> | 2016-06-02 15:48:15 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-06-02 15:48:16 -0700 |
commit | db444d2063df6c574882d9263e885c4fe1134133 (patch) | |
tree | 27ce4a3f181ae0b5ad4eff6893016e7d49dfce0a /xfa/fxbarcode/datamatrix | |
parent | ad700c2c1fc3c3843dae71e5982f462e42efc987 (diff) | |
download | pdfium-db444d2063df6c574882d9263e885c4fe1134133.tar.xz |
Fix all the code which has duplicate variable declarations
When there are duplicate variable declarations, the inner names shadow the
outter ones. This is error prone and harder to read. Remove all the
instances found by /analyze.
BUG=chromium:613623, chromium:427616
Review-Url: https://codereview.chromium.org/2027273002
Diffstat (limited to 'xfa/fxbarcode/datamatrix')
-rw-r--r-- | xfa/fxbarcode/datamatrix/BC_DataMatrixDataBlock.cpp | 27 | ||||
-rw-r--r-- | xfa/fxbarcode/datamatrix/BC_DataMatrixDecoder.cpp | 10 |
2 files changed, 15 insertions, 22 deletions
diff --git a/xfa/fxbarcode/datamatrix/BC_DataMatrixDataBlock.cpp b/xfa/fxbarcode/datamatrix/BC_DataMatrixDataBlock.cpp index 6b7680d1a8..a41e46afc9 100644 --- a/xfa/fxbarcode/datamatrix/BC_DataMatrixDataBlock.cpp +++ b/xfa/fxbarcode/datamatrix/BC_DataMatrixDataBlock.cpp @@ -40,17 +40,15 @@ CBC_DataMatrixDataBlock::GetDataBlocks(CFX_ByteArray* rawCodewords, ECBlocks* ecBlocks = version->GetECBlocks(); int32_t totalBlocks = 0; const CFX_ArrayTemplate<ECB*>& ecBlockArray = ecBlocks->GetECBlocks(); - int32_t i; - for (i = 0; i < ecBlockArray.GetSize(); i++) { + for (int32_t i = 0; i < ecBlockArray.GetSize(); i++) { totalBlocks += ecBlockArray[i]->GetCount(); } std::unique_ptr<CFX_ArrayTemplate<CBC_DataMatrixDataBlock*>> result( new CFX_ArrayTemplate<CBC_DataMatrixDataBlock*>()); result->SetSize(totalBlocks); int32_t numResultBlocks = 0; - int32_t j; - for (j = 0; j < ecBlockArray.GetSize(); j++) { - for (i = 0; i < ((ECB*)ecBlockArray[j])->GetCount(); i++) { + for (int32_t j = 0; j < ecBlockArray.GetSize(); j++) { + for (int32_t i = 0; i < ((ECB*)ecBlockArray[j])->GetCount(); i++) { int32_t numDataCodewords = ((ECB*)ecBlockArray[j])->GetDataCodewords(); int32_t numBlockCodewords = ecBlocks->GetECCodewords() + numDataCodewords; CFX_ByteArray codewords; @@ -60,14 +58,11 @@ CBC_DataMatrixDataBlock::GetDataBlocks(CFX_ByteArray* rawCodewords, codewords.SetSize(0); } } - int32_t longerBlocksTotalCodewords = (*result)[0]->GetCodewords()->GetSize(); int32_t longerBlocksNumDataCodewords = - longerBlocksTotalCodewords - ecBlocks->GetECCodewords(); - int32_t shorterBlocksNumDataCodewords = longerBlocksNumDataCodewords - 1; + (*result)[0]->GetCodewords()->GetSize() - ecBlocks->GetECCodewords(); int32_t rawCodewordsOffset = 0; - for (i = 0; i < shorterBlocksNumDataCodewords; i++) { - int32_t j; - for (j = 0; j < numResultBlocks; j++) { + for (int32_t i = 0; i < longerBlocksNumDataCodewords - 1; i++) { + for (int32_t j = 0; j < numResultBlocks; j++) { if (rawCodewordsOffset < rawCodewords->GetSize()) { (*result)[j]->GetCodewords()->operator[](i) = (*rawCodewords)[rawCodewordsOffset++]; @@ -76,17 +71,16 @@ CBC_DataMatrixDataBlock::GetDataBlocks(CFX_ByteArray* rawCodewords, } const bool specialVersion = version->GetVersionNumber() == 24; int32_t numLongerBlocks = specialVersion ? 8 : numResultBlocks; - for (j = 0; j < numLongerBlocks; j++) { + for (int32_t j = 0; j < numLongerBlocks; j++) { if (rawCodewordsOffset < rawCodewords->GetSize()) { (*result)[j]->GetCodewords()->operator[](longerBlocksNumDataCodewords - 1) = (*rawCodewords)[rawCodewordsOffset++]; } } - int32_t max = (*result)[0]->GetCodewords()->GetSize(); - for (i = longerBlocksNumDataCodewords; i < max; i++) { - int32_t j; - for (j = 0; j < numResultBlocks; j++) { + for (int32_t i = longerBlocksNumDataCodewords; + i < (*result)[0]->GetCodewords()->GetSize(); i++) { + for (int32_t j = 0; j < numResultBlocks; j++) { int32_t iOffset = specialVersion && j > 7 ? i - 1 : i; if (rawCodewordsOffset < rawCodewords->GetSize()) { (*result)[j]->GetCodewords()->operator[](iOffset) = @@ -100,6 +94,7 @@ CBC_DataMatrixDataBlock::GetDataBlocks(CFX_ByteArray* rawCodewords, } return result.release(); } + int32_t CBC_DataMatrixDataBlock::GetNumDataCodewords() { return m_numDataCodewords; } diff --git a/xfa/fxbarcode/datamatrix/BC_DataMatrixDecoder.cpp b/xfa/fxbarcode/datamatrix/BC_DataMatrixDecoder.cpp index 4276066444..ffa0a4d9d1 100644 --- a/xfa/fxbarcode/datamatrix/BC_DataMatrixDecoder.cpp +++ b/xfa/fxbarcode/datamatrix/BC_DataMatrixDecoder.cpp @@ -57,13 +57,12 @@ CBC_CommonDecoderResult* CBC_DataMatrixDecoder::Decode( BC_EXCEPTION_CHECK_ReturnValue(e, nullptr); int32_t dataBlocksCount = dataBlocks->GetSize(); int32_t totalBytes = 0; - int32_t i, j; - for (i = 0; i < dataBlocksCount; i++) { + for (int32_t i = 0; i < dataBlocksCount; i++) { totalBytes += (*dataBlocks)[i]->GetNumDataCodewords(); } CFX_ByteArray resultBytes; resultBytes.SetSize(totalBytes); - for (j = 0; j < dataBlocksCount; j++) { + for (int32_t j = 0; j < dataBlocksCount; j++) { CFX_ByteArray* codewordBytes = (*dataBlocks)[j]->GetCodewords(); int32_t numDataCodewords = (*dataBlocks)[j]->GetNumDataCodewords(); CorrectErrors(*codewordBytes, numDataCodewords, e); @@ -74,12 +73,11 @@ CBC_CommonDecoderResult* CBC_DataMatrixDecoder::Decode( delete dataBlocks; return nullptr; } - int32_t i; - for (i = 0; i < numDataCodewords; i++) { + for (int32_t i = 0; i < numDataCodewords; i++) { resultBytes[i * dataBlocksCount + j] = (*codewordBytes)[i]; } } - for (i = 0; i < (dataBlocks->GetSize()); i++) { + for (int32_t i = 0; i < (dataBlocks->GetSize()); i++) { delete (*dataBlocks)[i]; } delete dataBlocks; |