summaryrefslogtreecommitdiff
path: root/fpdfsdk
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 /fpdfsdk
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 'fpdfsdk')
-rw-r--r--fpdfsdk/formfiller/cffl_iformfiller.cpp6
-rw-r--r--fpdfsdk/fpdf_flatten.cpp4
-rw-r--r--fpdfsdk/fpdf_transformpage.cpp20
-rw-r--r--fpdfsdk/javascript/Field.cpp10
-rw-r--r--fpdfsdk/jsapi/fxjs_v8_embeddertest.cpp4
-rw-r--r--fpdfsdk/pdfwindow/PWL_Edit.cpp8
6 files changed, 28 insertions, 24 deletions
diff --git a/fpdfsdk/formfiller/cffl_iformfiller.cpp b/fpdfsdk/formfiller/cffl_iformfiller.cpp
index 06f24182ce..9dcc734a24 100644
--- a/fpdfsdk/formfiller/cffl_iformfiller.cpp
+++ b/fpdfsdk/formfiller/cffl_iformfiller.cpp
@@ -440,9 +440,9 @@ FX_BOOL CFFL_IFormFiller::OnSetFocus(CPDFSDK_Annot* pAnnot, FX_UINT nFlag) {
m_bNotifying = FALSE;
if (pWidget->IsAppModified()) {
- if (CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, FALSE)) {
- pFormFiller->ResetPDFWindow(pPageView,
- nValueAge == pWidget->GetValueAge());
+ if (CFFL_FormFiller* pFiller = GetFormFiller(pWidget, FALSE)) {
+ pFiller->ResetPDFWindow(pPageView,
+ nValueAge == pWidget->GetValueAge());
}
}
}
diff --git a/fpdfsdk/fpdf_flatten.cpp b/fpdfsdk/fpdf_flatten.cpp
index fe81246a0b..2d11bfee7b 100644
--- a/fpdfsdk/fpdf_flatten.cpp
+++ b/fpdfsdk/fpdf_flatten.cpp
@@ -482,8 +482,8 @@ DLLEXPORT int STDCALL FPDFPage_Flatten(FPDF_PAGE page, int nFlag) {
CFX_ByteString sFormName;
sFormName.Format("F%d", i);
- uint32_t dwObjNum = pDocument->AddIndirectObject(pObj);
- pXObject->SetAtReference(sFormName, pDocument, dwObjNum);
+ uint32_t dwStreamObjNum = pDocument->AddIndirectObject(pObj);
+ pXObject->SetAtReference(sFormName, pDocument, dwStreamObjNum);
CPDF_StreamAcc acc;
acc.LoadAllData(pNewXObject);
diff --git a/fpdfsdk/fpdf_transformpage.cpp b/fpdfsdk/fpdf_transformpage.cpp
index 5fe6e4ebcc..b78c79c3fc 100644
--- a/fpdfsdk/fpdf_transformpage.cpp
+++ b/fpdfsdk/fpdf_transformpage.cpp
@@ -138,7 +138,8 @@ DLLEXPORT FPDF_BOOL STDCALL FPDFPage_TransFormWithClip(FPDF_PAGE page,
pDoc->AddIndirectObject(pEndStream);
CPDF_Array* pContentArray = nullptr;
- if (CPDF_Array* pArray = ToArray(pContentObj)) {
+ CPDF_Array* pArray = ToArray(pContentObj);
+ if (pArray) {
pContentArray = pArray;
CPDF_Reference* pRef = new CPDF_Reference(pDoc, pStream->GetObjNum());
pContentArray->InsertAt(0, pRef);
@@ -146,8 +147,9 @@ DLLEXPORT FPDF_BOOL STDCALL FPDFPage_TransFormWithClip(FPDF_PAGE page,
} else if (CPDF_Reference* pReference = ToReference(pContentObj)) {
CPDF_Object* pDirectObj = pReference->GetDirect();
if (pDirectObj) {
- if (CPDF_Array* pArray = pDirectObj->AsArray()) {
- pContentArray = pArray;
+ CPDF_Array* pObjArray = pDirectObj->AsArray();
+ if (pObjArray) {
+ pContentArray = pObjArray;
CPDF_Reference* pRef = new CPDF_Reference(pDoc, pStream->GetObjNum());
pContentArray->InsertAt(0, pRef);
pContentArray->AddReference(pDoc, pEndStream);
@@ -175,8 +177,8 @@ DLLEXPORT FPDF_BOOL STDCALL FPDFPage_TransFormWithClip(FPDF_PAGE page,
CPDF_Dictionary* pDict = nullptr;
if (pObj->IsDictionary())
pDict = pObj->AsDictionary();
- else if (CPDF_Stream* pStream = pObj->AsStream())
- pDict = pStream->GetDict();
+ else if (CPDF_Stream* pObjStream = pObj->AsStream())
+ pDict = pObjStream->GetDict();
else
continue;
@@ -307,15 +309,17 @@ DLLEXPORT void STDCALL FPDFPage_InsertClipPath(FPDF_PAGE page,
pDoc->AddIndirectObject(pStream);
CPDF_Array* pContentArray = nullptr;
- if (CPDF_Array* pArray = ToArray(pContentObj)) {
+ CPDF_Array* pArray = ToArray(pContentObj);
+ if (pArray) {
pContentArray = pArray;
CPDF_Reference* pRef = new CPDF_Reference(pDoc, pStream->GetObjNum());
pContentArray->InsertAt(0, pRef);
} else if (CPDF_Reference* pReference = ToReference(pContentObj)) {
CPDF_Object* pDirectObj = pReference->GetDirect();
if (pDirectObj) {
- if (CPDF_Array* pArray = pDirectObj->AsArray()) {
- pContentArray = pArray;
+ CPDF_Array* pObjArray = pDirectObj->AsArray();
+ if (pObjArray) {
+ pContentArray = pObjArray;
CPDF_Reference* pRef = new CPDF_Reference(pDoc, pStream->GetObjNum());
pContentArray->InsertAt(0, pRef);
} else if (pDirectObj->IsStream()) {
diff --git a/fpdfsdk/javascript/Field.cpp b/fpdfsdk/javascript/Field.cpp
index 2a739deed0..5808982b43 100644
--- a/fpdfsdk/javascript/Field.cpp
+++ b/fpdfsdk/javascript/Field.cpp
@@ -144,9 +144,9 @@ void Field::ParseFieldName(const std::wstring& strFieldNameParsed,
std::wstring suffixal = strFieldNameParsed.substr(iStart + 1);
iControlNo = FXSYS_wtoi(suffixal.c_str());
if (iControlNo == 0) {
- int iStart;
- while ((iStart = suffixal.find_last_of(L" ")) != -1) {
- suffixal.erase(iStart, 1);
+ int iSpaceStart;
+ while ((iSpaceStart = suffixal.find_last_of(L" ")) != -1) {
+ suffixal.erase(iSpaceStart, 1);
}
if (suffixal.compare(L"0") != 0) {
@@ -249,8 +249,8 @@ void Field::UpdateFormControl(CPDFSDK_Document* pDocument,
FX_BOOL bRefresh) {
ASSERT(pFormControl);
- CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterForm();
- CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormControl);
+ CPDFSDK_InterForm* pForm = (CPDFSDK_InterForm*)pDocument->GetInterForm();
+ CPDFSDK_Widget* pWidget = pForm->GetWidget(pFormControl);
if (pWidget) {
if (bResetAP) {
diff --git a/fpdfsdk/jsapi/fxjs_v8_embeddertest.cpp b/fpdfsdk/jsapi/fxjs_v8_embeddertest.cpp
index 161487f356..a8358c4ee9 100644
--- a/fpdfsdk/jsapi/fxjs_v8_embeddertest.cpp
+++ b/fpdfsdk/jsapi/fxjs_v8_embeddertest.cpp
@@ -64,7 +64,7 @@ TEST_F(FXJSV8EmbedderTest, MultipleRutimes) {
{
v8::Local<v8::Context> context1 =
v8::Local<v8::Context>::New(isolate(), global_context1);
- v8::Context::Scope context_scope(context1);
+ v8::Context::Scope context_scope1(context1);
ExecuteInCurrentContext(kScript1);
CheckAssignmentInCurrentContext(kExpected1);
}
@@ -73,7 +73,7 @@ TEST_F(FXJSV8EmbedderTest, MultipleRutimes) {
{
v8::Local<v8::Context> context2 =
v8::Local<v8::Context>::New(isolate(), global_context2);
- v8::Context::Scope context_scope(context2);
+ v8::Context::Scope context_scope2(context2);
ExecuteInCurrentContext(kScript2);
CheckAssignmentInCurrentContext(kExpected2);
}
diff --git a/fpdfsdk/pdfwindow/PWL_Edit.cpp b/fpdfsdk/pdfwindow/PWL_Edit.cpp
index e39b6c13c7..eec1fd98c7 100644
--- a/fpdfsdk/pdfwindow/PWL_Edit.cpp
+++ b/fpdfsdk/pdfwindow/PWL_Edit.cpp
@@ -294,13 +294,13 @@ void CPWL_Edit::GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream) {
<< sEditAfter.AsStringC() << "ET\n";
if (sText.GetLength() > 0) {
- CFX_FloatRect rcClient = GetClientRect();
+ CFX_FloatRect rect = GetClientRect();
sAppStream << "q\n/Tx BMC\n";
if (!HasFlag(PES_TEXTOVERFLOW))
- sAppStream << rcClient.left << " " << rcClient.bottom << " "
- << rcClient.right - rcClient.left << " "
- << rcClient.top - rcClient.bottom << " re W n\n";
+ sAppStream << rect.left << " " << rect.bottom << " "
+ << rect.right - rect.left << " " << rect.top - rect.bottom
+ << " re W n\n";
sAppStream << sText;