summaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorzeshuai007 <51382517@qq.com>2020-06-03 17:24:38 +0800
committerJens Geyer <jensg@apache.org>2020-06-14 14:17:11 +0200
commit26681fbdb77f6dfaf2f2613d4ad860a224e84b71 (patch)
treeb742ea0959bd5e90e1748323a870291ef8ad8e9f /contrib
parent3f78c70bbba82c733b1545d39eb5b489ac384e4c (diff)
downloadthrift-26681fbdb77f6dfaf2f2613d4ad860a224e84b71.tar.gz
THRIFT-5225: Use nullptr instead of NULL
Patch: Zezeng Wang This closes #2168
Diffstat (limited to 'contrib')
-rw-r--r--contrib/async-test/test-server.cpp2
-rw-r--r--contrib/fb303/TClientInfo.cpp20
-rw-r--r--contrib/fb303/TClientInfo.h8
-rw-r--r--contrib/fb303/cpp/FacebookBase.cpp2
-rw-r--r--contrib/fb303/cpp/FacebookBase.h2
-rw-r--r--contrib/fb303/cpp/ServiceTracker.cpp24
-rw-r--r--contrib/fb303/cpp/ServiceTracker.h2
-rw-r--r--contrib/transport-sample/ThriftCommon.cpp2
-rw-r--r--contrib/zeromq/TZmqServer.cpp2
9 files changed, 32 insertions, 32 deletions
diff --git a/contrib/async-test/test-server.cpp b/contrib/async-test/test-server.cpp
index b304e1bc9..9e696c92c 100644
--- a/contrib/async-test/test-server.cpp
+++ b/contrib/async-test/test-server.cpp
@@ -28,7 +28,7 @@ class AggrAsyncHandler : public AggrCobSvIf {
public:
AggrAsyncHandler()
- : eb_(NULL)
+ : eb_(nullptr)
, pfact_(new TBinaryProtocolFactory())
{
leaf_ports_.push_back(8081);
diff --git a/contrib/fb303/TClientInfo.cpp b/contrib/fb303/TClientInfo.cpp
index 1fc661251..a4b00cf2d 100644
--- a/contrib/fb303/TClientInfo.cpp
+++ b/contrib/fb303/TClientInfo.cpp
@@ -34,7 +34,7 @@ void TClientInfoConnection::recordAddr(const sockaddr* addr) {
eraseAddr();
initTime();
ncalls_ = 0;
- if (addr != NULL) {
+ if (addr != nullptr) {
if (addr->sa_family == AF_INET) {
memcpy((void*)&addr_.ipv4, (const void *)addr, sizeof(sockaddr_in));
}
@@ -55,7 +55,7 @@ const char* TClientInfoConnection::getAddr(char* buf, int len) const {
case AF_INET6:
return inet_ntop(AF_INET6, &addr_.ipv6.sin6_addr, buf, len);
default:
- return NULL;
+ return nullptr;
}
}
@@ -70,7 +70,7 @@ void TClientInfoConnection::eraseCall() {
const char* TClientInfoConnection::getCall() const {
if (call_[0] == '\0') {
- return NULL;
+ return nullptr;
}
return call_;
}
@@ -90,7 +90,7 @@ void TClientInfoConnection::initTime() {
TClientInfoConnection* TClientInfo::getConnection(int fd, bool grow) {
if (fd < 0 || (!grow && fd >= info_.size())) {
- return NULL;
+ return nullptr;
}
return &info_[fd];
}
@@ -119,7 +119,7 @@ void TClientInfoServerHandler::deleteContext(void* connectionContext,
void TClientInfoServerHandler::processContext(void* connectionContext,
shared_ptr<TTransport> transport) {
Connect* call = static_cast<Connect*>(connectionContext);
- if (call->callInfo_ == NULL) {
+ if (call->callInfo_ == nullptr) {
if (typeid(*(transport.get())) == typeid(TSocket)) {
TSocket* tsocket = static_cast<TSocket*>(transport.get());
int fd = tsocket->getSocketFD();
@@ -127,7 +127,7 @@ void TClientInfoServerHandler::processContext(void* connectionContext,
return;
}
call->callInfo_ = call->clientInfo_->getConnection(fd, true);
- assert(call->callInfo_ != NULL);
+ assert(call->callInfo_ != nullptr);
socklen_t len;
call->callInfo_->recordAddr(tsocket->getCachedAddress(&len));
}
@@ -142,13 +142,13 @@ void TClientInfoServerHandler::getStatsStrings(vector<string>& result) {
for (int i = 0; i < clientInfo_.size(); ++i) {
TClientInfoConnection* info = clientInfo_.getConnection(i, false);
const char* callStr = info->getCall();
- if (callStr == NULL) {
+ if (callStr == nullptr) {
continue;
}
char addrBuf[INET6_ADDRSTRLEN];
const char* addrStr = info->getAddr(addrBuf, sizeof addrBuf);
- if (addrStr == NULL) {
+ if (addrStr == nullptr) {
// cerr << "no addr!" << endl;
continue;
}
@@ -168,11 +168,11 @@ void TClientInfoServerHandler::getStatsStrings(vector<string>& result) {
void* TClientInfoCallHandler::getContext(const char* fn_name, void* serverContext) {
if (serverContext) {
TClientInfoConnection* callInfo = static_cast<TClientInfoServerHandler::Connect*>(serverContext)->callInfo_;
- if (callInfo != NULL) {
+ if (callInfo != nullptr) {
callInfo->recordCall(fn_name);
}
}
- return NULL;
+ return nullptr;
}
} } } // namespace apache::thrift::server
diff --git a/contrib/fb303/TClientInfo.h b/contrib/fb303/TClientInfo.h
index 6668c1921..e3859a71e 100644
--- a/contrib/fb303/TClientInfo.h
+++ b/contrib/fb303/TClientInfo.h
@@ -174,7 +174,7 @@ class TClientInfoConnection {
void eraseAddr();
/**
- * Return a string representing the present address, or NULL if none.
+ * Return a string representing the present address, or nullptr if none.
* Copies the string into the buffer provided.
*/
const char* getAddr(char* buf, int len) const;
@@ -193,7 +193,7 @@ class TClientInfoConnection {
/**
* Return as string the thrift call either currently being processed or
* most recently processed if the connection is still open for additional
- * calls. Returns NULL if a call hasn't been made yet or processing
+ * calls. Returns nullptr if a call hasn't been made yet or processing
* has ended.
*/
const char* getCall() const;
@@ -229,7 +229,7 @@ class TClientInfo {
* Return the info object for a given file descriptor. If "grow" is true
* extend the info vector if required (such as for a file descriptor not seen
* before). If "grow" is false and the info vector isn't large enough,
- * or if "fd" is negative, return NULL.
+ * or if "fd" is negative, return nullptr.
*/
TClientInfoConnection* getConnection(int fd, bool grow);
@@ -258,7 +258,7 @@ class TClientInfoServerHandler : public TServerEventHandler {
explicit Connect(TClientInfo* clientInfo)
: clientInfo_(clientInfo)
- , callInfo_(NULL) {
+ , callInfo_(nullptr) {
}
};
diff --git a/contrib/fb303/cpp/FacebookBase.cpp b/contrib/fb303/cpp/FacebookBase.cpp
index 3c569759c..eb2e63cc5 100644
--- a/contrib/fb303/cpp/FacebookBase.cpp
+++ b/contrib/fb303/cpp/FacebookBase.cpp
@@ -24,7 +24,7 @@ using apache::thrift::concurrency::Guard;
FacebookBase::FacebookBase(std::string name) :
name_(name) {
- aliveSince_ = (int64_t) time(NULL);
+ aliveSince_ = (int64_t) time(nullptr);
}
inline void FacebookBase::getName(std::string& _return) {
diff --git a/contrib/fb303/cpp/FacebookBase.h b/contrib/fb303/cpp/FacebookBase.h
index daa524644..e0be4bf2e 100644
--- a/contrib/fb303/cpp/FacebookBase.h
+++ b/contrib/fb303/cpp/FacebookBase.h
@@ -65,7 +65,7 @@ class FacebookBase : virtual public FacebookServiceIf {
virtual void reinitialize() {}
virtual void shutdown() {
- if (server_.get() != NULL) {
+ if (server_.get() != nullptr) {
server_->stop();
}
}
diff --git a/contrib/fb303/cpp/ServiceTracker.cpp b/contrib/fb303/cpp/ServiceTracker.cpp
index 7a61b21a9..a2e670c76 100644
--- a/contrib/fb303/cpp/ServiceTracker.cpp
+++ b/contrib/fb303/cpp/ServiceTracker.cpp
@@ -46,7 +46,7 @@ ServiceTracker::ServiceTracker(facebook::fb303::FacebookBase *handler,
checkpointServices_(0)
{
if (featureCheckpoint_) {
- time_t now = time(NULL);
+ time_t now = time(nullptr);
checkpointTime_ = now;
} else {
checkpointTime_ = 0;
@@ -105,7 +105,7 @@ ServiceTracker::startService(const ServiceMethod &serviceMethod)
if (featureThreadCheck_ && !serviceMethod.featureLogOnly_) {
// note: Might want to put these messages in reportCheckpoint() if
// log is getting spammed.
- if (threadManager_ != NULL) {
+ if (threadManager_ != nullptr) {
size_t idle_count = threadManager_->idleWorkerCount();
if (idle_count == 0) {
stringstream message;
@@ -211,7 +211,7 @@ ServiceTracker::finishService(const ServiceMethod &serviceMethod)
// maybe report checkpoint
// note: ...if it's been long enough since the last report.
- time_t now = time(NULL);
+ time_t now = time(nullptr);
uint64_t check_interval = now - checkpointTime_;
if (check_interval >= CHECKPOINT_MINIMUM_INTERVAL_SECONDS) {
reportCheckpoint();
@@ -239,7 +239,7 @@ ServiceTracker::finishService(const ServiceMethod &serviceMethod)
void
ServiceTracker::reportCheckpoint()
{
- time_t now = time(NULL);
+ time_t now = time(nullptr);
uint64_t check_count = checkpointServices_;
uint64_t check_interval = now - checkpointTime_;
@@ -282,7 +282,7 @@ ServiceTracker::reportCheckpoint()
<< " checkpoint_speed_sum:" << check_duration
<< " lifetime_time:" << life_interval
<< " lifetime_services:" << life_count;
- if (featureThreadCheck_ && threadManager_ != NULL) {
+ if (featureThreadCheck_ && threadManager_ != nullptr) {
size_t worker_count = threadManager_->workerCount();
size_t idle_count = threadManager_->idleWorkerCount();
message << " total_workers:" << worker_count
@@ -321,7 +321,7 @@ ServiceTracker::defaultLogMethod(int level, const string &message)
{
if (level <= LOG_LEVEL) {
string level_string;
- time_t now = time(NULL);
+ time_t now = time(nullptr);
char now_pretty[26];
ctime_r(&now, now_pretty);
now_pretty[24] = '\0';
@@ -356,20 +356,20 @@ ServiceTracker::defaultLogMethod(int level, const string &message)
*/
Stopwatch::Stopwatch()
{
- gettimeofday(&startTime_, NULL);
+ gettimeofday(&startTime_, nullptr);
}
void
Stopwatch::reset()
{
- gettimeofday(&startTime_, NULL);
+ gettimeofday(&startTime_, nullptr);
}
uint64_t
Stopwatch::elapsedUnits(Stopwatch::Unit unit, string *label) const
{
timeval now_time;
- gettimeofday(&now_time, NULL);
+ gettimeofday(&now_time, nullptr);
time_t duration_secs = now_time.tv_sec - startTime_.tv_sec;
uint64_t duration_units;
@@ -377,7 +377,7 @@ Stopwatch::elapsedUnits(Stopwatch::Unit unit, string *label) const
case UNIT_SECONDS:
duration_units = duration_secs
+ (now_time.tv_usec - startTime_.tv_usec + 500000) / 1000000;
- if (NULL != label) {
+ if (nullptr != label) {
stringstream ss_label;
ss_label << duration_units << " secs";
label->assign(ss_label.str());
@@ -386,7 +386,7 @@ Stopwatch::elapsedUnits(Stopwatch::Unit unit, string *label) const
case UNIT_MICROSECONDS:
duration_units = duration_secs * 1000000
+ now_time.tv_usec - startTime_.tv_usec;
- if (NULL != label) {
+ if (nullptr != label) {
stringstream ss_label;
ss_label << duration_units << " us";
label->assign(ss_label.str());
@@ -396,7 +396,7 @@ Stopwatch::elapsedUnits(Stopwatch::Unit unit, string *label) const
default:
duration_units = duration_secs * 1000
+ (now_time.tv_usec - startTime_.tv_usec + 500) / 1000;
- if (NULL != label) {
+ if (nullptr != label) {
stringstream ss_label;
ss_label << duration_units << " ms";
label->assign(ss_label.str());
diff --git a/contrib/fb303/cpp/ServiceTracker.h b/contrib/fb303/cpp/ServiceTracker.h
index 9a3edd8f1..faaa4a72d 100644
--- a/contrib/fb303/cpp/ServiceTracker.h
+++ b/contrib/fb303/cpp/ServiceTracker.h
@@ -120,7 +120,7 @@ class Stopwatch
public:
enum Unit { UNIT_SECONDS, UNIT_MILLISECONDS, UNIT_MICROSECONDS };
Stopwatch();
- uint64_t elapsedUnits(Unit unit, std::string *label = NULL) const;
+ uint64_t elapsedUnits(Unit unit, std::string *label = nullptr) const;
void reset();
private:
timeval startTime_;
diff --git a/contrib/transport-sample/ThriftCommon.cpp b/contrib/transport-sample/ThriftCommon.cpp
index 60ebf7a00..2b676a88e 100644
--- a/contrib/transport-sample/ThriftCommon.cpp
+++ b/contrib/transport-sample/ThriftCommon.cpp
@@ -23,7 +23,7 @@ namespace thriftcommon
(int)boost::shared_dynamic_cast<TPipeServer>(transport)->getClientWrtPipeHandle());
//spawn the child process
- if (!CreateProcessA(NULL, handles, NULL,NULL,TRUE,0,NULL,NULL,&si,&pi))
+ if (!CreateProcessA(nullptr, handles, nullptr,nullptr,TRUE,0,nullptr,nullptr,&si,&pi))
{
GlobalOutput.perror("TPipeServer CreateProcess failed, GLE=", GetLastError());
return false;
diff --git a/contrib/zeromq/TZmqServer.cpp b/contrib/zeromq/TZmqServer.cpp
index 88660a330..1ad7db804 100644
--- a/contrib/zeromq/TZmqServer.cpp
+++ b/contrib/zeromq/TZmqServer.cpp
@@ -41,7 +41,7 @@ bool TZmqServer::serveOne(int recv_flags) {
outputProtocolFactory_->getProtocol(outputTransport));
shared_ptr<TMemoryBuffer> transport(new TMemoryBuffer);
- processor_->process(inputProtocol, outputProtocol, NULL);
+ processor_->process(inputProtocol, outputProtocol, nullptr);
if (zmq_type_ == ZMQ_REP) {
uint8_t* buf;