summaryrefslogtreecommitdiff
path: root/xfa/fxbarcode
diff options
context:
space:
mode:
authorweili <weili@chromium.org>2016-06-02 15:48:15 -0700
committerCommit bot <commit-bot@chromium.org>2016-06-02 15:48:16 -0700
commitdb444d2063df6c574882d9263e885c4fe1134133 (patch)
tree27ce4a3f181ae0b5ad4eff6893016e7d49dfce0a /xfa/fxbarcode
parentad700c2c1fc3c3843dae71e5982f462e42efc987 (diff)
downloadpdfium-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')
-rw-r--r--xfa/fxbarcode/BC_TwoDimWriter.cpp5
-rw-r--r--xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonDecoder.cpp8
-rw-r--r--xfa/fxbarcode/datamatrix/BC_DataMatrixDataBlock.cpp27
-rw-r--r--xfa/fxbarcode/datamatrix/BC_DataMatrixDecoder.cpp10
-rw-r--r--xfa/fxbarcode/oned/BC_OneDimWriter.cpp5
5 files changed, 23 insertions, 32 deletions
diff --git a/xfa/fxbarcode/BC_TwoDimWriter.cpp b/xfa/fxbarcode/BC_TwoDimWriter.cpp
index efab589ddc..c2fb37e091 100644
--- a/xfa/fxbarcode/BC_TwoDimWriter.cpp
+++ b/xfa/fxbarcode/BC_TwoDimWriter.cpp
@@ -46,10 +46,9 @@ void CBC_TwoDimWriter::RenderDeviceResult(CFX_RenderDevice* device,
CFX_PathData rect;
rect.AppendRect((FX_FLOAT)leftPos + x, (FX_FLOAT)topPos + y,
(FX_FLOAT)(leftPos + x + 1), (FX_FLOAT)(topPos + y + 1));
- CFX_GraphStateData stateData;
if (m_output->Get(x, y)) {
- device->DrawPath(&rect, &matri, &stateData, m_barColor, 0,
- FXFILL_WINDING);
+ CFX_GraphStateData data;
+ device->DrawPath(&rect, &matri, &data, m_barColor, 0, FXFILL_WINDING);
}
}
}
diff --git a/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonDecoder.cpp b/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonDecoder.cpp
index 81abd56370..f31a54747f 100644
--- a/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonDecoder.cpp
+++ b/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonDecoder.cpp
@@ -197,9 +197,9 @@ CFX_Int32Array* CBC_ReedSolomonDecoder::FindErrorMagnitudes(
FX_BOOL dataMatrix,
int32_t& e) {
int32_t s = errorLocations->GetSize();
- CFX_Int32Array* temp = new CFX_Int32Array;
- temp->SetSize(s);
- std::unique_ptr<CFX_Int32Array> result(temp);
+ CFX_Int32Array* tempArray = new CFX_Int32Array;
+ tempArray->SetSize(s);
+ std::unique_ptr<CFX_Int32Array> result(tempArray);
for (int32_t i = 0; i < s; i++) {
int32_t xiInverse = m_field->Inverse(errorLocations->operator[](i), e);
BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
@@ -212,7 +212,7 @@ CFX_Int32Array* CBC_ReedSolomonDecoder::FindErrorMagnitudes(
xiInverse)));
}
}
- int32_t temp = m_field->Inverse(denominator, temp);
+ int32_t temp = m_field->Inverse(denominator, e);
BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
(*result)[i] =
m_field->Multiply(errorEvaluator->EvaluateAt(xiInverse), temp);
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;
diff --git a/xfa/fxbarcode/oned/BC_OneDimWriter.cpp b/xfa/fxbarcode/oned/BC_OneDimWriter.cpp
index 7b1cc50d72..8580650223 100644
--- a/xfa/fxbarcode/oned/BC_OneDimWriter.cpp
+++ b/xfa/fxbarcode/oned/BC_OneDimWriter.cpp
@@ -345,10 +345,9 @@ void CBC_OneDimWriter::RenderDeviceResult(CFX_RenderDevice* device,
CFX_PathData rect;
rect.AppendRect((FX_FLOAT)x, (FX_FLOAT)y, (FX_FLOAT)(x + 1),
(FX_FLOAT)(y + 1));
- CFX_GraphStateData stateData;
if (m_output->Get(x, y)) {
- device->DrawPath(&rect, &matri, &stateData, m_barColor, 0,
- FXFILL_WINDING);
+ CFX_GraphStateData data;
+ device->DrawPath(&rect, &matri, &data, m_barColor, 0, FXFILL_WINDING);
}
}
}