Просмотр исходного кода

修正了所有eclipse c++代码静态分析警告

tanghai 14 лет назад
Родитель
Сommit
e68a7927f1

+ 8 - 3
Src/Egametang/Python/PythonInitTest.cc

@@ -10,12 +10,17 @@ using namespace boost::python;
 
 class PythonInitTest: public testing::Test
 {
+protected:
+	PythonInit python_init_;
+
 public:
 	PythonInitTest(): python_init_()
-	{}
+	{
+	}
 
-protected:
-	PythonInit python_init_;
+	virtual ~PythonInitTest()
+	{
+	}
 };
 
 TEST_F(PythonInitTest, Int)

+ 6 - 1
Src/Egametang/Python/PythonInterpreterTest.cc

@@ -13,7 +13,12 @@ protected:
 
 public:
 	PythonInterpreterTest(): python_interpreter_()
-	{}
+	{
+	}
+
+	virtual ~PythonInterpreterTest()
+	{
+	}
 };
 
 class PersonTest

+ 7 - 0
Src/Egametang/Rpc/RpcChannelTest.cc

@@ -81,6 +81,13 @@ public:
 
 class RpcChannelTest: public testing::Test
 {
+public:
+	RpcChannelTest()
+	{
+	}
+	virtual ~RpcChannelTest()
+	{
+	}
 };
 
 static void IOServiceRun(boost::asio::io_service& io_service)

+ 4 - 0
Src/Egametang/Rpc/RpcCommunicator.cc

@@ -11,6 +11,10 @@ RpcCommunicator::RpcCommunicator(boost::asio::io_service& io_service):
 {
 }
 
+RpcCommunicator::~RpcCommunicator()
+{
+}
+
 boost::asio::ip::tcp::socket& RpcCommunicator::Socket()
 {
 	return socket_;

+ 3 - 2
Src/Egametang/Rpc/RpcCommunicator.h

@@ -5,6 +5,7 @@
 #include <boost/unordered_map.hpp>
 #include <boost/asio.hpp>
 #include <boost/format.hpp>
+#include <boost/noncopyable.hpp>
 #include "Base/Marcos.h"
 #include "Base/Typedef.h"
 #include "Rpc/RpcTypedef.h"
@@ -33,14 +34,14 @@ struct RpcMeta
 	}
 };
 
-class RpcCommunicator
+class RpcCommunicator: public boost::noncopyable
 {
 protected:
 	boost::asio::io_service& io_service_;
 	boost::asio::ip::tcp::socket socket_;
 
 	explicit RpcCommunicator(boost::asio::io_service& io_service);
-
+	virtual ~RpcCommunicator();
 	boost::asio::ip::tcp::socket& Socket();
 
 	virtual void Stop();

+ 4 - 0
Src/Egametang/Rpc/RpcCommunicatorTest.cc

@@ -162,6 +162,10 @@ public:
 		rpc_client_(io_client_, global_port, barrier_)
 	{
 	}
+
+	virtual ~RpcCommunicatorTest()
+	{
+	}
 };
 
 

+ 1 - 0
Src/Egametang/Rpc/RpcController.cc

@@ -37,6 +37,7 @@ void RpcController::SetFailed(const std::string& reason)
 
 bool RpcController::IsCanceled() const
 {
+	return canceled_;
 }
 
 void RpcController::NotifyOnCancel(google::protobuf::Closure *callback)

+ 1 - 1
Src/Egametang/Rpc/RpcController.h

@@ -14,7 +14,7 @@ private:
 
 public:
 	RpcController();
-	~RpcController();
+	virtual ~RpcController();
 
 	// client
 	virtual void Reset();

+ 5 - 2
Src/Egametang/Thread/CountBarrierTest.cc

@@ -15,10 +15,13 @@ class CountBarrierTest: public testing::Test
 protected:
 	boost::detail::atomic_count count_;
 public:
-	CountBarrierTest():
-		count_(0)
+	CountBarrierTest(): count_(0)
 	{
 	}
+	virtual ~CountBarrierTest()
+	{
+	}
+
 	void Wait(CountBarrier& barrier)
 	{
 		barrier.Wait();

+ 1 - 1
Src/Egametang/Thread/ThreadPool.h

@@ -25,7 +25,7 @@ private:
 	void Runner();
 public:
 	ThreadPool(int num = 0);
-	~ThreadPool();
+	virtual ~ThreadPool();
 
 	virtual void Wait();
 	virtual bool PushTask(boost::function<void (void)> task);

+ 6 - 0
Src/Egametang/Thread/ThreadPoolTest.cc

@@ -11,10 +11,16 @@ class ThreadPoolTest: public testing::Test
 {
 protected:
 	ThreadPool pool_;
+
 public:
 	ThreadPoolTest() : pool_(10)
 	{
 	}
+
+	virtual ~ThreadPoolTest()
+	{
+	}
+
 	void Max(int a, int b, int* z)
 	{
 		*z = a > b? a : b;

+ 12 - 3
Src/Experimental/BoostFunctionTest.cc

@@ -10,14 +10,23 @@
 namespace Egametang {
 class BoostTest: public testing::Test
 {
+protected:
+	int a;
+	boost::function<int(int)> func;
+
 	void SetUp()
 	{
 		a = 6;
 	}
-protected:
-	int a;
-	boost::function<int(int)> func;
 public:
+	BoostTest()
+	{
+	}
+
+	virtual ~BoostTest()
+	{
+	}
+
 	int Max(int a, int b)
 	{
 		LOG(INFO) << a << " " << b;