Updated Branches: refs/heads/master 42cb873ea -> 7295745b1
THRIFT-2071 clang 3.2 reports warning when comparing shared_ptr<X> == NULL Patch: Konrad Grochowski Project: http://git-wip-us.apache.org/repos/asf/thrift/repo Commit: http://git-wip-us.apache.org/repos/asf/thrift/commit/7295745b Tree: http://git-wip-us.apache.org/repos/asf/thrift/tree/7295745b Diff: http://git-wip-us.apache.org/repos/asf/thrift/diff/7295745b Branch: refs/heads/master Commit: 7295745b1762255af50dadd0e480e8393a25f9ff Parents: 42cb873 Author: Roger Meier <[email protected]> Authored: Sat Jun 29 00:28:50 2013 +0200 Committer: Roger Meier <[email protected]> Committed: Sat Jun 29 00:28:50 2013 +0200 ---------------------------------------------------------------------- .../thrift/concurrency/BoostThreadFactory.cpp | 2 +- .../src/thrift/concurrency/ThreadManager.cpp | 4 +-- lib/cpp/src/thrift/concurrency/TimerManager.cpp | 2 +- .../src/thrift/server/TNonblockingServer.cpp | 18 +++++++------- lib/cpp/src/thrift/server/TSimpleServer.cpp | 26 ++++++++++---------- lib/cpp/src/thrift/server/TThreadPoolServer.cpp | 26 ++++++++++---------- lib/cpp/src/thrift/server/TThreadedServer.cpp | 26 ++++++++++---------- lib/cpp/src/thrift/transport/TServerTransport.h | 2 +- 8 files changed, 53 insertions(+), 53 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/thrift/blob/7295745b/lib/cpp/src/thrift/concurrency/BoostThreadFactory.cpp ---------------------------------------------------------------------- diff --git a/lib/cpp/src/thrift/concurrency/BoostThreadFactory.cpp b/lib/cpp/src/thrift/concurrency/BoostThreadFactory.cpp index 577329b..decacce 100644 --- a/lib/cpp/src/thrift/concurrency/BoostThreadFactory.cpp +++ b/lib/cpp/src/thrift/concurrency/BoostThreadFactory.cpp @@ -115,7 +115,7 @@ void* BoostThread::threadMain(void* arg) { shared_ptr<BoostThread> thread = *(shared_ptr<BoostThread>*)arg; delete reinterpret_cast<shared_ptr<BoostThread>*>(arg); - if (thread == NULL) { + if (!thread) { return (void*)0; } http://git-wip-us.apache.org/repos/asf/thrift/blob/7295745b/lib/cpp/src/thrift/concurrency/ThreadManager.cpp ---------------------------------------------------------------------- diff --git a/lib/cpp/src/thrift/concurrency/ThreadManager.cpp b/lib/cpp/src/thrift/concurrency/ThreadManager.cpp index d5373de..298dbac 100644 --- a/lib/cpp/src/thrift/concurrency/ThreadManager.cpp +++ b/lib/cpp/src/thrift/concurrency/ThreadManager.cpp @@ -308,7 +308,7 @@ class ThreadManager::Worker: public Runnable { } } - if (task != NULL) { + if (task) { if (task->state_ == ThreadManager::Task::EXECUTING) { try { task->run(); @@ -375,7 +375,7 @@ void ThreadManager::Impl::start() { { Synchronized s(monitor_); if (state_ == ThreadManager::UNINITIALIZED) { - if (threadFactory_ == NULL) { + if (!threadFactory_) { throw InvalidArgumentException(); } state_ = ThreadManager::STARTED; http://git-wip-us.apache.org/repos/asf/thrift/blob/7295745b/lib/cpp/src/thrift/concurrency/TimerManager.cpp ---------------------------------------------------------------------- diff --git a/lib/cpp/src/thrift/concurrency/TimerManager.cpp b/lib/cpp/src/thrift/concurrency/TimerManager.cpp index b47c697..6821b2e 100644 --- a/lib/cpp/src/thrift/concurrency/TimerManager.cpp +++ b/lib/cpp/src/thrift/concurrency/TimerManager.cpp @@ -174,7 +174,7 @@ void TimerManager::start() { bool doStart = false; { Synchronized s(monitor_); - if (threadFactory_ == NULL) { + if (!threadFactory_) { throw InvalidArgumentException(); } if (state_ == TimerManager::UNINITIALIZED) { http://git-wip-us.apache.org/repos/asf/thrift/blob/7295745b/lib/cpp/src/thrift/server/TNonblockingServer.cpp ---------------------------------------------------------------------- diff --git a/lib/cpp/src/thrift/server/TNonblockingServer.cpp b/lib/cpp/src/thrift/server/TNonblockingServer.cpp index 7902776..398eade 100644 --- a/lib/cpp/src/thrift/server/TNonblockingServer.cpp +++ b/lib/cpp/src/thrift/server/TNonblockingServer.cpp @@ -347,7 +347,7 @@ class TNonblockingServer::TConnection::Task: public Runnable { void run() { try { for (;;) { - if (serverEventHandler_ != NULL) { + if (serverEventHandler_) { serverEventHandler_->processContext(connectionContext_, connection_->getTSocket()); } if (!processor_->process(input_, output_, connectionContext_) || @@ -424,7 +424,7 @@ void TNonblockingServer::TConnection::init(THRIFT_SOCKET socket, // Set up for any server event handler serverEventHandler_ = server_->getEventHandler(); - if (serverEventHandler_ != NULL) { + if (serverEventHandler_) { connectionContext_ = serverEventHandler_->createContext(inputProtocol_, outputProtocol_); } else { @@ -615,10 +615,10 @@ void TNonblockingServer::TConnection::transition() { return; } else { try { - if (serverEventHandler_ != NULL) { - serverEventHandler_->processContext(connectionContext_, - getTSocket()); - } + if (serverEventHandler_) { + serverEventHandler_->processContext(connectionContext_, + getTSocket()); + } // Invoke the processor processor_->process(inputProtocol_, outputProtocol_, connectionContext_); @@ -828,7 +828,7 @@ void TNonblockingServer::TConnection::close() { GlobalOutput.perror("TConnection::close() event_del", THRIFT_GET_SOCKET_ERROR); } - if (serverEventHandler_ != NULL) { + if (serverEventHandler_) { serverEventHandler_->deleteContext(connectionContext_, inputProtocol_, outputProtocol_); } ioThread_ = NULL; @@ -1130,7 +1130,7 @@ void TNonblockingServer::listenSocket(THRIFT_SOCKET s) { void TNonblockingServer::setThreadManager(boost::shared_ptr<ThreadManager> threadManager) { threadManager_ = threadManager; - if (threadManager != NULL) { + if (threadManager) { threadManager->setExpireCallback(apache::thrift::stdcxx::bind(&TNonblockingServer::expireClose, this, apache::thrift::stdcxx::placeholders::_1)); threadPoolProcessing_ = true; } else { @@ -1215,7 +1215,7 @@ void TNonblockingServer::serve() { } // Notify handler of the preServe event - if (eventHandler_ != NULL) { + if (eventHandler_) { eventHandler_->preServe(); } http://git-wip-us.apache.org/repos/asf/thrift/blob/7295745b/lib/cpp/src/thrift/server/TSimpleServer.cpp ---------------------------------------------------------------------- diff --git a/lib/cpp/src/thrift/server/TSimpleServer.cpp b/lib/cpp/src/thrift/server/TSimpleServer.cpp index b132a66..5fc4c97 100644 --- a/lib/cpp/src/thrift/server/TSimpleServer.cpp +++ b/lib/cpp/src/thrift/server/TSimpleServer.cpp @@ -46,7 +46,7 @@ void TSimpleServer::serve() { serverTransport_->listen(); // Run the preServe event - if (eventHandler_ != NULL) { + if (eventHandler_) { eventHandler_->preServe(); } @@ -59,25 +59,25 @@ void TSimpleServer::serve() { inputProtocol = inputProtocolFactory_->getProtocol(inputTransport); outputProtocol = outputProtocolFactory_->getProtocol(outputTransport); } catch (TTransportException& ttx) { - if (inputTransport != NULL) { inputTransport->close(); } - if (outputTransport != NULL) { outputTransport->close(); } - if (client != NULL) { client->close(); } + if (inputTransport) { inputTransport->close(); } + if (outputTransport) { outputTransport->close(); } + if (client) { client->close(); } if (!stop_ || ttx.getType() != TTransportException::INTERRUPTED) { string errStr = string("TServerTransport died on accept: ") + ttx.what(); GlobalOutput(errStr.c_str()); } continue; } catch (TException& tx) { - if (inputTransport != NULL) { inputTransport->close(); } - if (outputTransport != NULL) { outputTransport->close(); } - if (client != NULL) { client->close(); } + if (inputTransport) { inputTransport->close(); } + if (outputTransport) { outputTransport->close(); } + if (client) { client->close(); } string errStr = string("Some kind of accept exception: ") + tx.what(); GlobalOutput(errStr.c_str()); continue; } catch (string s) { - if (inputTransport != NULL) { inputTransport->close(); } - if (outputTransport != NULL) { outputTransport->close(); } - if (client != NULL) { client->close(); } + if (inputTransport) { inputTransport->close(); } + if (outputTransport) { outputTransport->close(); } + if (client) { client->close(); } string errStr = string("Some kind of accept exception: ") + s; GlobalOutput(errStr.c_str()); break; @@ -88,12 +88,12 @@ void TSimpleServer::serve() { outputProtocol, client); void* connectionContext = NULL; - if (eventHandler_ != NULL) { + if (eventHandler_) { connectionContext = eventHandler_->createContext(inputProtocol, outputProtocol); } try { for (;;) { - if (eventHandler_ != NULL) { + if (eventHandler_) { eventHandler_->processContext(connectionContext, client); } if (!processor->process(inputProtocol, outputProtocol, @@ -112,7 +112,7 @@ void TSimpleServer::serve() { } catch (...) { GlobalOutput("TSimpleServer uncaught exception."); } - if (eventHandler_ != NULL) { + if (eventHandler_) { eventHandler_->deleteContext(connectionContext, inputProtocol, outputProtocol); } http://git-wip-us.apache.org/repos/asf/thrift/blob/7295745b/lib/cpp/src/thrift/server/TThreadPoolServer.cpp ---------------------------------------------------------------------- diff --git a/lib/cpp/src/thrift/server/TThreadPoolServer.cpp b/lib/cpp/src/thrift/server/TThreadPoolServer.cpp index 6ff946b..da33ec2 100644 --- a/lib/cpp/src/thrift/server/TThreadPoolServer.cpp +++ b/lib/cpp/src/thrift/server/TThreadPoolServer.cpp @@ -57,12 +57,12 @@ public: boost::shared_ptr<TServerEventHandler> eventHandler = server_.getEventHandler(); void* connectionContext = NULL; - if (eventHandler != NULL) { + if (eventHandler) { connectionContext = eventHandler->createContext(input_, output_); } try { for (;;) { - if (eventHandler != NULL) { + if (eventHandler) { eventHandler->processContext(connectionContext, transport_); } if (!processor_->process(input_, output_, connectionContext) || @@ -83,7 +83,7 @@ public: "TThreadPoolServer::Task::run()"); } - if (eventHandler != NULL) { + if (eventHandler) { eventHandler->deleteContext(connectionContext, input_, output_); } @@ -123,7 +123,7 @@ void TThreadPoolServer::serve() { serverTransport_->listen(); // Run the preServe event - if (eventHandler_ != NULL) { + if (eventHandler_) { eventHandler_->preServe(); } @@ -153,25 +153,25 @@ void TThreadPoolServer::serve() { threadManager_->add(task, timeout_, taskExpiration_); } catch (TTransportException& ttx) { - if (inputTransport != NULL) { inputTransport->close(); } - if (outputTransport != NULL) { outputTransport->close(); } - if (client != NULL) { client->close(); } + if (inputTransport) { inputTransport->close(); } + if (outputTransport) { outputTransport->close(); } + if (client) { client->close(); } if (!stop_ || ttx.getType() != TTransportException::INTERRUPTED) { string errStr = string("TThreadPoolServer: TServerTransport died on accept: ") + ttx.what(); GlobalOutput(errStr.c_str()); } continue; } catch (TException& tx) { - if (inputTransport != NULL) { inputTransport->close(); } - if (outputTransport != NULL) { outputTransport->close(); } - if (client != NULL) { client->close(); } + if (inputTransport) { inputTransport->close(); } + if (outputTransport) { outputTransport->close(); } + if (client) { client->close(); } string errStr = string("TThreadPoolServer: Caught TException: ") + tx.what(); GlobalOutput(errStr.c_str()); continue; } catch (string s) { - if (inputTransport != NULL) { inputTransport->close(); } - if (outputTransport != NULL) { outputTransport->close(); } - if (client != NULL) { client->close(); } + if (inputTransport) { inputTransport->close(); } + if (outputTransport) { outputTransport->close(); } + if (client) { client->close(); } string errStr = "TThreadPoolServer: Unknown exception: " + s; GlobalOutput(errStr.c_str()); break; http://git-wip-us.apache.org/repos/asf/thrift/blob/7295745b/lib/cpp/src/thrift/server/TThreadedServer.cpp ---------------------------------------------------------------------- diff --git a/lib/cpp/src/thrift/server/TThreadedServer.cpp b/lib/cpp/src/thrift/server/TThreadedServer.cpp index 6ed8fd8..909c3ce 100644 --- a/lib/cpp/src/thrift/server/TThreadedServer.cpp +++ b/lib/cpp/src/thrift/server/TThreadedServer.cpp @@ -59,12 +59,12 @@ public: boost::shared_ptr<TServerEventHandler> eventHandler = server_.getEventHandler(); void* connectionContext = NULL; - if (eventHandler != NULL) { + if (eventHandler) { connectionContext = eventHandler->createContext(input_, output_); } try { for (;;) { - if (eventHandler != NULL) { + if (eventHandler) { eventHandler->processContext(connectionContext, transport_); } if (!processor_->process(input_, output_, connectionContext) || @@ -83,7 +83,7 @@ public: } catch (...) { GlobalOutput("TThreadedServer uncaught exception."); } - if (eventHandler != NULL) { + if (eventHandler) { eventHandler->deleteContext(connectionContext, input_, output_); } @@ -143,7 +143,7 @@ void TThreadedServer::serve() { serverTransport_->listen(); // Run the preServe event - if (eventHandler_ != NULL) { + if (eventHandler_) { eventHandler_->preServe(); } @@ -191,25 +191,25 @@ void TThreadedServer::serve() { thread->start(); } catch (TTransportException& ttx) { - if (inputTransport != NULL) { inputTransport->close(); } - if (outputTransport != NULL) { outputTransport->close(); } - if (client != NULL) { client->close(); } + if (inputTransport) { inputTransport->close(); } + if (outputTransport) { outputTransport->close(); } + if (client) { client->close(); } if (!stop_ || ttx.getType() != TTransportException::INTERRUPTED) { string errStr = string("TThreadedServer: TServerTransport died on accept: ") + ttx.what(); GlobalOutput(errStr.c_str()); } continue; } catch (TException& tx) { - if (inputTransport != NULL) { inputTransport->close(); } - if (outputTransport != NULL) { outputTransport->close(); } - if (client != NULL) { client->close(); } + if (inputTransport) { inputTransport->close(); } + if (outputTransport) { outputTransport->close(); } + if (client) { client->close(); } string errStr = string("TThreadedServer: Caught TException: ") + tx.what(); GlobalOutput(errStr.c_str()); continue; } catch (string s) { - if (inputTransport != NULL) { inputTransport->close(); } - if (outputTransport != NULL) { outputTransport->close(); } - if (client != NULL) { client->close(); } + if (inputTransport) { inputTransport->close(); } + if (outputTransport) { outputTransport->close(); } + if (client) { client->close(); } string errStr = "TThreadedServer: Unknown exception: " + s; GlobalOutput(errStr.c_str()); break; http://git-wip-us.apache.org/repos/asf/thrift/blob/7295745b/lib/cpp/src/thrift/transport/TServerTransport.h ---------------------------------------------------------------------- diff --git a/lib/cpp/src/thrift/transport/TServerTransport.h b/lib/cpp/src/thrift/transport/TServerTransport.h index d54aa62..2ddee0d 100644 --- a/lib/cpp/src/thrift/transport/TServerTransport.h +++ b/lib/cpp/src/thrift/transport/TServerTransport.h @@ -55,7 +55,7 @@ class TServerTransport { */ boost::shared_ptr<TTransport> accept() { boost::shared_ptr<TTransport> result = acceptImpl(); - if (result == NULL) { + if (!result) { throw TTransportException("accept() may not return NULL"); } return result;
