Date: prev next · Thread: first prev next last
2011 Archives by date, by thread · List index


Hello,

Here is a patch for some cppcheck cleaning in sw
Compiling was ok

+ 1 -exec replaced by xargs

Julien

(LGPLv3+ / MPL)
commit 8bce9aee2348d6d34f190b2409390010b9a88e79
Author: Julien Nabet <serval2412@yahoo.fr>
Date:   Sun Jan 9 22:19:39 2011 +0100

    Some cppcheck cleaning

diff --git a/sw/source/core/access/accpara.cxx b/sw/source/core/access/accpara.cxx
index 8a1a24e..f3c2c16 100644
--- a/sw/source/core/access/accpara.cxx
+++ b/sw/source/core/access/accpara.cxx
@@ -2188,7 +2188,7 @@ sal_Bool SwAccessibleParagraph::setAttributes(
     {
         xPortion->setPropertyValues( aNames, aValues );
     }
-    catch( UnknownPropertyException e )
+    catch( UnknownPropertyException &e )
     {
         // error handling through return code!
         bRet = sal_False;
diff --git a/sw/source/core/doc/docbm.cxx b/sw/source/core/doc/docbm.cxx
index d4eaaa2..ed33bc8 100644
--- a/sw/source/core/doc/docbm.cxx
+++ b/sw/source/core/doc/docbm.cxx
@@ -1493,10 +1493,10 @@ void _RestoreCntntIdx(SwDoc* pDoc,
             case 0x0800:
             case 0x0801:
                 {
-                    USHORT nCnt = 0;
                     SwCrsrShell* pShell = pDoc->GetEditShell();
                     if( pShell )
                     {
+                        USHORT nCnt = 0;
                         FOREACHSHELL_START( pShell )
                             SwPaM *_pStkCrsr = PCURSH->GetStkCrsr();
                             if( _pStkCrsr )
@@ -1653,10 +1653,10 @@ void _RestoreCntntIdx(SvULongs& rSaveArr,
             case 0x0800:
             case 0x0801:
                 {
-                    USHORT nCnt = 0;
                     SwCrsrShell* pShell = pDoc->GetEditShell();
                     if( pShell )
                     {
+                        USHORT nCnt = 0;
                         FOREACHSHELL_START( pShell )
                             SwPaM *_pStkCrsr = PCURSH->GetStkCrsr();
                             if( _pStkCrsr )
diff --git a/sw/source/core/doc/doccomp.cxx b/sw/source/core/doc/doccomp.cxx
index aaf61ab..1100fe6 100644
--- a/sw/source/core/doc/doccomp.cxx
+++ b/sw/source/core/doc/doccomp.cxx
@@ -695,7 +695,6 @@ ULONG Compare::CompareSequence::CheckDiag( ULONG nStt1, ULONG nEnd1,
     for (c = 1;; ++c)
     {
         long d;                        /* Active diagonal. */
-        long big_snake = 0;
 
         /* Extend the top-down search by an edit step in each diagonal. */
         fmin > dmin ? pFDiag[--fmin - 1] = -1 : ++fmin;
@@ -713,8 +712,6 @@ ULONG Compare::CompareSequence::CheckDiag( ULONG nStt1, ULONG nEnd1,
             while( ULONG(x) < nEnd1 && ULONG(y) < nEnd2 &&
                 rMoved1.GetIndex( x ) == rMoved2.GetIndex( y ))
                 ++x, ++y;
-            if (x - oldx > 20)
-                big_snake = 1;
             pFDiag[d] = x;
             if( odd && bmin <= d && d <= bmax && pBDiag[d] <= pFDiag[d] )
             {
@@ -739,8 +736,6 @@ ULONG Compare::CompareSequence::CheckDiag( ULONG nStt1, ULONG nEnd1,
             while( ULONG(x) > nStt1 && ULONG(y) > nStt2 &&
                 rMoved1.GetIndex( x - 1 ) == rMoved2.GetIndex( y - 1 ))
                 --x, --y;
-            if (oldx - x > 20)
-                big_snake = 1;
             pBDiag[d] = x;
             if (!odd && fmin <= d && d <= fmax && pBDiag[d] <= pFDiag[d])
             {
diff --git a/sw/source/core/doc/docredln.cxx b/sw/source/core/doc/docredln.cxx
index 0ebd260..fe203fe 100644
--- a/sw/source/core/doc/docredln.cxx
+++ b/sw/source/core/doc/docredln.cxx
@@ -2999,11 +2999,11 @@ void SwRedlineExtraData_Format::Reject( SwPaM& rPam ) const
 int SwRedlineExtraData_Format::operator == ( const SwRedlineExtraData& rCmp ) const
 {
     int nRet = 1;
-    USHORT n = 0, nEnd = aWhichIds.Count();
+    USHORT nEnd = aWhichIds.Count();
     if( nEnd != ((SwRedlineExtraData_Format&)rCmp).aWhichIds.Count() )
         nRet = 0;
     else
-        for( ; n < nEnd; ++n )
+        for(USHORT n=0 ; n < nEnd; ++n )
             if( ((SwRedlineExtraData_Format&)rCmp).aWhichIds[n] != aWhichIds[n])
             {
                 nRet = 0;
@@ -3012,8 +3012,6 @@ int SwRedlineExtraData_Format::operator == ( const SwRedlineExtraData& rCmp ) 
co
     return nRet;
 }
 
-/*  */
-
 SwRedlineData::SwRedlineData( RedlineType_t eT, USHORT nAut )
     : pNext( 0 ), pExtraData( 0 ), eType( eT ), nAuthor( nAut ), nSeqNo( 0 )
 {
@@ -3066,8 +3064,6 @@ String SwRedlineData::GetDescr() const
     return aResult;
 }
 
-/*  */
-
 SwRedline::SwRedline(RedlineType_t eTyp, const SwPaM& rPam )
     : SwPaM( *rPam.GetMark(), *rPam.GetPoint() ),
     pRedlineData( new SwRedlineData( eTyp, GetDoc()->GetRedlineAuthor() ) ),
diff --git a/sw/source/core/layout/fly.cxx b/sw/source/core/layout/fly.cxx
index 7543804..ffd4b9c 100644
--- a/sw/source/core/layout/fly.cxx
+++ b/sw/source/core/layout/fly.cxx
@@ -2712,8 +2712,6 @@ BOOL SwFlyFrm::GetContour( PolyPolygon&   rContour,
                 const MapMode   aDispMap( MAP_TWIP );
                 const MapMode   aGrfMap( pGrfObj->GetPrefMapMode() );
                 const Size      aGrfSize( pGrfObj->GetPrefSize() );
-                double          fScaleX;
-                double          fScaleY;
                 Size            aOrgSize;
                 Point           aNewPoint;
                 BOOL            bPixelMap = aGrfMap.GetMapUnit() == MAP_PIXEL;
@@ -2725,8 +2723,8 @@ BOOL SwFlyFrm::GetContour( PolyPolygon&   rContour,
 
                 if ( aOrgSize.Width() && aOrgSize.Height() )
                 {
-                    fScaleX = (double) aOrig.Width() / aOrgSize.Width();
-                    fScaleY = (double) aOrig.Height() / aOrgSize.Height();
+                    double fScaleX = (double) aOrig.Width() / aOrgSize.Width();
+                    double fScaleY = (double) aOrig.Height() / aOrgSize.Height();
 
                     for ( USHORT j = 0, nPolyCount = rContour.Count(); j < nPolyCount; j++ )
                     {
diff --git a/sw/source/core/layout/frmtool.cxx b/sw/source/core/layout/frmtool.cxx
index 19bd600..172368e 100644
--- a/sw/source/core/layout/frmtool.cxx
+++ b/sw/source/core/layout/frmtool.cxx
@@ -2385,10 +2385,10 @@ const SdrObject *SwOrderIter::Top()
     pCurrent = 0;
     if ( pPage->GetSortedObjs() )
     {
-        UINT32 nTopOrd = 0;
         const SwSortedObjs *pObjs = pPage->GetSortedObjs();
         if ( pObjs->Count() )
         {
+            UINT32 nTopOrd = 0;
             (*pObjs)[0]->GetDrawObj()->GetOrdNum();  //Aktualisieren erzwingen!
             for ( USHORT i = 0; i < pObjs->Count(); ++i )
             {
@@ -2495,10 +2495,10 @@ const SdrObject *SwOrderIter::Prev()
     pCurrent = 0;
     if ( pPage->GetSortedObjs() )
     {
-        UINT32 nOrd = 0;
         const SwSortedObjs *pObjs = pPage->GetSortedObjs();
         if ( pObjs->Count() )
         {
+            UINT32 nOrd = 0;
             (*pObjs)[0]->GetDrawObj()->GetOrdNum();  //Aktualisieren erzwingen!
             for ( USHORT i = 0; i < pObjs->Count(); ++i )
             {
diff --git a/sw/source/core/layout/tabfrm.cxx b/sw/source/core/layout/tabfrm.cxx
index b1f847a..70f2223 100644
--- a/sw/source/core/layout/tabfrm.cxx
+++ b/sw/source/core/layout/tabfrm.cxx
@@ -937,7 +937,6 @@ bool SwTabFrm::RemoveFollowFlowLine()
     // NEW TABLES
     // If a row span follow flow line is removed, we want to move the whole span
     // to the master:
-    SwTwips nGrow = 0;
     long nRowsToMove = lcl_GetMaximumLayoutRowSpan( *pFollowFlowLine );
 
     if ( nRowsToMove > 1 )
@@ -945,6 +944,7 @@ bool SwTabFrm::RemoveFollowFlowLine()
         SWRECTFN( this )
         SwFrm* pRow = pFollowFlowLine->GetNext();
         SwFrm* pInsertBehind = GetLastLower();
+        SwTwips nGrow = 0;
 
         while ( pRow && nRowsToMove-- > 1 )
         {
@@ -1384,7 +1384,6 @@ bool SwTabFrm::Join()
     OSL_ENSURE( !HasFollowFlowLine(), "Joining follow flow line" );
 
     SwTabFrm *pFoll = GetFollow();
-    SwTwips nHeight = 0;       //Gesamthoehe der eingefuegten Zeilen als Return.
 
     if ( !pFoll->IsJoinLocked() )
     {
@@ -1397,6 +1396,7 @@ bool SwTabFrm::Join()
 
         SwFrm* pPrv = GetLastLower();
 
+        SwTwips nHeight = 0;   //Gesamthoehe der eingefuegten Zeilen als Return.
         while ( pRow )
         {
             pNxt = pRow->GetNext();
@@ -2419,9 +2419,8 @@ void SwTabFrm::MakeAll()
             // We better avoid splitting of a row frame if we are inside a columned
             // section which has a height of 0, because this is not growable and thus
             // all kinds of unexpected things could happen.
-            const SwSectionFrm* pTmpSct = 0;
             if ( IsInSct() &&
-                (pTmpSct = FindSctFrm())->Lower()->IsColumnFrm() &&
+                (FindSctFrm())->Lower()->IsColumnFrm() &&
                 0 == (GetUpper()->Frm().*fnRect->fnGetHeight)()  )
             {
                 bTryToSplit = false;
@@ -3182,10 +3181,9 @@ SwTwips SwTabFrm::GrowFrm( SwTwips nDist, BOOL bTst, BOOL bInfo )
             pFrm = pFrm->GetNext();
         }
 
-        long nTmp = 0;
         if ( nReal < nDist )
         {
-            nTmp = GetUpper()->Grow( nDist - ( nReal > 0 ? nReal : 0), bTst, bInfo );
+            long nTmp = GetUpper()->Grow( nDist - ( nReal > 0 ? nReal : 0), bTst, bInfo );
 
             if ( IsRestrictTableGrowth() )
             {
@@ -5374,10 +5372,10 @@ void SwCellFrm::Format( const SwBorderAttrs *pAttrs )
         if( ( bVertDir && ( nRemaining -= lcl_CalcTopAndBottomMargin( *this, *pAttrs ) ) < 
nPrtHeight ) ||
             (Lower()->Frm().*fnRect->fnGetTop)() != (this->*fnRect->fnGetPrtTop)() )
         {
-            long lTopOfst = 0,
-                    nDiff = (Prt().*fnRect->fnGetHeight)() - nRemaining;
+               long nDiff = (Prt().*fnRect->fnGetHeight)() - nRemaining;
             if ( nDiff >= 0 )
             {
+                long lTopOfst = 0;
                 if ( bVertDir )
                 {
                     switch ( rOri.GetVertOrient() )
diff --git a/sw/source/core/text/wrong.cxx b/sw/source/core/text/wrong.cxx
index f77d963..14cb3b5 100644
--- a/sw/source/core/text/wrong.cxx
+++ b/sw/source/core/text/wrong.cxx
@@ -187,7 +187,7 @@ xub_StrLen SwWrongList::NextWrong( xub_StrLen nChk ) const
 
 MSHORT SwWrongList::GetWrongPos( xub_StrLen nValue ) const
 {
-    MSHORT nOben = Count(), nMitte = 0, nUnten = 0;
+    MSHORT nOben = Count(), nUnten = 0;
 
     if( nOben > 0 )
     {
@@ -212,6 +212,7 @@ MSHORT SwWrongList::GetWrongPos( xub_StrLen nValue ) const
         }
 
         --nOben;
+        MSHORT nMitte = 0;
         while( nUnten <= nOben )
         {
             nMitte = nUnten + ( nOben - nUnten ) / 2;
commit 73e664dd8ea0c2f836c697f3201cce9d0bcccd76
Author: Julien Nabet <serval2412@yahoo.fr>
Date:   Sun Jan 9 16:22:34 2011 +0100

    replace -exec by xargs

diff --git a/solenv/inc/tg_ext.mk b/solenv/inc/tg_ext.mk
index 6942cd7..6a1584a 100644
--- a/solenv/inc/tg_ext.mk
+++ b/solenv/inc/tg_ext.mk
@@ -170,7 +170,7 @@ $(PACKAGE_DIR)/$(UNTAR_FLAG_FILE) : $(PRJ)/$(ROUT)/misc/$(TARFILE_MD5)-$(TARFILE
     $(COMMAND_ECHO)cd $(PACKAGE_DIR)$(fake_root_dir) && ( $(shell @$(TYPE) 
$(PRJ)/$(ROUT)/misc/$(TARFILE_MD5)-$(TARFILE_NAME).unpack)) && $(TOUCH) $(UNTAR_FLAG_FILE)
     @echo make writeable...
     @-cd $(PACKAGE_DIR) && chmod -R +rw $(TARFILE_ROOTDIR) && $(TOUCH) $(UNTAR_FLAG_FILE)
-    @-cd $(PACKAGE_DIR) && find $(TARFILE_ROOTDIR) -type d -exec chmod a+x {{}} \;
+    @-cd $(PACKAGE_DIR) && find $(TARFILE_ROOTDIR) -type d | xargs -i chmod a+x {{}} \;
 
 #add new files to patch
 $(PACKAGE_DIR)/$(ADD_FILES_FLAG_FILE) : $(PACKAGE_DIR)/$(UNTAR_FLAG_FILE) 
$(T_ADDITIONAL_FILES:+".dummy")

Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.