Fixed cppcheck warnings
diff --git a/tinyxml2.cpp b/tinyxml2.cpp
index b7dd909..8069d04 100644
--- a/tinyxml2.cpp
+++ b/tinyxml2.cpp
@@ -190,8 +190,6 @@
*q++ = LF;
}
else if ( (flags & NEEDS_ENTITY_PROCESSING) && *p == '&' ) {
- int i=0;
-
// Entities handled by tinyXML2:
// - special entities in the entity table [in/out]
// - numeric character reference [in]
@@ -207,7 +205,8 @@
TIXMLASSERT( q <= p );
}
else {
- for( i=0; i<NUM_ENTITIES; ++i ) {
+ int i=0;
+ for(; i<NUM_ENTITIES; ++i ) {
if ( strncmp( p+1, entities[i].pattern, entities[i].length ) == 0
&& *(p+entities[i].length+1) == ';' )
{
@@ -768,7 +767,7 @@
// We read the end tag. Return it to the parent.
if ( node->ToElement() && node->ToElement()->ClosingType() == XMLElement::CLOSING ) {
if ( parentEnd ) {
- *parentEnd = ((XMLElement*)node)->value;
+ *parentEnd = static_cast<XMLElement*>(node)->value;
}
DELETE_NODE( node );
return p;
diff --git a/tinyxml2.h b/tinyxml2.h
index 13629f4..1ad2f6f 100644
--- a/tinyxml2.h
+++ b/tinyxml2.h
@@ -587,7 +587,7 @@
XMLNode( XMLDocument* );
virtual ~XMLNode();
XMLNode( const XMLNode& ); // not supported
- void operator=( const XMLNode& ); // not supported
+ XMLNode& operator=( const XMLNode& ); // not supported
XMLDocument* document;
XMLNode* parent;
@@ -641,7 +641,7 @@
XMLText( XMLDocument* doc ) : XMLNode( doc ), isCData( false ) {}
virtual ~XMLText() {}
XMLText( const XMLText& ); // not supported
- void operator=( const XMLText& ); // not supported
+ XMLText& operator=( const XMLText& ); // not supported
private:
bool isCData;
@@ -666,7 +666,7 @@
XMLComment( XMLDocument* doc );
virtual ~XMLComment();
XMLComment( const XMLComment& ); // not supported
- void operator=( const XMLComment& ); // not supported
+ XMLComment& operator=( const XMLComment& ); // not supported
private:
};
@@ -700,7 +700,7 @@
XMLDeclaration( XMLDocument* doc );
virtual ~XMLDeclaration();
XMLDeclaration( const XMLDeclaration& ); // not supported
- void operator=( const XMLDeclaration& ); // not supported
+ XMLDeclaration& operator=( const XMLDeclaration& ); // not supported
};
@@ -728,7 +728,7 @@
XMLUnknown( XMLDocument* doc );
virtual ~XMLUnknown();
XMLUnknown( const XMLUnknown& ); // not supported
- void operator=( const XMLUnknown& ); // not supported
+ XMLUnknown& operator=( const XMLUnknown& ); // not supported
};
@@ -1265,7 +1265,7 @@
/// Copy constructor
XMLHandle( const XMLHandle& ref ) { node = ref.node; }
/// Assignment
- XMLHandle operator=( const XMLHandle& ref ) { node = ref.node; return *this; }
+ XMLHandle& operator=( const XMLHandle& ref ) { node = ref.node; return *this; }
/// Get the first child of this handle.
XMLHandle FirstChild() { return XMLHandle( node ? node->FirstChild() : 0 ); }
@@ -1311,7 +1311,7 @@
XMLConstHandle( const XMLNode& _node ) { node = &_node; }
XMLConstHandle( const XMLConstHandle& ref ) { node = ref.node; }
- XMLConstHandle operator=( const XMLConstHandle& ref ) { node = ref.node; return *this; }
+ XMLConstHandle& operator=( const XMLConstHandle& ref ) { node = ref.node; return *this; }
const XMLConstHandle FirstChild() const { return XMLConstHandle( node ? node->FirstChild() : 0 ); }
const XMLConstHandle FirstChildElement( const char* value=0 ) const { return XMLConstHandle( node ? node->FirstChildElement( value ) : 0 ); }
diff --git a/xmltest.cpp b/xmltest.cpp
index 7916a05..eceb860 100644
--- a/xmltest.cpp
+++ b/xmltest.cpp
@@ -411,8 +411,6 @@
doc.SaveFile( "resources/utf8testout.xml" );
// Check the round trip.
- char savedBuf[256];
- char verifyBuf[256];
int okay = 0;
@@ -429,8 +427,10 @@
if ( saved && verify )
{
okay = 1;
+ char verifyBuf[256];
while ( fgets( verifyBuf, 256, verify ) )
{
+ char savedBuf[256];
fgets( savedBuf, 256, saved );
NullLineEndings( verifyBuf );
NullLineEndings( savedBuf );
@@ -568,8 +568,8 @@
"<psg context=\"Line 5 has "quotation marks" and 'apostrophe marks'."
" It also has <, >, and &, as well as a fake copyright \xC2\xA9.\"/>\n",
buf, false );
+ fclose( textfile );
}
- fclose( textfile );
}
{