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


Hello,

Cppchecks reports this :
core/sw/source/core/doc/ftnidx.cxx
195     duplicateBranch style   Found duplicate branches for if and else.
284     duplicateBranch style   Found duplicate branches for if and else.

Here are the lines :
     180     // Set the array number for all footnotes starting from nPos
    181     for( ; nPos < Count(); ++nPos )
    182     {
    183         pTxtFtn = (*this)[ nPos ];
    184         const SwFmtFtn &rFtn = pTxtFtn->GetFtn();
    185         if( !rFtn.GetNumStr().Len() )
    186         {
    187             sal_uInt16 nSectNo = aNumArr.ChkNumber( *pTxtFtn );
    188             if( !nSectNo && ( rFtn.IsEndNote() || !bEndNoteOnly ))
    189                 nSectNo = rFtn.IsEndNote()
    190                             ? rEndInfo.nFtnOffset + nEndNo++
    191                             : rFtnInfo.nFtnOffset + nFtnNo++;
    192 
    193             if( nSectNo )
    194             {
    195                 if( rFtn.IsEndNote() )
    196                     pTxtFtn->SetNumber( nSectNo, &rFtn.GetNumStr()
);
    197                 else
    198                     pTxtFtn->SetNumber( nSectNo, &rFtn.GetNumStr()
);
    199             }
    200         }
    201     }
    202 }

And :
    270     for( sal_uInt16 nPos = 0; nPos < Count(); ++nPos )
    271     {
    272         pTxtFtn = (*this)[ nPos ];
    273         const SwFmtFtn &rFtn = pTxtFtn->GetFtn();
    274         if( !rFtn.GetNumStr().Len() )
    275         {
    276             sal_uInt16 nSectNo = aNumArr.ChkNumber( *pTxtFtn );
    277             if( !nSectNo && ( rFtn.IsEndNote() || !bEndNoteOnly ))
    278                 nSectNo = rFtn.IsEndNote()
    279                                 ? rEndInfo.nFtnOffset + (++nEndNo)
    280                                 : rFtnInfo.nFtnOffset + (++nFtnNo);
    281 
    282             if( nSectNo )
    283             {
    284                 if( rFtn.IsEndNote() )
    285                     pTxtFtn->SetNumber( nSectNo, &rFtn.GetNumStr()
);
    286                 else
    287                     pTxtFtn->SetNumber( nSectNo, &rFtn.GetNumStr()
);
    288             }
    289         }
    290     }

I took a look, it's there from initial import in 2000. There was a function
which had a third duplicate of this case which had been removed in 2004 with
the commit eb22f96c1987030671e567f9c3b6970101e6e7cc

Could we just remove the if in both cases or must something be added ?

Julien. 

--
View this message in context: 
http://nabble.documentfoundation.org/Double-Duplicate-branches-for-if-and-else-in-sw-source-core-doc-ftnidx-cxx-tp3704713p3704713.html
Sent from the Dev mailing list archive at Nabble.com.

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.