From db444d2063df6c574882d9263e885c4fe1134133 Mon Sep 17 00:00:00 2001 From: weili Date: Thu, 2 Jun 2016 15:48:15 -0700 Subject: 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 --- .../datamatrix/BC_DataMatrixDataBlock.cpp | 27 +++++++++------------- 1 file changed, 11 insertions(+), 16 deletions(-) (limited to 'xfa/fxbarcode/datamatrix/BC_DataMatrixDataBlock.cpp') 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& 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> result( new CFX_ArrayTemplate()); 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; } -- cgit v1.2.3