THRIFT-5225: Use nullptr instead of NULL
Patch: Zezeng Wang

This closes #2168
diff --git a/contrib/fb303/TClientInfo.cpp b/contrib/fb303/TClientInfo.cpp
index 1fc6612..a4b00cf 100644
--- a/contrib/fb303/TClientInfo.cpp
+++ b/contrib/fb303/TClientInfo.cpp
@@ -34,7 +34,7 @@
   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 @@
   case AF_INET6:
     return inet_ntop(AF_INET6, &addr_.ipv6.sin6_addr, buf, len);
   default:
-    return NULL;
+    return nullptr;
   }
 }
 
@@ -70,7 +70,7 @@
 
 const char* TClientInfoConnection::getCall() const {
   if (call_[0] == '\0') {
-      return NULL;
+      return nullptr;
   }
   return call_;
 }
@@ -90,7 +90,7 @@
 
 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::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 @@
         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 @@
   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* 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 6668c19..e3859a7 100644
--- a/contrib/fb303/TClientInfo.h
+++ b/contrib/fb303/TClientInfo.h
@@ -174,7 +174,7 @@
   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 @@
   /**
    * 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 @@
    * 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 @@
 
     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 3c56975..eb2e63c 100644
--- a/contrib/fb303/cpp/FacebookBase.cpp
+++ b/contrib/fb303/cpp/FacebookBase.cpp
@@ -24,7 +24,7 @@
 
 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 daa5246..e0be4bf 100644
--- a/contrib/fb303/cpp/FacebookBase.h
+++ b/contrib/fb303/cpp/FacebookBase.h
@@ -65,7 +65,7 @@
   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 7a61b21..a2e670c 100644
--- a/contrib/fb303/cpp/ServiceTracker.cpp
+++ b/contrib/fb303/cpp/ServiceTracker.cpp
@@ -46,7 +46,7 @@
     checkpointServices_(0)
 {
   if (featureCheckpoint_) {
-    time_t now = time(NULL);
+    time_t now = time(nullptr);
     checkpointTime_ = now;
   } else {
     checkpointTime_ = 0;
@@ -105,7 +105,7 @@
   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 @@
 
         // 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 @@
 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 @@
           << " 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 @@
 {
   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 @@
  */
 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 @@
   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 @@
   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 @@
   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 9a3edd8..faaa4a7 100644
--- a/contrib/fb303/cpp/ServiceTracker.h
+++ b/contrib/fb303/cpp/ServiceTracker.h
@@ -120,7 +120,7 @@
 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_;