From 49747ff2337fd1f4a3ee8e16d6328b8dacad99ec Mon Sep 17 00:00:00 2001 From: Mike Kaganski Date: Sat, 3 Nov 2018 15:43:04 +0300 Subject: tdf#120703 PVS: V547 Expression is always true/false Change-Id: I75082c85862b83ed2503900186ce9c70783e54db Reviewed-on: https://gerrit.libreoffice.org/62817 Tested-by: Jenkins Reviewed-by: Mike Kaganski --- sw/source/core/doc/DocumentRedlineManager.cxx | 18 ++++++++---------- sw/source/core/draw/dview.cxx | 11 ++--------- sw/source/filter/ww8/docxattributeoutput.cxx | 21 ++++++--------------- 3 files changed, 16 insertions(+), 34 deletions(-) (limited to 'sw') diff --git a/sw/source/core/doc/DocumentRedlineManager.cxx b/sw/source/core/doc/DocumentRedlineManager.cxx index 4e203e565108..be9f7610bee3 100644 --- a/sw/source/core/doc/DocumentRedlineManager.cxx +++ b/sw/source/core/doc/DocumentRedlineManager.cxx @@ -729,7 +729,8 @@ void DocumentRedlineManager::SetRedlineFlags( RedlineFlags eMode ) bool bSaveInXMLImportFlag = m_rDoc.IsInXMLImport(); m_rDoc.SetInXMLImport( false ); // and then hide/display everything - void (SwRangeRedline::*pFnc)(sal_uInt16, size_t) = nullptr; + void (SwRangeRedline::*pFnc)(sal_uInt16, size_t); // Allow compiler warn if use of + // uninitialized ptr is possible RedlineFlags eShowMode = RedlineFlags::ShowMask & eMode; if (eShowMode == (RedlineFlags::ShowInsert | RedlineFlags::ShowDelete)) @@ -747,16 +748,13 @@ void DocumentRedlineManager::SetRedlineFlags( RedlineFlags eMode ) CheckAnchoredFlyConsistency(m_rDoc); CHECK_REDLINE( *this ) - if (pFnc) - { - for (sal_uInt16 nLoop = 1; nLoop <= 2; ++nLoop) - for (size_t i = 0; i < mpRedlineTable->size(); ++i) - ((*mpRedlineTable)[i]->*pFnc)(nLoop, i); + for (sal_uInt16 nLoop = 1; nLoop <= 2; ++nLoop) + for (size_t i = 0; i < mpRedlineTable->size(); ++i) + ((*mpRedlineTable)[i]->*pFnc)(nLoop, i); - //SwRangeRedline::MoveFromSection routinely changes - //the keys that mpRedlineTable is sorted by - mpRedlineTable->Resort(); - } + //SwRangeRedline::MoveFromSection routinely changes + //the keys that mpRedlineTable is sorted by + mpRedlineTable->Resort(); CheckAnchoredFlyConsistency(m_rDoc); CHECK_REDLINE( *this ) diff --git a/sw/source/core/draw/dview.cxx b/sw/source/core/draw/dview.cxx index e97a4a70954f..9cafe342e3a6 100644 --- a/sw/source/core/draw/dview.cxx +++ b/sw/source/core/draw/dview.cxx @@ -954,16 +954,9 @@ void SwDrawView::DeleteMarked() pTmpRoot->StartAllAction(); pDoc->GetIDocumentUndoRedo().StartUndo(SwUndoId::EMPTY, nullptr); // replace marked -objects by its reference objects. + if (SdrPageView* pDrawPageView = m_rImp.GetPageView()) { - SdrPageView* pDrawPageView = m_rImp.GetPageView(); - if ( pDrawPageView ) - { - SdrMarkView* pMarkView = &(pDrawPageView->GetView()); - if ( pMarkView ) - { - ReplaceMarkedDrawVirtObjs( *pMarkView ); - } - } + ReplaceMarkedDrawVirtObjs(pDrawPageView->GetView()); } // Check what textboxes have to be deleted afterwards. diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index 47022173a6ea..b691312b5794 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -6178,7 +6178,7 @@ void DocxAttributeOutput::SectionType( sal_uInt8 nBreakCode ) /* break code: 0 No break, 1 New column 2 New page, 3 Even page, 4 Odd page */ - const char* pType = nullptr; + const char* pType; switch ( nBreakCode ) { case 1: pType = "nextColumn"; break; @@ -6188,10 +6188,7 @@ void DocxAttributeOutput::SectionType( sal_uInt8 nBreakCode ) default: pType = "continuous"; break; } - if ( pType ) - m_pSerializer->singleElementNS( XML_w, XML_type, - FSNS( XML_w, XML_val ), pType, - FSEND ); + m_pSerializer->singleElementNS(XML_w, XML_type, FSNS(XML_w, XML_val), pType, FSEND); } void DocxAttributeOutput::TextVerticalAdjustment( const drawing::TextVerticalAdjust nVA ) @@ -6254,7 +6251,7 @@ void DocxAttributeOutput::FontCharset( sal_uInt8 nCharSet, rtl_TextEncoding nEnc void DocxAttributeOutput::FontFamilyType( FontFamily eFamily ) const { - const char *pFamily = nullptr; + const char* pFamily; switch ( eFamily ) { case FAMILY_ROMAN: pFamily = "roman"; break; @@ -6265,15 +6262,12 @@ void DocxAttributeOutput::FontFamilyType( FontFamily eFamily ) const default: pFamily = "auto"; break; // no font family } - if ( pFamily ) - m_pSerializer->singleElementNS( XML_w, XML_family, - FSNS( XML_w, XML_val ), pFamily, - FSEND ); + m_pSerializer->singleElementNS(XML_w, XML_family, FSNS(XML_w, XML_val), pFamily, FSEND); } void DocxAttributeOutput::FontPitchType( FontPitch ePitch ) const { - const char *pPitch = nullptr; + const char* pPitch; switch ( ePitch ) { case PITCH_VARIABLE: pPitch = "variable"; break; @@ -6281,10 +6275,7 @@ void DocxAttributeOutput::FontPitchType( FontPitch ePitch ) const default: pPitch = "default"; break; // no info about the pitch } - if ( pPitch ) - m_pSerializer->singleElementNS( XML_w, XML_pitch, - FSNS( XML_w, XML_val ), pPitch, - FSEND ); + m_pSerializer->singleElementNS(XML_w, XML_pitch, FSNS(XML_w, XML_val), pPitch, FSEND); } void DocxAttributeOutput::EmbedFont( const OUString& name, FontFamily family, FontPitch pitch ) -- cgit