Question about cppcheck report on (SwCrsrShell::GetSmartTagTerm)
Michael Stahl
mstahl at redhat.com
Thu Dec 20 02:28:28 PST 2012
On 20/12/12 00:15, julien2412 wrote:
> Hello,
>
> Cppcheck reported this:
> [source/core/crsr/crsrsh.cxx:3357] -> [source/core/crsr/crsrsh.cxx:3365]:
> (performance) Variable 'rContent' is reassigned a value before the old one
> has been used.
>
> Indeed, we have these lines:
> 3356 SwIndex& rContent = GetCrsr()->GetPoint()->nContent;
> <-- Assignation 1
that is not an assignment, even though it looks like one at first
glance; it is in fact an initialization (C++ syntax is not meant to be
intuitive).
> 3357 rContent = nWordStart; <-- Assignation 2 without having
> used Assignation1
> 3358 SwRect aStartRect;
> 3359 SwCrsrMoveState aState;
> 3360 aState.bRealWidth = sal_True;
> 3361 SwCntntNode* pCntntNode = pCrsr->GetCntntNode();
> 3362 SwCntntFrm *pCntntFrame = pCntntNode->getLayoutFrm(
> GetLayout(), &rPt, pCrsr->GetPoint(), sal_False);
the pCrsr->GetPoint() will return the SwIndex that rContent points to,
so the value is in fact used (possibly getLayoutFrm will only look at
the nNode member and not nContent, but i guess cppcheck is not smart
enough to make that distinction?).
> 3363
> 3364 pCntntFrame->GetCharRect( aStartRect,
> *pCrsr->GetPoint(), &aState );
dito.
> 3365 rContent = nWordEnd - 1; <-- Assignation 3 without
> having used Assignation2
>
> http://opengrok.libreoffice.org/xref/core/sw/source/core/crsr/crsrsh.cxx#3357
>
> Any idea what to do with these assignations?
so at first glance it looks like a false positive.
More information about the LibreOffice
mailing list