[Libreoffice-commits] core.git: 2 commits - basic/source canvas/source dbaccess/source sd/source sw/source vcl/source vcl/win

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Sun Dec 2 04:31:35 UTC 2018


 basic/source/sbx/sbxform.cxx                       |    2 -
 canvas/source/simplecanvas/simplecanvasimpl.cxx    |    4 +--
 dbaccess/source/ui/querydesign/querycontroller.cxx |    2 -
 sd/source/core/sdpage.cxx                          |    3 --
 sd/source/core/sdpage2.cxx                         |    6 +----
 sd/source/ui/app/sdmod2.cxx                        |    2 -
 sd/source/ui/app/sdxfer.cxx                        |    2 -
 sd/source/ui/view/sdview.cxx                       |    4 +--
 sd/source/ui/view/sdview2.cxx                      |   11 ++++++---
 sw/source/core/docnode/section.cxx                 |   11 ++++-----
 sw/source/core/layout/sectfrm.cxx                  |    6 ++---
 sw/source/uibase/wrtsh/select.cxx                  |    2 -
 vcl/source/fontsubset/sft.cxx                      |    2 -
 vcl/win/gdi/salnativewidgets-luna.cxx              |   24 ++++++++++-----------
 vcl/win/window/salframe.cxx                        |    9 +++----
 15 files changed, 44 insertions(+), 46 deletions(-)

New commits:
commit 4da61d4cc8f70ff62d7bac23a1b97d9d7011a678
Author:     Mike Kaganski <mike.kaganski at collabora.com>
AuthorDate: Sun Dec 2 01:14:15 2018 +0300
Commit:     Mike Kaganski <mike.kaganski at collabora.com>
CommitDate: Sun Dec 2 05:31:19 2018 +0100

    tdf#120703 PVS: logical AND had been used instead of bitwise
    
    V560 A part of conditional expression is always true:
         sal_Int32(0xFF) != 0.
    
    Change-Id: I5f19c4ff20e91767d22a85239f9693d68ff360b1
    Reviewed-on: https://gerrit.libreoffice.org/64414
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>

diff --git a/canvas/source/simplecanvas/simplecanvasimpl.cxx b/canvas/source/simplecanvas/simplecanvasimpl.cxx
index fe558b0a8886..2e38ee8ffc2b 100644
--- a/canvas/source/simplecanvas/simplecanvasimpl.cxx
+++ b/canvas/source/simplecanvas/simplecanvasimpl.cxx
@@ -112,7 +112,7 @@ namespace
     private:
         bool isStrokingEnabled() const
         {
-            return maRenderState.m_aPenColor.getInValue() && sal_Int32(0xFF) != 0;
+            return maRenderState.m_aPenColor.getInValue() % 0x100 != 0;
         }
 
         rendering::RenderState createStrokingRenderState() const
@@ -125,7 +125,7 @@ namespace
 
         bool isFillingEnabled() const
         {
-            return maRenderState.m_aFillColor.getInValue() && sal_Int32(0xFF) != 0;
+            return maRenderState.m_aFillColor.getInValue() % 0x100 != 0;
         }
 
         rendering::RenderState createFillingRenderState() const
commit 1f2d3b3f09d16033dae1f99f7739564a5f4c5482
Author:     Mike Kaganski <mike.kaganski at collabora.com>
AuthorDate: Sun Dec 2 00:59:58 2018 +0300
Commit:     Mike Kaganski <mike.kaganski at collabora.com>
CommitDate: Sun Dec 2 05:31:10 2018 +0100

    tdf#120703 PVS: V560 A part of conditional expression is always true/false
    
    Change-Id: Ia9c496ec93bedb13764969bf21c3f21d84caacef
    Reviewed-on: https://gerrit.libreoffice.org/64413
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>

diff --git a/basic/source/sbx/sbxform.cxx b/basic/source/sbx/sbxform.cxx
index 45a88b556546..ce394fa903b3 100644
--- a/basic/source/sbx/sbxform.cxx
+++ b/basic/source/sbx/sbxform.cxx
@@ -647,7 +647,7 @@ void SbxBasicFormater::ScanFormatString( double dNumber,
                     // Remark: in Visual-Basic the first 0 turns on the 0 for
                     //         all the following # (up to the decimal point),
                     //         this behaviour is simulated here with the flag.
-                    if( bGenerateThousandSeparator && ( c=='0' || nMaxDigit >= nDigitPos ) && nDigitPos > 0 && (nDigitPos % 3 == 0) )
+                    if (bGenerateThousandSeparator && c == '0' && nDigitPos > 0 && (nDigitPos % 3 == 0))
                     {
                         sReturnStrg.append(cThousandSep);
                     }
diff --git a/dbaccess/source/ui/querydesign/querycontroller.cxx b/dbaccess/source/ui/querydesign/querycontroller.cxx
index b47c8727bf3e..9a42963ffdfa 100644
--- a/dbaccess/source/ui/querydesign/querycontroller.cxx
+++ b/dbaccess/source/ui/querydesign/querycontroller.cxx
@@ -1200,7 +1200,7 @@ bool OQueryController::askForNewName(const Reference<XNameAccess>& _xElements, b
     if(bNew)
     {
         OUString aDefaultName;
-        if ( ( _bSaveAs && !bNew ) || ( bNew && !m_sName.isEmpty() ) )
+        if (!m_sName.isEmpty())
             aDefaultName = m_sName;
         else
         {
diff --git a/sd/source/core/sdpage.cxx b/sd/source/core/sdpage.cxx
index 6475a933cfb0..5fdbd63e8007 100644
--- a/sd/source/core/sdpage.cxx
+++ b/sd/source/core/sdpage.cxx
@@ -2902,8 +2902,7 @@ bool SdPage::RestoreDefaultText( SdrObject* pObj )
                     // OutlinerParaObjects needs to be changed. The
                     // AutoGrowWidth/Height items still exist in the
                     // not changed object.
-                    if(pTextObj
-                        && pTextObj->GetOutlinerParaObject()
+                    if(pTextObj->GetOutlinerParaObject()
                         && pTextObj->GetOutlinerParaObject()->IsVertical() != bVertical)
                     {
                         ::tools::Rectangle aObjectRect = pTextObj->GetSnapRect();
diff --git a/sd/source/core/sdpage2.cxx b/sd/source/core/sdpage2.cxx
index 93d56c50b36c..0744eca27585 100644
--- a/sd/source/core/sdpage2.cxx
+++ b/sd/source/core/sdpage2.cxx
@@ -480,15 +480,13 @@ void SdPage::RemoveEmptyPresentationObjects()
 {
     SdrObjListIter  aShapeIter( this, SdrIterMode::DeepWithGroups );
 
-    SdrObject* pShape;
-    for( pShape = aShapeIter.Next(); pShape; pShape = aShapeIter.Next() )
+    for (SdrObject* pShape = aShapeIter.Next(); pShape; pShape = aShapeIter.Next())
     {
-        if( pShape && pShape->IsEmptyPresObj() )
+        if (pShape->IsEmptyPresObj())
         {
             RemoveObject( pShape->GetOrdNum() );
             SdrObject::Free( pShape );
         }
-
     }
 }
 
diff --git a/sd/source/ui/app/sdmod2.cxx b/sd/source/ui/app/sdmod2.cxx
index 979b46c1c3da..04aa3657adf7 100644
--- a/sd/source/ui/app/sdmod2.cxx
+++ b/sd/source/ui/app/sdmod2.cxx
@@ -135,7 +135,7 @@ static SdPage* GetCurrentPage( sd::ViewShell const * pViewSh, EditFieldInfo cons
 
         if(pPage)
         {
-            bMasterView = pPage && pPage->IsMasterPage();
+            bMasterView = pPage->IsMasterPage();
         }
     }
 
diff --git a/sd/source/ui/app/sdxfer.cxx b/sd/source/ui/app/sdxfer.cxx
index 14543f4f1a76..2c873604aa30 100644
--- a/sd/source/ui/app/sdxfer.cxx
+++ b/sd/source/ui/app/sdxfer.cxx
@@ -177,7 +177,7 @@ void SdTransferable::CreateObjectReplacement( SdrObject* pObj )
         {
             SdrUnoObj* pUnoCtrl = static_cast< SdrUnoObj* >( pObj );
 
-            if (pUnoCtrl && SdrInventor::FmForm == pUnoCtrl->GetObjInventor())
+            if (SdrInventor::FmForm == pUnoCtrl->GetObjInventor())
             {
                 const Reference< css::awt::XControlModel >& xControlModel( pUnoCtrl->GetUnoControlModel() );
 
diff --git a/sd/source/ui/view/sdview.cxx b/sd/source/ui/view/sdview.cxx
index caee8aba20c0..5938c80428d8 100644
--- a/sd/source/ui/view/sdview.cxx
+++ b/sd/source/ui/view/sdview.cxx
@@ -1254,7 +1254,7 @@ bool View::ShouldToggleOn(
                         continue;
                     pOutliner->SetText(*(pText->GetOutlinerParaObject()));
                     sal_Int16 nStatus = pOutliner->GetBulletsNumberingStatus();
-                    bToggleOn = (bNormalBullet && nStatus != 0) || (!bNormalBullet && nStatus != 1) || bToggleOn;
+                    bToggleOn = (bNormalBullet && nStatus != 0) || (!bNormalBullet && nStatus != 1);
                     pOutliner->Clear();
                 }
             }
@@ -1266,7 +1266,7 @@ bool View::ShouldToggleOn(
                 continue;
             pOutliner->SetText(*pParaObj);
             sal_Int16 nStatus = pOutliner->GetBulletsNumberingStatus();
-            bToggleOn = (bNormalBullet && nStatus != 0) || (!bNormalBullet && nStatus != 1) || bToggleOn;
+            bToggleOn = (bNormalBullet && nStatus != 0) || (!bNormalBullet && nStatus != 1);
             pOutliner->Clear();
         }
     }
diff --git a/sd/source/ui/view/sdview2.cxx b/sd/source/ui/view/sdview2.cxx
index 13526f297954..cf5fc2cc27a4 100644
--- a/sd/source/ui/view/sdview2.cxx
+++ b/sd/source/ui/view/sdview2.cxx
@@ -282,7 +282,7 @@ void View::DoPaste (::sd::Window* pWindow)
             if( pObj && pPage && pPage->GetPresObjKind(pObj) == PRESOBJ_TITLE )
             {
                 // remove all hard linebreaks from the title
-                if( pOutliner && pOutliner->GetParagraphCount() > 1 )
+                if (pOutliner->GetParagraphCount() > 1)
                 {
                     bool bOldUpdateMode = pOutliner->GetUpdateMode();
 
@@ -305,7 +305,7 @@ void View::DoPaste (::sd::Window* pWindow)
 
             if( !mrDoc.IsChanged() )
             {
-                if( pOutliner && pOutliner->IsModified() )
+                if (pOutliner->IsModified())
                     mrDoc.SetChanged();
             }
         }
@@ -502,7 +502,8 @@ sal_Int8 View::AcceptDrop( const AcceptDropEvent& rEvt, DropTargetHelper& rTarge
                 bool        bXFillExchange = rTargetHelper.IsDropFormatSupported( SotClipboardFormatId::XFA );
 
                 // check handle insert
-                if( !nRet && ( (bXFillExchange && ( SdrDragMode::Gradient == GetDragMode() )) || ( SdrDragMode::Transparence == GetDragMode() ) ) )
+                if ((bXFillExchange && (SdrDragMode::Gradient == GetDragMode()))
+                    || (SdrDragMode::Transparence == GetDragMode()))
                 {
                     const SdrHdlList& rHdlList = GetHdlList();
 
@@ -654,7 +655,9 @@ sal_Int8 View::ExecuteDrop( const ExecuteDropEvent& rEvt,
                 aPos = pTargetWindow->PixelToLogic( rEvt.maPosPixel );
 
             // handle insert?
-            if( (!nRet && ( SdrDragMode::Gradient == GetDragMode() )) || (( SdrDragMode::Transparence == GetDragMode() ) && aDataHelper.HasFormat( SotClipboardFormatId::XFA )) )
+            if ((SdrDragMode::Gradient == GetDragMode())
+                || ((SdrDragMode::Transparence == GetDragMode())
+                    && aDataHelper.HasFormat(SotClipboardFormatId::XFA)))
             {
                 const SdrHdlList& rHdlList = GetHdlList();
 
diff --git a/sw/source/core/docnode/section.cxx b/sw/source/core/docnode/section.cxx
index 80ae308c4b85..bf052828f906 100644
--- a/sw/source/core/docnode/section.cxx
+++ b/sw/source/core/docnode/section.cxx
@@ -595,10 +595,9 @@ void SwSection::MakeChildLinksVisible( const SwSectionNode& rSectNd )
     const ::sfx2::SvBaseLinks& rLnks = rSectNd.GetDoc()->getIDocumentLinksAdministration().GetLinkManager().GetLinks();
     for( auto n = rLnks.size(); n; )
     {
-        ::sfx2::SvBaseLink* pBLnk = &(*rLnks[ --n ]);
-        if( pBLnk && !pBLnk->IsVisible() &&
-            dynamic_cast< const SwBaseLink *>( pBLnk ) !=  nullptr &&
-            nullptr != ( pNd = static_cast<SwBaseLink*>(pBLnk)->GetAnchor() ) )
+        sfx2::SvBaseLink& rBLnk = *rLnks[--n];
+        if (!rBLnk.IsVisible() && dynamic_cast<const SwBaseLink*>(&rBLnk) != nullptr
+            && nullptr != (pNd = static_cast<SwBaseLink&>(rBLnk).GetAnchor()))
         {
             pNd = pNd->StartOfSectionNode(); // If it's a SectionNode
             const SwSectionNode* pParent;
@@ -609,7 +608,7 @@ void SwSection::MakeChildLinksVisible( const SwSectionNode& rSectNd )
 
             // It's within a normal Section, so show again
             if( !pParent )
-                pBLnk->SetVisible( true );
+                rBLnk.SetVisible(true);
         }
     }
 }
@@ -1134,7 +1133,7 @@ static void lcl_UpdateLinksInSect( SwBaseLink& rUpdLnk, SwSectionNode& rSectNd )
         SwBaseLink* pBLink;
 
         ::sfx2::SvBaseLink* pLnk = &(*rLnks[ --n ]);
-        if( pLnk && pLnk != &rUpdLnk &&
+        if( pLnk != &rUpdLnk &&
             OBJECT_CLIENT_FILE == pLnk->GetObjType() &&
             dynamic_cast< const SwBaseLink *>( pLnk ) !=  nullptr &&
             ( pBLink = static_cast<SwBaseLink*>(pLnk) )->IsInRange( rSectNd.GetIndex(),
diff --git a/sw/source/core/layout/sectfrm.cxx b/sw/source/core/layout/sectfrm.cxx
index 093d84d04f4e..0596f5076418 100644
--- a/sw/source/core/layout/sectfrm.cxx
+++ b/sw/source/core/layout/sectfrm.cxx
@@ -613,8 +613,8 @@ static SwContentFrame* lcl_GetNextContentFrame( const SwLayoutFrame* pLay, bool
         }
 
         bGoingUp = !( bGoingFwdOrBwd || bGoingDown );
-
-        if( !bFwd && bGoingDown && p )
+        assert(p);
+        if (!bFwd && bGoingDown)
             while ( p->GetNext() )
                 p = p->GetNext();
 
@@ -2184,7 +2184,7 @@ SwTwips SwSectionFrame::Grow_( SwTwips nDist, bool bTst )
             if( nGrow <= 0 )
             {
                 nGrow = 0;
-                if( nDist && !bTst )
+                if (!bTst)
                 {
                     if( bInCalcContent )
                         InvalidateSize_();
diff --git a/sw/source/uibase/wrtsh/select.cxx b/sw/source/uibase/wrtsh/select.cxx
index 3f4c2540f006..6459ef5284ff 100644
--- a/sw/source/uibase/wrtsh/select.cxx
+++ b/sw/source/uibase/wrtsh/select.cxx
@@ -880,7 +880,7 @@ int SwWrtShell::IntelligentCut(SelectionType nSelection, bool bCut)
 
     int cWord = NO_WORD;
         // is a word selected?
-    if(!cWord && cPrev && cNext &&
+    if (cPrev && cNext &&
         CH_TXTATR_BREAKWORD != cPrev && CH_TXTATR_INWORD != cPrev &&
         CH_TXTATR_BREAKWORD != cNext && CH_TXTATR_INWORD != cNext &&
         !rCC.isLetterNumeric( ( sText = OUString(cPrev) ), 0 ) &&
diff --git a/vcl/source/fontsubset/sft.cxx b/vcl/source/fontsubset/sft.cxx
index 9262c2bca365..e9225e8bb8bf 100644
--- a/vcl/source/fontsubset/sft.cxx
+++ b/vcl/source/fontsubset/sft.cxx
@@ -1070,7 +1070,7 @@ static sal_uInt32 getGlyph2(const sal_uInt8 *cmap, const sal_uInt32 nMaxCmapSize
     {
         k = Int16FromMOTA(subHeader2Keys[theHighByte]) / 8;
         // check if the subheader record fits into available space
-        if((k >= 0) && (reinterpret_cast<sal_uInt8 const *>(&subHeader2s[k]) - cmap >= int(nMaxCmapSize - sizeof(subHeader2))))
+        if(reinterpret_cast<sal_uInt8 const *>(&subHeader2s[k]) - cmap >= int(nMaxCmapSize - sizeof(subHeader2)))
             k = -1;
     }
 
diff --git a/vcl/win/gdi/salnativewidgets-luna.cxx b/vcl/win/gdi/salnativewidgets-luna.cxx
index 00c5c4c3c6f7..bda55c40fabf 100644
--- a/vcl/win/gdi/salnativewidgets-luna.cxx
+++ b/vcl/win/gdi/salnativewidgets-luna.cxx
@@ -871,15 +871,15 @@ static bool ImplDrawNativeControl( HDC hDC, HTHEME hTheme, RECT rc,
 
         OSL_ASSERT( aValue.getType() == ControlType::TabItem );
 
-        const TabitemValue *pValue = static_cast<const TabitemValue*>(&aValue);
-        if( pValue->isBothAligned() )
+        const TabitemValue& rValue = static_cast<const TabitemValue&>(aValue);
+        if (rValue.isBothAligned())
         {
             iPart = TABP_TABITEMLEFTEDGE;
             rc.right--;
         }
-        else if( pValue->isLeftAligned() )
+        else if (rValue.isLeftAligned())
             iPart = TABP_TABITEMLEFTEDGE;
-        else if( pValue->isRightAligned() )
+        else if (rValue.isRightAligned())
             iPart = TABP_TABITEMRIGHTEDGE;
         else iPart = TABP_TABITEM;
 
@@ -890,11 +890,11 @@ static bool ImplDrawNativeControl( HDC hDC, HTHEME hTheme, RECT rc,
             iState = TILES_SELECTED;
             // increase the selected tab
             rc.left-=2;
-            if( pValue && !pValue->isBothAligned() )
+            if (rValue.isBothAligned())
             {
-                if( pValue->isLeftAligned() || pValue->isNotAligned() )
+                if (rValue.isLeftAligned() || rValue.isNotAligned())
                     rc.right+=2;
-                if( pValue->isRightAligned() )
+                if (rValue.isRightAligned())
                     rc.right+=1;
             }
             rc.top-=2;
@@ -1498,18 +1498,18 @@ bool WinSalGraphics::getNativeControlRegion(  ControlType nType,
 
         if( rControlValue.getType() == ControlType::TabItem )
         {
-            const TabitemValue *pValue = static_cast<const TabitemValue*>(&rControlValue);
-            if ( pValue->isBothAligned() )
+            const TabitemValue& rValue = static_cast<const TabitemValue&>(rControlValue);
+            if (rValue.isBothAligned())
                 aControlRect.AdjustRight(-1);
 
             if ( nState & ControlState::SELECTED )
             {
                 aControlRect.AdjustLeft(-2);
-                if ( pValue && !pValue->isBothAligned() )
+                if (!rValue.isBothAligned())
                 {
-                    if ( pValue->isLeftAligned() || pValue->isNotAligned() )
+                    if (rValue.isLeftAligned() || rValue.isNotAligned())
                         aControlRect.AdjustRight(2);
-                    if ( pValue->isRightAligned() )
+                    if (rValue.isRightAligned())
                         aControlRect.AdjustRight(1);
                 }
                 aControlRect.AdjustTop(-2);
diff --git a/vcl/win/window/salframe.cxx b/vcl/win/window/salframe.cxx
index c3e2d294e155..50f9940ae2e9 100644
--- a/vcl/win/window/salframe.cxx
+++ b/vcl/win/window/salframe.cxx
@@ -2339,12 +2339,12 @@ OUString WinSalFrame::GetKeyName( sal_uInt16 nKeyCode )
     {
         nSysCode = VK_F1 + (nCode - KEY_F1);
         aFBuf[0] = 'F';
-        if ( (nCode >= KEY_F1) && (nCode <= KEY_F9) )
+        if (nCode <= KEY_F9)
         {
             aFBuf[1] = sal::static_int_cast<sal_Char>('1' + (nCode - KEY_F1));
             aFBuf[2] = 0;
         }
-        else if ( (nCode >= KEY_F10) && (nCode <= KEY_F19) )
+        else if (nCode <= KEY_F19)
         {
             aFBuf[1] = '1';
             aFBuf[2] = sal::static_int_cast<sal_Char>('0' + (nCode - KEY_F10));
@@ -3600,7 +3600,6 @@ bool ImplHandleSalObjKeyMsg( HWND hWnd, UINT nMsg,
         {
             SalKeyEvent     aKeyEvt;
             SalEvent        nEvent;
-            bool            bKeyUp = (nMsg == WM_KEYUP) || (nMsg == WM_SYSKEYUP);
 
             // convert KeyCode
             aKeyEvt.mnCode      = ImplSalGetKeyCode( wParam );
@@ -3608,7 +3607,7 @@ bool ImplHandleSalObjKeyMsg( HWND hWnd, UINT nMsg,
 
             if ( aKeyEvt.mnCode )
             {
-                if ( bKeyUp )
+                if (nMsg == WM_KEYUP)
                     nEvent = SalEvent::KeyUp;
                 else
                     nEvent = SalEvent::KeyInput;
@@ -4080,7 +4079,7 @@ static void ImplHandleForcePalette( HWND hWnd )
         if ( pFrame && pFrame->mpLocalGraphics && pFrame->mpLocalGraphics->getHDC() )
         {
             WinSalGraphics* pGraphics = pFrame->mpLocalGraphics;
-            if ( pGraphics && pGraphics->getDefPal() )
+            if (pGraphics->getDefPal())
             {
                 SelectPalette( pGraphics->getHDC(), hPal, FALSE );
                 if ( RealizePalette( pGraphics->getHDC() ) )


More information about the Libreoffice-commits mailing list