[Insight-developers] Anyone looked at cppcheck for static analysis of ITK?

Luis Ibanez luis.ibanez at kitware.com
Thu Sep 3 13:44:07 EDT 2009


Just for the record,

Please note that some of these issues have been
selected on purpose.

For example, we went through a lot of effort to
make the FixedArray  not  to have a constructor
so that the compiler with treat it as "Old Plain Data".

That said,
there are probably many issues that we should indeed fix.


      Luis


------------------------------------------------------------------------------------
On Wed, Sep 2, 2009 at 2:16 PM, kent
williams<norman-k-williams at uiowa.edu> wrote:
> I was running cppcheck over all our application source code, and while it
> didn't find any actual errors, it does pick up some style issues worth
> addressing in our code.
>
> https://sourceforge.net/apps/mediawiki/cppcheck/index.php?title=Main_Page
>
> As an exercise, I just ran it on the ITK Code tree, and it turns up stuff
> that's more along the lines of cleanup rather than serious problems -- ITK
> gets beat on pretty heavily after all!
>
> [./Common/itkSize.h:46]: (style) The class 'Size' has no constructor
> [./Common/itkFixedArray.h:146]: (style) Member variable not initialized in
> the constructor 'FixedArray::operator'
> [./Common/itkFixedArray.h:172]: (possible style) Member variable
> 'FixedArray::m_InternalArray' is not assigned a value in
> 'FixedArray::operator='
> [./Common/itkFixedArray.h:172]: (possible style) Member variable
> 'FixedArray::operator' is not assigned a value in 'FixedArray::operator='
> [./Common/itkFixedArray.h:172]: (possible style) Member variable
> 'FixedArray::ConstReverseIterator' is not assigned a value in
> 'FixedArray::operator='
> [./Common/itkIndex.h:67]: (style) The class 'Index' has no constructor
> [./Common/itkWeakPointer.h:104]: (possible style) Member variable
> 'WeakPointer<ProcessObject>::m_Pointer' is not assigned a value in
> 'WeakPointer<ProcessObject>::operator='
> [./Common/itkCommand.cxx:22]: (style) Member variable not initialized in the
> constructor 'CStyleCommand::m_ClientData'
> [./Common/itkVariableLengthVector.h:137]: (possible style) Member variable
> 'VariableLengthVector::m_NumElements' is not assigned a value in
> 'VariableLengthVector::operator='
> [./Common/itk_alloc.h:38]: (style) C-style pointer casting
> [./Common/itk_alloc.h:40]: (style) C-style pointer casting
>
> It also makes a lot of suggestions about limiting the scope of variables  --
> in other words situations like this:
>
> int tmp;
> if(a < b)
> {
> tmp = a; a = b; b = tmp;
> }
> // no further use of tmp
>
> Is this anything we want to think about using on a regular basis?
>
> Oh and it doesn't use a comprehensive C++ parser, so ITK throws thousands of
> false positives where it gets confused by complicated templates ;-) -- I
> logged a bug with the cppcheck project.
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the ITK FAQ at: http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-developers
>


More information about the Insight-developers mailing list