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




De : Noel Grandin <noel@peralex.com>
À : julien2412 <serval2412@yahoo.fr> 
Cc : libreoffice@lists.freedesktop.org 
Envoyé le : Vendredi 15 mars 2013 10h04
Objet : Re: About coverity 705746 (pormulti.cxx from sw module)
 

On 2013-03-15 10:30, julien2412 wrote:

Noel Grandin wrote 
I would guess that someone meant to move line 742 inside the first "if" 
statement, but only did half the job. 
Hello Noël, Perhaps I'm too sleepy this morning but I don't see the interest to
duplicate the "new" part. Any hint? 
I think the code should read:

 if( nLeft || nRight ) 
     { 
         if( !pCurr->GetPortion() ) 
             pCurr->SetPortion( new SwTxtPortion( *pCurr ) ); 
         if( nLeft ) 
         { 
             SwMarginPortion *pMarg = new SwMarginPortion( 0 ); 
             pMarg->AddPrtWidth( nLeft ); 
             pMarg->SetPortion( pCurr->GetPortion() ); 
             pCurr->SetPortion( pMarg ); 
         } 
         if( nRight ) 
         { 
            SwMarginPortion *pMarg = new SwMarginPortion( 0 ); 
             pMarg->AddPrtWidth( nRight ); 
             pCurr->FindLastPortion()->Append( pMarg ); 
         } 
    }

________________________________
Disclaimer: http://www.peralex.com/disclaimer.html

Since we have "if( nLeft || nRight )", what about:
 if( nLeft || nRight ) 
     { 
         if( !pCurr->GetPortion() ) 
             pCurr->SetPortion( new SwTxtPortion( *pCurr ) );
       SwMarginPortion *pMarg = new SwMarginPortion( 0 );
         if( nLeft ) 
         { 
             pMarg->AddPrtWidth( nLeft ); 
             pMarg->SetPortion( pCurr->GetPortion() ); 
             pCurr->SetPortion( pMarg ); 
         } 
         if( nRight )
         { 
             pMarg->AddPrtWidth( nRight ); 
             pCurr->FindLastPortion()->Append( pMarg ); 
         } 
    }

If nLeft and nRight are exlusive, it could also just be an if(nLeft)... else...

In both cases, no need to repeat "SwMarginPortion *pMarg = new SwMarginPortion( 0 );" since we're 
sure to be in one of these blocks.

Julien

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.