You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kudu.apache.org by da...@apache.org on 2016/01/19 23:48:14 UTC
[4/5] incubator-kudu git commit: Replace NULL with nullptr
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/35b49cc5/src/kudu/consensus/leader_election.cc
----------------------------------------------------------------------
diff --git a/src/kudu/consensus/leader_election.cc b/src/kudu/consensus/leader_election.cc
index 20fea08..5c01db0 100644
--- a/src/kudu/consensus/leader_election.cc
+++ b/src/kudu/consensus/leader_election.cc
@@ -197,7 +197,7 @@ void LeaderElection::Run() {
// The rest of the code below is for a typical multi-node configuration.
for (const std::string& voter_uuid : follower_uuids_) {
- VoterState* state = NULL;
+ VoterState* state = nullptr;
{
lock_guard<Lock> guard(&lock_);
state = FindOrDie(voter_state_, voter_uuid);
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/35b49cc5/src/kudu/consensus/log-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/consensus/log-test.cc b/src/kudu/consensus/log-test.cc
index 157d70b..9433706 100644
--- a/src/kudu/consensus/log-test.cc
+++ b/src/kudu/consensus/log-test.cc
@@ -300,7 +300,7 @@ void LogTest::DoCorruptionTest(CorruptionType type, CorruptionPosition place,
gscoped_ptr<LogReader> reader;
ASSERT_OK(LogReader::Open(fs_manager_.get(),
make_scoped_refptr(new LogIndex(log_->log_dir_)),
- kTestTablet, NULL, &reader));
+ kTestTablet, nullptr, &reader));
ASSERT_EQ(1, reader->num_segments());
SegmentSequence segments;
@@ -550,7 +550,7 @@ TEST_F(LogTest, TestGCOfIndexChunks) {
const int kNumOpsPerSegment = 5;
OpId op_id = MakeOpId(1, 999990);
ASSERT_OK(AppendMultiSegmentSequence(kNumTotalSegments, kNumOpsPerSegment,
- &op_id, NULL));
+ &op_id, nullptr));
// Run a GC on an op in the second index chunk. We should remove only the
// earliest segment, because we are set to retain 4.
@@ -712,7 +712,7 @@ TEST_F(LogTest, TestLogReader) {
LogReader reader(fs_manager_.get(),
scoped_refptr<LogIndex>(),
kTestTablet,
- NULL);
+ nullptr);
reader.InitEmptyReaderForTests();
ASSERT_OK(AppendNewEmptySegmentToReader(2, 10, &reader));
ASSERT_OK(AppendNewEmptySegmentToReader(3, 20, &reader));
@@ -761,7 +761,7 @@ TEST_F(LogTest, TestLogReader) {
ASSERT_EQ(4, segment->header().sequence_number());
segment = reader.GetSegmentBySequenceNumber(5);
- ASSERT_TRUE(segment.get() == NULL);
+ ASSERT_TRUE(segment.get() == nullptr);
}
// Test that, even if the LogReader's index is empty because no segments
@@ -1000,7 +1000,7 @@ TEST_F(LogTest, TestGetMaxIndexesToSegmentSizeMap) {
OpId op_id = MakeOpId(1, 10);
// Create 5 segments, starting from log index 10, with 5 ops per segment.
ASSERT_OK(AppendMultiSegmentSequence(kNumTotalSegments, kNumOpsPerSegment,
- &op_id, NULL));
+ &op_id, nullptr));
std::map<int64_t, int64_t> max_idx_to_segment_size;
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/35b49cc5/src/kudu/consensus/log.cc
----------------------------------------------------------------------
diff --git a/src/kudu/consensus/log.cc b/src/kudu/consensus/log.cc
index 89630d6..7285025 100644
--- a/src/kudu/consensus/log.cc
+++ b/src/kudu/consensus/log.cc
@@ -391,7 +391,7 @@ Status Log::Reserve(LogEntryTypePB type,
gscoped_ptr<LogEntryBatchPB> entry_batch,
LogEntryBatch** reserved_entry) {
TRACE_EVENT0("log", "Log::Reserve");
- DCHECK(reserved_entry != NULL);
+ DCHECK(reserved_entry != nullptr);
{
boost::shared_lock<rw_spinlock> read_lock(state_lock_.get_lock());
CHECK_EQ(kLogWriting, log_state_);
@@ -684,7 +684,7 @@ Status Log::Append(LogEntryPB* phys_entry) {
s = Sync();
}
}
- entry_batch.entry_batch_pb_->mutable_entry()->ExtractSubrange(0, 1, NULL);
+ entry_batch.entry_batch_pb_->mutable_entry()->ExtractSubrange(0, 1, nullptr);
return s;
}
@@ -905,7 +905,7 @@ Status Log::SwitchToAllocatedSegment() {
// Transform the currently-active segment into a readable one, since we
// need to be able to replay the segments for other peers.
{
- if (active_segment_.get() != NULL) {
+ if (active_segment_.get() != nullptr) {
boost::lock_guard<percpu_rwlock> l(state_lock_);
CHECK_OK(ReplaceSegmentInReaderUnlocked());
}
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/35b49cc5/src/kudu/consensus/log_anchor_registry.cc
----------------------------------------------------------------------
diff --git a/src/kudu/consensus/log_anchor_registry.cc b/src/kudu/consensus/log_anchor_registry.cc
index 6e6c399..d310d66 100644
--- a/src/kudu/consensus/log_anchor_registry.cc
+++ b/src/kudu/consensus/log_anchor_registry.cc
@@ -103,7 +103,7 @@ std::string LogAnchorRegistry::DumpAnchorInfo() const {
void LogAnchorRegistry::RegisterUnlocked(int64_t log_index,
const std::string& owner,
LogAnchor* anchor) {
- DCHECK(anchor != NULL);
+ DCHECK(anchor != nullptr);
DCHECK(!anchor->is_registered);
anchor->log_index = log_index;
@@ -115,7 +115,7 @@ void LogAnchorRegistry::RegisterUnlocked(int64_t log_index,
}
Status LogAnchorRegistry::UnregisterUnlocked(LogAnchor* anchor) {
- DCHECK(anchor != NULL);
+ DCHECK(anchor != nullptr);
DCHECK(anchor->is_registered);
AnchorMultiMap::iterator iter = anchors_.find(anchor->log_index);
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/35b49cc5/src/kudu/consensus/log_cache.cc
----------------------------------------------------------------------
diff --git a/src/kudu/consensus/log_cache.cc b/src/kudu/consensus/log_cache.cc
index 8f92ab4..89e4c60 100644
--- a/src/kudu/consensus/log_cache.cc
+++ b/src/kudu/consensus/log_cache.cc
@@ -137,7 +137,7 @@ Status LogCache::AppendOperations(const vector<ReplicateRefPtr>& msgs,
// Now remove the overwritten operations.
for (int64_t i = first_idx_in_batch; i < next_sequential_op_index_; ++i) {
ReplicateRefPtr msg = EraseKeyReturnValuePtr(&cache_, i);
- if (msg != NULL) {
+ if (msg != nullptr) {
AccountForMessageRemovalUnlocked(msg);
}
}
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/35b49cc5/src/kudu/consensus/log_index.cc
----------------------------------------------------------------------
diff --git a/src/kudu/consensus/log_index.cc b/src/kudu/consensus/log_index.cc
index 1b99b2b..06e3e94 100644
--- a/src/kudu/consensus/log_index.cc
+++ b/src/kudu/consensus/log_index.cc
@@ -100,11 +100,11 @@ Status CheckError(int rc, const char* operation) {
LogIndex::IndexChunk::IndexChunk(const std::string& path)
: path_(path),
fd_(-1),
- mapping_(NULL) {
+ mapping_(nullptr) {
}
LogIndex::IndexChunk::~IndexChunk() {
- if (mapping_ != NULL) {
+ if (mapping_ != nullptr) {
munmap(mapping_, kChunkFileSize);
}
@@ -121,9 +121,9 @@ Status LogIndex::IndexChunk::Open() {
RETRY_ON_EINTR(err, ftruncate(fd_, kChunkFileSize));
RETURN_NOT_OK(CheckError(fd_, "truncate"));
- mapping_ = static_cast<uint8_t*>(mmap(NULL, kChunkFileSize, PROT_READ | PROT_WRITE,
+ mapping_ = static_cast<uint8_t*>(mmap(nullptr, kChunkFileSize, PROT_READ | PROT_WRITE,
MAP_SHARED, fd_, 0));
- if (mapping_ == NULL) {
+ if (mapping_ == nullptr) {
int err = errno;
return Status::IOError("Unable to mmap()", ErrnoToString(err), err);
}
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/35b49cc5/src/kudu/consensus/log_reader.cc
----------------------------------------------------------------------
diff --git a/src/kudu/consensus/log_reader.cc b/src/kudu/consensus/log_reader.cc
index 131d91a..8faeb29 100644
--- a/src/kudu/consensus/log_reader.cc
+++ b/src/kudu/consensus/log_reader.cc
@@ -88,7 +88,7 @@ Status LogReader::OpenFromRecoveryDir(FsManager *fs_manager,
// When recovering, we don't want to have any log index -- since it isn't fsynced()
// during writing, its contents are useless to us.
- scoped_refptr<LogIndex> index(NULL);
+ scoped_refptr<LogIndex> index(nullptr);
gscoped_ptr<LogReader> log_reader(new LogReader(fs_manager, index, tablet_id,
metric_entity));
RETURN_NOT_OK_PREPEND(log_reader->Init(recovery_path),
@@ -262,7 +262,7 @@ void LogReader::GetMaxIndexesToSegmentSizeMap(int64_t min_op_idx, int32_t segmen
scoped_refptr<ReadableLogSegment> LogReader::GetSegmentBySequenceNumber(int64_t seq) const {
boost::lock_guard<simple_spinlock> lock(lock_);
if (segments_.empty()) {
- return NULL;
+ return nullptr;
}
// We always have a contiguous set of log segments, so we can find the requested
@@ -270,7 +270,7 @@ scoped_refptr<ReadableLogSegment> LogReader::GetSegmentBySequenceNumber(int64_t
int64_t first_seqno = segments_[0]->header().sequence_number();
int64_t relative = seq - first_seqno;
if (relative < 0 || relative >= segments_.size()) {
- return NULL;
+ return nullptr;
}
DCHECK_EQ(segments_[relative]->header().sequence_number(), seq);
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/35b49cc5/src/kudu/consensus/log_util.cc
----------------------------------------------------------------------
diff --git a/src/kudu/consensus/log_util.cc b/src/kudu/consensus/log_util.cc
index c29d628..9e39629 100644
--- a/src/kudu/consensus/log_util.cc
+++ b/src/kudu/consensus/log_util.cc
@@ -430,7 +430,7 @@ Status ReadableLogSegment::ReadEntries(vector<LogEntryPB*>* entries,
file_size() - footer_.ByteSize() - kLogSegmentFooterMagicAndFooterLength :
readable_to_offset;
- if (end_offset != NULL) {
+ if (end_offset != nullptr) {
*end_offset = offset;
}
@@ -498,8 +498,8 @@ Status ReadableLogSegment::ReadEntries(vector<LogEntryPB*>* entries,
}
current_batch->mutable_entry()->ExtractSubrange(0,
current_batch->entry_size(),
- NULL);
- if (end_offset != NULL) {
+ nullptr);
+ if (end_offset != nullptr) {
*end_offset = offset;
}
}
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/35b49cc5/src/kudu/consensus/peer_manager.cc
----------------------------------------------------------------------
diff --git a/src/kudu/consensus/peer_manager.cc b/src/kudu/consensus/peer_manager.cc
index b00a7ad..57483d2 100644
--- a/src/kudu/consensus/peer_manager.cc
+++ b/src/kudu/consensus/peer_manager.cc
@@ -58,7 +58,7 @@ Status PeerManager::UpdateRaftConfig(const RaftConfigPB& config) {
for (const RaftPeerPB& peer_pb : config.peers()) {
new_peers.insert(peer_pb.permanent_uuid());
Peer* peer = FindPtrOrNull(peers_, peer_pb.permanent_uuid());
- if (peer != NULL) {
+ if (peer != nullptr) {
continue;
}
if (peer_pb.permanent_uuid() == local_uuid_) {
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/35b49cc5/src/kudu/consensus/raft_consensus-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/consensus/raft_consensus-test.cc b/src/kudu/consensus/raft_consensus-test.cc
index 1876bcf..ec264be 100644
--- a/src/kudu/consensus/raft_consensus-test.cc
+++ b/src/kudu/consensus/raft_consensus-test.cc
@@ -90,7 +90,7 @@ class MockQueue : public PeerMessageQueue {
class MockPeerManager : public PeerManager {
public:
- MockPeerManager() : PeerManager("", "", NULL, NULL, NULL, NULL) {}
+ MockPeerManager() : PeerManager("", "", nullptr, nullptr, nullptr, nullptr) {}
MOCK_METHOD1(UpdateRaftConfig, Status(const consensus::RaftConfigPB& config));
MOCK_METHOD1(SignalRequest, void(bool force_if_queue_empty));
MOCK_METHOD0(Close, void());
@@ -201,7 +201,7 @@ class RaftConsensusTest : public KuduTest {
config_ = BuildRaftConfigPBForTests(num_peers);
config_.set_opid_index(kInvalidOpIdIndex);
- gscoped_ptr<PeerProxyFactory> proxy_factory(new LocalTestPeerProxyFactory(NULL));
+ gscoped_ptr<PeerProxyFactory> proxy_factory(new LocalTestPeerProxyFactory(nullptr));
string peer_uuid = config_.peers(num_peers - 1).permanent_uuid();
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/35b49cc5/src/kudu/consensus/raft_consensus.cc
----------------------------------------------------------------------
diff --git a/src/kudu/consensus/raft_consensus.cc b/src/kudu/consensus/raft_consensus.cc
index 7607630..213bf56 100644
--- a/src/kudu/consensus/raft_consensus.cc
+++ b/src/kudu/consensus/raft_consensus.cc
@@ -877,7 +877,7 @@ Status RaftConsensus::CheckLeaderRequestUnlocked(const ConsensusRequestPB* reque
mutable_req->mutable_ops()->ExtractSubrange(
deduped_req->first_message_idx,
deduped_req->messages.size(),
- NULL);
+ nullptr);
}
RETURN_NOT_OK(s);
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/35b49cc5/src/kudu/consensus/raft_consensus_quorum-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/consensus/raft_consensus_quorum-test.cc b/src/kudu/consensus/raft_consensus_quorum-test.cc
index 1b3ecba..e8fd4f6 100644
--- a/src/kudu/consensus/raft_consensus_quorum-test.cc
+++ b/src/kudu/consensus/raft_consensus_quorum-test.cc
@@ -232,7 +232,7 @@ class RaftConsensusQuorumTest : public KuduTest {
}
}
CHECK(false) << "Proxy not found";
- return NULL;
+ return nullptr;
}
Status AppendDummyMessage(int peer_idx,
@@ -260,9 +260,9 @@ class RaftConsensusQuorumTest : public KuduTest {
Status CommitDummyMessage(int peer_idx,
ConsensusRound* round,
- shared_ptr<Synchronizer>* commit_sync = NULL) {
+ shared_ptr<Synchronizer>* commit_sync = nullptr) {
StatusCallback commit_callback;
- if (commit_sync != NULL) {
+ if (commit_sync != nullptr) {
commit_sync->reset(new Synchronizer());
commit_callback = Bind(&FireSharedSynchronizer, *commit_sync);
} else {
@@ -379,7 +379,7 @@ class RaftConsensusQuorumTest : public KuduTest {
CommitMode commit_mode,
OpId* last_op_id,
vector<scoped_refptr<ConsensusRound> >* rounds,
- shared_ptr<Synchronizer>* commit_sync = NULL) {
+ shared_ptr<Synchronizer>* commit_sync = nullptr) {
for (int i = 0; i < seq_size; i++) {
scoped_refptr<ConsensusRound> round;
ASSERT_OK(AppendDummyMessage(leader_idx, &round));
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/35b49cc5/src/kudu/experiments/merge-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/experiments/merge-test.cc b/src/kudu/experiments/merge-test.cc
index f8b1271..b9760a2 100644
--- a/src/kudu/experiments/merge-test.cc
+++ b/src/kudu/experiments/merge-test.cc
@@ -86,16 +86,16 @@ void SimpleMerge(const vector<vector<MergeType> > &in_lists,
}
while (true) {
- MergeTypeIter *smallest = NULL;
+ MergeTypeIter *smallest = nullptr;
for (int i = 0; i < in_lists.size(); i++) {
if (iters[i] == in_lists[i].end()) continue;
- if (smallest == NULL ||
+ if (smallest == nullptr ||
*iters[i] < **smallest) {
smallest = &iters[i];
}
}
- if (smallest == NULL) break;
+ if (smallest == nullptr) break;
out->push_back(**smallest);
(*smallest)++;
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/35b49cc5/src/kudu/fs/block_manager-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/fs/block_manager-test.cc b/src/kudu/fs/block_manager-test.cc
index 8bdba82..6f3d0a4 100644
--- a/src/kudu/fs/block_manager-test.cc
+++ b/src/kudu/fs/block_manager-test.cc
@@ -376,7 +376,7 @@ TYPED_TEST(BlockManagerTest, EndToEndTest) {
// Delete the block.
ASSERT_OK(this->bm_->DeleteBlock(written_block->id()));
- ASSERT_TRUE(this->bm_->OpenBlock(written_block->id(), NULL)
+ ASSERT_TRUE(this->bm_->OpenBlock(written_block->id(), nullptr)
.IsNotFound());
}
@@ -394,7 +394,7 @@ TYPED_TEST(BlockManagerTest, ReadAfterDeleteTest) {
gscoped_ptr<ReadableBlock> read_block;
ASSERT_OK(this->bm_->OpenBlock(written_block->id(), &read_block));
ASSERT_OK(this->bm_->DeleteBlock(written_block->id()));
- ASSERT_TRUE(this->bm_->OpenBlock(written_block->id(), NULL)
+ ASSERT_TRUE(this->bm_->OpenBlock(written_block->id(), nullptr)
.IsNotFound());
// But we should still be able to read from the opened block.
@@ -507,7 +507,7 @@ TYPED_TEST(BlockManagerTest, AbortTest) {
ASSERT_OK(written_block->Append(test_data));
ASSERT_OK(written_block->Abort());
ASSERT_EQ(WritableBlock::CLOSED, written_block->state());
- ASSERT_TRUE(this->bm_->OpenBlock(written_block->id(), NULL)
+ ASSERT_TRUE(this->bm_->OpenBlock(written_block->id(), nullptr)
.IsNotFound());
ASSERT_OK(this->bm_->CreateBlock(&written_block));
@@ -515,7 +515,7 @@ TYPED_TEST(BlockManagerTest, AbortTest) {
ASSERT_OK(written_block->FlushDataAsync());
ASSERT_OK(written_block->Abort());
ASSERT_EQ(WritableBlock::CLOSED, written_block->state());
- ASSERT_TRUE(this->bm_->OpenBlock(written_block->id(), NULL)
+ ASSERT_TRUE(this->bm_->OpenBlock(written_block->id(), nullptr)
.IsNotFound());
}
@@ -564,7 +564,7 @@ TYPED_TEST(BlockManagerTest, PersistenceTest) {
ASSERT_OK(read_block->Read(0, test_data.length(), &data, scratch.get()));
ASSERT_EQ(test_data, data);
ASSERT_OK(read_block->Close());
- ASSERT_TRUE(new_bm->OpenBlock(written_block3->id(), NULL)
+ ASSERT_TRUE(new_bm->OpenBlock(written_block3->id(), nullptr)
.IsNotFound());
}
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/35b49cc5/src/kudu/fs/file_block_manager.cc
----------------------------------------------------------------------
diff --git a/src/kudu/fs/file_block_manager.cc b/src/kudu/fs/file_block_manager.cc
index 8de5698..9f71a75 100644
--- a/src/kudu/fs/file_block_manager.cc
+++ b/src/kudu/fs/file_block_manager.cc
@@ -507,7 +507,7 @@ bool FileBlockManager::FindBlockPath(const BlockId& block_id,
*path = internal::FileBlockLocation::FromBlockId(
metadata_file->path(), block_id).GetFullPath();
}
- return metadata_file != NULL;
+ return metadata_file != nullptr;
}
FileBlockManager::FileBlockManager(Env* env, const BlockManagerOptions& opts)
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/35b49cc5/src/kudu/fs/fs_manager.cc
----------------------------------------------------------------------
diff --git a/src/kudu/fs/fs_manager.cc b/src/kudu/fs/fs_manager.cc
index b03b003..117389f 100644
--- a/src/kudu/fs/fs_manager.cc
+++ b/src/kudu/fs/fs_manager.cc
@@ -113,7 +113,7 @@ FsManager::FsManager(Env* env, const string& root_path)
read_only_(false),
wal_fs_root_(root_path),
data_fs_roots_({ root_path }),
- metric_entity_(NULL),
+ metric_entity_(nullptr),
initted_(false) {
}
@@ -324,7 +324,7 @@ void FsManager::CreateInstanceMetadata(InstanceMetadataPB* metadata) {
metadata->set_uuid(oid_generator.Next());
string time_str;
- StringAppendStrftime(&time_str, "%Y-%m-%d %H:%M:%S", time(NULL), false);
+ StringAppendStrftime(&time_str, "%Y-%m-%d %H:%M:%S", time(nullptr), false);
string hostname;
if (!GetHostname(&hostname).ok()) {
hostname = "<unknown host>";
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/35b49cc5/src/kudu/fs/log_block_manager.cc
----------------------------------------------------------------------
diff --git a/src/kudu/fs/log_block_manager.cc b/src/kudu/fs/log_block_manager.cc
index c5c4d97..61f2c2e 100644
--- a/src/kudu/fs/log_block_manager.cc
+++ b/src/kudu/fs/log_block_manager.cc
@@ -1122,7 +1122,7 @@ Status LogBlockManager::Open() {
unordered_map<string, PathInstanceMetadataFile*> metadata_files;
ValueDeleter deleter(&metadata_files);
for (const string& root_path : root_paths_) {
- InsertOrDie(&metadata_files, root_path, NULL);
+ InsertOrDie(&metadata_files, root_path, nullptr);
}
// Submit each open to its own thread pool and wait for them to complete.
@@ -1296,7 +1296,7 @@ void LogBlockManager::AddNewContainerUnlocked(LogBlockContainer* container) {
}
LogBlockContainer* LogBlockManager::GetAvailableContainer() {
- LogBlockContainer* container = NULL;
+ LogBlockContainer* container = nullptr;
lock_guard<simple_spinlock> l(&lock_);
if (!available_containers_.empty()) {
container = available_containers_.front();
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/35b49cc5/src/kudu/gutil/callback_internal.cc
----------------------------------------------------------------------
diff --git a/src/kudu/gutil/callback_internal.cc b/src/kudu/gutil/callback_internal.cc
index f8b7582..05b9e8f 100644
--- a/src/kudu/gutil/callback_internal.cc
+++ b/src/kudu/gutil/callback_internal.cc
@@ -8,14 +8,14 @@ namespace kudu {
namespace internal {
bool CallbackBase::is_null() const {
- return bind_state_.get() == NULL;
+ return bind_state_.get() == nullptr;
}
void CallbackBase::Reset() {
- polymorphic_invoke_ = NULL;
+ polymorphic_invoke_ = nullptr;
// NULL the bind_state_ last, since it may be holding the last ref to whatever
// object owns us, and we may be deleted after that.
- bind_state_ = NULL;
+ bind_state_ = nullptr;
}
bool CallbackBase::Equals(const CallbackBase& other) const {
@@ -25,7 +25,7 @@ bool CallbackBase::Equals(const CallbackBase& other) const {
CallbackBase::CallbackBase(BindStateBase* bind_state)
: bind_state_(bind_state),
- polymorphic_invoke_(NULL) {
+ polymorphic_invoke_(nullptr) {
DCHECK(!bind_state_.get() || bind_state_->HasOneRef());
}
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/35b49cc5/src/kudu/gutil/hash/city.cc
----------------------------------------------------------------------
diff --git a/src/kudu/gutil/hash/city.cc b/src/kudu/gutil/hash/city.cc
index 027b08c..cc00ff7 100644
--- a/src/kudu/gutil/hash/city.cc
+++ b/src/kudu/gutil/hash/city.cc
@@ -305,7 +305,7 @@ uint128 CityHash128(const char *s, size_t len) {
uint128(LittleEndian::Load64(s) ^ k3,
LittleEndian::Load64(s + 8)));
} else if (len >= 8) {
- return CityHash128WithSeed(NULL,
+ return CityHash128WithSeed(nullptr,
0,
uint128(LittleEndian::Load64(s) ^ (len * k0),
LittleEndian::Load64(s + len - 8) ^ k1));
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/35b49cc5/src/kudu/gutil/once.cc
----------------------------------------------------------------------
diff --git a/src/kudu/gutil/once.cc b/src/kudu/gutil/once.cc
index b79af32..1b97f8f 100644
--- a/src/kudu/gutil/once.cc
+++ b/src/kudu/gutil/once.cc
@@ -34,7 +34,7 @@ void GoogleOnceInternalInit(Atomic32 *control, void (*func)(),
GOOGLE_ONCE_INTERNAL_RUNNING) == GOOGLE_ONCE_INTERNAL_INIT ||
base::internal::SpinLockWait(control, ARRAYSIZE(trans), trans) ==
GOOGLE_ONCE_INTERNAL_INIT) {
- if (func != 0) {
+ if (func != nullptr) {
(*func)();
} else {
(*func_with_arg)(arg);
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/35b49cc5/src/kudu/gutil/ref_counted_memory.cc
----------------------------------------------------------------------
diff --git a/src/kudu/gutil/ref_counted_memory.cc b/src/kudu/gutil/ref_counted_memory.cc
index ba4e5c6..b24ae8b 100644
--- a/src/kudu/gutil/ref_counted_memory.cc
+++ b/src/kudu/gutil/ref_counted_memory.cc
@@ -50,7 +50,7 @@ RefCountedBytes* RefCountedBytes::TakeVector(
const unsigned char* RefCountedBytes::front() const {
// STL will assert if we do front() on an empty vector, but calling code
// expects a NULL.
- return size() ? &data_.front() : NULL;
+ return size() ? &data_.front() : nullptr;
}
size_t RefCountedBytes::size() const {
@@ -71,7 +71,7 @@ RefCountedString* RefCountedString::TakeString(std::string* to_destroy) {
}
const unsigned char* RefCountedString::front() const {
- return data_.empty() ? NULL :
+ return data_.empty() ? nullptr :
reinterpret_cast<const unsigned char*>(data_.data());
}
@@ -86,7 +86,7 @@ RefCountedMallocedMemory::RefCountedMallocedMemory(
}
const unsigned char* RefCountedMallocedMemory::front() const {
- return length_ ? data_ : NULL;
+ return length_ ? data_ : nullptr;
}
size_t RefCountedMallocedMemory::size() const {
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/35b49cc5/src/kudu/gutil/stringprintf.cc
----------------------------------------------------------------------
diff --git a/src/kudu/gutil/stringprintf.cc b/src/kudu/gutil/stringprintf.cc
index 8f1b390..169ea95 100644
--- a/src/kudu/gutil/stringprintf.cc
+++ b/src/kudu/gutil/stringprintf.cc
@@ -41,7 +41,7 @@ void StringAppendV(string* dst, const char* format, va_list ap) {
// Error or MSVC running out of space. MSVC 8.0 and higher
// can be asked about space needed with the special idiom below:
va_copy(backup_ap, ap);
- result = vsnprintf(NULL, 0, format, backup_ap);
+ result = vsnprintf(nullptr, 0, format, backup_ap);
va_end(backup_ap);
}
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/35b49cc5/src/kudu/gutil/strings/escaping.cc
----------------------------------------------------------------------
diff --git a/src/kudu/gutil/strings/escaping.cc b/src/kudu/gutil/strings/escaping.cc
index aa12b3c..0a52a40 100644
--- a/src/kudu/gutil/strings/escaping.cc
+++ b/src/kudu/gutil/strings/escaping.cc
@@ -75,7 +75,7 @@ int EscapeStrForCSV(const char* src, char* dest, int dest_len) {
#define IS_OCTAL_DIGIT(c) (((c) >= '0') && ((c) <= '7'))
int UnescapeCEscapeSequences(const char* source, char* dest) {
- return UnescapeCEscapeSequences(source, dest, NULL);
+ return UnescapeCEscapeSequences(source, dest, nullptr);
}
int UnescapeCEscapeSequences(const char* source, char* dest,
@@ -215,7 +215,7 @@ int UnescapeCEscapeSequences(const char* source, char* dest,
//
// ----------------------------------------------------------------------
int UnescapeCEscapeString(const string& src, string* dest) {
- return UnescapeCEscapeString(src, dest, NULL);
+ return UnescapeCEscapeString(src, dest, nullptr);
}
int UnescapeCEscapeString(const string& src, string* dest,
@@ -230,7 +230,7 @@ int UnescapeCEscapeString(const string& src, string* dest,
string UnescapeCEscapeString(const string& src) {
gscoped_array<char> unescaped(new char[src.size() + 1]);
- int len = UnescapeCEscapeSequences(src.c_str(), unescaped.get(), NULL);
+ int len = UnescapeCEscapeSequences(src.c_str(), unescaped.get(), nullptr);
return string(unescaped.get(), len);
}
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/35b49cc5/src/kudu/gutil/strings/join.cc
----------------------------------------------------------------------
diff --git a/src/kudu/gutil/strings/join.cc b/src/kudu/gutil/strings/join.cc
index 0211c42..75a6db1 100644
--- a/src/kudu/gutil/strings/join.cc
+++ b/src/kudu/gutil/strings/join.cc
@@ -50,7 +50,7 @@ char* JoinUsingToBuffer(const vector<const char*>& components,
int result_buffer_size,
char* result_buffer,
int* result_length_p) {
- CHECK(result_buffer != NULL);
+ CHECK(result_buffer != nullptr);
const int num_components = components.size();
const int max_str_len = result_buffer_size - 1;
char* curr_dest = result_buffer;
@@ -76,7 +76,7 @@ char* JoinUsingToBuffer(const vector<const char*>& components,
if (result_buffer_size > 0)
*curr_dest = '\0'; // add null termination
- if (result_length_p != NULL) // set string length value
+ if (result_length_p != nullptr) // set string length value
*result_length_p = num_chars;
return result_buffer;
@@ -95,7 +95,7 @@ void JoinStringsInArray(string const* const* components,
int num_components,
const char* delim,
string * result) {
- CHECK(result != NULL);
+ CHECK(result != nullptr);
result->clear();
for (int i = 0; i < num_components; i++) {
if (i>0) {
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/35b49cc5/src/kudu/gutil/strings/memutil.cc
----------------------------------------------------------------------
diff --git a/src/kudu/gutil/strings/memutil.cc b/src/kudu/gutil/strings/memutil.cc
index 4f4c29a..390d2a0 100644
--- a/src/kudu/gutil/strings/memutil.cc
+++ b/src/kudu/gutil/strings/memutil.cc
@@ -23,8 +23,8 @@ int memcasecmp(const char *s1, const char *s2, size_t len) {
char *memdup(const char *s, size_t slen) {
void *copy;
- if ( (copy=malloc(slen)) == NULL )
- return NULL;
+ if ( (copy=malloc(slen)) == nullptr )
+ return nullptr;
memcpy(copy, s, slen);
return reinterpret_cast<char *>(copy);
}
@@ -34,7 +34,7 @@ char *memrchr(const char *s, int c, size_t slen) {
if (*e == c)
return const_cast<char *>(e);
}
- return NULL;
+ return nullptr;
}
size_t memspn(const char *s, size_t slen, const char *accept) {
@@ -74,7 +74,7 @@ char *mempbrk(const char *s, size_t slen, const char *accept) {
if (sc == *s)
return const_cast<char *>(s);
}
- return NULL;
+ return nullptr;
}
template<bool case_sensitive>
@@ -104,7 +104,7 @@ const char *int_memmatch(const char *phaystack, size_t haylen,
needle = needlestart;
}
}
- return NULL;
+ return nullptr;
}
// explicit template instantiations
@@ -121,7 +121,7 @@ const char *memmatch(const char *phaystack, size_t haylen,
return phaystack; // even if haylen is 0
}
if (haylen < neelen)
- return NULL;
+ return nullptr;
const char* match;
const char* hayend = phaystack + haylen - neelen + 1;
@@ -134,5 +134,5 @@ const char *memmatch(const char *phaystack, size_t haylen,
else
phaystack = match + 1;
}
- return NULL;
+ return nullptr;
}
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/35b49cc5/src/kudu/gutil/strings/numbers.cc
----------------------------------------------------------------------
diff --git a/src/kudu/gutil/strings/numbers.cc b/src/kudu/gutil/strings/numbers.cc
index ea44b2b..7bdb57c 100644
--- a/src/kudu/gutil/strings/numbers.cc
+++ b/src/kudu/gutil/strings/numbers.cc
@@ -46,7 +46,7 @@ static inline bool EatADouble(const char** text, int* len, bool allow_question,
const char* pos = *text;
int rem = *len; // remaining length, or -1 if null-terminated
- if (pos == NULL || rem == 0)
+ if (pos == nullptr || rem == 0)
return false;
if (allow_question && (*pos == '?')) {
@@ -138,7 +138,7 @@ bool ParseDoubleRange(const char* text, int len, const char** end,
*from = -HUGE_VAL;
*to = HUGE_VAL;
}
- if (opts.allow_currency && (is_currency != NULL))
+ if (opts.allow_currency && (is_currency != nullptr))
*is_currency = false;
assert(len >= -1);
@@ -155,10 +155,10 @@ bool ParseDoubleRange(const char* text, int len, const char** end,
double* dest = (comparator == '>') ? from : to;
EatAChar(&text, &len, "=", true, false);
if (opts.allow_currency && EatAChar(&text, &len, "$", true, false))
- if (is_currency != NULL)
+ if (is_currency != nullptr)
*is_currency = true;
- if (!EatADouble(&text, &len, opts.allow_unbounded_markers, dest, NULL,
- NULL))
+ if (!EatADouble(&text, &len, opts.allow_unbounded_markers, dest, nullptr,
+ nullptr))
return false;
*end = text;
return EatAChar(&text, &len, opts.acceptable_terminators, false,
@@ -179,9 +179,9 @@ bool ParseDoubleRange(const char* text, int len, const char** end,
bool final_period = false;
bool* check_initial_minus = (strchr(opts.separators, '-') && !seen_dollar
&& (opts.num_required_bounds < 2)) ?
- (&initial_minus_sign) : NULL;
+ (&initial_minus_sign) : nullptr;
bool* check_final_period = strchr(opts.separators, '.') ? (&final_period)
- : NULL;
+ : nullptr;
bool double_seen = EatADouble(&text, &len, opts.allow_unbounded_markers,
from, check_initial_minus, check_final_period);
@@ -235,7 +235,7 @@ bool ParseDoubleRange(const char* text, int len, const char** end,
|| (opts.allow_currency && !double_seen))
&& EatAChar(&text, &len, "$", true, false);
bool second_double_seen = EatADouble(
- &text, &len, opts.allow_unbounded_markers, to, NULL, NULL);
+ &text, &len, opts.allow_unbounded_markers, to, nullptr, nullptr);
if (opts.num_required_bounds > double_seen + second_double_seen)
return false;
if (second_dollar_seen && !second_double_seen) {
@@ -247,7 +247,7 @@ bool ParseDoubleRange(const char* text, int len, const char** end,
seen_dollar = seen_dollar || second_dollar_seen;
}
- if (seen_dollar && (is_currency != NULL))
+ if (seen_dollar && (is_currency != nullptr))
*is_currency = true;
// We're done. But we have to check that the next char is a proper
// terminator.
@@ -293,7 +293,7 @@ void ConsumeStrayLeadingZeroes(string *const str) {
// --------------------------------------------------------------------
int32 ParseLeadingInt32Value(const char *str, int32 deflt) {
- char *error = NULL;
+ char *error = nullptr;
long value = strtol(str, &error, 0);
// Limit long values to int32 min/max. Needed for lp64; no-op on 32 bits.
if (value > numeric_limits<int32>::max()) {
@@ -307,7 +307,7 @@ int32 ParseLeadingInt32Value(const char *str, int32 deflt) {
uint32 ParseLeadingUInt32Value(const char *str, uint32 deflt) {
if (numeric_limits<unsigned long>::max() == numeric_limits<uint32>::max()) {
// When long is 32 bits, we can use strtoul.
- char *error = NULL;
+ char *error = nullptr;
const uint32 value = strtoul(str, &error, 0);
return (error == str) ? deflt : value;
} else {
@@ -316,7 +316,7 @@ uint32 ParseLeadingUInt32Value(const char *str, uint32 deflt) {
// it would be impossible to differentiate "-2" (that should wrap
// around to the value UINT_MAX-1) from a string with ULONG_MAX-1
// (that should be pegged to UINT_MAX due to overflow).
- char *error = NULL;
+ char *error = nullptr;
int64 value = strto64(str, &error, 0);
if (value > numeric_limits<uint32>::max() ||
value < -static_cast<int64>(numeric_limits<uint32>::max())) {
@@ -337,7 +337,7 @@ uint32 ParseLeadingUInt32Value(const char *str, uint32 deflt) {
// --------------------------------------------------------------------
int32 ParseLeadingDec32Value(const char *str, int32 deflt) {
- char *error = NULL;
+ char *error = nullptr;
long value = strtol(str, &error, 10);
// Limit long values to int32 min/max. Needed for lp64; no-op on 32 bits.
if (value > numeric_limits<int32>::max()) {
@@ -351,7 +351,7 @@ int32 ParseLeadingDec32Value(const char *str, int32 deflt) {
uint32 ParseLeadingUDec32Value(const char *str, uint32 deflt) {
if (numeric_limits<unsigned long>::max() == numeric_limits<uint32>::max()) {
// When long is 32 bits, we can use strtoul.
- char *error = NULL;
+ char *error = nullptr;
const uint32 value = strtoul(str, &error, 10);
return (error == str) ? deflt : value;
} else {
@@ -360,7 +360,7 @@ uint32 ParseLeadingUDec32Value(const char *str, uint32 deflt) {
// it would be impossible to differentiate "-2" (that should wrap
// around to the value UINT_MAX-1) from a string with ULONG_MAX-1
// (that should be pegged to UINT_MAX due to overflow).
- char *error = NULL;
+ char *error = nullptr;
int64 value = strto64(str, &error, 10);
if (value > numeric_limits<uint32>::max() ||
value < -static_cast<int64>(numeric_limits<uint32>::max())) {
@@ -380,19 +380,19 @@ uint32 ParseLeadingUDec32Value(const char *str, uint32 deflt) {
// UInt64 and Int64 cannot handle decimal numbers with leading 0s.
// --------------------------------------------------------------------
uint64 ParseLeadingUInt64Value(const char *str, uint64 deflt) {
- char *error = NULL;
+ char *error = nullptr;
const uint64 value = strtou64(str, &error, 0);
return (error == str) ? deflt : value;
}
int64 ParseLeadingInt64Value(const char *str, int64 deflt) {
- char *error = NULL;
+ char *error = nullptr;
const int64 value = strto64(str, &error, 0);
return (error == str) ? deflt : value;
}
uint64 ParseLeadingHex64Value(const char *str, uint64 deflt) {
- char *error = NULL;
+ char *error = nullptr;
const uint64 value = strtou64(str, &error, 16);
return (error == str) ? deflt : value;
}
@@ -407,13 +407,13 @@ uint64 ParseLeadingHex64Value(const char *str, uint64 deflt) {
// --------------------------------------------------------------------
int64 ParseLeadingDec64Value(const char *str, int64 deflt) {
- char *error = NULL;
+ char *error = nullptr;
const int64 value = strto64(str, &error, 10);
return (error == str) ? deflt : value;
}
uint64 ParseLeadingUDec64Value(const char *str, uint64 deflt) {
- char *error = NULL;
+ char *error = nullptr;
const uint64 value = strtou64(str, &error, 10);
return (error == str) ? deflt : value;
}
@@ -425,7 +425,7 @@ uint64 ParseLeadingUDec64Value(const char *str, uint64 deflt) {
// --------------------------------------------------------------------
double ParseLeadingDoubleValue(const char *str, double deflt) {
- char *error = NULL;
+ char *error = nullptr;
errno = 0;
const double value = strtod(str, &error);
if (errno != 0 || // overflow/underflow happened
@@ -926,7 +926,7 @@ extern const char two_ASCII_digits[100][2]; // from strutil.cc
char* FastUInt32ToBufferLeft(uint32 u, char* buffer) {
uint digits;
- const char *ASCII_digits = NULL;
+ const char *ASCII_digits = nullptr;
// The idea of this implementation is to trim the number of divides to as few
// as possible by using multiplication and subtraction rather than mod (%),
// and by outputting two digits at a time rather than one.
@@ -1020,7 +1020,7 @@ char* FastInt32ToBufferLeft(int32 i, char* buffer) {
char* FastUInt64ToBufferLeft(uint64 u64, char* buffer) {
uint digits;
- const char *ASCII_digits = NULL;
+ const char *ASCII_digits = nullptr;
uint32 u = static_cast<uint32>(u64);
if (u == u64) return FastUInt32ToBufferLeft(u, buffer);
@@ -1248,7 +1248,7 @@ char* DoubleToBuffer(double value, char* buffer) {
// larger than the precision we asked for.
DCHECK(snprintf_result > 0 && snprintf_result < kDoubleToBufferSize);
- if (strtod(buffer, NULL) != value) {
+ if (strtod(buffer, nullptr) != value) {
snprintf_result =
snprintf(buffer, kDoubleToBufferSize, "%.*g", DBL_DIG+2, value);
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/35b49cc5/src/kudu/gutil/strings/serialize.cc
----------------------------------------------------------------------
diff --git a/src/kudu/gutil/strings/serialize.cc b/src/kudu/gutil/strings/serialize.cc
index ba631d1..56fd95b 100644
--- a/src/kudu/gutil/strings/serialize.cc
+++ b/src/kudu/gutil/strings/serialize.cc
@@ -280,7 +280,7 @@ bool DictionaryInt32Decode(hash_map<string, int32>* dictionary,
dictionary->clear();
for (int i = 0; i < items.size(); ++i) {
- char *error = NULL;
+ char *error = nullptr;
const int32 value = strto32(items[i].second.c_str(), &error, 0);
if (error == items[i].second.c_str() || *error != '\0') {
// parsing error
@@ -299,7 +299,7 @@ bool DictionaryInt64Decode(hash_map<string, int64>* dictionary,
dictionary->clear();
for (int i = 0; i < items.size(); ++i) {
- char *error = NULL;
+ char *error = nullptr;
const int64 value = strto64(items[i].second.c_str(), &error, 0);
if (error == items[i].second.c_str() || *error != '\0') {
// parsing error
@@ -319,7 +319,7 @@ bool DictionaryDoubleDecode(hash_map<string, double>* dictionary,
dictionary->clear();
for (int i = 0; i < items.size(); ++i) {
- char *error = NULL;
+ char *error = nullptr;
const double value = strtod(items[i].second.c_str(), &error);
if (error == items[i].second.c_str() || *error != '\0') {
// parsing error
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/35b49cc5/src/kudu/gutil/strings/split.cc
----------------------------------------------------------------------
diff --git a/src/kudu/gutil/strings/split.cc b/src/kudu/gutil/strings/split.cc
index 1f1eb0a..5eca7a7 100644
--- a/src/kudu/gutil/strings/split.cc
+++ b/src/kudu/gutil/strings/split.cc
@@ -472,12 +472,12 @@ vector<char*>* SplitUsing(char* full, const char* delim) {
void SplitToVector(char* full, const char* delim, vector<char*>* vec,
bool omit_empty_strings) {
char* next = full;
- while ((next = gstrsep(&full, delim)) != NULL) {
+ while ((next = gstrsep(&full, delim)) != nullptr) {
if (omit_empty_strings && next[0] == '\0') continue;
vec->push_back(next);
}
// Add last element (or full string if no delimeter found):
- if (full != NULL) {
+ if (full != nullptr) {
vec->push_back(full);
}
}
@@ -485,12 +485,12 @@ void SplitToVector(char* full, const char* delim, vector<char*>* vec,
void SplitToVector(char* full, const char* delim, vector<const char*>* vec,
bool omit_empty_strings) {
char* next = full;
- while ((next = gstrsep(&full, delim)) != NULL) {
+ while ((next = gstrsep(&full, delim)) != nullptr) {
if (omit_empty_strings && next[0] == '\0') continue;
vec->push_back(next);
}
// Add last element (or full string if no delimeter found):
- if (full != NULL) {
+ if (full != nullptr) {
vec->push_back(full);
}
}
@@ -691,7 +691,7 @@ DEFINE_SPLIT_ONE_NUMBER_TOKEN(HexUint64, uint64, strtou64_16)
bool SplitRange(const char* rangestr, int* from, int* to) {
// We need to do the const-cast because strol takes a char**, not const char**
char* val = const_cast<char*>(rangestr);
- if (val == NULL || EOS(*val)) return true; // we'll say nothingness is ok
+ if (val == nullptr || EOS(*val)) return true; // we'll say nothingness is ok
if ( val[0] == '-' && EOS(val[1]) ) // CASE 1: -
return true; // nothing changes
@@ -871,7 +871,7 @@ char* SplitStructuredLineInternal(char* line,
if (!expected_to_close.empty()) {
return current; // Missing closing symbol(s)
}
- return NULL; // Success
+ return nullptr; // Success
}
bool SplitStructuredLineInternal(StringPiece line,
@@ -1033,7 +1033,7 @@ bool SplitStringIntoKeyValuePairs(const string& line,
// --------------------------------------------------------------------
const char* SplitLeadingDec32Values(const char *str, vector<int32> *result) {
for (;;) {
- char *end = NULL;
+ char *end = nullptr;
long value = strtol(str, &end, 10);
if (end == str)
break;
@@ -1053,7 +1053,7 @@ const char* SplitLeadingDec32Values(const char *str, vector<int32> *result) {
const char* SplitLeadingDec64Values(const char *str, vector<int64> *result) {
for (;;) {
- char *end = NULL;
+ char *end = nullptr;
const int64 value = strtoll(str, &end, 10);
if (end == str)
break;
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/35b49cc5/src/kudu/gutil/strings/stringpiece.cc
----------------------------------------------------------------------
diff --git a/src/kudu/gutil/strings/stringpiece.cc b/src/kudu/gutil/strings/stringpiece.cc
index 9df0f38..d6f23ee 100644
--- a/src/kudu/gutil/strings/stringpiece.cc
+++ b/src/kudu/gutil/strings/stringpiece.cc
@@ -81,7 +81,7 @@ int StringPiece::find(char c, size_type pos) const {
}
const char* result = static_cast<const char*>(
memchr(ptr_ + pos, c, length_ - pos));
- return result != NULL ? result - ptr_ : npos;
+ return result != nullptr ? result - ptr_ : npos;
}
int StringPiece::rfind(StringPiece s, size_type pos) const {
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/35b49cc5/src/kudu/gutil/strings/strip.cc
----------------------------------------------------------------------
diff --git a/src/kudu/gutil/strings/strip.cc b/src/kudu/gutil/strings/strip.cc
index 6089c22..112ac31 100644
--- a/src/kudu/gutil/strings/strip.cc
+++ b/src/kudu/gutil/strings/strip.cc
@@ -286,7 +286,7 @@ int StripDupCharacters(string* s, char dup_char, int start_pos) {
// Remove leading, trailing, and duplicate internal whitespace.
// ----------------------------------------------------------------------
void RemoveExtraWhitespace(string* s) {
- assert(s != NULL);
+ assert(s != nullptr);
// Empty strings clearly have no whitespace, and this code assumes that
// string length is greater than 0
if (s->empty())
@@ -324,7 +324,7 @@ void RemoveExtraWhitespace(string* s) {
void StripLeadingWhiteSpace(string* str) {
char const* const leading = StripLeadingWhiteSpace(
const_cast<char*>(str->c_str()));
- if (leading != NULL) {
+ if (leading != nullptr) {
string const tmp(leading);
str->assign(tmp);
} else {
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/35b49cc5/src/kudu/gutil/strings/substitute.cc
----------------------------------------------------------------------
diff --git a/src/kudu/gutil/strings/substitute.cc b/src/kudu/gutil/strings/substitute.cc
index eabb9d5..245894b 100644
--- a/src/kudu/gutil/strings/substitute.cc
+++ b/src/kudu/gutil/strings/substitute.cc
@@ -93,7 +93,7 @@ void SubstituteAndAppend(
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
};
// Determine total size needed.
@@ -112,7 +112,7 @@ void SubstituteAndAppend(
SubstituteArg::SubstituteArg(const void* value) {
COMPILE_ASSERT(sizeof(scratch_) >= sizeof(value) * 2 + 2,
fix_sizeof_scratch_);
- if (value == NULL) {
+ if (value == nullptr) {
text_ = "NULL";
size_ = strlen(text_);
} else {
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/35b49cc5/src/kudu/gutil/strings/util.cc
----------------------------------------------------------------------
diff --git a/src/kudu/gutil/strings/util.cc b/src/kudu/gutil/strings/util.cc
index 16917a5..4ff104d 100644
--- a/src/kudu/gutil/strings/util.cc
+++ b/src/kudu/gutil/strings/util.cc
@@ -56,9 +56,9 @@ char* strnstr(const char* haystack, const char* needle,
}
size_t needle_len = strlen(needle);
char* where;
- while ((where = strnchr(haystack, *needle, haystack_len)) != NULL) {
+ while ((where = strnchr(haystack, *needle, haystack_len)) != nullptr) {
if (where - haystack + needle_len > haystack_len) {
- return NULL;
+ return nullptr;
}
if (strncmp(where, needle, needle_len) == 0) {
return where;
@@ -66,18 +66,18 @@ char* strnstr(const char* haystack, const char* needle,
haystack_len -= where + 1 - haystack;
haystack = where + 1;
}
- return NULL;
+ return nullptr;
}
const char* strnprefix(const char* haystack, int haystack_size,
const char* needle, int needle_size) {
if (needle_size > haystack_size) {
- return NULL;
+ return nullptr;
} else {
if (strncmp(haystack, needle, needle_size) == 0) {
return haystack + needle_size;
} else {
- return NULL;
+ return nullptr;
}
}
}
@@ -85,12 +85,12 @@ const char* strnprefix(const char* haystack, int haystack_size,
const char* strncaseprefix(const char* haystack, int haystack_size,
const char* needle, int needle_size) {
if (needle_size > haystack_size) {
- return NULL;
+ return nullptr;
} else {
if (strncasecmp(haystack, needle, needle_size) == 0) {
return haystack + needle_size;
} else {
- return NULL;
+ return nullptr;
}
}
}
@@ -103,20 +103,20 @@ char* strcasesuffix(char* str, const char* suffix) {
if (lenstr >= lensuffix && 0 == strcasecmp(strbeginningoftheend, suffix)) {
return (strbeginningoftheend);
} else {
- return (NULL);
+ return (nullptr);
}
}
const char* strnsuffix(const char* haystack, int haystack_size,
const char* needle, int needle_size) {
if (needle_size > haystack_size) {
- return NULL;
+ return nullptr;
} else {
const char* start = haystack + haystack_size - needle_size;
if (strncmp(start, needle, needle_size) == 0) {
return start;
} else {
- return NULL;
+ return nullptr;
}
}
}
@@ -124,20 +124,20 @@ const char* strnsuffix(const char* haystack, int haystack_size,
const char* strncasesuffix(const char* haystack, int haystack_size,
const char* needle, int needle_size) {
if (needle_size > haystack_size) {
- return NULL;
+ return nullptr;
} else {
const char* start = haystack + haystack_size - needle_size;
if (strncasecmp(start, needle, needle_size) == 0) {
return start;
} else {
- return NULL;
+ return nullptr;
}
}
}
char* strchrnth(const char* str, const char& c, int n) {
- if (str == NULL)
- return NULL;
+ if (str == nullptr)
+ return nullptr;
if (n <= 0)
return const_cast<char*>(str);
const char* sp;
@@ -149,18 +149,18 @@ char* strchrnth(const char* str, const char& c, int n) {
break;
}
}
- return (k < n) ? NULL : const_cast<char*>(sp);
+ return (k < n) ? nullptr : const_cast<char*>(sp);
}
char* AdjustedLastPos(const char* str, char separator, int n) {
- if ( str == NULL )
- return NULL;
- const char* pos = NULL;
+ if ( str == nullptr )
+ return nullptr;
+ const char* pos = nullptr;
if ( n > 0 )
pos = strchrnth(str, separator, n);
// if n <= 0 or separator appears fewer than n times, get the last occurrence
- if ( pos == NULL)
+ if ( pos == nullptr)
pos = strrchr(str, separator);
return const_cast<char*>(pos);
}
@@ -238,7 +238,7 @@ void StringReplace(const StringPiece& s, const StringPiece& oldsub,
int GlobalReplaceSubstring(const StringPiece& substring,
const StringPiece& replacement,
string* s) {
- CHECK(s != NULL);
+ CHECK(s != nullptr);
if (s->empty() || substring.empty())
return 0;
string tmp;
@@ -306,7 +306,7 @@ char *gstrcasestr(const char* haystack, const char* needle) {
do {
do {
if ((sc = *haystack++) == 0)
- return NULL;
+ return nullptr;
} while (ascii_tolower(sc) != c);
} while (strncasecmp(haystack, needle, len) != 0);
haystack--;
@@ -333,7 +333,7 @@ const char *gstrncasestr(const char* haystack, const char* needle, size_t len) {
do {
if (len-- <= needle_len
|| 0 == (sc = *haystack++))
- return NULL;
+ return nullptr;
} while (ascii_tolower(sc) != c);
} while (strncasecmp(haystack, needle, needle_len) != 0);
haystack--;
@@ -361,22 +361,22 @@ char *gstrncasestr_split(const char* str,
const char* prefix, char non_alpha,
const char* suffix,
size_t n) {
- int prelen = prefix == NULL ? 0 : strlen(prefix);
- int suflen = suffix == NULL ? 0 : strlen(suffix);
+ int prelen = prefix == nullptr ? 0 : strlen(prefix);
+ int suflen = suffix == nullptr ? 0 : strlen(suffix);
// adjust the string and its length to avoid unnessary searching.
// an added benefit is to avoid unnecessary range checks in the if
// statement in the inner loop.
- if (suflen + prelen >= n) return NULL;
+ if (suflen + prelen >= n) return nullptr;
str += prelen;
n -= prelen;
n -= suflen;
- const char* where = NULL;
+ const char* where = nullptr;
// for every occurance of non_alpha in the string ...
while ((where = static_cast<const char*>(
- memchr(str, non_alpha, n))) != NULL) {
+ memchr(str, non_alpha, n))) != nullptr) {
// ... test whether it is followed by suffix and preceded by prefix
if ((!suflen || strncasecmp(where + 1, suffix, suflen) == 0) &&
(!prelen || strncasecmp(where - prelen, prefix, prelen) == 0)) {
@@ -387,7 +387,7 @@ char *gstrncasestr_split(const char* str,
str = where + 1;
}
- return NULL;
+ return nullptr;
}
// ----------------------------------------------------------------------
@@ -414,7 +414,7 @@ char *strcasestr_alnum(const char *haystack, const char *needle) {
// Skip non-alnums at beginning
while ( !ascii_isalnum(*haystack) )
if ( *haystack++ == '\0' )
- return NULL;
+ return nullptr;
haystack_ptr = haystack;
while ( *needle_ptr != '\0' ) {
@@ -425,7 +425,7 @@ char *strcasestr_alnum(const char *haystack, const char *needle) {
while ( !ascii_isalnum(*haystack_ptr) )
if ( *haystack_ptr++ == '\0' )
- return NULL;
+ return nullptr;
if ( ascii_tolower(*needle_ptr) == ascii_tolower(*haystack_ptr) ) {
// Case-insensitive match - advance
@@ -436,7 +436,7 @@ char *strcasestr_alnum(const char *haystack, const char *needle) {
haystack++;
while ( !ascii_isalnum(*haystack) )
if ( *haystack++ == '\0' )
- return NULL;
+ return nullptr;
haystack_ptr = haystack;
needle_ptr = needle;
}
@@ -477,7 +477,7 @@ int CountSubstring(StringPiece text, StringPiece substring) {
const char* strstr_delimited(const char* haystack,
const char* needle,
char delim) {
- if (!needle || !haystack) return NULL;
+ if (!needle || !haystack) return nullptr;
if (*needle == '\0') return haystack;
int needle_len = strlen(needle);
@@ -504,12 +504,12 @@ const char* strstr_delimited(const char* haystack,
// No match. Consume non-delimiter characters until we run out of them.
while (*haystack != delim) {
- if (*haystack == '\0') return NULL;
+ if (*haystack == '\0') return nullptr;
++haystack;
}
}
LOG(FATAL) << "Unreachable statement";
- return NULL;
+ return nullptr;
}
@@ -523,8 +523,8 @@ char* gstrsep(char** stringp, const char* delim) {
int c, sc;
char *tok;
- if ((s = *stringp) == NULL)
- return NULL;
+ if ((s = *stringp) == nullptr)
+ return nullptr;
tok = s;
while (true) {
@@ -533,7 +533,7 @@ char* gstrsep(char** stringp, const char* delim) {
do {
if ((sc = *spanp++) == c) {
if (c == 0)
- s = NULL;
+ s = nullptr;
else
s[-1] = 0;
*stringp = s;
@@ -542,7 +542,7 @@ char* gstrsep(char** stringp, const char* delim) {
} while (sc != 0);
}
- return NULL; /* should not happen */
+ return nullptr; /* should not happen */
}
void FastStringAppend(string* s, const char* data, int len) {
@@ -593,7 +593,7 @@ char* FastTimeToBuffer(time_t s, char* buffer) {
}
struct tm tm;
- if (PortableSafeGmtime(&s, &tm) == NULL) {
+ if (PortableSafeGmtime(&s, &tm) == nullptr) {
// Error message must fit in 30-char buffer.
memcpy(buffer, "Invalid:", sizeof("Invalid:"));
FastInt64ToBufferLeft(s, buffer+strlen(buffer));
@@ -678,15 +678,15 @@ char* FastTimeToBuffer(time_t s, char* buffer) {
// and didn't want to (or cannot) modify the string
// ----------------------------------------------------------------------
char* strdup_with_new(const char* the_string) {
- if (the_string == NULL)
- return NULL;
+ if (the_string == nullptr)
+ return nullptr;
else
return strndup_with_new(the_string, strlen(the_string));
}
char* strndup_with_new(const char* the_string, int max_length) {
- if (the_string == NULL)
- return NULL;
+ if (the_string == nullptr)
+ return nullptr;
char* result = new char[max_length + 1];
result[max_length] = '\0'; // terminate the string because strncpy might not
@@ -710,17 +710,17 @@ char* strndup_with_new(const char* the_string, int max_length) {
// Precondition: (end_ptr != NULL)
// ----------------------------------------------------------------------
const char* ScanForFirstWord(const char* the_string, const char** end_ptr) {
- CHECK(end_ptr != NULL) << ": precondition violated";
+ CHECK(end_ptr != nullptr) << ": precondition violated";
- if (the_string == NULL) // empty string
- return NULL;
+ if (the_string == nullptr) // empty string
+ return nullptr;
const char* curr = the_string;
while ((*curr != '\0') && ascii_isspace(*curr)) // skip initial spaces
++curr;
if (*curr == '\0') // no valid word found
- return NULL;
+ return nullptr;
// else has a valid word
const char* first_word = curr;
@@ -745,7 +745,7 @@ const char *AdvanceIdentifier(const char *str) {
// We could have used ascii_isalpha and ascii_isalnum.
char ch = *str++;
if (!((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') || ch == '_'))
- return NULL;
+ return nullptr;
while (true) {
ch = *str;
if (!((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') ||
@@ -776,7 +776,7 @@ template <typename CHAR, typename NEXT>
static void EatSameChars(const CHAR** pattern, const CHAR* pattern_end,
const CHAR** string, const CHAR* string_end,
NEXT next) {
- const CHAR* escape = NULL;
+ const CHAR* escape = nullptr;
while (*pattern != pattern_end && *string != string_end) {
if (!escape && IsWildcard(**pattern)) {
// We don't want to match wildcard here, except if it's escaped.
@@ -812,7 +812,7 @@ static void EatSameChars(const CHAR** pattern, const CHAR* pattern_end,
return;
}
- escape = NULL;
+ escape = nullptr;
}
}
@@ -924,7 +924,7 @@ bool FindTagValuePair(const char* arg_str, char tag_value_separator,
char **tag, int *tag_len,
char **value, int *value_len) {
char* in_str = const_cast<char*>(arg_str); // For msvc8.
- if (in_str == NULL)
+ if (in_str == nullptr)
return false;
char tv_sep_or_term[3] = {tag_value_separator, string_terminal, '\0'};
char attr_sep_or_term[3] = {attribute_separator, string_terminal, '\0'};
@@ -932,20 +932,20 @@ bool FindTagValuePair(const char* arg_str, char tag_value_separator,
// Look for beginning of tag
*tag = strpbrk(in_str, attr_sep_or_term);
// If string_terminal is '\0', strpbrk won't find it but return null.
- if (*tag == NULL || **tag == string_terminal)
+ if (*tag == nullptr || **tag == string_terminal)
*tag = in_str;
else
(*tag)++; // Move past separator
// Now look for value...
char *tv_sep_pos = strpbrk(*tag, tv_sep_or_term);
- if (tv_sep_pos == NULL || *tv_sep_pos == string_terminal)
+ if (tv_sep_pos == nullptr || *tv_sep_pos == string_terminal)
return false;
// ...and end of value
char *attr_sep_pos = strpbrk(tv_sep_pos, attr_sep_or_term);
*tag_len = tv_sep_pos - *tag;
*value = tv_sep_pos + 1;
- if (attr_sep_pos != NULL)
+ if (attr_sep_pos != nullptr)
*value_len = attr_sep_pos - *value;
else
*value_len = strlen(*value);
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/35b49cc5/src/kudu/gutil/sysinfo.cc
----------------------------------------------------------------------
diff --git a/src/kudu/gutil/sysinfo.cc b/src/kudu/gutil/sysinfo.cc
index fbb0f98..a222fbb 100644
--- a/src/kudu/gutil/sysinfo.cc
+++ b/src/kudu/gutil/sysinfo.cc
@@ -337,7 +337,7 @@ static void InitializeSystemInfo() {
int num_cpus = 0;
size_t size = sizeof(num_cpus);
int numcpus_name[] = { CTL_HW, HW_NCPU };
- if (::sysctl(numcpus_name, arraysize(numcpus_name), &num_cpus, &size, 0, 0)
+ if (::sysctl(numcpus_name, arraysize(numcpus_name), &num_cpus, &size, nullptr, 0)
== 0
&& (size == sizeof(num_cpus)))
cpuinfo_num_cpus = num_cpus;
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/35b49cc5/src/kudu/gutil/walltime.cc
----------------------------------------------------------------------
diff --git a/src/kudu/gutil/walltime.cc b/src/kudu/gutil/walltime.cc
index a8ca7cf..03fbc51 100644
--- a/src/kudu/gutil/walltime.cc
+++ b/src/kudu/gutil/walltime.cc
@@ -141,7 +141,7 @@ bool WallTime_Parse_Timezone(const char* time_spec,
memset(&split_time, 0, sizeof(split_time));
}
const char* parsed = strptime(time_spec, format, &split_time);
- if (parsed == NULL) return false;
+ if (parsed == nullptr) return false;
// If format ends with "%S", match fractional seconds
double fraction = 0.0;
@@ -190,9 +190,9 @@ void StringAppendStrftime(string* dst,
struct tm tm;
bool conversion_error;
if (local) {
- conversion_error = (localtime_r(&when, &tm) == NULL);
+ conversion_error = (localtime_r(&when, &tm) == nullptr);
} else {
- conversion_error = (gmtime_r(&when, &tm) == NULL);
+ conversion_error = (gmtime_r(&when, &tm) == nullptr);
}
if (conversion_error) {
// If we couldn't convert the time, don't append anything.
@@ -203,6 +203,6 @@ void StringAppendStrftime(string* dst,
string LocalTimeAsString() {
string ret;
- StringAppendStrftime(&ret, "%Y-%m-%d %H:%M:%S %Z", time(NULL), true);
+ StringAppendStrftime(&ret, "%Y-%m-%d %H:%M:%S %Z", time(nullptr), true);
return ret;
}
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/35b49cc5/src/kudu/integration-tests/alter_table-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/integration-tests/alter_table-test.cc b/src/kudu/integration-tests/alter_table-test.cc
index 1dfeee2..33aef92 100644
--- a/src/kudu/integration-tests/alter_table-test.cc
+++ b/src/kudu/integration-tests/alter_table-test.cc
@@ -146,7 +146,7 @@ class AlterTableTest : public KuduTest {
// we'll end up calling the destructor from the test code instead of the
// normal location, which can cause crashes, etc.
tablet_peer_.reset();
- if (cluster_->mini_tablet_server(0)->server() != NULL) {
+ if (cluster_->mini_tablet_server(0)->server() != nullptr) {
cluster_->mini_tablet_server(0)->Shutdown();
}
}
@@ -299,7 +299,7 @@ TEST_F(AlterTableTest, TestAddNotNullableColumnWithoutDefaults) {
step->mutable_add_column()->mutable_schema());
AlterTableResponsePB resp;
Status s = cluster_->mini_master()->master()->catalog_manager()->AlterTable(
- &req, &resp, NULL);
+ &req, &resp, nullptr);
ASSERT_TRUE(s.IsInvalidArgument());
ASSERT_STR_CONTAINS(s.ToString(), "column `c2`: NOT NULL columns must have a default");
}
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/35b49cc5/src/kudu/integration-tests/client-stress-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/integration-tests/client-stress-test.cc b/src/kudu/integration-tests/client-stress-test.cc
index 6401bfc..4a6e80e 100644
--- a/src/kudu/integration-tests/client-stress-test.cc
+++ b/src/kudu/integration-tests/client-stress-test.cc
@@ -243,7 +243,7 @@ TEST_F(ClientStressTest_LowMemory, TestMemoryThrottling) {
int64_t value;
Status s = cluster_->tablet_server(i)->GetInt64Metric(
&METRIC_ENTITY_tablet,
- NULL,
+ nullptr,
&METRIC_leader_memory_pressure_rejections,
"value",
&value);
@@ -253,7 +253,7 @@ TEST_F(ClientStressTest_LowMemory, TestMemoryThrottling) {
}
s = cluster_->tablet_server(i)->GetInt64Metric(
&METRIC_ENTITY_tablet,
- NULL,
+ nullptr,
&METRIC_follower_memory_pressure_rejections,
"value",
&value);
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/35b49cc5/src/kudu/integration-tests/cluster_itest_util.cc
----------------------------------------------------------------------
diff --git a/src/kudu/integration-tests/cluster_itest_util.cc b/src/kudu/integration-tests/cluster_itest_util.cc
index 2cbfa4f..5d892e4 100644
--- a/src/kudu/integration-tests/cluster_itest_util.cc
+++ b/src/kudu/integration-tests/cluster_itest_util.cc
@@ -452,7 +452,7 @@ Status LeaderStepDown(const TServerDetails* replica,
rpc.set_timeout(timeout);
RETURN_NOT_OK(replica->consensus_proxy->LeaderStepDown(req, &resp, &rpc));
if (resp.has_error()) {
- if (error != NULL) {
+ if (error != nullptr) {
*error = resp.error();
}
return StatusFromPB(resp.error().status())
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/35b49cc5/src/kudu/integration-tests/external_mini_cluster.cc
----------------------------------------------------------------------
diff --git a/src/kudu/integration-tests/external_mini_cluster.cc b/src/kudu/integration-tests/external_mini_cluster.cc
index 0af21c7..6c9de1a 100644
--- a/src/kudu/integration-tests/external_mini_cluster.cc
+++ b/src/kudu/integration-tests/external_mini_cluster.cc
@@ -263,7 +263,7 @@ string ExternalMiniCluster::GetBindIpForTabletServer(int index) const {
}
Status ExternalMiniCluster::AddTabletServer() {
- CHECK(leader_master() != NULL)
+ CHECK(leader_master() != nullptr)
<< "Must have started at least 1 master before adding tablet servers";
int idx = tablet_servers_.size();
@@ -418,7 +418,7 @@ ExternalTabletServer* ExternalMiniCluster::tablet_server_by_uuid(const std::stri
return ts.get();
}
}
- return NULL;
+ return nullptr;
}
int ExternalMiniCluster::tablet_server_index_by_uuid(const std::string& uuid) const {
@@ -601,7 +601,7 @@ Status ExternalDaemon::Resume() {
}
bool ExternalDaemon::IsShutdown() const {
- return process_.get() == NULL;
+ return process_.get() == nullptr;
}
bool ExternalDaemon::IsProcessAlive() const {
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/35b49cc5/src/kudu/integration-tests/mini_cluster.cc
----------------------------------------------------------------------
diff --git a/src/kudu/integration-tests/mini_cluster.cc b/src/kudu/integration-tests/mini_cluster.cc
index 3af4192..ab45391 100644
--- a/src/kudu/integration-tests/mini_cluster.cc
+++ b/src/kudu/integration-tests/mini_cluster.cc
@@ -196,7 +196,7 @@ MiniMaster* MiniCluster::leader_mini_master() {
}
LOG(ERROR) << "No leader master elected after " << kMasterLeaderElectionWaitTimeSeconds
<< " seconds.";
- return NULL;
+ return nullptr;
}
void MiniCluster::Shutdown() {
@@ -304,7 +304,7 @@ Status MiniCluster::WaitForTabletServerCount(int count,
Status MiniCluster::CreateClient(KuduClientBuilder* builder,
client::sp::shared_ptr<KuduClient>* client) {
KuduClientBuilder default_builder;
- if (builder == NULL) {
+ if (builder == nullptr) {
builder = &default_builder;
}
builder->clear_master_server_addrs();
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/35b49cc5/src/kudu/integration-tests/raft_consensus-itest.cc
----------------------------------------------------------------------
diff --git a/src/kudu/integration-tests/raft_consensus-itest.cc b/src/kudu/integration-tests/raft_consensus-itest.cc
index b7ed3b3..0cf01dc 100644
--- a/src/kudu/integration-tests/raft_consensus-itest.cc
+++ b/src/kudu/integration-tests/raft_consensus-itest.cc
@@ -417,7 +417,7 @@ TEST_F(RaftConsensusITest, TestGetPermanentUuid) {
BuildAndStart(vector<string>());
RaftPeerPB peer;
- TServerDetails* leader = NULL;
+ TServerDetails* leader = nullptr;
ASSERT_OK(GetLeaderReplicaWithRetries(tablet_id_, &leader));
peer.mutable_last_known_addr()->CopyFrom(leader->registration.rpc_addresses(0));
const string expected_uuid = leader->instance_id.permanent_uuid();
@@ -466,7 +466,7 @@ TEST_F(RaftConsensusITest, TestFailedTransaction) {
RpcController controller;
controller.set_timeout(MonoDelta::FromSeconds(FLAGS_rpc_timeout));
- TServerDetails* leader = NULL;
+ TServerDetails* leader = nullptr;
ASSERT_OK(GetLeaderReplicaWithRetries(tablet_id_, &leader));
ASSERT_OK(DCHECK_NOTNULL(leader->tserver_proxy.get())->Write(req, &resp, &controller));
@@ -606,7 +606,7 @@ TEST_F(RaftConsensusITest, TestRunLeaderElection) {
}
void RaftConsensusITest::Write128KOpsToLeader(int num_writes) {
- TServerDetails* leader = NULL;
+ TServerDetails* leader = nullptr;
ASSERT_OK(GetLeaderReplicaWithRetries(tablet_id_, &leader));
WriteRequestPB req;
@@ -641,7 +641,7 @@ TEST_F(RaftConsensusITest, TestCatchupAfterOpsEvicted) {
extra_flags.push_back("--consensus_max_batch_size_bytes=500000");
BuildAndStart(extra_flags);
TServerDetails* replica = (*tablet_replicas_.begin()).second;
- ASSERT_TRUE(replica != NULL);
+ ASSERT_TRUE(replica != nullptr);
ExternalTabletServer* replica_ets = cluster_->tablet_server_by_uuid(replica->uuid());
// Pause a replica
@@ -674,10 +674,10 @@ void RaftConsensusITest::CauseFollowerToFallBehindLogGC(string* leader_uuid,
// Find a leader. In case we paused the leader above, this will wait until
// we have elected a new one.
- TServerDetails* leader = NULL;
+ TServerDetails* leader = nullptr;
while (true) {
Status s = GetLeaderReplicaWithRetries(tablet_id_, &leader);
- if (s.ok() && leader != NULL && leader != replica) {
+ if (s.ok() && leader != nullptr && leader != replica) {
break;
}
SleepFor(MonoDelta::FromMilliseconds(10));
@@ -1196,7 +1196,7 @@ TEST_F(RaftConsensusITest, TestReplicaBehaviorViaRPC) {
int64_t term_from_metric = -1;
ASSERT_OK(cluster_->tablet_server_by_uuid(replica_ts->uuid())->GetInt64Metric(
&METRIC_ENTITY_tablet,
- NULL,
+ nullptr,
&METRIC_raft_term,
"value",
&term_from_metric));
@@ -2135,14 +2135,14 @@ TEST_F(RaftConsensusITest, TestAutoCreateReplica) {
InsertOrDie(&active_tablet_servers, leader->uuid(), leader);
InsertOrDie(&active_tablet_servers, follower->uuid(), follower);
- TServerDetails* new_node = NULL;
+ TServerDetails* new_node = nullptr;
for (TServerDetails* ts : tservers) {
if (!ContainsKey(active_tablet_servers, ts->uuid())) {
new_node = ts;
break;
}
}
- ASSERT_TRUE(new_node != NULL);
+ ASSERT_TRUE(new_node != nullptr);
// Elect the leader (still only a consensus config size of 2).
ASSERT_OK(StartElection(leader, tablet_id_, MonoDelta::FromSeconds(10)));
@@ -2239,7 +2239,7 @@ TEST_F(RaftConsensusITest, TestMemoryRemainsConstantDespiteTwoDeadFollowers) {
int64_t num_rejections = 0;
ASSERT_OK(cluster_->tablet_server(leader_ts_idx)->GetInt64Metric(
&METRIC_ENTITY_tablet,
- NULL,
+ nullptr,
&METRIC_transaction_memory_pressure_rejections,
"value",
&num_rejections));
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/35b49cc5/src/kudu/integration-tests/remote_bootstrap-itest.cc
----------------------------------------------------------------------
diff --git a/src/kudu/integration-tests/remote_bootstrap-itest.cc b/src/kudu/integration-tests/remote_bootstrap-itest.cc
index 828f03a..914e140 100644
--- a/src/kudu/integration-tests/remote_bootstrap-itest.cc
+++ b/src/kudu/integration-tests/remote_bootstrap-itest.cc
@@ -528,8 +528,8 @@ TEST_F(RemoteBootstrapITest, TestDeleteLeaderDuringRemoteBootstrapStressTest) {
int leader_index = -1;
int follower_index = -1;
- TServerDetails* leader_ts = NULL;
- TServerDetails* follower_ts = NULL;
+ TServerDetails* leader_ts = nullptr;
+ TServerDetails* follower_ts = nullptr;
for (int i = 0; i < FLAGS_test_delete_leader_num_iters; i++) {
LOG(INFO) << "Iteration " << (i + 1);
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/35b49cc5/src/kudu/integration-tests/ts_tablet_manager-itest.cc
----------------------------------------------------------------------
diff --git a/src/kudu/integration-tests/ts_tablet_manager-itest.cc b/src/kudu/integration-tests/ts_tablet_manager-itest.cc
index e792f5d..d8499ed 100644
--- a/src/kudu/integration-tests/ts_tablet_manager-itest.cc
+++ b/src/kudu/integration-tests/ts_tablet_manager-itest.cc
@@ -96,7 +96,7 @@ void TsTabletManagerITest::SetUp() {
opts.num_tablet_servers = kNumReplicas;
cluster_.reset(new MiniCluster(env_.get(), opts));
ASSERT_OK(cluster_->Start());
- ASSERT_OK(cluster_->CreateClient(NULL, &client_));
+ ASSERT_OK(cluster_->CreateClient(nullptr, &client_));
}
void TsTabletManagerITest::TearDown() {
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/35b49cc5/src/kudu/master/catalog_manager.cc
----------------------------------------------------------------------
diff --git a/src/kudu/master/catalog_manager.cc b/src/kudu/master/catalog_manager.cc
index 8b1cfb8..729fe4b 100644
--- a/src/kudu/master/catalog_manager.cc
+++ b/src/kudu/master/catalog_manager.cc
@@ -234,7 +234,7 @@ class TabletLoader : public TabletVisitor {
// Add the tablet to the tablet manager
catalog_manager_->tablet_map_[tablet->tablet_id()] = tablet;
- if (table == NULL) {
+ if (table == nullptr) {
// if the table is missing and the tablet is in "preparing" state
// may mean that the table was not created (maybe due to a failed write
// for the sys-tablets). The cleaner will remove
@@ -282,7 +282,7 @@ class CatalogManagerBgTasks {
public:
explicit CatalogManagerBgTasks(CatalogManager *catalog_manager)
: closing_(false), pending_updates_(false),
- thread_(NULL), catalog_manager_(catalog_manager) {
+ thread_(nullptr), catalog_manager_(catalog_manager) {
}
~CatalogManagerBgTasks() {}
@@ -338,7 +338,7 @@ void CatalogManagerBgTasks::Shutdown() {
}
Wake();
- if (thread_ != NULL) {
+ if (thread_ != nullptr) {
CHECK_OK(ThreadJoiner(thread_.get()).Join());
}
}
@@ -710,7 +710,7 @@ Status CatalogManager::CreateTable(const CreateTableRequestPB* orig_req,
// Decode split rows.
vector<KuduPartialRow> split_rows;
- RowOperationsPBDecoder decoder(&req.split_rows(), &client_schema, &schema, NULL);
+ RowOperationsPBDecoder decoder(&req.split_rows(), &client_schema, &schema, nullptr);
vector<DecodedRowOperation> ops;
RETURN_NOT_OK(decoder.DecodeOperations(&ops));
@@ -766,7 +766,7 @@ Status CatalogManager::CreateTable(const CreateTableRequestPB* orig_req,
// b. Verify that the table does not exist.
table = FindPtrOrNull(table_names_map_, req.name());
- if (table != NULL) {
+ if (table != nullptr) {
s = Status::AlreadyPresent("Table already exists", table->id());
SetupError(resp->mutable_error(), MasterErrorPB::TABLE_ALREADY_PRESENT, s);
return s;
@@ -848,7 +848,7 @@ Status CatalogManager::IsCreateTableDone(const IsCreateTableDoneRequestPB* req,
// 1. Lookup the table and verify if it exists
TRACE("Looking up table");
RETURN_NOT_OK(FindTable(req->table(), &table));
- if (table == NULL) {
+ if (table == nullptr) {
Status s = Status::NotFound("The table does not exist", req->table().DebugString());
SetupError(resp->mutable_error(), MasterErrorPB::TABLE_NOT_FOUND, s);
return s;
@@ -932,7 +932,7 @@ Status CatalogManager::DeleteTable(const DeleteTableRequestPB* req,
// 1. Lookup the table and verify if it exists
TRACE("Looking up table");
RETURN_NOT_OK(FindTable(req->table(), &table));
- if (table == NULL) {
+ if (table == nullptr) {
Status s = Status::NotFound("The table does not exist", req->table().DebugString());
SetupError(resp->mutable_error(), MasterErrorPB::TABLE_NOT_FOUND, s);
return s;
@@ -1084,7 +1084,7 @@ Status CatalogManager::AlterTable(const AlterTableRequestPB* req,
// 1. Lookup the table and verify if it exists
TRACE("Looking up table");
RETURN_NOT_OK(FindTable(req->table(), &table));
- if (table == NULL) {
+ if (table == nullptr) {
Status s = Status::NotFound("The table does not exist", req->table().DebugString());
SetupError(resp->mutable_error(), MasterErrorPB::TABLE_NOT_FOUND, s);
return s;
@@ -1125,7 +1125,7 @@ Status CatalogManager::AlterTable(const AlterTableRequestPB* req,
// Verify that the table does not exist
scoped_refptr<TableInfo> other_table = FindPtrOrNull(table_names_map_, req->new_table_name());
- if (other_table != NULL) {
+ if (other_table != nullptr) {
Status s = Status::AlreadyPresent("Table already exists", other_table->id());
SetupError(resp->mutable_error(), MasterErrorPB::TABLE_ALREADY_PRESENT, s);
return s;
@@ -1202,7 +1202,7 @@ Status CatalogManager::IsAlterTableDone(const IsAlterTableDoneRequestPB* req,
// 1. Lookup the table and verify if it exists
TRACE("Looking up table");
RETURN_NOT_OK(FindTable(req->table(), &table));
- if (table == NULL) {
+ if (table == nullptr) {
Status s = Status::NotFound("The table does not exist", req->table().DebugString());
SetupError(resp->mutable_error(), MasterErrorPB::TABLE_NOT_FOUND, s);
return s;
@@ -1233,7 +1233,7 @@ Status CatalogManager::GetTableSchema(const GetTableSchemaRequestPB* req,
// 1. Lookup the table and verify if it exists
TRACE("Looking up table");
RETURN_NOT_OK(FindTable(req->table(), &table));
- if (table == NULL) {
+ if (table == nullptr) {
Status s = Status::NotFound("The table does not exist", req->table().DebugString());
SetupError(resp->mutable_error(), MasterErrorPB::TABLE_NOT_FOUND, s);
return s;
@@ -1292,7 +1292,7 @@ Status CatalogManager::ListTables(const ListTablesRequestPB* req,
bool CatalogManager::GetTableInfo(const string& table_id, scoped_refptr<TableInfo> *table) {
boost::shared_lock<LockType> l(lock_);
*table = FindPtrOrNull(table_ids_map_, table_id);
- return *table != NULL;
+ return *table != nullptr;
}
void CatalogManager::GetAllTables(std::vector<scoped_refptr<TableInfo> > *tables) {
@@ -1388,13 +1388,13 @@ Status CatalogManager::HandleReportedTablet(TSDescriptor* ts_desc,
if (!tablet) {
LOG(INFO) << "Got report from unknown tablet " << report.tablet_id()
<< ": Sending delete request for this orphan tablet";
- SendDeleteTabletRequest(report.tablet_id(), TABLET_DATA_DELETED, boost::none, NULL, ts_desc,
+ SendDeleteTabletRequest(report.tablet_id(), TABLET_DATA_DELETED, boost::none, nullptr, ts_desc,
"Report from unknown tablet");
return Status::OK();
}
if (!tablet->table()) {
LOG(INFO) << "Got report from an orphaned tablet " << report.tablet_id();
- SendDeleteTabletRequest(report.tablet_id(), TABLET_DATA_DELETED, boost::none, NULL, ts_desc,
+ SendDeleteTabletRequest(report.tablet_id(), TABLET_DATA_DELETED, boost::none, nullptr, ts_desc,
"Report from an orphaned tablet");
return Status::OK();
}
@@ -1683,7 +1683,7 @@ Status CatalogManager::GetTabletPeer(const string& tablet_id,
// Note: CatalogManager has only one table, 'sys_catalog', with only
// one tablet.
boost::shared_lock<LockType> l(lock_);
- CHECK(sys_catalog_.get() != NULL) << "sys_catalog_ must be initialized!";
+ CHECK(sys_catalog_.get() != nullptr) << "sys_catalog_ must be initialized!";
if (sys_catalog_->tablet_id() == tablet_id) {
*tablet_peer = sys_catalog_->tablet_peer();
} else {
@@ -1961,7 +1961,7 @@ class RetryingTSRpcTask : public MonitoredTask {
// Clean up request and release resources. May call 'delete this'.
void UnregisterAsyncTask() {
end_ts_ = MonoTime::Now(MonoTime::FINE);
- if (table_ != NULL) {
+ if (table_ != nullptr) {
table_->RemoveTask(this);
} else {
// This is a floating task (since the table does not exist)
@@ -2452,7 +2452,7 @@ void CatalogManager::SendDeleteTabletRequest(
new AsyncDeleteReplica(master_, worker_pool_.get(), ts_desc->permanent_uuid(), table,
tablet_id, delete_type, cas_config_opid_index_less_or_equal,
reason);
- if (table != NULL) {
+ if (table != nullptr) {
table->AddTask(call);
} else {
// This is a floating task (since the table does not exist)
@@ -2931,7 +2931,7 @@ Status CatalogManager::GetTableLocations(const GetTableLocationsRequestPB* req,
scoped_refptr<TableInfo> table;
RETURN_NOT_OK(FindTable(req->table(), &table));
- if (table == NULL) {
+ if (table == nullptr) {
Status s = Status::NotFound("The table does not exist");
SetupError(resp->mutable_error(), MasterErrorPB::TABLE_NOT_FOUND, s);
return s;
@@ -3090,7 +3090,7 @@ uint32_t TabletInfo::reported_schema_version() const {
std::string TabletInfo::ToString() const {
return Substitute("$0 (table $1)", tablet_id_,
- (table_ != NULL ? table_->ToString() : "MISSING"));
+ (table_ != nullptr ? table_->ToString() : "MISSING"));
}
void PersistentTabletInfo::set_state(SysTabletsEntryPB::State state, const string& msg) {
@@ -3132,7 +3132,7 @@ void TableInfo::AddTablets(const vector<TabletInfo*>& tablets) {
}
void TableInfo::AddTabletUnlocked(TabletInfo* tablet) {
- TabletInfo* old = NULL;
+ TabletInfo* old = nullptr;
if (UpdateReturnCopy(&tablet_map_,
tablet->metadata().dirty().pb.partition().partition_key_start(),
tablet, &old)) {
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/35b49cc5/src/kudu/master/sys_catalog-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/master/sys_catalog-test.cc b/src/kudu/master/sys_catalog-test.cc
index 165a328..51de9b0 100644
--- a/src/kudu/master/sys_catalog-test.cc
+++ b/src/kudu/master/sys_catalog-test.cc
@@ -210,7 +210,7 @@ class TabletLoader : public TabletVisitor {
const std::string& tablet_id,
const SysTabletsEntryPB& metadata) OVERRIDE {
// Setup the tablet info
- TabletInfo *tablet = new TabletInfo(NULL, tablet_id);
+ TabletInfo *tablet = new TabletInfo(nullptr, tablet_id);
TabletMetadataLock l(tablet, TabletMetadataLock::WRITE);
l.mutable_data()->pb.CopyFrom(metadata);
l.Commit();
@@ -333,7 +333,7 @@ TEST_F(SysCatalogTest, TestSysCatalogTabletsOperations) {
// Verify that data mutations are not available from metadata() until commit.
TEST_F(SysCatalogTest, TestTabletInfoCommit) {
- scoped_refptr<TabletInfo> tablet(new TabletInfo(NULL, "123"));
+ scoped_refptr<TabletInfo> tablet(new TabletInfo(nullptr, "123"));
// Mutate the tablet, the changes should not be visible
TabletMetadataLock l(tablet.get(), TabletMetadataLock::WRITE);
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/35b49cc5/src/kudu/rpc/blocking_ops.cc
----------------------------------------------------------------------
diff --git a/src/kudu/rpc/blocking_ops.cc b/src/kudu/rpc/blocking_ops.cc
index 00d9193..923d855 100644
--- a/src/kudu/rpc/blocking_ops.cc
+++ b/src/kudu/rpc/blocking_ops.cc
@@ -49,7 +49,7 @@ Status EnsureBlockingMode(const Socket* const sock) {
Status SendFramedMessageBlocking(Socket* sock, const MessageLite& header, const MessageLite& msg,
const MonoTime& deadline) {
- DCHECK(sock != NULL);
+ DCHECK(sock != nullptr);
DCHECK(header.IsInitialized()) << "header protobuf must be initialized";
DCHECK(msg.IsInitialized()) << "msg protobuf must be initialized";
@@ -79,10 +79,10 @@ Status SendFramedMessageBlocking(Socket* sock, const MessageLite& header, const
Status ReceiveFramedMessageBlocking(Socket* sock, faststring* recv_buf,
MessageLite* header, Slice* param_buf, const MonoTime& deadline) {
- DCHECK(sock != NULL);
- DCHECK(recv_buf != NULL);
- DCHECK(header != NULL);
- DCHECK(param_buf != NULL);
+ DCHECK(sock != nullptr);
+ DCHECK(recv_buf != nullptr);
+ DCHECK(header != nullptr);
+ DCHECK(param_buf != nullptr);
RETURN_NOT_OK(EnsureBlockingMode(sock));
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/35b49cc5/src/kudu/rpc/connection.cc
----------------------------------------------------------------------
diff --git a/src/kudu/rpc/connection.cc b/src/kudu/rpc/connection.cc
index 6478029..c861373 100644
--- a/src/kudu/rpc/connection.cc
+++ b/src/kudu/rpc/connection.cc
@@ -460,7 +460,7 @@ void Connection::HandleCallResponse(gscoped_ptr<InboundTransfer> transfer) {
CallAwaitingResponse *car_ptr =
EraseKeyReturnValuePtr(&awaiting_response_, resp->call_id());
- if (PREDICT_FALSE(car_ptr == NULL)) {
+ if (PREDICT_FALSE(car_ptr == nullptr)) {
LOG(WARNING) << ToString() << ": Got a response for call id " << resp->call_id() << " which "
<< "was not pending! Ignoring.";
return;
@@ -469,7 +469,7 @@ void Connection::HandleCallResponse(gscoped_ptr<InboundTransfer> transfer) {
// The car->timeout_timer ev::timer will be stopped automatically by its destructor.
scoped_car car(car_pool_.make_scoped_ptr(car_ptr));
- if (PREDICT_FALSE(car->call.get() == NULL)) {
+ if (PREDICT_FALSE(car->call.get() == nullptr)) {
// The call already failed due to a timeout.
VLOG(1) << "Got response to call id " << resp->call_id() << " after client already timed out";
return;
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/35b49cc5/src/kudu/rpc/inbound_call.cc
----------------------------------------------------------------------
diff --git a/src/kudu/rpc/inbound_call.cc b/src/kudu/rpc/inbound_call.cc
index da7f9b2..bcef576 100644
--- a/src/kudu/rpc/inbound_call.cc
+++ b/src/kudu/rpc/inbound_call.cc
@@ -103,7 +103,7 @@ void InboundCall::ApplicationErrorToPB(int error_ext_id, const std::string& mess
err->set_message(message);
const FieldDescriptor* app_error_field =
err->GetReflection()->FindKnownExtensionByNumber(error_ext_id);
- if (app_error_field != NULL) {
+ if (app_error_field != nullptr) {
err->GetReflection()->MutableMessage(err, app_error_field)->CheckTypeAndMergeFrom(app_error_pb);
} else {
LOG(DFATAL) << "Unable to find application error extension ID " << error_ext_id
@@ -240,7 +240,7 @@ void InboundCall::RecordCallReceived() {
}
void InboundCall::RecordHandlingStarted(scoped_refptr<Histogram> incoming_queue_time) {
- DCHECK(incoming_queue_time != NULL);
+ DCHECK(incoming_queue_time != nullptr);
DCHECK(!timing_.time_handled.Initialized()); // Protect against multiple calls.
timing_.time_handled = MonoTime::Now(MonoTime::FINE);
incoming_queue_time->Increment(
@@ -248,7 +248,7 @@ void InboundCall::RecordHandlingStarted(scoped_refptr<Histogram> incoming_queue_
}
void InboundCall::RecordHandlingCompleted(scoped_refptr<Histogram> handler_run_time) {
- DCHECK(handler_run_time != NULL);
+ DCHECK(handler_run_time != nullptr);
DCHECK(!timing_.time_completed.Initialized()); // Protect against multiple calls.
timing_.time_completed = MonoTime::Now(MonoTime::FINE);
handler_run_time->Increment(
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/35b49cc5/src/kudu/rpc/messenger.cc
----------------------------------------------------------------------
diff --git a/src/kudu/rpc/messenger.cc b/src/kudu/rpc/messenger.cc
index ce869cc..739916e 100644
--- a/src/kudu/rpc/messenger.cc
+++ b/src/kudu/rpc/messenger.cc
@@ -278,13 +278,13 @@ void Messenger::ScheduleOnReactor(const boost::function<void(const Status&)>& fu
DCHECK(!reactors_.empty());
// If we're already running on a reactor thread, reuse it.
- Reactor* chosen = NULL;
+ Reactor* chosen = nullptr;
for (Reactor* r : reactors_) {
if (r->IsCurrentThread()) {
chosen = r;
}
}
- if (chosen == NULL) {
+ if (chosen == nullptr) {
// Not running on a reactor thread, pick one at random.
chosen = reactors_[rand() % reactors_.size()];
}
@@ -299,7 +299,7 @@ const scoped_refptr<RpcService> Messenger::rpc_service(const string& service_nam
if (FindCopy(rpc_services_, service_name, &service)) {
return service;
} else {
- return scoped_refptr<RpcService>(NULL);
+ return scoped_refptr<RpcService>(nullptr);
}
}