THRIFT-5225: Use nullptr instead of NULL
Patch: Zezeng Wang
This closes #2168
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_;