From 734463fcc751dcc0eb50e1c42144b4e1f3a1df4d Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Tue, 3 Feb 2009 15:28:53 +0000 Subject: [PATCH] Warning fixes --- examples/osgcluster/broadcaster.cpp | 2 +- examples/osgcluster/osgcluster.cpp | 2 +- examples/osgcluster/receiver.cpp | 2 +- .../osgimagesequence/osgimagesequence.cpp | 4 +++ examples/osgmovie/osgmovie.cpp | 5 ++++ examples/osgunittests/UnitTestFramework.cpp | 7 +++++- examples/osgunittests/UnitTestFramework.h | 25 +++++++++++++++++-- include/osgIntrospection/Reflector | 4 +++ include/osgIntrospection/TypedConstructorInfo | 1 - include/osgIntrospection/TypedMethodInfo | 2 +- src/OpenThreads/win32/Win32Thread.cpp | 4 +-- src/osgPlugins/3ds/ReaderWriter3DS.cpp | 4 ++- src/osgPlugins/cfg/ConfigLexer.cpp | 4 +++ src/osgPlugins/jpeg/ReaderWriterJPEG.cpp | 4 +++ src/osgPlugins/lwo/lwo2types.h | 13 ++++++++-- src/osgPlugins/obj/OBJWriterNodeVisitor.cpp | 8 ++++-- src/osgPlugins/txp/ReaderWriterTXP.cpp | 2 ++ src/osgPlugins/txp/TXPIO.cpp | 4 +++ src/osgPlugins/txp/TXPParser.cpp | 3 +++ src/osgPlugins/txp/trpage_material.cpp | 6 ----- src/osgUtil/Simplifier.cpp | 2 +- src/osgUtil/TriStrip_tri_stripper.h | 21 ++++++++++++++++ 22 files changed, 107 insertions(+), 22 deletions(-) diff --git a/examples/osgcluster/broadcaster.cpp b/examples/osgcluster/broadcaster.cpp index ca19e1306..885ca8da1 100644 --- a/examples/osgcluster/broadcaster.cpp +++ b/examples/osgcluster/broadcaster.cpp @@ -196,7 +196,7 @@ void Broadcaster::sync( void ) unsigned int size = sizeof( SOCKADDR_IN ); sendto( _so, (const char *)_buffer, _buffer_size, 0, (struct sockaddr *)&saddr, size ); int err = WSAGetLastError (); - int *dum = (int*) _buffer; + if (err!=0) fprintf( stderr, "Broadcaster::sync() - error %d\n",err ); #else unsigned int size = sizeof( struct sockaddr_in ); sendto( _so, (const void *)_buffer, _buffer_size, 0, (struct sockaddr *)&saddr, size ); diff --git a/examples/osgcluster/osgcluster.cpp b/examples/osgcluster/osgcluster.cpp index d5298991f..f0ea857fa 100644 --- a/examples/osgcluster/osgcluster.cpp +++ b/examples/osgcluster/osgcluster.cpp @@ -386,7 +386,7 @@ class DataConverter _swapBytes = !_swapBytes; } - cameraPacket._masterKilled = readUInt(); + cameraPacket._masterKilled = readUInt()!=0; read(cameraPacket._matrix); read(cameraPacket._frameStamp); diff --git a/examples/osgcluster/receiver.cpp b/examples/osgcluster/receiver.cpp index 52b02f863..eaa6ba1e3 100644 --- a/examples/osgcluster/receiver.cpp +++ b/examples/osgcluster/receiver.cpp @@ -142,7 +142,7 @@ void Receiver::sync( void ) recvfrom( _so, (char *)_buffer, _buffer_size, 0, (sockaddr*)&saddr, &size ); // recvfrom(sock_Receive, szMessage, 256, 0, (sockaddr*)&addr_Cli, &clilen) int err = WSAGetLastError (); - int *dum = (int*) _buffer; + if (err!=0) fprintf( stderr, "Receiver::sync() - error %d\n",err ); while( select( _so+1, &fdset, 0L, 0L, &tv ) ) { diff --git a/examples/osgimagesequence/osgimagesequence.cpp b/examples/osgimagesequence/osgimagesequence.cpp index cd31658f7..cc5e14d9d 100644 --- a/examples/osgimagesequence/osgimagesequence.cpp +++ b/examples/osgimagesequence/osgimagesequence.cpp @@ -230,6 +230,10 @@ protected: } ImageStreamList& _imageStreamList; + + protected: + + FindImageStreamsVisitor& operator = (const FindImageStreamsVisitor&) { return *this; } }; diff --git a/examples/osgmovie/osgmovie.cpp b/examples/osgmovie/osgmovie.cpp index c9cea11e5..51bda6c5f 100644 --- a/examples/osgmovie/osgmovie.cpp +++ b/examples/osgmovie/osgmovie.cpp @@ -108,6 +108,11 @@ protected: } ImageStreamList& _imageStreamList; + + protected: + + FindImageStreamsVisitor& operator = (const FindImageStreamsVisitor&) { return *this; } + }; diff --git a/examples/osgunittests/UnitTestFramework.cpp b/examples/osgunittests/UnitTestFramework.cpp index 3c7fe3710..13305fb05 100644 --- a/examples/osgunittests/UnitTestFramework.cpp +++ b/examples/osgunittests/UnitTestFramework.cpp @@ -290,7 +290,8 @@ bool TestRunner::visitEnter( TestSuite* pSuite ) namespace osgUtx{ -struct isSpecified{ +struct isSpecified +{ const std::string& pTestName_; @@ -299,6 +300,10 @@ struct isSpecified{ bool operator()(const std::string& specifiedTest){ return pTestName_.find(specifiedTest) == 0; } + +protected: + + isSpecified& operator = (const isSpecified&) { return *this; } }; } diff --git a/examples/osgunittests/UnitTestFramework.h b/examples/osgunittests/UnitTestFramework.h index 6a26a0f44..f908fa8f3 100644 --- a/examples/osgunittests/UnitTestFramework.h +++ b/examples/osgunittests/UnitTestFramework.h @@ -386,6 +386,29 @@ its result, and a textual description of any problems. class TestRecord { public: + + TestRecord() {} + + TestRecord(const TestRecord& rhs): + name_(rhs.name_), + start_(rhs.start_), + stop_(rhs.stop_), + result_(rhs.result_), + problem_(rhs.problem_) + {} + + TestRecord& operator = (const TestRecord& rhs) + { + if (&rhs==this) return *this; + + name_ = rhs.name_; + start_ = rhs.start_; + stop_ = rhs.stop_; + result_ = rhs.result_; + problem_ = rhs.problem_; + + return *this; + } void start(); void stop(); @@ -394,8 +417,6 @@ class TestRecord void log(const std::exception& e); void log(const std::string& s); - // Default copy construction and assignment are OK - // FIXME: Add accessors? private: diff --git a/include/osgIntrospection/Reflector b/include/osgIntrospection/Reflector index 91f944d2a..c20d03ad8 100644 --- a/include/osgIntrospection/Reflector +++ b/include/osgIntrospection/Reflector @@ -631,6 +631,10 @@ namespace osgIntrospection values.push_back(Value(i->first).convertTo(_itype)); } } + + protected: + + Indexer& operator = (const Indexer&) { return *this; } }; struct Remover: PropertyRemover diff --git a/include/osgIntrospection/TypedConstructorInfo b/include/osgIntrospection/TypedConstructorInfo index 9caa61502..a90f2ab2f 100644 --- a/include/osgIntrospection/TypedConstructorInfo +++ b/include/osgIntrospection/TypedConstructorInfo @@ -32,7 +32,6 @@ namespace osgIntrospection Value createInstance(ValueList& /*args*/) const { - return IC::create(); } diff --git a/include/osgIntrospection/TypedMethodInfo b/include/osgIntrospection/TypedMethodInfo index ba5571ce3..6ef7ee225 100644 --- a/include/osgIntrospection/TypedMethodInfo +++ b/include/osgIntrospection/TypedMethodInfo @@ -15,7 +15,7 @@ #ifndef OSGINTROSPECTION_TYPEDMETHODINFO_ #define OSGINTROSPECTION_TYPEDMETHODINFO_ -#if defined(_MSC_VER) +#if defined(_MSC_VER) && defined(OSG_DISABLE_MSVC_WARNINGS) // disable for this header the VS warning C4121 : "alignment of a member was sensitive to packing" #pragma warning( push ) #pragma warning( disable : 4121) diff --git a/src/OpenThreads/win32/Win32Thread.cpp b/src/OpenThreads/win32/Win32Thread.cpp index 02b9af9c5..afa8dd70a 100644 --- a/src/OpenThreads/win32/Win32Thread.cpp +++ b/src/OpenThreads/win32/Win32Thread.cpp @@ -136,8 +136,8 @@ namespace OpenThreads { // Print information related to thread schduling parameters. // static void PrintThreadSchedulingInfo(Thread *thread) { - Win32ThreadPrivateData *pd = - static_cast(thread->_prvData); + + // Win32ThreadPrivateData *pd = static_cast(thread->_prvData); std::cout<<"Thread "<< thread <<" priority : "; diff --git a/src/osgPlugins/3ds/ReaderWriter3DS.cpp b/src/osgPlugins/3ds/ReaderWriter3DS.cpp index 96192f4fd..b7591dddb 100644 --- a/src/osgPlugins/3ds/ReaderWriter3DS.cpp +++ b/src/osgPlugins/3ds/ReaderWriter3DS.cpp @@ -78,7 +78,9 @@ class PrintVisitor : public NodeVisitor virtual void apply(LOD& node) { apply((Group&)node); } protected: - + + PrintVisitor& operator = (const PrintVisitor&) { return *this; } + std::ostream& _out; int _indent; int _step; diff --git a/src/osgPlugins/cfg/ConfigLexer.cpp b/src/osgPlugins/cfg/ConfigLexer.cpp index bc9f59eaa..166df3804 100644 --- a/src/osgPlugins/cfg/ConfigLexer.cpp +++ b/src/osgPlugins/cfg/ConfigLexer.cpp @@ -9,6 +9,10 @@ #define YY_FLEX_MAJOR_VERSION 2 #define YY_FLEX_MINOR_VERSION 5 +#if defined(_MSC_VER) && defined(OSG_DISABLE_MSVC_WARNINGS) + // disable '=' : conversion from 'int' to 'char', possible loss of data style warnings + #pragma warning( disable : 4244) +#endif /* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */ diff --git a/src/osgPlugins/jpeg/ReaderWriterJPEG.cpp b/src/osgPlugins/jpeg/ReaderWriterJPEG.cpp index 411c8f744..d4aaeb249 100644 --- a/src/osgPlugins/jpeg/ReaderWriterJPEG.cpp +++ b/src/osgPlugins/jpeg/ReaderWriterJPEG.cpp @@ -56,6 +56,10 @@ extern "C" #include #include +#if defined(_MSC_VER) && defined(OSG_DISABLE_MSVC_WARNINGS) + #pragma warning( disable : 4611 ) +#endif + namespace osgDBJPEG { diff --git a/src/osgPlugins/lwo/lwo2types.h b/src/osgPlugins/lwo/lwo2types.h index c35f0a602..c27f5a415 100644 --- a/src/osgPlugins/lwo/lwo2types.h +++ b/src/osgPlugins/lwo/lwo2types.h @@ -17,8 +17,17 @@ namespace lwo2 // basic types -struct ID4 { - char id[4]; +struct ID4 +{ + ID4() + { + id[0] = 0; + id[1] = 0; + id[2] = 0; + id[3] = 0; + } + + char id[4]; }; typedef signed char I1; diff --git a/src/osgPlugins/obj/OBJWriterNodeVisitor.cpp b/src/osgPlugins/obj/OBJWriterNodeVisitor.cpp index 8914f6666..b15ede497 100644 --- a/src/osgPlugins/obj/OBJWriterNodeVisitor.cpp +++ b/src/osgPlugins/obj/OBJWriterNodeVisitor.cpp @@ -70,6 +70,9 @@ class ValueVisitor : public osg::ValueVisitor { _fout << v[0] << ' ' << v[1] << ' ' << v[2]; } private: + + ValueVisitor& operator = (const ValueVisitor&) { return *this; } + std::ostream& _fout; osg::Matrix _m; bool _applyMatrix, _isNormal; @@ -302,6 +305,9 @@ class PrimitiveIndexWriter : public osg::PrimitiveIndexFunctor { } private: + + PrimitiveIndexWriter& operator = (const PrimitiveIndexWriter&) { return *this; } + std::ostream& _fout; GLenum _modeCache; std::vector _indexCache; @@ -309,8 +315,6 @@ class PrimitiveIndexWriter : public osg::PrimitiveIndexFunctor { bool _hasNormalCoords, _hasTexCoords; osg::Geometry* _geo; unsigned int _normalIndex; - - }; diff --git a/src/osgPlugins/txp/ReaderWriterTXP.cpp b/src/osgPlugins/txp/ReaderWriterTXP.cpp index c26739708..0b4a4f85c 100644 --- a/src/osgPlugins/txp/ReaderWriterTXP.cpp +++ b/src/osgPlugins/txp/ReaderWriterTXP.cpp @@ -652,6 +652,8 @@ public: protected: osg::Node* seamReplacement(osg::Node* node); + + SeamFinder& operator = (const SeamFinder&) { return *this; } int _x, _y, _lod; const TXPArchive::TileInfo& _info; diff --git a/src/osgPlugins/txp/TXPIO.cpp b/src/osgPlugins/txp/TXPIO.cpp index 3e7988dd2..6b1501fbf 100644 --- a/src/osgPlugins/txp/TXPIO.cpp +++ b/src/osgPlugins/txp/TXPIO.cpp @@ -62,6 +62,10 @@ public: NodeVisitor::apply(node); } osgDB::Output &_fw; + +protected: + + Dump2Osg& operator = (const Dump2Osg&) { return *this; } }; diff --git a/src/osgPlugins/txp/TXPParser.cpp b/src/osgPlugins/txp/TXPParser.cpp index 8cb14f233..b32679961 100644 --- a/src/osgPlugins/txp/TXPParser.cpp +++ b/src/osgPlugins/txp/TXPParser.cpp @@ -293,6 +293,9 @@ public: traverse(group); } protected: + + FindEmptyGroupsVisitor& operator = (const FindEmptyGroupsVisitor&) { return *this; } + osg::NodeList& _nl; }; diff --git a/src/osgPlugins/txp/trpage_material.cpp b/src/osgPlugins/txp/trpage_material.cpp index 0dbc1ad33..466948198 100644 --- a/src/osgPlugins/txp/trpage_material.cpp +++ b/src/osgPlugins/txp/trpage_material.cpp @@ -1074,21 +1074,15 @@ bool trpgTexture::isValid() const switch (mode) { case External: return (name != NULL); - break; case Local: return (type != trpg_Unknown && sizeX != -1 && sizeY != -1); - break; case Global: return (type != trpg_Unknown); - break; case Template: return (type != trpg_Unknown && sizeX != -1 && sizeY != -1); - break; default: return false; } - - return false; } diff --git a/src/osgUtil/Simplifier.cpp b/src/osgUtil/Simplifier.cpp index ab65e4bfc..73c42f5a0 100644 --- a/src/osgUtil/Simplifier.cpp +++ b/src/osgUtil/Simplifier.cpp @@ -1650,7 +1650,7 @@ class CopyPointsToVertexArrayVisitor : public osg::ArrayVisitor protected: - CopyPointsToVertexArrayVisitor& operator = (CopyPointsToArrayVisitor&) { return *this; } + CopyPointsToVertexArrayVisitor& operator = (const CopyPointsToArrayVisitor&) { return *this; } }; diff --git a/src/osgUtil/TriStrip_tri_stripper.h b/src/osgUtil/TriStrip_tri_stripper.h index d53cda117..e4df3ce87 100644 --- a/src/osgUtil/TriStrip_tri_stripper.h +++ b/src/osgUtil/TriStrip_tri_stripper.h @@ -82,7 +82,28 @@ class triangle { public: triangle(); + + triangle(const triangle& tri): + m_A(tri.m_A), + m_B(tri.m_B), + m_C(tri.m_C), + m_StripID(tri.m_StripID) + { + } + triangle(const indice A, const indice B, const indice C); + + triangle& operator = (const triangle& tri) + { + if (&tri==this) return *this; + + m_A = tri.m_A; + m_B = tri.m_B; + m_C = tri.m_C; + m_StripID = tri.m_StripID; + + return *this; + } void SetStripID(const size_t StripID);