Page MenuHomePhabricator

fix bugs/issues found by cppcheck
Closed, ResolvedPublic

Description

Fix easy bugs and small issues by using cppcheck (http://cppcheck.sourceforge.net)

Event Timeline

User hentsch has pushed new remote branch:

bug-19816-cppCheckOnMitkCore

In Modules/Core/src/Interactions/mitkDisplayInteractor.cpp you moved a variable initialization into a for loop. I would disagree to initialize the variable over and over again instead of the single shot:

@@ -918,12 +918,13 @@ bool mitk::DisplayInteractor::GetBoolProperty( mitk::PropertyList::Pointer prope
mitk::DataNode::Pointer mitk::DisplayInteractor::GetTopLayerNode(mitk::DataStorage::SetOfObjects::ConstPointer nodes, mitk::Point3D worldposition, BaseRenderer *ren)
{

mitk::DataNode::Pointer node;
  • int maxlayer = -32768;
  • bool isHelper (false);

+

if(nodes.IsNotNull())
{

+ int maxlayer = -32768;

for (unsigned int x = 0; x < nodes->size(); x++)
{

+ bool isHelper (false); // <-- Please move this up to maylayer

nodes->at(x)->GetBoolProperty("helper object", isHelper);
if(nodes->at(x)->GetData()->GetGeometry()->IsInside(worldposition) && isHelper == false)
{

Also we could replace most of the iterator-for-loops with auto range-based for loops, but that isn't your problem. :-)

[caeb4b]: Merge branch 'bug-19816-cppCheckOnMitkCore'

Merged commits:

2016-07-22 14:42:01 Clemens Hentschke [c3324d]
reverted a change after review


2016-07-08 11:59:57 Clemens Hentschke [c3918d]
forgot a file

Signed-off-by: Clemens Hentschke <c.hentschke@dkfz-heidelberg.de>


2016-07-08 11:58:53 Clemens Hentschke [28c03c]
fixed trivial bugs and code styling issues (recommended by cppcheck) (deleted unused variables, prefix instead of operators, catching exceptions by reference, simplyfing code where variables values are never used or overwritten)

Signed-off-by: Clemens Hentschke <c.hentschke@dkfz-heidelberg.de>