summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorweili <weili@chromium.org>2016-05-20 15:38:29 -0700
committerCommit bot <commit-bot@chromium.org>2016-05-20 15:38:30 -0700
commit038aa531bcf1a76764d3cef46fd9b8e08b166dae (patch)
treed1ef7d15ff37e4c98d1d7522b225755ba99bc330
parentdc3ccdfb49c4d533d524d2084a7ebe5117f35934 (diff)
downloadpdfium-038aa531bcf1a76764d3cef46fd9b8e08b166dae.tar.xz
Clean up XFA code which causes warnings
This is part of efforts to bring XFA to chromium_code standard. The warnings are from unreachable code, or using potentially uninitialized variables, or using assignment within a condition. This change list only contains easy to fix cases. More cleanups will follow. BUG=pdfium:29 Review-Url: https://codereview.chromium.org/1998873002
-rw-r--r--xfa/fde/cfde_txtedtengine.cpp17
-rw-r--r--xfa/fde/css/fde_cssstyleselector.cpp2
-rw-r--r--xfa/fde/css/fde_cssstylesheet.cpp2
-rw-r--r--xfa/fde/xml/fde_xml_imp.cpp1
-rw-r--r--xfa/fgas/layout/fgas_textbreak.cpp29
-rw-r--r--xfa/fwl/core/fwl_widgetmgrimp.cpp14
-rw-r--r--xfa/fwl/lightwidget/cfwl_theme.cpp2
-rw-r--r--xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.cpp41
-rw-r--r--xfa/fxbarcode/oned/BC_OneDimReader.cpp4
-rw-r--r--xfa/fxbarcode/oned/BC_OnedCode128Reader.cpp4
-rw-r--r--xfa/fxbarcode/oned/BC_OnedCode128Writer.cpp5
-rw-r--r--xfa/fxbarcode/oned/BC_OnedUPCAReader.cpp4
-rw-r--r--xfa/fxfa/app/xfa_ffdocview.cpp4
-rw-r--r--xfa/fxfa/app/xfa_ffnotify.cpp8
-rw-r--r--xfa/fxfa/app/xfa_ffwidget.cpp65
-rw-r--r--xfa/fxfa/app/xfa_ffwidgetacc.cpp2
-rw-r--r--xfa/fxfa/fm2js/xfa_fm2jscontext.cpp30
-rw-r--r--xfa/fxfa/parser/xfa_basic_imp.cpp1
-rw-r--r--xfa/fxfa/parser/xfa_document_datamerger_imp.cpp4
-rw-r--r--xfa/fxfa/parser/xfa_localemgr.cpp5
-rw-r--r--xfa/fxfa/parser/xfa_object_imp.cpp2
-rw-r--r--xfa/fxfa/parser/xfa_parser_imp.cpp1
-rw-r--r--xfa/fxfa/parser/xfa_utils.h8
-rw-r--r--xfa/fxfa/parser/xfa_utils_imp.cpp2
24 files changed, 117 insertions, 140 deletions
diff --git a/xfa/fde/cfde_txtedtengine.cpp b/xfa/fde/cfde_txtedtengine.cpp
index a99d8087c5..ecdaf67120 100644
--- a/xfa/fde/cfde_txtedtengine.cpp
+++ b/xfa/fde/cfde_txtedtengine.cpp
@@ -1023,21 +1023,15 @@ void CFDE_TxtEdtEngine::UpdatePages() {
return;
if (nSize > nPageCount) {
- IFDE_TxtEdtPage* pPage = NULL;
- int32_t i = 0;
- for (i = nSize - 1; i >= nPageCount; i--) {
+ for (int32_t i = nSize - 1; i >= nPageCount; i--) {
delete m_PagePtrArray[i];
m_PagePtrArray.RemoveAt(i);
}
return;
}
if (nSize < nPageCount) {
- IFDE_TxtEdtPage* pPage = NULL;
- int32_t i = 0;
- for (i = nSize; i < nPageCount; i++) {
- pPage = IFDE_TxtEdtPage::Create(this, i);
- m_PagePtrArray.Add(pPage);
- }
+ for (int32_t i = nSize; i < nPageCount; i++)
+ m_PagePtrArray.Add(IFDE_TxtEdtPage::Create(this, i));
return;
}
}
@@ -1606,10 +1600,9 @@ FX_BOOL CFDE_TxtEdtEngine::IsSelect() {
void CFDE_TxtEdtEngine::DeleteSelect() {
int32_t nCountRange = CountSelRanges();
if (nCountRange > 0) {
- int32_t nSelStart;
- int32_t nSelCount;
+ int32_t nSelStart = 0;
while (nCountRange > 0) {
- nSelCount = GetSelRange(--nCountRange, nSelStart);
+ int32_t nSelCount = GetSelRange(--nCountRange, nSelStart);
delete m_SelRangePtrArr[nCountRange];
m_SelRangePtrArr.RemoveAt(nCountRange);
DeleteRange_DoRecord(nSelStart, nSelCount, TRUE);
diff --git a/xfa/fde/css/fde_cssstyleselector.cpp b/xfa/fde/css/fde_cssstyleselector.cpp
index 05f036b1f3..bce8f704b8 100644
--- a/xfa/fde/css/fde_cssstyleselector.cpp
+++ b/xfa/fde/css/fde_cssstyleselector.cpp
@@ -543,7 +543,7 @@ void CFDE_CSSStyleSelector::AppendInlineStyle(CFDE_CSSDeclaration* pDecl,
if (!pSyntax->Init(psz, iLen, 32, TRUE))
return;
- int32_t iLen2;
+ int32_t iLen2 = 0;
const FX_WCHAR* psz2;
FDE_CSSPROPERTYARGS args;
args.pStringCache = nullptr;
diff --git a/xfa/fde/css/fde_cssstylesheet.cpp b/xfa/fde/css/fde_cssstylesheet.cpp
index dcfd302a58..80da3b042e 100644
--- a/xfa/fde/css/fde_cssstylesheet.cpp
+++ b/xfa/fde/css/fde_cssstylesheet.cpp
@@ -321,7 +321,6 @@ FDE_CSSSYNTAXSTATUS CFDE_CSSStyleSheet::LoadFontFaceRule(
FDE_CSSSWITCHDEFAULTS();
}
}
- return FDE_CSSSYNTAXSTATUS_None;
}
FDE_CSSSYNTAXSTATUS CFDE_CSSStyleSheet::LoadImportRule(
CFDE_CSSSyntaxParser* pSyntax) {
@@ -353,7 +352,6 @@ FDE_CSSSYNTAXSTATUS CFDE_CSSStyleSheet::SkipRuleSet(
FDE_CSSSWITCHDEFAULTS();
}
}
- return FDE_CSSSYNTAXSTATUS_None;
}
void CFDE_CSSStyleRule::SetSelector(IFX_MemoryAllocator* pStaticStore,
const CFDE_CSSSelectorArray& list) {
diff --git a/xfa/fde/xml/fde_xml_imp.cpp b/xfa/fde/xml/fde_xml_imp.cpp
index 446db86950..d7b22e076f 100644
--- a/xfa/fde/xml/fde_xml_imp.cpp
+++ b/xfa/fde/xml/fde_xml_imp.cpp
@@ -354,7 +354,6 @@ FX_BOOL CFDE_XMLNode::InsertNodeItem(CFDE_XMLNode::NodeItem eItem,
default:
return FALSE;
}
- return FALSE;
}
CFDE_XMLNode* CFDE_XMLNode::RemoveNodeItem(CFDE_XMLNode::NodeItem eItem) {
CFDE_XMLNode* pNode = NULL;
diff --git a/xfa/fgas/layout/fgas_textbreak.cpp b/xfa/fgas/layout/fgas_textbreak.cpp
index 4b4ef1fa7b..6f018b3c25 100644
--- a/xfa/fgas/layout/fgas_textbreak.cpp
+++ b/xfa/fgas/layout/fgas_textbreak.cpp
@@ -1194,15 +1194,10 @@ int32_t CFX_TxtBreak::GetDisplayPos(const FX_TXTRUN* pTxtRun,
FX_BOOL bVerticalDoc = (dwStyles & FX_TXTLAYOUTSTYLE_VerticalLayout) != 0;
FX_BOOL bVerticalChar = (dwStyles & FX_TXTLAYOUTSTYLE_VerticalChars) != 0;
int32_t iRotation = GetLineRotation(dwStyles) + pTxtRun->iCharRotation;
- int32_t iCharRotation;
- FX_WCHAR wch, wPrev = 0xFEFF, wNext, wForm, wLast = 0xFEFF;
- int32_t iWidth, iCharWidth, iCharHeight;
FX_FLOAT fX, fY, fCharWidth, fCharHeight;
int32_t iHorScale = pTxtRun->iHorizontalScale;
int32_t iVerScale = pTxtRun->iVerticalScale;
FX_BOOL bSkipSpace = pTxtRun->bSkipSpace;
- FX_BOOL bEmptyChar, bShadda = FALSE, bLam = FALSE;
- uint32_t dwProps, dwCharType;
FX_FORMCHAR formChars[3];
FX_FLOAT fYBase;
fX = rtText.left;
@@ -1217,8 +1212,17 @@ int32_t CFX_TxtBreak::GetDisplayPos(const FX_TXTRUN* pTxtRun,
fYBase = rtText.top + (rtText.height - fFontSize) / 2.0f;
fY = fYBase + fAscent;
}
- int32_t iCount = 0, iNext, iForms;
+ int32_t iCount = 0;
+ int32_t iNext = 0;
+ FX_WCHAR wPrev = 0xFEFF;
+ FX_WCHAR wNext = 0xFEFF;
+ FX_WCHAR wForm = 0xFEFF;
+ FX_WCHAR wLast = 0xFEFF;
+ FX_BOOL bShadda = FALSE;
+ FX_BOOL bLam = FALSE;
for (int32_t i = 0; i <= iLength; i++) {
+ int32_t iWidth;
+ FX_WCHAR wch;
if (pAccess != NULL) {
wch = pAccess->GetChar(pIdentity, i);
iWidth = pAccess->GetWidth(pIdentity, i);
@@ -1226,8 +1230,8 @@ int32_t CFX_TxtBreak::GetDisplayPos(const FX_TXTRUN* pTxtRun,
wch = *pStr++;
iWidth = *pWidths++;
}
- dwProps = FX_GetUnicodeProperties(wch);
- dwCharType = (dwProps & FX_CHARTYPEBITSMASK);
+ uint32_t dwProps = FX_GetUnicodeProperties(wch);
+ uint32_t dwCharType = (dwProps & FX_CHARTYPEBITSMASK);
if (dwCharType == FX_CHARTYPE_ArabicAlef && iWidth == 0) {
wPrev = 0xFEFF;
wLast = wch;
@@ -1340,17 +1344,17 @@ int32_t CFX_TxtBreak::GetDisplayPos(const FX_TXTRUN* pTxtRun,
bLam = FALSE;
}
dwProps = FX_GetUnicodeProperties(wForm);
- iCharRotation = iRotation;
+ int32_t iCharRotation = iRotation;
if (bVerticalChar && (dwProps & 0x8000) != 0) {
iCharRotation++;
}
iCharRotation %= 4;
- bEmptyChar =
+ FX_BOOL bEmptyChar =
(dwCharType >= FX_CHARTYPE_Tab && dwCharType <= FX_CHARTYPE_Control);
if (wForm == 0xFEFF) {
bEmptyChar = TRUE;
}
- iForms = bLam ? 3 : 1;
+ int32_t iForms = bLam ? 3 : 1;
iCount += (bEmptyChar && bSkipSpace) ? 0 : iForms;
if (pCharPos == NULL) {
if (iWidth > 0) {
@@ -1359,7 +1363,7 @@ int32_t CFX_TxtBreak::GetDisplayPos(const FX_TXTRUN* pTxtRun,
wLast = wch;
continue;
}
- iCharWidth = iWidth;
+ int32_t iCharWidth = iWidth;
if (iCharWidth < 0) {
iCharWidth = -iCharWidth;
}
@@ -1394,6 +1398,7 @@ int32_t CFX_TxtBreak::GetDisplayPos(const FX_TXTRUN* pTxtRun,
*pWSForms += wForm;
}
}
+ int32_t iCharHeight;
if (bVerticalDoc) {
iCharHeight = iCharWidth;
iCharWidth = 1000;
diff --git a/xfa/fwl/core/fwl_widgetmgrimp.cpp b/xfa/fwl/core/fwl_widgetmgrimp.cpp
index ff379722e7..93f39a98e5 100644
--- a/xfa/fwl/core/fwl_widgetmgrimp.cpp
+++ b/xfa/fwl/core/fwl_widgetmgrimp.cpp
@@ -447,21 +447,17 @@ IFWL_Widget* CFWL_WidgetMgr::GetSiblingRadioButton(IFWL_Widget* pWidget,
}
IFWL_Widget* CFWL_WidgetMgr::GetRadioButtonGroupHeader(
IFWL_Widget* pRadioButton) {
- if (pRadioButton->GetStyles() & FWL_WGTSTYLE_Group) {
- return pRadioButton;
- }
IFWL_Widget* pNext = pRadioButton;
- while ((pNext = GetSiblingRadioButton(pNext, FALSE)) != NULL) {
- if (pNext->GetStyles() & FWL_WGTSTYLE_Group) {
+ while (pNext) {
+ if (pNext->GetStyles() & FWL_WGTSTYLE_Group)
return pNext;
- }
+ pNext = GetSiblingRadioButton(pNext, FALSE);
}
pNext = GetWidget(pRadioButton, FWL_WGTRELATION_LastSibling);
- while ((pNext = GetSiblingRadioButton(pNext, FALSE)) && pNext &&
+ while ((pNext = GetSiblingRadioButton(pNext, FALSE)) != nullptr &&
pNext != pRadioButton) {
- if (pNext->GetStyles() & FWL_WGTSTYLE_Group) {
+ if (pNext->GetStyles() & FWL_WGTSTYLE_Group)
return pNext;
- }
}
pNext = GetWidget(pRadioButton, FWL_WGTRELATION_FirstSibling);
return GetSiblingRadioButton(pNext, TRUE);
diff --git a/xfa/fwl/lightwidget/cfwl_theme.cpp b/xfa/fwl/lightwidget/cfwl_theme.cpp
index a070e046c1..4824667080 100644
--- a/xfa/fwl/lightwidget/cfwl_theme.cpp
+++ b/xfa/fwl/lightwidget/cfwl_theme.cpp
@@ -56,7 +56,7 @@ uint32_t CFWL_Theme::GetThemeID(IFWL_Widget* pWidget) {
uint32_t CFWL_Theme::SetThemeID(IFWL_Widget* pWidget,
uint32_t dwThemeID,
FX_BOOL bChildren) {
- uint32_t dwID;
+ uint32_t dwID = 0;
for (const auto& pTheme : m_ThemesArray) {
dwID = pTheme->GetThemeID(pWidget);
pTheme->SetThemeID(pWidget, dwThemeID, FALSE);
diff --git a/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.cpp b/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.cpp
index b3c4326ed6..aec4a1ca22 100644
--- a/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.cpp
+++ b/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.cpp
@@ -104,14 +104,11 @@ CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256Poly::Clone(int32_t& e) {
CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256Poly::AddOrSubtract(
CBC_ReedSolomonGF256Poly* other,
int32_t& e) {
- if (IsZero()) {
+ if (IsZero())
return other->Clone(e);
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
- }
- if (other->IsZero()) {
+ if (other->IsZero())
return Clone(e);
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
- }
+
CFX_Int32Array smallerCoefficients;
smallerCoefficients.Copy(m_coefficients);
CFX_Int32Array largerCoefficients;
@@ -141,11 +138,9 @@ CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256Poly::AddOrSubtract(
CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256Poly::Multiply(
CBC_ReedSolomonGF256Poly* other,
int32_t& e) {
- if (IsZero() || other->IsZero()) {
- CBC_ReedSolomonGF256Poly* temp = m_field->GetZero()->Clone(e);
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
- return temp;
- }
+ if (IsZero() || other->IsZero())
+ return m_field->GetZero()->Clone(e);
+
CFX_Int32Array aCoefficients;
aCoefficients.Copy(m_coefficients);
int32_t aLength = m_coefficients.GetSize();
@@ -169,15 +164,11 @@ CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256Poly::Multiply(
}
CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256Poly::Multiply(int32_t scalar,
int32_t& e) {
- if (scalar == 0) {
- CBC_ReedSolomonGF256Poly* temp = m_field->GetZero()->Clone(e);
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
- return temp;
- }
- if (scalar == 1) {
+ if (scalar == 0)
+ return m_field->GetZero()->Clone(e);
+ if (scalar == 1)
return Clone(e);
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
- }
+
int32_t size = m_coefficients.GetSize();
CFX_Int32Array product;
product.SetSize(size);
@@ -195,13 +186,11 @@ CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256Poly::MultiplyByMonomial(
int32_t& e) {
if (degree < 0) {
e = BCExceptionDegreeIsNegative;
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
- }
- if (coefficient == 0) {
- CBC_ReedSolomonGF256Poly* temp = m_field->GetZero()->Clone(e);
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
- return temp;
+ return nullptr;
}
+ if (coefficient == 0)
+ return m_field->GetZero()->Clone(e);
+
int32_t size = m_coefficients.GetSize();
CFX_Int32Array product;
product.SetSize(size + degree);
@@ -219,7 +208,7 @@ CFX_ArrayTemplate<CBC_ReedSolomonGF256Poly*>* CBC_ReedSolomonGF256Poly::Divide(
int32_t& e) {
if (other->IsZero()) {
e = BCExceptionDivideByZero;
- BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
+ return nullptr;
}
std::unique_ptr<CBC_ReedSolomonGF256Poly> quotient(
m_field->GetZero()->Clone(e));
diff --git a/xfa/fxbarcode/oned/BC_OneDimReader.cpp b/xfa/fxbarcode/oned/BC_OneDimReader.cpp
index 5187c34af9..a1cfc9b492 100644
--- a/xfa/fxbarcode/oned/BC_OneDimReader.cpp
+++ b/xfa/fxbarcode/oned/BC_OneDimReader.cpp
@@ -211,9 +211,7 @@ int32_t CBC_OneDimReader::DecodeDigit(CBC_CommonBitArray* row,
}
if (bestMatch >= 0) {
return bestMatch;
- } else {
- e = BCExceptionNotFound;
- return 0;
}
+ e = BCExceptionNotFound;
return 0;
}
diff --git a/xfa/fxbarcode/oned/BC_OnedCode128Reader.cpp b/xfa/fxbarcode/oned/BC_OnedCode128Reader.cpp
index b5f5aa5fe4..a0479e7f6d 100644
--- a/xfa/fxbarcode/oned/BC_OnedCode128Reader.cpp
+++ b/xfa/fxbarcode/oned/BC_OnedCode128Reader.cpp
@@ -150,10 +150,8 @@ int32_t CBC_OnedCode128Reader::DecodeCode(CBC_CommonBitArray* row,
}
if (bestMatch >= 0) {
return bestMatch;
- } else {
- e = BCExceptionNotFound;
- return 0;
}
+ e = BCExceptionNotFound;
return 0;
}
CFX_ByteString CBC_OnedCode128Reader::DecodeRow(int32_t rowNumber,
diff --git a/xfa/fxbarcode/oned/BC_OnedCode128Writer.cpp b/xfa/fxbarcode/oned/BC_OnedCode128Writer.cpp
index 5806b3d09d..bc9b14f04e 100644
--- a/xfa/fxbarcode/oned/BC_OnedCode128Writer.cpp
+++ b/xfa/fxbarcode/oned/BC_OnedCode128Writer.cpp
@@ -45,10 +45,7 @@ FX_BOOL CBC_OnedCode128Writer::CheckContentValidity(
if (m_codeFormat == BC_CODE128_B || m_codeFormat == BC_CODE128_C) {
while (position < contents.GetLength()) {
patternIndex = (int32_t)contents.GetAt(position);
- if (patternIndex >= 32 && patternIndex <= 126 && patternIndex != 34) {
- position++;
- continue;
- } else {
+ if (patternIndex < 32 || patternIndex > 126 || patternIndex == 34) {
ret = FALSE;
break;
}
diff --git a/xfa/fxbarcode/oned/BC_OnedUPCAReader.cpp b/xfa/fxbarcode/oned/BC_OnedUPCAReader.cpp
index 50a8fbb2f9..eb197b916c 100644
--- a/xfa/fxbarcode/oned/BC_OnedUPCAReader.cpp
+++ b/xfa/fxbarcode/oned/BC_OnedUPCAReader.cpp
@@ -89,9 +89,7 @@ CFX_ByteString CBC_OnedUPCAReader::MaybeReturnResult(CFX_ByteString& result,
if (result[0] == '0') {
result.Delete(0);
return result;
- } else {
- e = BCExceptionFormatException;
- return "";
}
+ e = BCExceptionFormatException;
return "";
}
diff --git a/xfa/fxfa/app/xfa_ffdocview.cpp b/xfa/fxfa/app/xfa_ffdocview.cpp
index d8543fa511..131e8cd82f 100644
--- a/xfa/fxfa/app/xfa_ffdocview.cpp
+++ b/xfa/fxfa/app/xfa_ffdocview.cpp
@@ -874,9 +874,9 @@ CXFA_WidgetAcc* CXFA_WidgetAccIterator::MoveToNext() {
CXFA_Node* pItem = m_pCurWidgetAcc ? m_ContentIterator.MoveToNext()
: m_ContentIterator.GetCurrent();
while (pItem) {
- if ((m_pCurWidgetAcc = (CXFA_WidgetAcc*)pItem->GetWidgetData())) {
+ m_pCurWidgetAcc = (CXFA_WidgetAcc*)pItem->GetWidgetData();
+ if (m_pCurWidgetAcc)
return m_pCurWidgetAcc;
- }
pItem = m_ContentIterator.MoveToNext();
}
return NULL;
diff --git a/xfa/fxfa/app/xfa_ffnotify.cpp b/xfa/fxfa/app/xfa_ffnotify.cpp
index 4d7d4799f2..e8fb4dd1dc 100644
--- a/xfa/fxfa/app/xfa_ffnotify.cpp
+++ b/xfa/fxfa/app/xfa_ffnotify.cpp
@@ -56,7 +56,7 @@ void CXFA_FFNotify::OnWidgetListItemAdded(CXFA_WidgetData* pSender,
return;
CXFA_FFWidget* pWidget = nullptr;
- while ((pWidget = pWidgetAcc->GetNextWidget(pWidget))) {
+ while ((pWidget = pWidgetAcc->GetNextWidget(pWidget)) != nullptr) {
if (pWidget->IsLoaded()) {
if (pWidgetAcc->IsListBox()) {
static_cast<CXFA_FFListBox*>(pWidget)->InsertItem(pLabel, iIndex);
@@ -74,7 +74,7 @@ void CXFA_FFNotify::OnWidgetListItemRemoved(CXFA_WidgetData* pSender,
return;
CXFA_FFWidget* pWidget = nullptr;
- while ((pWidget = pWidgetAcc->GetNextWidget(pWidget))) {
+ while ((pWidget = pWidgetAcc->GetNextWidget(pWidget)) != nullptr) {
if (pWidget->IsLoaded()) {
if (pWidgetAcc->IsListBox()) {
static_cast<CXFA_FFListBox*>(pWidget)->DeleteItem(iIndex);
@@ -360,7 +360,7 @@ void CXFA_FFNotify::OnValueChanging(CXFA_Node* pSender, XFA_ATTRIBUTE eAttr) {
return;
CXFA_FFWidget* pWidget = nullptr;
- while ((pWidget = pWidgetAcc->GetNextWidget(pWidget))) {
+ while ((pWidget = pWidgetAcc->GetNextWidget(pWidget)) != nullptr) {
if (pWidget->IsLoaded())
pWidget->AddInvalidateRect();
}
@@ -422,7 +422,7 @@ void CXFA_FFNotify::OnValueChanged(CXFA_Node* pSender,
}
}
CXFA_FFWidget* pWidget = nullptr;
- while ((pWidget = pWidgetAcc->GetNextWidget(pWidget))) {
+ while ((pWidget = pWidgetAcc->GetNextWidget(pWidget)) != nullptr) {
if (!pWidget->IsLoaded())
continue;
diff --git a/xfa/fxfa/app/xfa_ffwidget.cpp b/xfa/fxfa/app/xfa_ffwidget.cpp
index 3af84a6bbe..8ce583a782 100644
--- a/xfa/fxfa/app/xfa_ffwidget.cpp
+++ b/xfa/fxfa/app/xfa_ffwidget.cpp
@@ -270,12 +270,13 @@ void CXFA_FFWidget::Rotate2Normal(FX_FLOAT& fx, FX_FLOAT& fy) {
}
static void XFA_GetMatrix(CFX_Matrix& m,
int32_t iRotate,
- int32_t at,
+ XFA_ATTRIBUTEENUM at,
const CFX_RectF& rt) {
if (!iRotate) {
return;
}
- FX_FLOAT fAnchorX, fAnchorY;
+ FX_FLOAT fAnchorX = 0;
+ FX_FLOAT fAnchorY = 0;
switch (at) {
case XFA_ATTRIBUTEENUM_TopLeft:
fAnchorX = rt.left, fAnchorY = rt.top;
@@ -305,6 +306,8 @@ static void XFA_GetMatrix(CFX_Matrix& m,
case XFA_ATTRIBUTEENUM_BottomRight:
fAnchorX = rt.right(), fAnchorY = rt.bottom();
break;
+ default:
+ break;
}
switch (iRotate) {
case 90:
@@ -1157,20 +1160,15 @@ static void XFA_BOX_GetPath(CXFA_Box box,
FX_BOOL bStart,
FX_BOOL bCorner) {
ASSERT(nIndex >= 0 && nIndex < 8);
- FX_BOOL bInverted, bRound;
- FX_FLOAT fRadius1, fRadius2, sx, sy, vx, vy, nx, ny, offsetY, offsetX,
- offsetEX, offsetEY;
- CFX_PointF cpStart, cp, cp1, cp2;
- CFX_RectF rtRadius;
int32_t n = (nIndex & 1) ? nIndex - 1 : nIndex;
CXFA_Corner corner1(strokes[n].GetNode());
CXFA_Corner corner2(strokes[(n + 2) % 8].GetNode());
- fRadius1 = bCorner ? corner1.GetRadius() : 0;
- fRadius2 = bCorner ? corner2.GetRadius() : 0;
- bInverted = corner1.IsInverted();
- offsetY = 0.0f;
- offsetX = 0.0f;
- bRound = corner1.GetJoinType() == XFA_ATTRIBUTEENUM_Round;
+ FX_FLOAT fRadius1 = bCorner ? corner1.GetRadius() : 0.0f;
+ FX_FLOAT fRadius2 = bCorner ? corner2.GetRadius() : 0.0f;
+ FX_BOOL bInverted = corner1.IsInverted();
+ FX_FLOAT offsetY = 0.0f;
+ FX_FLOAT offsetX = 0.0f;
+ FX_BOOL bRound = corner1.GetJoinType() == XFA_ATTRIBUTEENUM_Round;
FX_FLOAT halfAfter = 0.0f;
FX_FLOAT halfBefore = 0.0f;
CXFA_Stroke stroke = strokes[nIndex];
@@ -1189,12 +1187,21 @@ static void XFA_BOX_GetPath(CXFA_Box box,
CXFA_Stroke edgeBefore = strokes[(nIndex + 8 - 2) % 8];
CXFA_Stroke edgeAfter = strokes[(nIndex + 2) % 8];
if (!bRound && !bInverted) {
- { halfBefore = edgeBefore.GetThickness() / 2; }
- { halfAfter = edgeAfter.GetThickness() / 2; }
+ halfBefore = edgeBefore.GetThickness() / 2;
+ halfAfter = edgeAfter.GetThickness() / 2;
}
}
- offsetEX = 0.0f;
- offsetEY = 0.0f;
+ FX_FLOAT offsetEX = 0.0f;
+ FX_FLOAT offsetEY = 0.0f;
+ FX_FLOAT sx = 0.0f;
+ FX_FLOAT sy = 0.0f;
+ FX_FLOAT vx = 1.0f;
+ FX_FLOAT vy = 1.0f;
+ FX_FLOAT nx = 1.0f;
+ FX_FLOAT ny = 1.0f;
+ CFX_PointF cpStart;
+ CFX_PointF cp1;
+ CFX_PointF cp2;
if (bRound) {
sy = FX_PI / 2;
}
@@ -1291,6 +1298,7 @@ static void XFA_BOX_GetPath(CXFA_Box box,
if (bInverted) {
sy *= -1;
}
+ CFX_RectF rtRadius;
rtRadius.Set(cp1.x + offsetX * 2, cp1.y + offsetY * 2,
fRadius1 * 2 * vx - offsetX * 2,
fRadius1 * 2 * vy - offsetY * 2);
@@ -1301,6 +1309,7 @@ static void XFA_BOX_GetPath(CXFA_Box box,
path.ArcTo(rtRadius.left, rtRadius.top, rtRadius.width, rtRadius.height, sx,
sy);
} else {
+ CFX_PointF cp;
if (bInverted) {
cp.x = cp1.x + fRadius1 * vx, cp.y = cp1.y + fRadius1 * vy;
} else {
@@ -1369,17 +1378,21 @@ static void XFA_BOX_GetFillPath(CXFA_Box box,
rtWidget.height);
return;
}
- FX_BOOL bInverted, bRound;
- FX_FLOAT fRadius1, fRadius2, sx, sy, vx, vy, nx, ny;
- CFX_PointF cp, cp1, cp2;
- CFX_RectF rtRadius;
+
for (int32_t i = 0; i < 8; i += 2) {
+ FX_FLOAT sx = 0.0f;
+ FX_FLOAT sy = 0.0f;
+ FX_FLOAT vx = 1.0f;
+ FX_FLOAT vy = 1.0f;
+ FX_FLOAT nx = 1.0f;
+ FX_FLOAT ny = 1.0f;
+ CFX_PointF cp1, cp2;
CXFA_Corner corner1(strokes[i].GetNode());
CXFA_Corner corner2(strokes[(i + 2) % 8].GetNode());
- fRadius1 = corner1.GetRadius();
- fRadius2 = corner2.GetRadius();
- bInverted = corner1.IsInverted();
- bRound = corner1.GetJoinType() == XFA_ATTRIBUTEENUM_Round;
+ FX_FLOAT fRadius1 = corner1.GetRadius();
+ FX_FLOAT fRadius2 = corner2.GetRadius();
+ FX_BOOL bInverted = corner1.IsInverted();
+ FX_BOOL bRound = corner1.GetJoinType() == XFA_ATTRIBUTEENUM_Round;
if (bRound) {
sy = FX_PI / 2;
}
@@ -1439,6 +1452,7 @@ static void XFA_BOX_GetFillPath(CXFA_Box box,
if (bInverted) {
sy *= -1;
}
+ CFX_RectF rtRadius;
rtRadius.Set(cp1.x, cp1.y, fRadius1 * 2 * vx, fRadius1 * 2 * vy);
rtRadius.Normalize();
if (bInverted) {
@@ -1447,6 +1461,7 @@ static void XFA_BOX_GetFillPath(CXFA_Box box,
fillPath.ArcTo(rtRadius.left, rtRadius.top, rtRadius.width,
rtRadius.height, sx, sy);
} else {
+ CFX_PointF cp;
if (bInverted) {
cp.x = cp1.x + fRadius1 * vx, cp.y = cp1.y + fRadius1 * vy;
} else {
diff --git a/xfa/fxfa/app/xfa_ffwidgetacc.cpp b/xfa/fxfa/app/xfa_ffwidgetacc.cpp
index 08c52de79a..2c84a7f9b7 100644
--- a/xfa/fxfa/app/xfa_ffwidgetacc.cpp
+++ b/xfa/fxfa/app/xfa_ffwidgetacc.cpp
@@ -713,7 +713,7 @@ CXFA_FFWidget* CXFA_WidgetAcc::GetNextWidget(CXFA_FFWidget* pWidget) {
}
void CXFA_WidgetAcc::UpdateUIDisplay(CXFA_FFWidget* pExcept) {
CXFA_FFWidget* pWidget = NULL;
- while ((pWidget = GetNextWidget(pWidget))) {
+ while ((pWidget = GetNextWidget(pWidget)) != nullptr) {
if (pWidget == pExcept || !pWidget->IsLoaded() ||
(GetUIType() != XFA_ELEMENT_CheckButton && pWidget->IsFocused())) {
continue;
diff --git a/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp b/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp
index 96ebbfa1e9..4813eb1a63 100644
--- a/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp
+++ b/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp
@@ -1291,7 +1291,7 @@ void CXFA_FM2JSContext::Num2Date(FXJSE_HOBJECT hThis,
int32_t argc = args.GetLength();
if ((argc > 0) && (argc < 4)) {
FX_BOOL bFlags = FALSE;
- int32_t dDate;
+ int32_t dDate = 0;
CFX_ByteString formatString;
CFX_ByteString localString;
FXJSE_HVALUE dateValue = GetSimpleHValue(hThis, args, 0);
@@ -1446,7 +1446,7 @@ void CXFA_FM2JSContext::Num2GMTime(FXJSE_HOBJECT hThis,
int32_t argc = args.GetLength();
if ((argc > 0) && (argc < 4)) {
FX_BOOL bFlags = FALSE;
- int32_t iTime;
+ int32_t iTime = 0;
CFX_ByteString formatString;
CFX_ByteString localString;
FXJSE_HVALUE timeValue = GetSimpleHValue(hThis, args, 0);
@@ -1508,7 +1508,7 @@ void CXFA_FM2JSContext::Num2Time(FXJSE_HOBJECT hThis,
int32_t argc = args.GetLength();
if ((argc > 0) && (argc < 4)) {
FX_BOOL bFlags = FALSE;
- FX_FLOAT fTime;
+ FX_FLOAT fTime = 0.0f;
CFX_ByteString formatString;
CFX_ByteString localString;
FXJSE_HVALUE timeValue = GetSimpleHValue(hThis, args, 0);
@@ -4860,7 +4860,7 @@ void CXFA_FM2JSContext::Str(FXJSE_HOBJECT hThis,
int32_t argc = args.GetLength();
if ((argc > 0) && (argc < 4)) {
FX_BOOL bFlags = FALSE;
- FX_FLOAT fNumber;
+ FX_FLOAT fNumber = 0.0f;
int32_t iWidth = 10;
int32_t iPrecision = 0;
FXJSE_HVALUE numberValue = GetSimpleHValue(hThis, args, 0);
@@ -5171,7 +5171,7 @@ void CXFA_FM2JSContext::WordNum(FXJSE_HOBJECT hThis,
int32_t argc = args.GetLength();
if ((argc > 0) && (argc < 4)) {
FX_BOOL bFlags = FALSE;
- FX_FLOAT fNumber;
+ FX_FLOAT fNumber = 0.0f;
int32_t iIdentifier = 0;
CFX_ByteString localeString;
FXJSE_HVALUE numberValue = GetSimpleHValue(hThis, args, 0);
@@ -5477,14 +5477,12 @@ void CXFA_FM2JSContext::Post(FXJSE_HOBJECT hThis,
CFX_ByteString bsContentType;
CFX_ByteString bsEncode;
CFX_ByteString bsHeader;
- FXJSE_HVALUE argOne;
- FXJSE_HVALUE argTwo;
- FXJSE_HVALUE argThree;
- FXJSE_HVALUE argFour;
- FXJSE_HVALUE argFive;
- argOne = GetSimpleHValue(hThis, args, 0);
+ FXJSE_HVALUE argThree = nullptr;
+ FXJSE_HVALUE argFour = nullptr;
+ FXJSE_HVALUE argFive = nullptr;
+ FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0);
HValueToUTF8String(argOne, bsURL);
- argTwo = GetSimpleHValue(hThis, args, 1);
+ FXJSE_HVALUE argTwo = GetSimpleHValue(hThis, args, 1);
HValueToUTF8String(argTwo, bsData);
if (argc > 2) {
argThree = GetSimpleHValue(hThis, args, 2);
@@ -5548,12 +5546,10 @@ void CXFA_FM2JSContext::Put(FXJSE_HOBJECT hThis,
CFX_ByteString bsURL;
CFX_ByteString bsData;
CFX_ByteString bsEncode;
- FXJSE_HVALUE argOne;
- FXJSE_HVALUE argTwo;
- FXJSE_HVALUE argThree;
- argOne = GetSimpleHValue(hThis, args, 0);
+ FXJSE_HVALUE argThree = nullptr;
+ FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0);
HValueToUTF8String(argOne, bsURL);
- argTwo = GetSimpleHValue(hThis, args, 1);
+ FXJSE_HVALUE argTwo = GetSimpleHValue(hThis, args, 1);
HValueToUTF8String(argTwo, bsData);
if (argc > 2) {
argThree = GetSimpleHValue(hThis, args, 2);
diff --git a/xfa/fxfa/parser/xfa_basic_imp.cpp b/xfa/fxfa/parser/xfa_basic_imp.cpp
index 728ecfc319..759d530439 100644
--- a/xfa/fxfa/parser/xfa_basic_imp.cpp
+++ b/xfa/fxfa/parser/xfa_basic_imp.cpp
@@ -488,7 +488,6 @@ FX_BOOL CXFA_Measurement::ToUnit(XFA_UNIT eUnit, FX_FLOAT& fValue) const {
fValue = 0;
return FALSE;
}
- return FALSE;
}
XFA_UNIT CXFA_Measurement::GetUnit(const CFX_WideStringC& wsUnit) {
if (wsUnit == FX_WSTRC(L"mm")) {
diff --git a/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp b/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp
index 41a0acd70b..5bd8f08970 100644
--- a/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp
+++ b/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp
@@ -886,13 +886,13 @@ static CXFA_Node* XFA_DataMerge_CopyContainer_SubformSet(
pTemplateChild, TRUE);
} else if (pTemplateChild->GetObjectType() ==
XFA_OBJECTTYPE_ContainerNode) {
- CXFA_Node* pDataMatch;
bSelfMatch = FALSE;
eBindMatch = XFA_ATTRIBUTEENUM_None;
+ CXFA_Node* pDataMatch;
if (eRelation != XFA_ATTRIBUTEENUM_Ordered &&
(pDataMatch = XFA_DataMerge_FindMatchingDataNode(
pDocument, pTemplateChild, pDataScope, bAccessedDataDOM,
- FALSE, NULL, bSelfMatch, eBindMatch))) {
+ FALSE, NULL, bSelfMatch, eBindMatch)) != nullptr) {
XFA_DataMerge_RecurseRecord sNewRecord = {pTemplateChild,
pDataMatch};
if (bSelfMatch) {
diff --git a/xfa/fxfa/parser/xfa_localemgr.cpp b/xfa/fxfa/parser/xfa_localemgr.cpp
index 0982537b15..83c7cf025d 100644
--- a/xfa/fxfa/parser/xfa_localemgr.cpp
+++ b/xfa/fxfa/parser/xfa_localemgr.cpp
@@ -1123,9 +1123,8 @@ static uint16_t XFA_GetLanguage(CFX_WideString wsLanguage) {
CXFA_LocaleMgr::CXFA_LocaleMgr(CXFA_Node* pLocaleSet, CFX_WideString wsDeflcid)
: m_dwLocaleFlags(0x00) {
m_dwDeflcid = XFA_GetLanguage(wsDeflcid);
- CXFA_Node* pNodeLocale = NULL;
- if (pLocaleSet &&
- (pNodeLocale = pLocaleSet->GetNodeItem(XFA_NODEITEM_FirstChild))) {
+ if (pLocaleSet) {
+ CXFA_Node* pNodeLocale = pLocaleSet->GetNodeItem(XFA_NODEITEM_FirstChild);
while (pNodeLocale) {
m_LocaleArray.Add(new CXFA_NodeLocale(pNodeLocale));
pNodeLocale = pNodeLocale->GetNodeItem(XFA_NODEITEM_NextSibling);
diff --git a/xfa/fxfa/parser/xfa_object_imp.cpp b/xfa/fxfa/parser/xfa_object_imp.cpp
index 0fbde1f160..6a6303e64e 100644
--- a/xfa/fxfa/parser/xfa_object_imp.cpp
+++ b/xfa/fxfa/parser/xfa_object_imp.cpp
@@ -4504,7 +4504,7 @@ CXFA_Node* CXFA_Node::GetProperty(int32_t index,
}
CXFA_Document* pFactory = m_pDocument->GetParser()->GetFactory();
const XFA_PACKETINFO* pPacket = XFA_GetPacketByID(dwPacket);
- CXFA_Node* pNewNode;
+ CXFA_Node* pNewNode = nullptr;
for (; iCount <= index; iCount++) {
pNewNode = pFactory->CreateNode(pPacket, eProperty);
if (!pNewNode) {
diff --git a/xfa/fxfa/parser/xfa_parser_imp.cpp b/xfa/fxfa/parser/xfa_parser_imp.cpp
index 3369e59479..9cadcc6d1c 100644
--- a/xfa/fxfa/parser/xfa_parser_imp.cpp
+++ b/xfa/fxfa/parser/xfa_parser_imp.cpp
@@ -362,7 +362,6 @@ CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket(CFDE_XMLNode* pXMLDocumentNode,
default:
return ParseAsXDPPacket_User(pXMLDocumentNode, ePacketID);
}
- return NULL;
}
CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_XDP(
CFDE_XMLNode* pXMLDocumentNode,
diff --git a/xfa/fxfa/parser/xfa_utils.h b/xfa/fxfa/parser/xfa_utils.h
index 821e485e25..d6633a4c7f 100644
--- a/xfa/fxfa/parser/xfa_utils.h
+++ b/xfa/fxfa/parser/xfa_utils.h
@@ -120,7 +120,7 @@ class CXFA_NodeIteratorTemplate {
NodeType** ppNode = NULL;
NodeType* pCurrent = GetCurrent();
while (m_NodeStack.GetSize() > 0) {
- while ((ppNode = m_NodeStack.GetTopElement())) {
+ while ((ppNode = m_NodeStack.GetTopElement()) != nullptr) {
if (pCurrent != *ppNode) {
return *ppNode;
}
@@ -130,7 +130,7 @@ class CXFA_NodeIteratorTemplate {
}
m_NodeStack.Push(pChild);
}
- while ((ppNode = m_NodeStack.GetTopElement())) {
+ while ((ppNode = m_NodeStack.GetTopElement()) != nullptr) {
NodeType* pNext = TraverseStrategy::GetNextSibling(*ppNode);
m_NodeStack.Pop();
if (m_NodeStack.GetSize() == 0) {
@@ -145,8 +145,8 @@ class CXFA_NodeIteratorTemplate {
return NULL;
}
NodeType* SkipChildrenAndMoveToNext() {
- NodeType** ppNode = NULL;
- while ((ppNode = m_NodeStack.GetTopElement())) {
+ NodeType** ppNode = nullptr;
+ while ((ppNode = m_NodeStack.GetTopElement()) != nullptr) {
NodeType* pNext = TraverseStrategy::GetNextSibling(*ppNode);
m_NodeStack.Pop();
if (m_NodeStack.GetSize() == 0) {
diff --git a/xfa/fxfa/parser/xfa_utils_imp.cpp b/xfa/fxfa/parser/xfa_utils_imp.cpp
index 77cac00b89..d576b4de06 100644
--- a/xfa/fxfa/parser/xfa_utils_imp.cpp
+++ b/xfa/fxfa/parser/xfa_utils_imp.cpp
@@ -255,14 +255,12 @@ FX_BOOL XFA_IsLayoutElement(XFA_ELEMENT eElement, FX_BOOL bLayoutContainer) {
case XFA_ELEMENT_Subform:
case XFA_ELEMENT_ExclGroup:
case XFA_ELEMENT_SubformSet:
- return TRUE;
case XFA_ELEMENT_PageArea:
case XFA_ELEMENT_Form:
return TRUE;
default:
return FALSE;
}
- return FALSE;
}
static const FX_DOUBLE fraction_scales[] = {0.1,