[Libreoffice] Double Duplicate branches for if and else in sw/source/core/doc/ftnidx.cxx
julien2412
serval2412 at yahoo.fr
Tue Jan 31 13:29:58 PST 2012
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.
More information about the LibreOffice
mailing list