kudu-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From danburk...@apache.org
Subject [1/5] incubator-kudu git commit: Replace NULL with nullptr
Date Tue, 19 Jan 2016 22:48:11 GMT
Repository: incubator-kudu
Updated Branches:
  refs/heads/master 5489476ea -> 35b49cc5a


http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/35b49cc5/src/kudu/util/resettable_heartbeater.cc
----------------------------------------------------------------------
diff --git a/src/kudu/util/resettable_heartbeater.cc b/src/kudu/util/resettable_heartbeater.cc
index 1a524a6..30456d4 100644
--- a/src/kudu/util/resettable_heartbeater.cc
+++ b/src/kudu/util/resettable_heartbeater.cc
@@ -146,7 +146,7 @@ bool ResettableHeartbeaterThread::IsCurrentThread() const {
 }
 
 Status ResettableHeartbeaterThread::Start() {
-  CHECK(thread_ == NULL);
+  CHECK(thread_ == nullptr);
   run_latch_.Reset(1);
   return kudu::Thread::Create("heartbeater", strings::Substitute("$0-heartbeat", name_),
                               &ResettableHeartbeaterThread::RunThread,

http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/35b49cc5/src/kudu/util/rle-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/util/rle-test.cc b/src/kudu/util/rle-test.cc
index 73e14b8..5d0266f 100644
--- a/src/kudu/util/rle-test.cc
+++ b/src/kudu/util/rle-test.cc
@@ -198,7 +198,7 @@ void ValidateRle(const vector<T>& values, int bit_width,
   if (expected_len != -1) {
     EXPECT_EQ(encoded_len, expected_len);
   }
-  if (expected_encoding != NULL) {
+  if (expected_encoding != nullptr) {
     EXPECT_EQ(memcmp(buffer.data(), expected_encoding, expected_len), 0)
       << "\n"
       << "Expected: " << HexDump(Slice(expected_encoding, expected_len)) <<
"\n"
@@ -239,7 +239,7 @@ TEST(Rle, SpecificSequences) {
   }
 
   for (int width = 9; width <= MAX_WIDTH; ++width) {
-    ValidateRle(values, width, NULL, 2 * (1 + BitUtil::Ceil(width, 8)));
+    ValidateRle(values, width, nullptr, 2 * (1 + BitUtil::Ceil(width, 8)));
   }
 
   // Test 100 0's and 1's alternating
@@ -257,7 +257,7 @@ TEST(Rle, SpecificSequences) {
   // num_groups and expected_buffer only valid for bit width = 1
   ValidateRle(values, 1, expected_buffer, 1 + num_groups);
   for (int width = 2; width <= MAX_WIDTH; ++width) {
-    ValidateRle(values, width, NULL, 1 + BitUtil::Ceil(width * 100, 8));
+    ValidateRle(values, width, nullptr, 1 + BitUtil::Ceil(width * 100, 8));
   }
 }
 
@@ -269,7 +269,7 @@ void TestRleValues(int bit_width, int num_vals, int value = -1) {
   for (int v = 0; v < num_vals; ++v) {
     values.push_back((value != -1) ? value : (v % mod));
   }
-  ValidateRle(values, bit_width, NULL, -1);
+  ValidateRle(values, bit_width, nullptr, -1);
 }
 
 TEST(Rle, TestValues) {
@@ -295,7 +295,7 @@ TEST_F(BitRle, AllSame) {
       values.push_back(v ? true : false);
     }
 
-    ValidateRle(values, 1, NULL, 3);
+    ValidateRle(values, 1, nullptr, 3);
   }
 }
 
@@ -305,13 +305,13 @@ TEST_F(BitRle, Flush) {
   vector<bool> values;
   for (int i = 0; i < 16; ++i) values.push_back(1);
   values.push_back(false);
-  ValidateRle(values, 1, NULL, -1);
+  ValidateRle(values, 1, nullptr, -1);
   values.push_back(true);
-  ValidateRle(values, 1, NULL, -1);
+  ValidateRle(values, 1, nullptr, -1);
   values.push_back(true);
-  ValidateRle(values, 1, NULL, -1);
+  ValidateRle(values, 1, nullptr, -1);
   values.push_back(true);
-  ValidateRle(values, 1, NULL, -1);
+  ValidateRle(values, 1, nullptr, -1);
 }
 
 // Test some random sequences.
@@ -333,7 +333,7 @@ TEST_F(BitRle, Random) {
       }
       parity = !parity;
     }
-    ValidateRle(values, (iters % MAX_WIDTH) + 1, NULL, -1);
+    ValidateRle(values, (iters % MAX_WIDTH) + 1, nullptr, -1);
   }
 }
 
@@ -359,7 +359,7 @@ TEST_F(BitRle, RepeatedPattern) {
     }
   }
 
-  ValidateRle(values, 1, NULL, -1);
+  ValidateRle(values, 1, nullptr, -1);
 }
 
 TEST_F(TestRle, TestBulkPut) {

http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/35b49cc5/src/kudu/util/rolling_log.cc
----------------------------------------------------------------------
diff --git a/src/kudu/util/rolling_log.cc b/src/kudu/util/rolling_log.cc
index c9b30ae..836cf52 100644
--- a/src/kudu/util/rolling_log.cc
+++ b/src/kudu/util/rolling_log.cc
@@ -204,7 +204,7 @@ class ScopedGzipCloser {
   }
 
   void Cancel() {
-    file_ = NULL;
+    file_ = nullptr;
   }
 
  private:

http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/35b49cc5/src/kudu/util/spinlock_profiling.cc
----------------------------------------------------------------------
diff --git a/src/kudu/util/spinlock_profiling.cc b/src/kudu/util/spinlock_profiling.cc
index bfe8e1b..f4a375f 100644
--- a/src/kudu/util/spinlock_profiling.cc
+++ b/src/kudu/util/spinlock_profiling.cc
@@ -53,7 +53,7 @@ namespace kudu {
 
 static const double kMicrosPerSecond = 1000000.0;
 
-static LongAdder* g_contended_cycles = NULL;
+static LongAdder* g_contended_cycles = nullptr;
 
 namespace {
 
@@ -131,7 +131,7 @@ class ContentionStacks {
 };
 
 Atomic32 g_profiling_enabled = 0;
-ContentionStacks* g_contention_stacks = NULL;
+ContentionStacks* g_contention_stacks = nullptr;
 
 void ContentionStacks::AddStack(const StackTrace& s, int64_t cycles) {
   uint64_t hash = s.HashCode();

http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/35b49cc5/src/kudu/util/status.cc
----------------------------------------------------------------------
diff --git a/src/kudu/util/status.cc b/src/kudu/util/status.cc
index 6a5a616..291d4bf 100644
--- a/src/kudu/util/status.cc
+++ b/src/kudu/util/status.cc
@@ -40,7 +40,7 @@ Status::Status(Code code, const Slice& msg, const Slice& msg2,
 }
 
 std::string Status::CodeAsString() const {
-  if (state_ == NULL) {
+  if (state_ == nullptr) {
     return "OK";
   }
 
@@ -109,7 +109,7 @@ std::string Status::CodeAsString() const {
 
 std::string Status::ToString() const {
   std::string result(CodeAsString());
-  if (state_ == NULL) {
+  if (state_ == nullptr) {
     return result;
   }
 
@@ -126,7 +126,7 @@ std::string Status::ToString() const {
 }
 
 Slice Status::message() const {
-  if (state_ == NULL) {
+  if (state_ == nullptr) {
     return Slice();
   }
 
@@ -136,7 +136,7 @@ Slice Status::message() const {
 }
 
 int16_t Status::posix_code() const {
-  if (state_ == NULL) {
+  if (state_ == nullptr) {
     return 0;
   }
   int16_t posix_code;

http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/35b49cc5/src/kudu/util/striped64.cc
----------------------------------------------------------------------
diff --git a/src/kudu/util/striped64.cc b/src/kudu/util/striped64.cc
index b22bac6..7b566e7 100644
--- a/src/kudu/util/striped64.cc
+++ b/src/kudu/util/striped64.cc
@@ -55,8 +55,8 @@ DEFINE_STATIC_THREAD_LOCAL(HashCode, Striped64, hashcode_);
 
 Striped64::Striped64()
     : busy_(false),
-      cell_buffer_(NULL),
-      cells_(NULL),
+      cell_buffer_(nullptr),
+      cells_(nullptr),
       num_cells_(0) {
 }
 

http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/35b49cc5/src/kudu/util/subprocess.cc
----------------------------------------------------------------------
diff --git a/src/kudu/util/subprocess.cc b/src/kudu/util/subprocess.cc
index bc801c6..94d57a1 100644
--- a/src/kudu/util/subprocess.cc
+++ b/src/kudu/util/subprocess.cc
@@ -73,7 +73,7 @@ void DisableSigPipe() {
   act.sa_handler = SIG_IGN;
   sigemptyset(&act.sa_mask);
   act.sa_flags = 0;
-  PCHECK(sigaction(SIGPIPE, &act, NULL) == 0);
+  PCHECK(sigaction(SIGPIPE, &act, nullptr) == 0);
 }
 
 void EnsureSigPipeDisabled() {
@@ -85,7 +85,7 @@ void EnsureSigPipeDisabled() {
 // This function is not async-signal-safe.
 Status OpenProcFdDir(DIR** dir) {
   *dir = opendir(kProcSelfFd);
-  if (PREDICT_FALSE(dir == NULL)) {
+  if (PREDICT_FALSE(dir == nullptr)) {
     return Status::IOError(Substitute("opendir(\"$0\") failed", kProcSelfFd),
                            ErrnoToString(errno), errno);
   }
@@ -119,7 +119,7 @@ void CloseNonStandardFDs(DIR* fd_dir) {
   // make it as lean and mean as possible -- this runs in the subprocess
   // after a fork, so there's some possibility that various global locks
   // inside malloc() might be held, so allocating memory is a no-no.
-  PCHECK(fd_dir != NULL);
+  PCHECK(fd_dir != nullptr);
   int dir_fd = dirfd(fd_dir);
 
   struct DIRENT* ent;
@@ -131,7 +131,7 @@ void CloseNonStandardFDs(DIR* fd_dir) {
   // malloc() or free(). We could use readdir64_r() instead, but all that
   // buys us is reentrancy, and not async-signal-safety, due to the use of
   // dir->lock, so seems not worth the added complexity in lifecycle & plumbing.
-  while ((ent = READDIR(fd_dir)) != NULL) {
+  while ((ent = READDIR(fd_dir)) != nullptr) {
     uint32_t fd;
     if (!safe_strtou32(ent->d_name, &fd)) continue;
     if (!(fd == STDIN_FILENO  ||
@@ -243,7 +243,7 @@ Status Subprocess::Start() {
   for (const string& arg : argv_) {
     argv_ptrs.push_back(const_cast<char*>(arg.c_str()));
   }
-  argv_ptrs.push_back(NULL);
+  argv_ptrs.push_back(nullptr);
 
   // Pipe from caller process to child's stdin
   // [0] = stdin for child, [1] = how parent writes to it
@@ -264,7 +264,7 @@ Status Subprocess::Start() {
     PCHECK(pipe2(child_stderr, O_CLOEXEC) == 0);
   }
 
-  DIR* fd_dir = NULL;
+  DIR* fd_dir = nullptr;
   RETURN_NOT_OK_PREPEND(OpenProcFdDir(&fd_dir), "Unable to open fd dir");
   shared_ptr<DIR> fd_dir_closer(fd_dir, CloseProcFdDir);
 

http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/35b49cc5/src/kudu/util/test_main.cc
----------------------------------------------------------------------
diff --git a/src/kudu/util/test_main.cc b/src/kudu/util/test_main.cc
index b65ef01..dd9af5f 100644
--- a/src/kudu/util/test_main.cc
+++ b/src/kudu/util/test_main.cc
@@ -57,14 +57,14 @@ static void CreateAndStartTimer() {
   // Create the test-timeout timer.
   memset(&action, 0, sizeof(action));
   action.sa_handler = &KillTestOnTimeout;
-  CHECK_ERR(sigaction(SIGALRM, &action, NULL)) << "Unable to set timeout action";
+  CHECK_ERR(sigaction(SIGALRM, &action, nullptr)) << "Unable to set timeout action";
 
   timer.it_interval.tv_sec = 0;                      // No repeat.
   timer.it_interval.tv_usec = 0;
   timer.it_value.tv_sec = FLAGS_test_timeout_after;  // Fire in timeout seconds.
   timer.it_value.tv_usec = 0;
 
-  CHECK_ERR(setitimer(ITIMER_REAL, &timer, NULL)) << "Unable to set timeout timer";
+  CHECK_ERR(setitimer(ITIMER_REAL, &timer, nullptr)) << "Unable to set timeout
timer";
 }
 
 static void KillTestOnTimeout(int signum) {

http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/35b49cc5/src/kudu/util/test_util.cc
----------------------------------------------------------------------
diff --git a/src/kudu/util/test_util.cc b/src/kudu/util/test_util.cc
index a4fb64f..51746ee 100644
--- a/src/kudu/util/test_util.cc
+++ b/src/kudu/util/test_util.cc
@@ -91,7 +91,7 @@ string KuduTest::GetTestPath(const string& relative_path) {
 
 bool AllowSlowTests() {
   char *e = getenv(kSlowTestsEnvVariable);
-  if ((e == NULL) ||
+  if ((e == nullptr) ||
       (strlen(e) == 0) ||
       (strcasecmp(e, "false") == 0) ||
       (strcasecmp(e, "0") == 0) ||

http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/35b49cc5/src/kudu/util/threadlocal.cc
----------------------------------------------------------------------
diff --git a/src/kudu/util/threadlocal.cc b/src/kudu/util/threadlocal.cc
index 5314bd7..11e8e33 100644
--- a/src/kudu/util/threadlocal.cc
+++ b/src/kudu/util/threadlocal.cc
@@ -37,7 +37,7 @@ static GoogleOnceType once = GOOGLE_ONCE_INIT;
 // thread.
 static void InvokeDestructors(void* t) {
   PerThreadDestructorList* d = reinterpret_cast<PerThreadDestructorList*>(t);
-  while (d != NULL) {
+  while (d != nullptr) {
     d->destructor(d->arg);
     PerThreadDestructorList* next = d->next;
     delete d;

http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/35b49cc5/src/kudu/util/threadpool.cc
----------------------------------------------------------------------
diff --git a/src/kudu/util/threadpool.cc b/src/kudu/util/threadpool.cc
index 3f2dfe3..63aaa39 100644
--- a/src/kudu/util/threadpool.cc
+++ b/src/kudu/util/threadpool.cc
@@ -344,7 +344,7 @@ Status ThreadPool::CreateThreadUnlocked() {
   // The first few threads are permanent, and do not time out.
   bool permanent = (num_threads_ < min_threads_);
   Status s = kudu::Thread::Create("thread pool", strings::Substitute("$0 [worker]", name_),
-                                  &ThreadPool::DispatchThread, this, permanent, NULL);
+                                  &ThreadPool::DispatchThread, this, permanent, nullptr);
   if (s.ok()) {
     num_threads_++;
   }

http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/35b49cc5/src/kudu/util/trace-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/util/trace-test.cc b/src/kudu/util/trace-test.cc
index 049ed90..1891dfc 100644
--- a/src/kudu/util/trace-test.cc
+++ b/src/kudu/util/trace-test.cc
@@ -79,7 +79,7 @@ TEST_F(TraceTest, TestAttach) {
     EXPECT_EQ(traceA.get(), Trace::CurrentTrace());
     TRACE("hello from traceA");
   }
-  EXPECT_TRUE(Trace::CurrentTrace() == NULL);
+  EXPECT_TRUE(Trace::CurrentTrace() == nullptr);
   TRACE("this goes nowhere");
 
   EXPECT_EQ(XOutDigits(traceA->DumpToString(false)),
@@ -313,7 +313,7 @@ class TraceEventCallbackTest : public KuduTest {
  public:
   virtual void SetUp() OVERRIDE {
     KuduTest::SetUp();
-    ASSERT_EQ(NULL, s_instance);
+    ASSERT_EQ(nullptr, s_instance);
     s_instance = this;
   }
   virtual void TearDown() OVERRIDE {
@@ -324,7 +324,7 @@ class TraceEventCallbackTest : public KuduTest {
     TraceResultBuffer::FlushTraceLogToString();
 
     ASSERT_TRUE(!!s_instance);
-    s_instance = NULL;
+    s_instance = nullptr;
     KuduTest::TearDown();
 
   }
@@ -380,15 +380,15 @@ class TraceEventCallbackTest : public KuduTest {
       for (Value::ConstMemberIterator it = value.MemberBegin();
            it != value.MemberEnd();
            ++it) {
-        if (it->name.IsString() && strstr(it->name.GetString(), string_to_match)
!= NULL) {
+        if (it->name.IsString() && strstr(it->name.GetString(), string_to_match)
!= nullptr) {
           return &value;
         }
-        if (it->value.IsString() && strstr(it->value.GetString(), string_to_match)
!= NULL) {
+        if (it->value.IsString() && strstr(it->value.GetString(), string_to_match)
!= nullptr) {
           return &value;
         }
       }
     }
-    return NULL;
+    return nullptr;
   }
 
   // For TraceEventCallbackAndRecordingX tests.

http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/35b49cc5/src/kudu/util/trace.cc
----------------------------------------------------------------------
diff --git a/src/kudu/util/trace.cc b/src/kudu/util/trace.cc
index af12ad5..bc1085c 100644
--- a/src/kudu/util/trace.cc
+++ b/src/kudu/util/trace.cc
@@ -36,8 +36,8 @@ __thread Trace* Trace::threadlocal_trace_;
 
 Trace::Trace()
   : arena_(new ThreadSafeArena(1024, 128*1024)),
-    entries_head_(NULL),
-    entries_tail_(NULL) {
+    entries_head_(nullptr),
+    entries_tail_(nullptr) {
 }
 
 Trace::~Trace() {
@@ -82,7 +82,7 @@ void Trace::SubstituteAndTrace(const char* file_path,
                                const SubstituteArg& arg6, const SubstituteArg& arg7,
                                const SubstituteArg& arg8, const SubstituteArg& arg9)
{
   const SubstituteArg* const args_array[] = {
-    &arg0, &arg1, &arg2, &arg3, &arg4, &arg5, &arg6, &arg7,
&arg8, &arg9, NULL
+    &arg0, &arg1, &arg2, &arg3, &arg4, &arg5, &arg6, &arg7,
&arg8, &arg9, nullptr
   };
 
   int msg_len = strings::internal::SubstitutedSize(format, args_array);
@@ -104,12 +104,12 @@ TraceEntry* Trace::NewEntry(int msg_len, const char* file_path, int
line_number)
 
 void Trace::AddEntry(TraceEntry* entry) {
   lock_guard<simple_spinlock> l(&lock_);
-  entry->next = NULL;
+  entry->next = nullptr;
 
-  if (entries_tail_ != NULL) {
+  if (entries_tail_ != nullptr) {
     entries_tail_->next = entry;
   } else {
-    DCHECK(entries_head_ == NULL);
+    DCHECK(entries_head_ == nullptr);
     entries_head_ = entry;
   }
   entries_tail_ = entry;
@@ -125,7 +125,7 @@ void Trace::Dump(std::ostream* out, bool include_time_deltas) const {
   {
     lock_guard<simple_spinlock> l(&lock_);
     for (TraceEntry* cur = entries_head_;
-         cur != NULL;
+         cur != nullptr;
          cur = cur->next) {
       entries.push_back(cur);
     }
@@ -188,7 +188,7 @@ string Trace::DumpToString(bool include_time_deltas) const {
 
 void Trace::DumpCurrentTrace() {
   Trace* t = CurrentTrace();
-  if (t == NULL) {
+  if (t == nullptr) {
     LOG(INFO) << "No trace is currently active.";
     return;
   }

http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/35b49cc5/src/kudu/util/url-coding.cc
----------------------------------------------------------------------
diff --git a/src/kudu/util/url-coding.cc b/src/kudu/util/url-coding.cc
index 13052cb..4aae48e 100644
--- a/src/kudu/util/url-coding.cc
+++ b/src/kudu/util/url-coding.cc
@@ -191,7 +191,7 @@ bool Base64Decode(const string& in, string* out) {
 }
 
 void EscapeForHtml(const string& in, std::stringstream* out) {
-  DCHECK(out != NULL);
+  DCHECK(out != nullptr);
   for (const char& c : in) {
     switch (c) {
       case '<': (*out) << "&lt;";

http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/35b49cc5/src/kudu/util/user.cc
----------------------------------------------------------------------
diff --git a/src/kudu/util/user.cc b/src/kudu/util/user.cc
index 3097550..c8a2868 100644
--- a/src/kudu/util/user.cc
+++ b/src/kudu/util/user.cc
@@ -35,7 +35,7 @@ using std::string;
 namespace kudu {
 
 Status GetLoggedInUser(string* user_name) {
-  DCHECK(user_name != NULL);
+  DCHECK(user_name != nullptr);
 
   struct passwd pwd;
   struct passwd *result;
@@ -46,12 +46,12 @@ Status GetLoggedInUser(string* user_name) {
   }
 
   gscoped_ptr<char[], FreeDeleter> buf(static_cast<char *>(malloc(bufsize)));
-  if (buf.get() == NULL) {
+  if (buf.get() == nullptr) {
     return Status::RuntimeError("Malloc failed", ErrnoToString(errno), errno);
   }
 
   int ret = getpwuid_r(getuid(), &pwd, buf.get(), bufsize, &result);
-  if (result == NULL) {
+  if (result == nullptr) {
     if (ret == 0) {
       return Status::NotFound("Current logged-in user not found! This is an unexpected error.");
     } else {


Mime
View raw message