Use nullptr instead of NULL / 0 more consistently.

Summary: Closes https://github.com/facebook/rocksdb/pull/3569

Differential Revision: D7170968

Pulled By: yiwu-arbug

fbshipit-source-id: 308a6b7dd358a04fd9a7de3d927bfd8abd57d348
main
Bruce Mitchener 7 years ago committed by Facebook Github Bot
parent f021f1d9e1
commit 0de710f5b8
  1. 8
      db/c.cc
  2. 2
      db/db_compaction_filter_test.cc
  3. 8
      db/db_tailing_iter_test.cc
  4. 6
      db/deletefile_test.cc
  5. 10
      db/fault_injection_test.cc
  6. 6
      db/log_test.cc
  7. 6
      db/version_set.cc
  8. 2
      env/env_posix.cc
  9. 6
      env/mock_env.cc
  10. 4
      include/rocksdb/env.h
  11. 2
      port/port_posix.cc
  12. 2
      util/dynamic_bloom.cc
  13. 2
      util/thread_list_test.cc
  14. 2
      utilities/redis/redis_list_iterator.h
  15. 6
      utilities/redis/redis_lists.cc

@ -3026,7 +3026,7 @@ void rocksdb_sstfilewriter_delete(rocksdb_sstfilewriter_t* writer,
void rocksdb_sstfilewriter_finish(rocksdb_sstfilewriter_t* writer,
char** errptr) {
SaveError(errptr, writer->rep->Finish(NULL));
SaveError(errptr, writer->rep->Finish(nullptr));
}
void rocksdb_sstfilewriter_destroy(rocksdb_sstfilewriter_t* writer) {
@ -3808,7 +3808,7 @@ rocksdb_pinnableslice_t* rocksdb_get_pinned(
if (!s.IsNotFound()) {
SaveError(errptr, s);
}
return NULL;
return nullptr;
}
return v;
}
@ -3825,7 +3825,7 @@ rocksdb_pinnableslice_t* rocksdb_get_pinned_cf(
if (!s.IsNotFound()) {
SaveError(errptr, s);
}
return NULL;
return nullptr;
}
return v;
}
@ -3836,7 +3836,7 @@ const char* rocksdb_pinnableslice_value(const rocksdb_pinnableslice_t* v,
size_t* vlen) {
if (!v) {
*vlen = 0;
return NULL;
return nullptr;
}
*vlen = v->rep.size();

@ -767,7 +767,7 @@ TEST_F(DBTestCompactionFilter, CompactionFilterIgnoreSnapshot) {
iter->Next();
}
ASSERT_EQ(count, 6);
read_options.snapshot = 0;
read_options.snapshot = nullptr;
std::unique_ptr<Iterator> iter1(db_->NewIterator(read_options));
iter1->SeekToFirst();
count = 0;

@ -214,9 +214,9 @@ TEST_F(DBTestTailingIterator, TailingIteratorTrimSeekToNext) {
}
ASSERT_TRUE(file_iters_renewed_null);
ASSERT_TRUE(file_iters_renewed_copy);
iter = 0;
itern = 0;
iterh = 0;
iter = nullptr;
itern = nullptr;
iterh = nullptr;
BlockBasedTableOptions table_options;
table_options.no_block_cache = true;
table_options.block_cache_compressed = nullptr;
@ -229,7 +229,7 @@ TEST_F(DBTestTailingIterator, TailingIteratorTrimSeekToNext) {
Slice target1(buf5, 20);
iteri->Seek(target1);
ASSERT_TRUE(iteri->status().IsIncomplete());
iteri = 0;
iteri = nullptr;
read_options.read_tier = kReadAllTier;
options.table_factory.reset(NewBlockBasedTableFactory());

@ -228,7 +228,7 @@ TEST_F(DeleteFileTest, PurgeObsoleteFilesTest) {
// this time, we keep an iterator alive
ReopenDB(true);
Iterator *itr = 0;
Iterator *itr = nullptr;
CreateTwoLevels();
itr = db_->NewIterator(ReadOptions());
db_->CompactRange(compact_options, &first_slice, &last_slice);
@ -249,7 +249,7 @@ TEST_F(DeleteFileTest, BackgroundPurgeTest) {
Slice first_slice(first), last_slice(last);
// We keep an iterator alive
Iterator* itr = 0;
Iterator* itr = nullptr;
CreateTwoLevels();
ReadOptions options;
options.background_purge_on_iterator_cleanup = true;
@ -289,7 +289,7 @@ TEST_F(DeleteFileTest, BackgroundPurgeCopyOptions) {
Slice first_slice(first), last_slice(last);
// We keep an iterator alive
Iterator* itr = 0;
Iterator* itr = nullptr;
CreateTwoLevels();
ReadOptions* options = new ReadOptions();
options->background_purge_on_iterator_cleanup = true;

@ -76,8 +76,8 @@ class FaultInjectionTest : public testing::Test,
sync_use_wal_(false),
sync_use_compact_(true),
base_env_(nullptr),
env_(NULL),
db_(NULL) {
env_(nullptr),
db_(nullptr) {
}
~FaultInjectionTest() {
@ -139,9 +139,9 @@ class FaultInjectionTest : public testing::Test,
}
Status NewDB() {
assert(db_ == NULL);
assert(db_ == nullptr);
assert(tiny_cache_ == nullptr);
assert(env_ == NULL);
assert(env_ == nullptr);
env_ =
new FaultInjectionTestEnv(base_env_ ? base_env_.get() : Env::Default());
@ -176,7 +176,7 @@ class FaultInjectionTest : public testing::Test,
Status s = DestroyDB(dbname_, options_);
delete env_;
env_ = NULL;
env_ = nullptr;
tiny_cache_.reset();

@ -163,7 +163,7 @@ class LogTest : public ::testing::TestWithParam<int> {
source_holder_(
test::GetSequentialFileReader(new StringSource(reader_contents_))),
writer_(std::move(dest_holder_), 123, GetParam()),
reader_(NULL, std::move(source_holder_), &report_, true /*checksum*/,
reader_(nullptr, std::move(source_holder_), &report_, true /*checksum*/,
0 /*initial_offset*/, 123) {
int header_size = GetParam() ? kRecyclableHeaderSize : kHeaderSize;
initial_offset_last_record_offsets_[0] = 0;
@ -271,7 +271,7 @@ class LogTest : public ::testing::TestWithParam<int> {
unique_ptr<SequentialFileReader> file_reader(
test::GetSequentialFileReader(new StringSource(reader_contents_)));
unique_ptr<Reader> offset_reader(
new Reader(NULL, std::move(file_reader), &report_,
new Reader(nullptr, std::move(file_reader), &report_,
true /*checksum*/, WrittenBytes() + offset_past_end, 123));
Slice record;
std::string scratch;
@ -284,7 +284,7 @@ class LogTest : public ::testing::TestWithParam<int> {
unique_ptr<SequentialFileReader> file_reader(
test::GetSequentialFileReader(new StringSource(reader_contents_)));
unique_ptr<Reader> offset_reader(
new Reader(NULL, std::move(file_reader), &report_,
new Reader(nullptr, std::move(file_reader), &report_,
true /*checksum*/, initial_offset, 123));
Slice record;
std::string scratch;

@ -3016,7 +3016,7 @@ Status VersionSet::Recover(
{
VersionSet::LogReporter reporter;
reporter.status = &s;
log::Reader reader(NULL, std::move(manifest_file_reader), &reporter,
log::Reader reader(nullptr, std::move(manifest_file_reader), &reporter,
true /*checksum*/, 0 /*initial_offset*/, 0);
Slice record;
std::string scratch;
@ -3285,7 +3285,7 @@ Status VersionSet::ListColumnFamilies(std::vector<std::string>* column_families,
column_family_names.insert({0, kDefaultColumnFamilyName});
VersionSet::LogReporter reporter;
reporter.status = &s;
log::Reader reader(NULL, std::move(file_reader), &reporter, true /*checksum*/,
log::Reader reader(nullptr, std::move(file_reader), &reporter, true /*checksum*/,
0 /*initial_offset*/, 0);
Slice record;
std::string scratch;
@ -3445,7 +3445,7 @@ Status VersionSet::DumpManifest(Options& options, std::string& dscname,
{
VersionSet::LogReporter reporter;
reporter.status = &s;
log::Reader reader(NULL, std::move(file_reader), &reporter,
log::Reader reader(nullptr, std::move(file_reader), &reporter,
true /*checksum*/, 0 /*initial_offset*/, 0);
Slice record;
std::string scratch;

2
env/env_posix.cc vendored

@ -647,7 +647,7 @@ class PosixEnv : public Env {
virtual void Schedule(void (*function)(void* arg1), void* arg,
Priority pri = LOW, void* tag = nullptr,
void (*unschedFunction)(void* arg) = 0) override;
void (*unschedFunction)(void* arg) = nullptr) override;
virtual int UnSchedule(void* arg, Priority pri) override;

6
env/mock_env.cc vendored

@ -454,7 +454,7 @@ Status MockEnv::NewSequentialFile(const std::string& fname,
auto fn = NormalizePath(fname);
MutexLock lock(&mutex_);
if (file_map_.find(fn) == file_map_.end()) {
*result = NULL;
*result = nullptr;
return Status::IOError(fn, "File not found");
}
auto* f = file_map_[fn];
@ -471,7 +471,7 @@ Status MockEnv::NewRandomAccessFile(const std::string& fname,
auto fn = NormalizePath(fname);
MutexLock lock(&mutex_);
if (file_map_.find(fn) == file_map_.end()) {
*result = NULL;
*result = nullptr;
return Status::IOError(fn, "File not found");
}
auto* f = file_map_[fn];
@ -488,7 +488,7 @@ Status MockEnv::NewRandomRWFile(const std::string& fname,
auto fn = NormalizePath(fname);
MutexLock lock(&mutex_);
if (file_map_.find(fn) == file_map_.end()) {
*result = NULL;
*result = nullptr;
return Status::IOError(fn, "File not found");
}
auto* f = file_map_[fn];

@ -321,7 +321,7 @@ class Env {
// registered at the time of Schedule is invoked with arg as a parameter.
virtual void Schedule(void (*function)(void* arg), void* arg,
Priority pri = LOW, void* tag = nullptr,
void (*unschedFunction)(void* arg) = 0) = 0;
void (*unschedFunction)(void* arg) = nullptr) = 0;
// Arrange to remove jobs for given arg from the queue_ if they are not
// already scheduled. Caller is expected to have exclusive lock on arg.
@ -1029,7 +1029,7 @@ class EnvWrapper : public Env {
Status UnlockFile(FileLock* l) override { return target_->UnlockFile(l); }
void Schedule(void (*f)(void* arg), void* a, Priority pri,
void* tag = nullptr, void (*u)(void* arg) = 0) override {
void* tag = nullptr, void (*u)(void* arg) = nullptr) override {
return target_->Schedule(f, a, pri, tag, u);
}

@ -193,7 +193,7 @@ void *cacheline_aligned_alloc(size_t size) {
#elif ( _POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600 || defined(__APPLE__))
void *m;
errno = posix_memalign(&m, CACHE_LINE_SIZE, size);
return errno ? NULL : m;
return errno ? nullptr : m;
#else
return malloc(size);
#endif

@ -45,7 +45,7 @@ DynamicBloom::DynamicBloom(uint32_t num_probes,
kNumBlocks(0),
kNumProbes(num_probes),
hash_func_(hash_func == nullptr ? &BloomHash : hash_func),
data_(0) {}
data_(nullptr) {}
void DynamicBloom::SetRawData(unsigned char* raw_data, uint32_t total_bits,
uint32_t num_blocks) {

@ -47,7 +47,7 @@ class SimulatedBackgroundTask {
}
Env::Default()->GetThreadStatusUpdater()->ClearThreadState();
Env::Default()->GetThreadStatusUpdater()->ClearThreadOperation();
Env::Default()->GetThreadStatusUpdater()->SetColumnFamilyInfoKey(0);
Env::Default()->GetThreadStatusUpdater()->SetColumnFamilyInfoKey(nullptr);
running_count_--;
bg_cv_.notify_all();
}

@ -288,7 +288,7 @@ class RedisListIterator {
/// Will throw an exception based on the passed-in message.
/// This function is guaranteed to STOP THE CONTROL-FLOW.
/// (i.e.: you do not have to call "return" after calling ThrowError)
void ThrowError(const char* const /*msg*/ = NULL) {
void ThrowError(const char* const /*msg*/ = nullptr) {
// TODO: For now we ignore the msg parameter. This can be expanded later.
throw RedisListException();
}

@ -101,7 +101,7 @@ bool RedisLists::Index(const std::string& key, int32_t index,
if (curIndex == index && !it.Done()) {
Slice elem;
it.GetCurrent(&elem);
if (result != NULL) {
if (result != nullptr) {
*result = elem.ToString();
}
@ -345,7 +345,7 @@ bool RedisLists::PopLeft(const std::string& key, std::string* result) {
db_->Put(put_option_, key, it.WriteResult());
// Return the value
if (result != NULL) {
if (result != nullptr) {
*result = elem.ToString();
}
return true;
@ -385,7 +385,7 @@ bool RedisLists::PopRight(const std::string& key, std::string* result) {
db_->Put(put_option_, key, it.WriteResult());
// Return the value
if (result != NULL) {
if (result != nullptr) {
*result = elem.ToString();
}
return true;

Loading…
Cancel
Save