From 773ba28bfb3ce86dd2f9704d39d60b00d5f30b77 Mon Sep 17 00:00:00 2001 From: Tobias Lippert Date: Thu, 15 Aug 2013 22:27:46 +0200 Subject: Bug # 51154: cppunit warning cleaning This patch allows to compile the code with gcc's -Weffc++ It consists mostly of making copy constructors and assignment operators explicit and private, and of initializing all members in initializer lists. Change-Id: I6f1cae812c58e3791c2386a1288501cf2f559610 Reviewed-on: https://gerrit.libreoffice.org/5424 Reviewed-by: Tor Lillqvist Tested-by: Tor Lillqvist --- include/cppunit/Message.h | 4 ++-- include/cppunit/Protector.h | 2 ++ include/cppunit/SynchronizedObject.h | 12 +++++++++--- include/cppunit/XmlOutputter.h | 2 +- include/cppunit/ui/text/TextTestRunner.h | 6 ++++++ 5 files changed, 20 insertions(+), 6 deletions(-) (limited to 'include/cppunit') diff --git a/include/cppunit/Message.h b/include/cppunit/Message.h index 7c462d5..5b5e4ec 100644 --- a/include/cppunit/Message.h +++ b/include/cppunit/Message.h @@ -38,7 +38,7 @@ CPPUNIT_NS_BEGIN class CPPUNIT_API Message { public: - Message(); + Message() {}; // Ensure thread-safe copy by detaching the string. Message( const Message &other ); @@ -57,7 +57,7 @@ public: const std::string &detail2, const std::string &detail3 ); - ~Message(); + virtual ~Message(); Message &operator =( const Message &other ); diff --git a/include/cppunit/Protector.h b/include/cppunit/Protector.h index d14e75f..c6d2e7c 100644 --- a/include/cppunit/Protector.h +++ b/include/cppunit/Protector.h @@ -84,6 +84,8 @@ public: ~ProtectorGuard(); private: + ProtectorGuard( const ProtectorGuard& ); /* not copyable */ + ProtectorGuard& operator=( const ProtectorGuard& ); /* not assignable */ TestResult *m_result; }; diff --git a/include/cppunit/SynchronizedObject.h b/include/cppunit/SynchronizedObject.h index 0f7d094..59c3cbb 100644 --- a/include/cppunit/SynchronizedObject.h +++ b/include/cppunit/SynchronizedObject.h @@ -50,15 +50,21 @@ protected: public: ExclusiveZone( SynchronizationObject *syncObject ) - : m_syncObject( syncObject ) + : m_syncObject( syncObject ) { - m_syncObject->lock(); + m_syncObject->lock(); } ~ExclusiveZone() { - m_syncObject->unlock (); + m_syncObject->unlock (); } + private: + /// Prevents the use of the copy constructor. + ExclusiveZone( const ExclusiveZone& ); + + /// Prevents the use of the copy operator. + ExclusiveZone& operator=( const ExclusiveZone& ); }; virtual void setSynchronizationObject( SynchronizationObject *syncObject ); diff --git a/include/cppunit/XmlOutputter.h b/include/cppunit/XmlOutputter.h index 0de9676..da8164a 100644 --- a/include/cppunit/XmlOutputter.h +++ b/include/cppunit/XmlOutputter.h @@ -46,7 +46,7 @@ public: */ XmlOutputter( TestResultCollector *result, OStream &stream, - std::string encoding = std::string("ISO-8859-1") ); + const std::string& encoding = std::string("ISO-8859-1") ); /// Destructor. virtual ~XmlOutputter(); diff --git a/include/cppunit/ui/text/TextTestRunner.h b/include/cppunit/ui/text/TextTestRunner.h index 86da4d4..6250166 100644 --- a/include/cppunit/ui/text/TextTestRunner.h +++ b/include/cppunit/ui/text/TextTestRunner.h @@ -86,6 +86,12 @@ protected: virtual void wait( bool doWait ); virtual void printResult( bool doPrintResult ); +private: + // prohibit copying + TextTestRunner( const TextTestRunner& ); + // prohibit copying + TextTestRunner& operator=( const TextTestRunner& ); + TestResultCollector *m_result; TestResult *m_eventManager; Outputter *m_outputter; -- cgit v1.2.1