bmeaut / grainautline

GrainAutLine: image processing for geology and material sciences
GNU General Public License v3.0
0 stars 2 forks source link

ActiveContours C++ warnings #99

Closed szotsaki closed 8 years ago

szotsaki commented 8 years ago

Please, fix the following C++ warnings generated by cppcheck:

[MarbleCommon/ActiveContours/BalloonForce.cpp:19]: (performance) Prefer prefix ++/-- operators for non-primitive types.
[MarbleCommon/ActiveContours/DarknessForce.cpp:28]: (style) Clarify calculation precedence for '%' and '?'.
[MarbleCommon/ActiveContours/EdgeForce.cpp:50]: (style) Clarify calculation precedence for '%' and '?'.
[MarbleCommon/ActiveContours/GVFForce.h:35]: (warning) Member variable 'GVFForce::mu' is not initialized in the constructor.
[MarbleCommon/ActiveContours/GVFForce.h:35]: (warning) Member variable 'GVFForce::deltaTFactor' is not initialized in the constructor.
[MarbleCommon/ActiveContours/GVFForce.h:35]: (warning) Member variable 'GVFForce::edgeMapType' is not initialized in the constructor.
[MarbleCommon/ActiveContours/GVFForce.h:35]: (warning) Member variable 'GVFForce::deltaT' is not initialized in the constructor.
[MarbleCommon/ActiveContours/GVFForce.h:35]: (warning) Member variable 'GVFForce::r' is not initialized in the constructor.
[MarbleCommon/ActiveContours/GVFForce.h:35]: (warning) Member variable 'GVFForce::maxIter' is not initialized in the constructor.
[MarbleCommon/ActiveContours/GVFForce.h:35]: (warning) Member variable 'GVFForce::iterThreshold' is not initialized in the constructor.
[MarbleCommon/ActiveContours/snake.cpp:30]: (performance) Variable 'snakePoints' is assigned in constructor body. Consider performing initialization in initialization list.
[MarbleCommon/ActiveContours/GVFForce.h:35]: (style) Class 'GVFForce' has a constructor with 1 argument that is not explicit.
[MarbleCommon/ActiveContours/GVFForce.cpp:182]: (style) Clarify calculation precedence for '%' and '?'.
[MarbleCommon/ActiveContours/GVFForce.cpp:205]: (style) Clarify calculation precedence for '%' and '?'.
[MarbleCommon/ActiveContours/NetworkSnake.h:86]: (warning) Member variable 'NetworkSnakeIterationDescriptor::junctionPointIndex' is not initialized in the constructor.
[MarbleCommon/ActiveContours/NetworkSnake.h:86]: (warning) Member variable 'NetworkSnakeIterationDescriptor::segmentIndex' is not initialized in the constructor.
[MarbleCommon/ActiveContours/NetworkSnake.h:86]: (warning) Member variable 'NetworkSnakeIterationDescriptor::segmentPointIndex' is not initialized in the constructor.
[MarbleCommon/Processors/ActiveContoursDynamic.cpp:39]: (performance) Prefer prefix ++/-- operators for non-primitive types.
[MarbleCommon/Processors/ActiveContoursNormalizedInnerForces.cpp:38]: (style) The scope of the variable 'diffX' can be reduced.
[MarbleCommon/Processors/ActiveContoursNormalizedInnerForces.cpp:39]: (style) The scope of the variable 'diffY' can be reduced.
[MarbleCommon/Processors/ActiveContoursNormalizedInnerForces.cpp:40]: (style) The scope of the variable 'length' can be reduced.
[MarbleCommon/Processors/ActiveContoursNetworkSnake.cpp:26]: (style) Variable 'secondNeighbors' is assigned a value that is never used.

Additionally, the following C++ warnings exist generated by GCC:

../../MarbleCommon/ActiveContours/GVFForce.cpp: In member function 'void GVFForce::calculateEdgeMap()':
../../MarbleCommon/ActiveContours/GVFForce.cpp:124:12: warning: switch missing default case [-Wswitch-default]
     switch (edgeMapType)
            ^

../../MarbleCommon/Processors/ActiveContoursProcessor.cpp:261:63: warning: unused parameter 'psd' [-Wunused-parameter]
 bool ActiveContoursProcessor::Step(ProcessingStateDescriptor &psd)
                                                               ^
szotsaki commented 8 years ago

Current cppcheck warnings:

[MarbleCommon/ActiveContours/StaticSnake.h:33]: (style) Class 'StaticSnake' has a constructor with 1 argument that is not explicit.
[MarbleCommon/ActiveContours/StaticSnake.h:39]: (style) Class 'StaticSnake' has a constructor with 1 argument that is not explicit.
[MarbleCommon/ActiveContours/DynamicSnakeInterface.h:14]: (style) Class 'DynamicSnakeInterface' has a constructor with 1 argument that is not explicit.
[MarbleCommon/ActiveContours/GVFForce.h:35]: (style) Class 'GVFForce' has a constructor with 1 argument that is not explicit.

Current GCC warnings:

In file included from ../../MarbleCommon/ActiveContours/GVFForce.cpp:1:0:
../../MarbleCommon/ActiveContours/GVFForce.h: In constructor 'GVFForce::GVFForce(const cv::String&)':
../../MarbleCommon/ActiveContours/GVFForce.h:121:17: warning: 'GVFForce::edgeMapType' will be initialized after [-Wreorder]
     EdgeMapType edgeMapType;
                 ^
../../MarbleCommon/ActiveContours/GVFForce.h:111:11: warning:   'float GVFForce::mu' [-Wreorder]
     float mu;
           ^
../../MarbleCommon/ActiveContours/GVFForce.h:35:5: warning:   when initialized here [-Wreorder]
     GVFForce(const cv::String& fileName)
     ^
../../MarbleCommon/ActiveContours/GVFForce.h:157:11: warning: 'GVFForce::iterThreshold' will be initialized after [-Wreorder]
     float iterThreshold;
           ^
../../MarbleCommon/ActiveContours/GVFForce.h:146:14: warning:   'unsigned int GVFForce::iterCnt' [-Wreorder]
     unsigned iterCnt;
              ^
../../MarbleCommon/ActiveContours/GVFForce.h:35:5: warning:   when initialized here [-Wreorder]
     GVFForce(const cv::String& fileName)
     ^
../../MarbleCommon/ActiveContours/GVFForce.cpp: In member function 'void GVFForce::calculateEdgeMap()':
../../MarbleCommon/ActiveContours/GVFForce.cpp:124:12: warning: enumeration value 'NOT_DEFINED' not handled in switch [-Wswitch-enum]
     switch (edgeMapType)
            ^

For the first ones, just reorder the initialisation order in the constructor to match the declaration order in the body.