sw/source/core/doc/DocumentFieldsManager.cxx | 7 ++++--- sw/source/core/doc/doctxm.cxx | 20 ++++++++++++-------- sw/source/core/docnode/ndtbl.cxx | 14 ++++++++------ sw/source/core/docnode/swbaslnk.cxx | 7 ++++--- sw/source/core/edit/autofmt.cxx | 9 ++++----- sw/source/core/edit/edlingu.cxx | 26 ++++++++++++++------------ sw/source/core/frmedt/fecopy.cxx | 12 ++++++------ sw/source/core/layout/paintfrm.cxx | 5 +++-- sw/source/core/text/txtfrm.cxx | 12 +++++++++--- sw/source/core/txtnode/txtedt.cxx | 2 +- 10 files changed, 65 insertions(+), 49 deletions(-)
New commits: commit 199e687c12de402f51f86c6b81bb9bdcd514337c Author: Michael Stahl <mst...@redhat.com> Date: Mon Nov 28 15:06:46 2016 +0100 sw core: de-obfuscate assignments in conditions to help GCC GCC 6.2.1 with -Og produces spurious -Werror=maybe-uninitialized on variables that are assigned in conditions; perhaps it's better to de-obfuscate the code if even GCC is confused about it. Change-Id: Ib42290abd0e45158900b3d42e1b666fa4d0fa7f3 Reviewed-on: https://gerrit.libreoffice.org/31330 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Michael Stahl <mst...@redhat.com> diff --git a/sw/source/core/doc/DocumentFieldsManager.cxx b/sw/source/core/doc/DocumentFieldsManager.cxx index 49fef17..1053a9c 100644 --- a/sw/source/core/doc/DocumentFieldsManager.cxx +++ b/sw/source/core/doc/DocumentFieldsManager.cxx @@ -670,9 +670,10 @@ void DocumentFieldsManager::UpdateTableFields( SfxPoolItem* pHt ) // new fields are inserted at the beginning of the modify chain // that gives faster calculation on import // mba: do we really need &m_rDoc "optimization"? Is it still valid? - SwTableField* pField; - if( !pFormatField->GetTextField() || (nsSwExtendedSubType::SUB_CMD & - (pField = static_cast<SwTableField*>(pFormatField->GetField()))->GetSubType() )) + if (!pFormatField->GetTextField()) + continue; + SwTableField *const pField(static_cast<SwTableField*>(pFormatField->GetField())); + if (nsSwExtendedSubType::SUB_CMD & pField->GetSubType()) continue; // needs to be recalculated diff --git a/sw/source/core/doc/doctxm.cxx b/sw/source/core/doc/doctxm.cxx index b3462b7..87d1c60 100644 --- a/sw/source/core/doc/doctxm.cxx +++ b/sw/source/core/doc/doctxm.cxx @@ -734,9 +734,13 @@ bool SwTOXBaseSection::SetPosAtStartEnd( SwPosition& rPos ) const void SwTOXBaseSection::Update(const SfxItemSet* pAttr, const bool _bNewTOX ) { - const SwSectionNode* pSectNd; - if( !SwTOXBase::GetRegisteredIn()->HasWriterListeners() || - !GetFormat() || nullptr == (pSectNd = GetFormat()->GetSectionNode() ) || + if (!SwTOXBase::GetRegisteredIn()->HasWriterListeners() || + !GetFormat()) + { + return; + } + SwSectionNode const*const pSectNd(GetFormat()->GetSectionNode()); + if (nullptr == pSectNd || !pSectNd->GetNodes().IsDocNodes() || IsHiddenFlag() ) { @@ -1119,15 +1123,15 @@ void SwTOXBaseSection::UpdateMarks( const SwTOXInternational& rIntl, TOXTypes eTOXTyp = GetTOXType()->GetType(); SwIterator<SwTOXMark,SwTOXType> aIter( *pType ); - SwTextTOXMark* pTextMark; - SwTOXMark* pMark; - for( pMark = aIter.First(); pMark; pMark = aIter.Next() ) + for (SwTOXMark* pMark = aIter.First(); pMark; pMark = aIter.Next()) { ::SetProgressState( 0, pDoc->GetDocShell() ); - if( pMark->GetTOXType()->GetType() == eTOXTyp && - nullptr != ( pTextMark = pMark->GetTextTOXMark() ) ) + if (pMark->GetTOXType()->GetType() == eTOXTyp) { + SwTextTOXMark *const pTextMark(pMark->GetTextTOXMark()); + if (nullptr == pTextMark) + continue; const SwTextNode* pTOXSrc = pTextMark->GetpTextNd(); // Only insert TOXMarks from the Doc, not from the // UNDO. diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx index da7d011..f3604c1 100644 --- a/sw/source/core/docnode/ndtbl.cxx +++ b/sw/source/core/docnode/ndtbl.cxx @@ -1531,9 +1531,10 @@ static void lcl_DelBox( SwTableBox* pBox, DelTabPara* pDelPara ) *pBox->GetSttNd()->EndOfSectionNode() ); // Delete the Section pDelPara->rNds.SectionUp( &aDelRg ); - const SwTextNode* pCurTextNd; - if( T2T_PARA != pDelPara->cCh && pDelPara->pLastNd && - nullptr != ( pCurTextNd = aDelRg.aStart.GetNode().GetTextNode() )) + const SwTextNode* pCurTextNd = nullptr; + if (T2T_PARA != pDelPara->cCh && pDelPara->pLastNd) + pCurTextNd = aDelRg.aStart.GetNode().GetTextNode(); + if (nullptr != pCurTextNd) { // Join the current text node with the last from the previous box if possible sal_uLong nNdIdx = aDelRg.aStart.GetIndex(); @@ -1579,9 +1580,10 @@ bool SwNodes::TableToText( const SwNodeRange& rRange, sal_Unicode cCh, SwUndoTableToText* pUndo ) { // Is a Table selected? - SwTableNode* pTableNd; - if( rRange.aStart.GetIndex() >= rRange.aEnd.GetIndex() || - nullptr == ( pTableNd = rRange.aStart.GetNode().GetTableNode()) || + if (rRange.aStart.GetIndex() >= rRange.aEnd.GetIndex()) + return false; + SwTableNode *const pTableNd(rRange.aStart.GetNode().GetTableNode()); + if (nullptr == pTableNd || &rRange.aEnd.GetNode() != pTableNd->EndOfSectionNode() ) return false; diff --git a/sw/source/core/docnode/swbaslnk.cxx b/sw/source/core/docnode/swbaslnk.cxx index 3e0c93af..8602ef9 100644 --- a/sw/source/core/docnode/swbaslnk.cxx +++ b/sw/source/core/docnode/swbaslnk.cxx @@ -300,9 +300,10 @@ static bool SetGrfFlySize( const Size& rGrfSz, SwGrfNode* pGrfNd, const Size& rO if ( !(aSz.Width() && aSz.Height()) && rGrfSz.Width() && rGrfSz.Height() ) { - SwFrameFormat* pFormat; - if( pGrfNd->IsChgTwipSize() && - nullptr != (pFormat = pGrfNd->GetFlyFormat()) ) + SwFrameFormat* pFormat = nullptr; + if (pGrfNd->IsChgTwipSize()) + pFormat = pGrfNd->GetFlyFormat(); + if (nullptr != pFormat) { Size aCalcSz( aSz ); if ( !aSz.Height() && aSz.Width() ) diff --git a/sw/source/core/edit/autofmt.cxx b/sw/source/core/edit/autofmt.cxx index 1109e5d..7ed1013 100644 --- a/sw/source/core/edit/autofmt.cxx +++ b/sw/source/core/edit/autofmt.cxx @@ -1420,11 +1420,10 @@ void SwAutoFormat::BuildEnum( sal_uInt16 nLvl, sal_uInt16 nDigitLevel ) // replace bullet character with defined one const OUString& rStr = m_pCurTextNd->GetText(); sal_Int32 nTextStt = 0; - const sal_Unicode* pFndBulletChr; - if( m_aFlags.bChgEnumNum && - 2 < rStr.getLength() && - nullptr != ( pFndBulletChr = StrChr( pBulletChar, rStr[ nTextStt ] )) - && IsSpace( rStr[ nTextStt + 1 ] ) ) + const sal_Unicode* pFndBulletChr = nullptr; + if (m_aFlags.bChgEnumNum && 2 < rStr.getLength()) + pFndBulletChr = StrChr(pBulletChar, rStr[nTextStt]); + if (nullptr != pFndBulletChr && IsSpace(rStr[nTextStt + 1])) { if( m_aFlags.bAFormatByInput ) { diff --git a/sw/source/core/edit/edlingu.cxx b/sw/source/core/edit/edlingu.cxx index bbb479f..b1c7e17 100644 --- a/sw/source/core/edit/edlingu.cxx +++ b/sw/source/core/edit/edlingu.cxx @@ -849,12 +849,13 @@ uno::Reference< XSpellAlternatives > SwPosition aPos( *pCursor->GetPoint() ); Point aPt( *pPt ); SwCursorMoveState eTmpState( MV_SETONLYTEXT ); - SwTextNode *pNode; - SwWrongList *pWrong; - if( GetLayout()->GetCursorOfst( &aPos, aPt, &eTmpState ) && - nullptr != (pNode = aPos.nNode.GetNode().GetTextNode()) && - nullptr != (pWrong = pNode->GetWrong()) && - !pNode->IsInProtectSect() ) + SwTextNode *pNode = nullptr; + SwWrongList *pWrong = nullptr; + if (GetLayout()->GetCursorOfst( &aPos, aPt, &eTmpState )) + pNode = aPos.nNode.GetNode().GetTextNode(); + if (nullptr != pNode) + pWrong = pNode->GetWrong(); + if (nullptr != pWrong && !pNode->IsInProtectSect()) { sal_Int32 nBegin = aPos.nContent.GetIndex(); sal_Int32 nLen = 1; @@ -960,12 +961,13 @@ bool SwEditShell::GetGrammarCorrection( SwPosition aPos( *pCursor->GetPoint() ); Point aPt( *pPt ); SwCursorMoveState eTmpState( MV_SETONLYTEXT ); - SwTextNode *pNode; - SwGrammarMarkUp *pWrong; - if( GetLayout()->GetCursorOfst( &aPos, aPt, &eTmpState ) && - nullptr != (pNode = aPos.nNode.GetNode().GetTextNode()) && - nullptr != (pWrong = pNode->GetGrammarCheck()) && - !pNode->IsInProtectSect() ) + SwTextNode *pNode = nullptr; + SwGrammarMarkUp *pWrong = nullptr; + if (GetLayout()->GetCursorOfst( &aPos, aPt, &eTmpState )) + pNode = aPos.nNode.GetNode().GetTextNode(); + if (nullptr != pNode) + pWrong = pNode->GetGrammarCheck(); + if (nullptr != pWrong && !pNode->IsInProtectSect()) { sal_Int32 nBegin = aPos.nContent.GetIndex(); sal_Int32 nLen = 1; diff --git a/sw/source/core/frmedt/fecopy.cxx b/sw/source/core/frmedt/fecopy.cxx index 330c677..419c147 100644 --- a/sw/source/core/frmedt/fecopy.cxx +++ b/sw/source/core/frmedt/fecopy.cxx @@ -580,11 +580,11 @@ bool SwFEShell::Copy( SwFEShell* pDestShell, const Point& rSttPt, // Sizes will be corrected by percentage. // find boxes via the layout - const SwTableNode* pTableNd; SwSelBoxes aBoxes; GetTableSel( *this, aBoxes ); - if( !aBoxes.empty() && - nullptr != (pTableNd = aBoxes[0]->GetSttNd()->FindTableNode()) ) + SwTableNode const*const pTableNd( + aBoxes.empty() ? nullptr : aBoxes[0]->GetSttNd()->FindTableNode()); + if (nullptr != pTableNd) { SwPosition* pDstPos = nullptr; if( this == pDestShell ) @@ -696,7 +696,7 @@ bool SwFEShell::Paste( SwDoc* pClpDoc ) // (individual boxes in the area are retrieved via the layout) SwFieldType* pTableFieldTyp = GetDoc()->getIDocumentFieldsAccess().GetSysFieldType( RES_TABLEFLD ); - SwTableNode *pDestNd, *pSrcNd = aCpyPam.GetNode().GetTableNode(); + SwTableNode *const pSrcNd = aCpyPam.GetNode().GetTableNode(); if( !pSrcNd ) // TabellenNode ? { // nicht ueberspringen!! SwContentNode* pCNd = aCpyPam.GetNode().GetContentNode(); @@ -830,8 +830,8 @@ bool SwFEShell::Paste( SwDoc* pClpDoc ) for(SwPaM& rPaM : GetCursor()->GetRingContainer()) { - if( pSrcNd && - nullptr != ( pDestNd = GetDoc()->IsIdxInTable( rPaM.GetPoint()->nNode )) && + SwTableNode *const pDestNd(GetDoc()->IsIdxInTable(rPaM.GetPoint()->nNode)); + if (pSrcNd && nullptr != pDestNd && // are we at the beginning of the cell? (if not, we will insert a nested table) // first paragraph of the cell? rPaM.GetNode().GetIndex() == rPaM.GetNode().FindTableBoxStartNode()->GetIndex()+1 && diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx index 1509b74..b73b625 100644 --- a/sw/source/core/layout/paintfrm.cxx +++ b/sw/source/core/layout/paintfrm.cxx @@ -7634,8 +7634,9 @@ Graphic SwFlyFrameFormat::MakeGraphic( ImageMap* pMap ) //search any Fly! SwIterator<SwFrame,SwFormat> aIter( *this ); SwFrame *pFirst = aIter.First(); - SwViewShell *pSh; - if ( pFirst && nullptr != ( pSh = pFirst->getRootFrame()->GetCurrShell()) ) + SwViewShell *const pSh = + (pFirst) ? pFirst->getRootFrame()->GetCurrShell() : nullptr; + if (nullptr != pSh) { SwViewShell *pOldGlobal = gProp.pSGlobalShell; gProp.pSGlobalShell = pSh; diff --git a/sw/source/core/text/txtfrm.cxx b/sw/source/core/text/txtfrm.cxx index 217f449..f1d5677 100644 --- a/sw/source/core/text/txtfrm.cxx +++ b/sw/source/core/text/txtfrm.cxx @@ -750,10 +750,16 @@ void SwTextFrame::CalcLineSpace() if( IsLocked() || !HasPara() ) return; - SwParaPortion *pPara; if( GetDrawObjs() || - GetTextNode()->GetSwAttrSet().GetLRSpace().IsAutoFirst() || - ( pPara = GetPara() )->IsFixLineHeight() ) + GetTextNode()->GetSwAttrSet().GetLRSpace().IsAutoFirst()) + { + Init(); + return; + } + + SwParaPortion *const pPara(GetPara()); + assert(pPara); + if (pPara->IsFixLineHeight()) { Init(); return; diff --git a/sw/source/core/txtnode/txtedt.cxx b/sw/source/core/txtnode/txtedt.cxx index 4fead8e..7ab42af 100644 --- a/sw/source/core/txtnode/txtedt.cxx +++ b/sw/source/core/txtnode/txtedt.cxx @@ -446,7 +446,7 @@ void SwTextNode::RstTextAttr( // iterate over attribute array until start of attribute is behind deletion range size_t i = 0; - sal_Int32 nAttrStart; + sal_Int32 nAttrStart = sal_Int32(); SwTextAttr *pHt = nullptr; while ( (i < m_pSwpHints->Count()) && ( ( ( nAttrStart = m_pSwpHints->Get(i)->GetStart()) < nEnd ) _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits