[Libreoffice-commits] core.git: 10 commits - basctl/source chart2/source editeng/source framework/source sw/source

Caolán McNamara caolanm at redhat.com
Sun Feb 9 09:14:13 PST 2014


 basctl/source/basicide/baside2.cxx         |   20 ++++++++++----------
 chart2/source/view/main/DummyXShape.cxx    |   29 +++++++++++++----------------
 editeng/source/editeng/editdoc.cxx         |    6 +++---
 framework/source/services/autorecovery.cxx |    4 +++-
 sw/source/core/docnode/ndtbl.cxx           |    2 +-
 sw/source/core/text/itrform2.hxx           |   10 +++++-----
 sw/source/core/text/itrpaint.hxx           |   15 ++++++++-------
 sw/source/filter/ww8/ww8atr.cxx            |    4 ++--
 8 files changed, 45 insertions(+), 45 deletions(-)

New commits:
commit 53c84ea21e4e709f3b40d5f56ce764f0c4ce1fc7
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Sun Feb 9 16:42:44 2014 +0000

    coverity#1169804 Unchecked return value
    
    Change-Id: I32fb858ab78a741a194ae11a3147645d786c9afe

diff --git a/framework/source/services/autorecovery.cxx b/framework/source/services/autorecovery.cxx
index 95362d7..faf8e86 100644
--- a/framework/source/services/autorecovery.cxx
+++ b/framework/source/services/autorecovery.cxx
@@ -4126,7 +4126,9 @@ AutoRecovery::EFailureSafeResult AutoRecovery::implts_copyFile(const OUString& s
 
     try
     {
-        ::ucbhelper::Content::create(sSource, xEnvironment, m_xContext, aSourceContent);
+        bool bSuccess = ::ucbhelper::Content::create(sSource, xEnvironment, m_xContext, aSourceContent);
+        if (!bSuccess)
+            return AutoRecovery::E_ORIGINAL_FILE_MISSING;
         aTargetContent.transferContent(aSourceContent, ::ucbhelper::InsertOperation_COPY, sTargetName, nNameClash);
     }
     catch(const css::uno::Exception&)
commit f2fb3c464716e5f14e5b966592adb5b6714c0566
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Sun Feb 9 16:36:42 2014 +0000

    coverity#1169806 Operands don't affect result
    
    Change-Id: I8c219ae3b1adcc615d75a61afba9414eb8acdc22

diff --git a/editeng/source/editeng/editdoc.cxx b/editeng/source/editeng/editdoc.cxx
index 51c0275..728badf 100644
--- a/editeng/source/editeng/editdoc.cxx
+++ b/editeng/source/editeng/editdoc.cxx
@@ -795,7 +795,7 @@ long ParaPortionList::GetYOffset(const ParaPortion* pPPortion) const
 sal_Int32 ParaPortionList::FindParagraph(long nYOffset) const
 {
     long nY = 0;
-    for (sal_Int32 i = 0, n = maPortions.size(); i < n; ++i)
+    for (size_t i = 0, n = maPortions.size(); i < n; ++i)
     {
         nY += maPortions[i].GetHeight(); // should also be correct even in bVisible!
         if ( nY > nYOffset )
commit 54cb92d14175af8991aa33eadf6396ef16835bb7
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Sun Feb 9 16:28:41 2014 +0000

    coverity#1169807 Operands don't affect result
    
    Change-Id: Ie96de8af75be60435f00593ca33d1dff2f42a02c

diff --git a/editeng/source/editeng/editdoc.cxx b/editeng/source/editeng/editdoc.cxx
index 296c132..51c0275 100644
--- a/editeng/source/editeng/editdoc.cxx
+++ b/editeng/source/editeng/editdoc.cxx
@@ -2062,7 +2062,7 @@ void EditDoc::Release(sal_Int32 nPos)
 
 sal_Int32 EditDoc::Count() const
 {
-    sal_Int32 nSize = maContents.size();
+    size_t nSize = maContents.size();
     if (nSize > SAL_MAX_INT32)
     {
         SAL_WARN( "editeng", "EditDoc::Count - overflow " << nSize);
commit 24c5cac41fc6592c0d5639be1ffa9fddcf7b0810
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Sun Feb 9 16:27:35 2014 +0000

    coverity#1169808 Operands don't affect result
    
    Change-Id: I95a3c09056a00a6839f25ecf54acc15e366cc360

diff --git a/editeng/source/editeng/editdoc.cxx b/editeng/source/editeng/editdoc.cxx
index 4732c62..296c132 100644
--- a/editeng/source/editeng/editdoc.cxx
+++ b/editeng/source/editeng/editdoc.cxx
@@ -764,7 +764,7 @@ void ParaPortionList::Append(ParaPortion* p)
 
 sal_Int32 ParaPortionList::Count() const
 {
-    sal_Int32 nSize = maPortions.size();
+    size_t nSize = maPortions.size();
     if (nSize > SAL_MAX_INT32)
     {
         SAL_WARN( "editeng", "ParaPortionList::Count - overflow " << nSize);
commit 6683634c7c683bda2081c9c36ae80115e8693206
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Sun Feb 9 16:19:34 2014 +0000

    coverity#1169816 Division or modulo by zero
    
    Change-Id: Ibd07c0d3766467f2b11b0a9fb18ca089ddcb1cb2

diff --git a/basctl/source/basicide/baside2.cxx b/basctl/source/basicide/baside2.cxx
index d8312b5..520b61c 100644
--- a/basctl/source/basicide/baside2.cxx
+++ b/basctl/source/basicide/baside2.cxx
@@ -886,26 +886,26 @@ sal_Int32 ModulWindow::FormatAndPrint( Printer* pPrinter, sal_Int32 nPrintPage )
 
     OUString aTitle( CreateQualifiedName() );
 
-    sal_uInt16 nLineHeight = (sal_uInt16) pPrinter->GetTextHeight();
+    sal_Int32 nLineHeight = pPrinter->GetTextHeight();
     if(nLineHeight == 0)
     {
         nLineHeight = 1;
     }
-    sal_uInt16 nParaSpace = 10;
+    sal_Int32 nParaSpace = 10;
 
     Size aPaperSz = pPrinter->GetOutputSize();
     aPaperSz.Width() -= (Print::nLeftMargin + Print::nRightMargin);
     aPaperSz.Height() -= (Print::nTopMargin + Print::nBottomMargin);
 
     // nLinepPage is not correct if there's a line break
-    sal_uInt16 nLinespPage = (sal_uInt16) (aPaperSz.Height()/nLineHeight);
-    long nXTextWidth = pPrinter->GetTextWidth( "X" );
+    sal_Int32 nLinespPage = aPaperSz.Height()/nLineHeight;
+    long nXTextWidth = pPrinter->approximate_char_width();
 
-    sal_uInt16 nCharspLine = (sal_uInt16) (aPaperSz.Width() / nXTextWidth > 1 ? nXTextWidth : 1);
+    sal_Int32 nCharspLine = aPaperSz.Width() / (nXTextWidth > 1 ? nXTextWidth : 1);
     sal_uLong nParas = GetEditEngine()->GetParagraphCount();
 
-    sal_uInt16 nPages = (sal_uInt16) (nParas/nLinespPage+1 );
-    sal_uInt16 nCurPage = 1;
+    sal_Int32 nPages = nParas/nLinespPage+1;
+    sal_Int32 nCurPage = 1;
 
     lcl_PrintHeader( pPrinter, nPages, nCurPage, aTitle, nPrintPage == 0 );
     Point aPos( Print::nLeftMargin, Print::nTopMargin );
@@ -913,8 +913,8 @@ sal_Int32 ModulWindow::FormatAndPrint( Printer* pPrinter, sal_Int32 nPrintPage )
     {
         OUString aLine( GetEditEngine()->GetText( nPara ) );
         lcl_ConvertTabsToSpaces( aLine );
-        sal_uInt16 nLines = aLine.getLength()/nCharspLine+1;
-        for ( sal_uInt16 nLine = 0; nLine < nLines; nLine++ )
+        sal_Int32 nLines = aLine.getLength()/nCharspLine+1;
+        for (sal_Int32 nLine = 0; nLine < nLines; ++nLine)
         {
             sal_Int32 nBeginIndex = nLine*nCharspLine;
             sal_Int32 nCopyCount = std::min<sal_Int32>(nCharspLine, aLine.getLength()-nBeginIndex);
@@ -935,7 +935,7 @@ sal_Int32 ModulWindow::FormatAndPrint( Printer* pPrinter, sal_Int32 nPrintPage )
     pPrinter->SetFont( aOldFont );
     pPrinter->SetMapMode( eOldMapMode );
 
-    return sal_Int32(nCurPage);
+    return nCurPage;
 }
 
 
commit 9d97cf74dc0eb51ebf0406c072489ed035b32463
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Sun Feb 9 16:09:17 2014 +0000

    coverity#1169817 Unchecked dynamic_cast
    
    Change-Id: I7ec12380f2f010ad04f4fd36b6a53f287a12fd3f

diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx
index 5e43c77..9e8b26f 100644
--- a/sw/source/filter/ww8/ww8atr.cxx
+++ b/sw/source/filter/ww8/ww8atr.cxx
@@ -432,11 +432,11 @@ void MSWordExportBase::OutputSectionBreaks( const SfxItemSet *pSet, const SwNode
     if ( pSet && pSet->Count() )
     {
         if ( SFX_ITEM_SET == pSet->GetItemState( RES_PAGEDESC, false, &pItem ) &&
-             dynamic_cast<const SwFmtPageDesc*>(pItem)->GetRegisteredIn() != NULL)
+             static_cast<const SwFmtPageDesc*>(pItem)->GetRegisteredIn() != NULL)
         {
             bBreakSet = true;
             bNewPageDesc = true;
-            pPgDesc = (const SwFmtPageDesc*)pItem;
+            pPgDesc = static_cast<const SwFmtPageDesc*>(pItem);
             pAktPageDesc = pPgDesc->GetPageDesc();
         }
         else if ( SFX_ITEM_SET == pSet->GetItemState( RES_BREAK, false, &pItem ) )
commit 506e8ad83a706cf725910c4734ac7ad2626af95a
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Sun Feb 9 16:06:33 2014 +0000

    coverity#1169819 Unchecked dynamic_cast
    
    Change-Id: I8db30306719ea297f312453d81601983e708ad33

diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx
index 0d08fab..406e368 100644
--- a/sw/source/core/docnode/ndtbl.cxx
+++ b/sw/source/core/docnode/ndtbl.cxx
@@ -4438,7 +4438,7 @@ sal_Bool SwDoc::UnProtectCells( const SwSelBoxes& rBoxes )
                 else
                 {
                     SwTableBoxFmt *const pNewBoxFmt(
-                        dynamic_cast<SwTableBoxFmt*>(pBox->ClaimFrmFmt()));
+                        static_cast<SwTableBoxFmt*>(pBox->ClaimFrmFmt()));
                     pNewBoxFmt->ResetFmtAttr( RES_PROTECT );
                     aFmtsMap.insert(std::make_pair(pBoxFmt, pNewBoxFmt));
                 }
commit 327010784c4ea3d8ead3eb7053c7d293e3b13afd
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Sun Feb 9 16:03:34 2014 +0000

    1169820 Dereference after null check
    
    Change-Id: I0390add3651df64ab41212cb62a8a450d8d3babd

diff --git a/sw/source/core/text/itrform2.hxx b/sw/source/core/text/itrform2.hxx
index 21eee9b..240bcc4 100644
--- a/sw/source/core/text/itrform2.hxx
+++ b/sw/source/core/text/itrform2.hxx
@@ -153,12 +153,12 @@ public:
     bool CalcOnceMore();
 
     void CtorInitTxtFormatter( SwTxtFrm *pFrm, SwTxtFormatInfo *pInf );
-    SwTxtFormatter( SwTxtFrm *pTxtFrm, SwTxtFormatInfo *pTxtFmtInf )
-        : SwTxtPainter(pTxtFrm!=NULL ? pTxtFrm->GetTxtNode() : NULL)
+    SwTxtFormatter(SwTxtFrm *pTxtFrm, SwTxtFormatInfo *pTxtFmtInf)
+        : SwTxtPainter(pTxtFrm->GetTxtNode())
         , bUnclipped(false)
-        {
-            CtorInitTxtFormatter( pTxtFrm, pTxtFmtInf );
-        }
+    {
+        CtorInitTxtFormatter( pTxtFrm, pTxtFmtInf );
+    }
     ~SwTxtFormatter();
 
     sal_Int32 FormatLine( const sal_Int32 nStart );
commit abf097c340789009ad80b84432972cbb9ebe5396
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Sun Feb 9 16:02:15 2014 +0000

    coverity#1169821 Dereference after null check
    
    Change-Id: Ia239505f1fd58ffd371be1d3a49fcb008982bcf5

diff --git a/sw/source/core/text/itrpaint.hxx b/sw/source/core/text/itrpaint.hxx
index 187d955..f230337 100644
--- a/sw/source/core/text/itrpaint.hxx
+++ b/sw/source/core/text/itrpaint.hxx
@@ -36,17 +36,18 @@ class SwTxtPainter : public SwTxtCursor
                                 long nAdjustBaseLine = 0 );
 protected:
     void CtorInitTxtPainter( SwTxtFrm *pFrm, SwTxtPaintInfo *pInf );
-    inline SwTxtPainter(SwTxtNode* pTxtNode)
+    SwTxtPainter(SwTxtNode* pTxtNode)
         : SwTxtCursor(pTxtNode)
         , bPaintDrop(false)
-        { }
+    {
+    }
 
 public:
-    inline SwTxtPainter( SwTxtFrm *pTxtFrm, SwTxtPaintInfo *pTxtPaintInf )
-        : SwTxtCursor( pTxtFrm != NULL ? pTxtFrm->GetTxtNode() : NULL)
-        {
-            CtorInitTxtPainter( pTxtFrm, pTxtPaintInf );
-        }
+    SwTxtPainter(SwTxtFrm *pTxtFrm, SwTxtPaintInfo *pTxtPaintInf)
+        : SwTxtCursor(pTxtFrm->GetTxtNode())
+    {
+        CtorInitTxtPainter( pTxtFrm, pTxtPaintInf );
+    }
     void DrawTextLine( const SwRect &rPaint, SwSaveClip &rClip,
                        const bool bUnderSz );
     void PaintDropPortion();
commit d9b5127b033e55fd7d634f0d5496d7185682677c
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Sun Feb 9 16:00:06 2014 +0000

    coverity#1169824 Explicit null dereferenced
    
    Change-Id: I5fe32e480d8cc372bccae25a0d180210e34075cf

diff --git a/chart2/source/view/main/DummyXShape.cxx b/chart2/source/view/main/DummyXShape.cxx
index 8eb97e3..4ed9622 100644
--- a/chart2/source/view/main/DummyXShape.cxx
+++ b/chart2/source/view/main/DummyXShape.cxx
@@ -1119,26 +1119,23 @@ bool DummyChart::initWindow()
         winData.pVisual = (void*)(vi->visual);
         pWindow.reset(new SystemChildWindow(mpWindow.get(), 0, &winData, sal_False));
         pChildSysData = pWindow->GetSystemData();
-
-        if( !pChildSysData )
-            return false;
     }
 
+    if (!pWindow || !pChildSysData)
+        return false;
 
-    if( pWindow )
-    {
-        pWindow->SetMouseTransparent( sal_True );
-        pWindow->SetParentClipMode( PARENTCLIPMODE_NOCLIP );
-        pWindow->EnableEraseBackground( sal_False );
-        pWindow->SetControlForeground();
-        pWindow->SetControlBackground();
+    pWindow->SetMouseTransparent( sal_True );
+    pWindow->SetParentClipMode( PARENTCLIPMODE_NOCLIP );
+    pWindow->EnableEraseBackground( sal_False );
+    pWindow->SetControlForeground();
+    pWindow->SetControlBackground();
+
+    GLWin.dpy = reinterpret_cast<Display*>(pChildSysData->pDisplay);
+    GLWin.win = pChildSysData->aWindow;
+    GLWin.vi = vi;
+    GLWin.GLXExtensions = glXQueryExtensionsString( GLWin.dpy, GLWin.screen );
+    OSL_TRACE("available GLX extensions: %s", GLWin.GLXExtensions);
 
-        GLWin.dpy = reinterpret_cast<Display*>(pChildSysData->pDisplay);
-        GLWin.win = pChildSysData->aWindow;
-        GLWin.vi = vi;
-        GLWin.GLXExtensions = glXQueryExtensionsString( GLWin.dpy, GLWin.screen );
-        OSL_TRACE("available GLX extensions: %s", GLWin.GLXExtensions);
-    }
     return true;
 }
 


More information about the Libreoffice-commits mailing list