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.
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.