Skip to content
This repository has been archived by the owner on Jul 11, 2023. It is now read-only.

checked sources with static code analysis tool [cppcheck] #59

Open
GoogleCodeExporter opened this issue Mar 17, 2015 · 0 comments
Open

Comments

@GoogleCodeExporter
Copy link

What steps will reproduce the problem?
1. download cppcheck at http://sourceforge.net/projects/cppcheck/
2. cppcheck --enable=all [tinyXML++-soures]
3. receive warnings

What is the expected output? What do you see instead?


What version of the product are you using? On what operating system?
svn head

Please provide any additional information below.

The tool discoverd a few stylistic issues like an operator= overloading
that returns void! Normally it should return a reference to itself (==*this).

    void operator=( const TiXmlElement& base );

Another possible issue is a not initialized class member in constructors.
It is allways whise to do this, because you set your members to a defined
status during object creation. Otherwise thier value is undefined.


Here is the output from cppcheck:

[tinystr.h:116]: (Style) Member variable 'TiXmlString::rep_' is not
assigned a value in 'TiXmlString::operator='
[tinystr.h:110]: (Style) 'operator=' should return reference to self
[tinystr.h:116]: (Style) 'operator=' should return reference to self
[tinyxml.h:1245]: (Style) Member variable not initialized in the
constructor 'TiXmlText::cdata'
[tinyxml.h:1246]: (Style) Member variable 'TiXmlText::cdata' is not
assigned a value in 'TiXmlText::operator='
[tinyxml.h:974]: (Style) 'operator=' should return something
[tinyxml.h:1181]: (Style) 'operator=' should return something
[tinyxml.h:1246]: (Style) 'operator=' should return something
[tinyxml.h:1313]: (Style) 'operator=' should return something
[tinyxml.h:1381]: (Style) 'operator=' should return something
[tinyxml.h:1434]: (Style) 'operator=' should return something
[tinyxml.h:1480]: (Style) 'operator=' should return something
[tinyxmlparser.cpp:177]: (Style) The function 'TiXmlParsingData::Cursor'
can be const
[tinyxml.cpp:910]: (Style) Member variable not initialized in the
constructor 'TiXmlDocument::useMicrosoftBOM'
[tinyxml.cpp:910]: (Style) Member variable not initialized in the
constructor 'TiXmlDocument::tabsize'
[tinyxml.cpp:910]: (Style) Member variable not initialized in the
constructor 'TiXmlDocument::errorId'
[tinyxml.cpp:910]: (Style) Member variable not initialized in the
constructor 'TiXmlDocument::error'
[ticpp.h:407]: (Style) 'operator=' should return something
[ticpp.h:278]: (Style) The function 'Base::SetImpRC' can be const
[ticpp.cpp:1145] -> [ticpprc.h:117]: (Style) The function
'TiCppRCImp::IsNull' can be const
[ticpp.cpp:295]: (Style) Empty string test can be simplified to "*value ==
'\0'"
[ticpp.cpp:325]: (Style) Empty string test can be simplified to "*value ==
'\0'"
[ticpp.cpp:484]: (Style) Empty string test can be simplified to "*value ==
'\0'"
[ticpp.cpp:514]: (Style) Empty string test can be simplified to "*value ==
'\0'"
[ticpp.cpp:544]: (Style) Empty string test can be simplified to "*value ==
'\0'"
[ticpp.cpp:584]: (Style) Empty string test can be simplified to "*value ==
'\0'"


Hope it helps a bit!

Best regards

Ettl Martin




Original issue reported on code.google.com by [email protected] on 22 May 2010 at 9:12

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant