diff options
author | A. Jesse Jiryu Davis <jesse@mongodb.com> | 2019-06-14 16:42:10 -0400 |
---|---|---|
committer | A. Jesse Jiryu Davis <jesse@mongodb.com> | 2019-06-14 19:23:18 -0400 |
commit | 47b380f03e8898f4706ff01fa2be64dfb72e0dba (patch) | |
tree | fb3508758c9abd0e297afee43ac847bf5aebcbbb /src/mongo/db/storage | |
parent | b3c26131f6ab3f919beca658341e737de5d45683 (diff) | |
download | mongo-47b380f03e8898f4706ff01fa2be64dfb72e0dba.tar.gz |
SERVER-41071 Replace NULL and 0 with nullptr
Diffstat (limited to 'src/mongo/db/storage')
34 files changed, 96 insertions, 93 deletions
diff --git a/src/mongo/db/storage/biggie/biggie_record_store.h b/src/mongo/db/storage/biggie/biggie_record_store.h index 5f62b5ab5e8..813c575ecf7 100644 --- a/src/mongo/db/storage/biggie/biggie_record_store.h +++ b/src/mongo/db/storage/biggie/biggie_record_store.h @@ -64,7 +64,7 @@ public: virtual bool isCapped() const; virtual void setCappedCallback(CappedCallback*); virtual int64_t storageSize(OperationContext* opCtx, - BSONObjBuilder* extraInfo = NULL, + BSONObjBuilder* extraInfo = nullptr, int infoLevel = 0) const; virtual bool findRecord(OperationContext* opCtx, const RecordId& loc, RecordData* rd) const; diff --git a/src/mongo/db/storage/devnull/devnull_kv_engine.cpp b/src/mongo/db/storage/devnull/devnull_kv_engine.cpp index 6500879bde3..59a45b990ea 100644 --- a/src/mongo/db/storage/devnull/devnull_kv_engine.cpp +++ b/src/mongo/db/storage/devnull/devnull_kv_engine.cpp @@ -87,7 +87,7 @@ public: } virtual int64_t storageSize(OperationContext* opCtx, - BSONObjBuilder* extraInfo = NULL, + BSONObjBuilder* extraInfo = nullptr, int infoLevel = 0) const { return 0; } diff --git a/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_record_store.h b/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_record_store.h index 37b526f4c1a..439cbe1cdf6 100644 --- a/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_record_store.h +++ b/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_record_store.h @@ -104,7 +104,7 @@ public: virtual Status touch(OperationContext* opCtx, BSONObjBuilder* output) const; virtual int64_t storageSize(OperationContext* opCtx, - BSONObjBuilder* extraInfo = NULL, + BSONObjBuilder* extraInfo = nullptr, int infoLevel = 0) const; virtual long long dataSize(OperationContext* opCtx) const { diff --git a/src/mongo/db/storage/key_string.cpp b/src/mongo/db/storage/key_string.cpp index a7fab7792c3..d30ac2d93b0 100644 --- a/src/mongo/db/storage/key_string.cpp +++ b/src/mongo/db/storage/key_string.cpp @@ -346,7 +346,7 @@ void KeyString::_appendAllElementsForIndexing(const BSONObj& obj, const int elemIdx = elemCount++; const bool invert = (ord.get(elemIdx) == -1); - _appendBsonValue(elem, invert, NULL); + _appendBsonValue(elem, invert, nullptr); dassert(elem.fieldNameSize() < 3); // fieldNameSize includes the NUL @@ -517,7 +517,7 @@ void KeyString::_appendArray(const BSONArray& val, bool invert) { _append(CType::kArray, invert); BSONForEach(elem, val) { // No generic ctype byte needed here since no name is encoded. - _appendBsonValue(elem, invert, NULL); + _appendBsonValue(elem, invert, nullptr); } _append(int8_t(0), invert); } diff --git a/src/mongo/db/storage/kv/kv_catalog.cpp b/src/mongo/db/storage/kv/kv_catalog.cpp index b9922cea3f9..46a821a805c 100644 --- a/src/mongo/db/storage/kv/kv_catalog.cpp +++ b/src/mongo/db/storage/kv/kv_catalog.cpp @@ -330,7 +330,7 @@ KVCatalog::KVCatalog(RecordStore* rs, _engine(engine) {} KVCatalog::~KVCatalog() { - _rs = NULL; + _rs = nullptr; } std::string KVCatalog::_newRand() { diff --git a/src/mongo/db/storage/mobile/mobile_record_store.h b/src/mongo/db/storage/mobile/mobile_record_store.h index ac2d7e4e229..9379a7760f7 100644 --- a/src/mongo/db/storage/mobile/mobile_record_store.h +++ b/src/mongo/db/storage/mobile/mobile_record_store.h @@ -113,7 +113,7 @@ public: Status touch(OperationContext* opCtx, BSONObjBuilder* output) const override; int64_t storageSize(OperationContext* opCtx, - BSONObjBuilder* extraInfo = NULL, + BSONObjBuilder* extraInfo = nullptr, int infoLevel = 0) const override; long long dataSize(OperationContext* opCtx) const override; diff --git a/src/mongo/db/storage/mobile/mobile_recovery_unit.cpp b/src/mongo/db/storage/mobile/mobile_recovery_unit.cpp index d8ff95a9e50..60181ac0b02 100644 --- a/src/mongo/db/storage/mobile/mobile_recovery_unit.cpp +++ b/src/mongo/db/storage/mobile/mobile_recovery_unit.cpp @@ -146,7 +146,7 @@ bool MobileRecoveryUnit::waitUntilDurable() { Lock::GlobalLock lk(opCtx, MODE_X); // Use FULL mode to guarantee durability ret = sqlite3_wal_checkpoint_v2(_session.get()->getSession(), - NULL, + nullptr, SQLITE_CHECKPOINT_FULL, &framesInWAL, &checkpointedFrames); diff --git a/src/mongo/db/storage/mobile/mobile_sqlite_statement.cpp b/src/mongo/db/storage/mobile/mobile_sqlite_statement.cpp index 151ad0d68d7..7760dff5788 100644 --- a/src/mongo/db/storage/mobile/mobile_sqlite_statement.cpp +++ b/src/mongo/db/storage/mobile/mobile_sqlite_statement.cpp @@ -59,14 +59,14 @@ void SqliteStatement::finalize() { int status = sqlite3_finalize(_stmt); fassert(37053, status == _exceptionStatus); - _stmt = NULL; + _stmt = nullptr; } void SqliteStatement::prepare(const MobileSession& session) { SQLITE_STMT_TRACE() << "Preparing: " << _sqlQuery.data(); - int status = - sqlite3_prepare_v2(session.getSession(), _sqlQuery.data(), _sqlQuery.size(), &_stmt, NULL); + int status = sqlite3_prepare_v2( + session.getSession(), _sqlQuery.data(), _sqlQuery.size(), &_stmt, nullptr); if (status == SQLITE_BUSY) { SQLITE_STMT_TRACE() << "Throwing writeConflictException, " << "SQLITE_BUSY while preparing: " << _sqlQuery.data(); @@ -150,8 +150,8 @@ const char* SqliteStatement::getColText(int colIndex) { void SqliteStatement::_execQuery(sqlite3* session, const char* query) { LOG(MOBILE_TRACE_LEVEL) << "MobileSE: SQLite sqlite3_exec: " << query; - char* errMsg = NULL; - int status = sqlite3_exec(session, query, NULL, NULL, &errMsg); + char* errMsg = nullptr; + int status = sqlite3_exec(session, query, nullptr, nullptr, &errMsg); if (status == SQLITE_BUSY || status == SQLITE_LOCKED) { LOG(MOBILE_TRACE_LEVEL) << "MobileSE: " << (status == SQLITE_BUSY ? "Busy" : "Locked") diff --git a/src/mongo/db/storage/mobile/mobile_util.cpp b/src/mongo/db/storage/mobile/mobile_util.cpp index 141cff1a070..3159dd169f8 100644 --- a/src/mongo/db/storage/mobile/mobile_util.cpp +++ b/src/mongo/db/storage/mobile/mobile_util.cpp @@ -91,7 +91,7 @@ Status sqliteRCToStatus(int retCode, const char* prefix) { } const char* sqliteStatusToStr(int retStatus) { - const char* msg = NULL; + const char* msg = nullptr; switch (retStatus) { case SQLITE_OK: diff --git a/src/mongo/db/storage/mobile/mobile_util.h b/src/mongo/db/storage/mobile/mobile_util.h index 93ca3fdd51d..9cdb8bf0e15 100644 --- a/src/mongo/db/storage/mobile/mobile_util.h +++ b/src/mongo/db/storage/mobile/mobile_util.h @@ -44,7 +44,7 @@ namespace embedded { /** * Converts SQLite return codes to MongoDB statuses. */ -Status sqliteRCToStatus(int retCode, const char* prefix = NULL); +Status sqliteRCToStatus(int retCode, const char* prefix = nullptr); /** * Converts SQLite return codes to string equivalents. @@ -54,7 +54,10 @@ const char* sqliteStatusToStr(int retStatus); /** * Checks if retStatus == desiredStatus; else calls fassert. */ -void checkStatus(int retStatus, int desiredStatus, const char* fnName, const char* errMsg = NULL); +void checkStatus(int retStatus, + int desiredStatus, + const char* fnName, + const char* errMsg = nullptr); /** * Validate helper function to log an error and append the error to the results. diff --git a/src/mongo/db/storage/record_data.h b/src/mongo/db/storage/record_data.h index 5cc99b7f50d..67a3feb8413 100644 --- a/src/mongo/db/storage/record_data.h +++ b/src/mongo/db/storage/record_data.h @@ -43,7 +43,7 @@ namespace mongo { */ class RecordData { public: - RecordData() : _data(NULL), _size(0) {} + RecordData() : _data(nullptr), _size(0) {} RecordData(const char* data, int size) : _data(data), _size(size) {} RecordData(SharedBuffer ownedData, int size) diff --git a/src/mongo/db/storage/record_store.h b/src/mongo/db/storage/record_store.h index 7880616da03..d5152e51d23 100644 --- a/src/mongo/db/storage/record_store.h +++ b/src/mongo/db/storage/record_store.h @@ -286,7 +286,7 @@ public: * @return total estimate size (in bytes) on stable storage */ virtual int64_t storageSize(OperationContext* opCtx, - BSONObjBuilder* extraInfo = NULL, + BSONObjBuilder* extraInfo = nullptr, int infoLevel = 0) const = 0; // CRUD related diff --git a/src/mongo/db/storage/record_store_test_harness.cpp b/src/mongo/db/storage/record_store_test_harness.cpp index 6a72d25e954..b93e8029d34 100644 --- a/src/mongo/db/storage/record_store_test_harness.cpp +++ b/src/mongo/db/storage/record_store_test_harness.cpp @@ -75,7 +75,7 @@ TEST(RecordStoreTestHarness, Simple1) { RecordData rd; ASSERT(!rs->findRecord(opCtx.get(), RecordId(111, 17), &rd)); - ASSERT(rd.data() == NULL); + ASSERT(rd.data() == nullptr); ASSERT(rs->findRecord(opCtx.get(), loc1, &rd)); ASSERT_EQUALS(s, rd.data()); diff --git a/src/mongo/db/storage/record_store_test_recordstore.cpp b/src/mongo/db/storage/record_store_test_recordstore.cpp index c5a95f250c2..38649fa89da 100644 --- a/src/mongo/db/storage/record_store_test_recordstore.cpp +++ b/src/mongo/db/storage/record_store_test_recordstore.cpp @@ -48,7 +48,7 @@ TEST(RecordStoreTestHarness, RecordStoreName) { { const char* name = rs->name(); - ASSERT(name != NULL && name[0] != '\0'); + ASSERT(name != nullptr && name[0] != '\0'); } } diff --git a/src/mongo/db/storage/record_store_test_storagesize.cpp b/src/mongo/db/storage/record_store_test_storagesize.cpp index 743559a1079..cba9e555c16 100644 --- a/src/mongo/db/storage/record_store_test_storagesize.cpp +++ b/src/mongo/db/storage/record_store_test_storagesize.cpp @@ -75,7 +75,7 @@ TEST(RecordStoreTestHarness, StorageSizeNonEmpty) { { ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); - ASSERT(rs->storageSize(opCtx.get(), NULL) >= 0); + ASSERT(rs->storageSize(opCtx.get(), nullptr) >= 0); } } diff --git a/src/mongo/db/storage/record_store_test_touch.cpp b/src/mongo/db/storage/record_store_test_touch.cpp index 43b52b39ba2..edafde0683e 100644 --- a/src/mongo/db/storage/record_store_test_touch.cpp +++ b/src/mongo/db/storage/record_store_test_touch.cpp @@ -122,7 +122,7 @@ TEST(RecordStoreTestHarness, TouchEmptyWithNullStats) { { ServiceContext::UniqueOperationContext opCtx( harnessHelper->newOperationContext(harnessHelper->client())); - Status status = rs->touch(opCtx.get(), NULL /* stats output */); + Status status = rs->touch(opCtx.get(), nullptr /* stats output */); ASSERT(status.isOK() || status.code() == ErrorCodes::CommandNotSupported); } } @@ -164,7 +164,7 @@ TEST(RecordStoreTestHarness, TouchNonEmptyWithNullStats) { harnessHelper->newOperationContext(harnessHelper->client())); // XXX does not verify the collection was loaded into cache // (even if supported by storage engine) - Status status = rs->touch(opCtx.get(), NULL /* stats output */); + Status status = rs->touch(opCtx.get(), nullptr /* stats output */); ASSERT(status.isOK() || status.code() == ErrorCodes::CommandNotSupported); } } diff --git a/src/mongo/db/storage/remove_saver.cpp b/src/mongo/db/storage/remove_saver.cpp index d49e1cc5dd5..16ad9b482e9 100644 --- a/src/mongo/db/storage/remove_saver.cpp +++ b/src/mongo/db/storage/remove_saver.cpp @@ -135,7 +135,7 @@ Status RemoveSaver::goingToDelete(const BSONObj& o) { << " for remove saving: " << redact(errnoWithDescription()); error() << msg; _out.reset(); - _out = 0; + _out = nullptr; return Status(ErrorCodes::FileNotOpen, msg); } } diff --git a/src/mongo/db/storage/sorted_data_interface.h b/src/mongo/db/storage/sorted_data_interface.h index ee745bf7cfe..8bda0d3d660 100644 --- a/src/mongo/db/storage/sorted_data_interface.h +++ b/src/mongo/db/storage/sorted_data_interface.h @@ -180,7 +180,7 @@ public: */ virtual long long numEntries(OperationContext* opCtx) const { long long x = -1; - fullValidate(opCtx, &x, NULL); + fullValidate(opCtx, &x, nullptr); return x; } diff --git a/src/mongo/db/storage/sorted_data_interface_test_fullvalidate.cpp b/src/mongo/db/storage/sorted_data_interface_test_fullvalidate.cpp index db5d4493df5..e396052e9fa 100644 --- a/src/mongo/db/storage/sorted_data_interface_test_fullvalidate.cpp +++ b/src/mongo/db/storage/sorted_data_interface_test_fullvalidate.cpp @@ -69,7 +69,7 @@ TEST(SortedDataInterface, FullValidate) { { long long numKeysOut; const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); - sorted->fullValidate(opCtx.get(), &numKeysOut, NULL); + sorted->fullValidate(opCtx.get(), &numKeysOut, nullptr); // fullValidate() can set numKeysOut as the number of existing keys or -1. ASSERT(numKeysOut == nToInsert || numKeysOut == -1); } diff --git a/src/mongo/db/storage/sorted_data_interface_test_harness.cpp b/src/mongo/db/storage/sorted_data_interface_test_harness.cpp index f92ba9c83bb..43bb6df5c4a 100644 --- a/src/mongo/db/storage/sorted_data_interface_test_harness.cpp +++ b/src/mongo/db/storage/sorted_data_interface_test_harness.cpp @@ -97,7 +97,7 @@ TEST(SortedDataInterface, InsertWithDups1) { ASSERT_EQUALS(2, sorted->numEntries(opCtx.get())); long long x = 0; - sorted->fullValidate(opCtx.get(), &x, NULL); + sorted->fullValidate(opCtx.get(), &x, nullptr); ASSERT_EQUALS(2, x); } } diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_index.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_index.cpp index 95fe1bf3b50..966cfe4c8c4 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_index.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_index.cpp @@ -79,7 +79,7 @@ MONGO_FAIL_POINT_DEFINE(WTEmulateOutOfOrderNextIndexKey); using std::string; using std::vector; -static const WiredTigerItem emptyItem(NULL, 0); +static const WiredTigerItem emptyItem(nullptr, 0); bool hasFieldNames(const BSONObj& obj) { @@ -572,14 +572,14 @@ protected: // an unexpected pause in building an index. WT_SESSION* session = _session->getSession(); int err = session->open_cursor( - session, idx->uri().c_str(), NULL, "bulk,checkpoint_wait=false", &cursor); + session, idx->uri().c_str(), nullptr, "bulk,checkpoint_wait=false", &cursor); if (!err) return cursor; warning() << "failed to create WiredTiger bulk cursor: " << wiredtiger_strerror(err); warning() << "falling back to non-bulk cursor for index " << idx->uri(); - invariantWTOK(session->open_cursor(session, idx->uri().c_str(), NULL, NULL, &cursor)); + invariantWTOK(session->open_cursor(session, idx->uri().c_str(), nullptr, nullptr, &cursor)); return cursor; } diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp index 9971b1e387d..38dc2f6913a 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp @@ -631,7 +631,7 @@ WiredTigerKVEngine::WiredTigerKVEngine(const std::string& canonicalName, Status s(wtRCToStatus(ret)); msgasserted(28718, s.reason()); } - invariantWTOK(_conn->close(_conn, NULL)); + invariantWTOK(_conn->close(_conn, nullptr)); // After successful recovery, remove the journal directory. try { boost::filesystem::remove_all(journalPath); @@ -706,7 +706,7 @@ WiredTigerKVEngine::~WiredTigerKVEngine() { cleanShutdown(); } - _sessionCache.reset(NULL); + _sessionCache.reset(nullptr); } void WiredTigerKVEngine::appendGlobalStats(BSONObjBuilder& b) { @@ -887,7 +887,7 @@ Status WiredTigerKVEngine::_salvageIfNeeded(const char* uri) { WiredTigerSession sessionWrapper(_conn); WT_SESSION* session = sessionWrapper.getSession(); - int rc = (session->verify)(session, uri, NULL); + int rc = (session->verify)(session, uri, nullptr); if (rc == 0) { log() << "Verify succeeded on uri " << uri << ". Not salvaging."; return Status::OK(); @@ -912,7 +912,7 @@ Status WiredTigerKVEngine::_salvageIfNeeded(const char* uri) { } log() << "Verify failed on uri " << uri << ". Running a salvage operation."; - auto status = wtRCToStatus(session->salvage(session, uri, NULL), "Salvage failed:"); + auto status = wtRCToStatus(session->salvage(session, uri, nullptr), "Salvage failed:"); if (status.isOK()) { return {ErrorCodes::DataModifiedByRepair, str::stream() << "Salvaged data for " << uri}; } @@ -952,7 +952,7 @@ Status WiredTigerKVEngine::_rebuildIdent(WT_SESSION* session, const char* uri) { return swMetadata.getStatus(); } - int rc = session->drop(session, uri, NULL); + int rc = session->drop(session, uri, nullptr); if (rc != 0) { error() << "Failed to drop " << uri; return wtRCToStatus(rc); @@ -995,9 +995,9 @@ Status WiredTigerKVEngine::beginBackup(OperationContext* opCtx) { // This cursor will be freed by the backupSession being closed as the session is uncached auto session = std::make_unique<WiredTigerSession>(_conn); - WT_CURSOR* c = NULL; + WT_CURSOR* c = nullptr; WT_SESSION* s = session->getSession(); - int ret = WT_OP_CHECK(s->open_cursor(s, "backup:", NULL, NULL, &c)); + int ret = WT_OP_CHECK(s->open_cursor(s, "backup:", nullptr, nullptr, &c)); if (ret != 0) { return wtRCToStatus(ret); } @@ -1025,9 +1025,9 @@ StatusWith<std::vector<std::string>> WiredTigerKVEngine::beginNonBlockingBackup( // This cursor will be freed by the backupSession being closed as the session is uncached auto sessionRaii = std::make_unique<WiredTigerSession>(_conn); - WT_CURSOR* cursor = NULL; + WT_CURSOR* cursor = nullptr; WT_SESSION* session = sessionRaii->getSession(); - int wtRet = session->open_cursor(session, "backup:", NULL, NULL, &cursor); + int wtRet = session->open_cursor(session, "backup:", nullptr, nullptr, &cursor); if (wtRet != 0) { return wtRCToStatus(wtRet); } @@ -1059,9 +1059,9 @@ StatusWith<std::vector<std::string>> WiredTigerKVEngine::extendBackupCursor( uassert(51033, "Cannot extend backup cursor with in-memory mode.", !isEphemeral()); invariant(_backupCursor); - WT_CURSOR* cursor = NULL; + WT_CURSOR* cursor = nullptr; WT_SESSION* session = _backupSession->getSession(); - int wtRet = session->open_cursor(session, NULL, _backupCursor, "target=(\"log:\")", &cursor); + int wtRet = session->open_cursor(session, nullptr, _backupCursor, "target=(\"log:\")", &cursor); if (wtRet != 0) { return wtRCToStatus(wtRet); } @@ -1475,8 +1475,8 @@ bool WiredTigerKVEngine::hasIdent(OperationContext* opCtx, StringData ident) con bool WiredTigerKVEngine::_hasUri(WT_SESSION* session, const std::string& uri) const { // can't use WiredTigerCursor since this is called from constructor. - WT_CURSOR* c = NULL; - int ret = session->open_cursor(session, "metadata:create", NULL, NULL, &c); + WT_CURSOR* c = nullptr; + int ret = session->open_cursor(session, "metadata:create", nullptr, nullptr, &c); if (ret == ENOENT) return false; invariantWTOK(ret); diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_prefixed_index_test.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_prefixed_index_test.cpp index 3ded0dc99b6..df39f655421 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_prefixed_index_test.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_prefixed_index_test.cpp @@ -56,9 +56,9 @@ using std::string; class MyHarnessHelper final : public SortedDataInterfaceHarnessHelper { public: - MyHarnessHelper() : _dbpath("wt_test"), _conn(NULL) { + MyHarnessHelper() : _dbpath("wt_test"), _conn(nullptr) { const char* config = "create,cache_size=1G,"; - int ret = wiredtiger_open(_dbpath.path().c_str(), NULL, config, &_conn); + int ret = wiredtiger_open(_dbpath.path().c_str(), nullptr, config, &_conn); invariantWTOK(ret); _fastClockSource = std::make_unique<SystemClockSource>(); @@ -67,7 +67,7 @@ public: ~MyHarnessHelper() final { delete _sessionCache; - _conn->close(_conn, NULL); + _conn->close(_conn, nullptr); } std::unique_ptr<SortedDataInterface> newSortedDataInterface(bool unique, bool partial) final { diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp index 84d2f3ece7b..0b16064f6e8 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp @@ -1502,7 +1502,7 @@ Status WiredTigerRecordStore::truncate(OperationContext* opCtx) { invariantWTOK(ret); WT_SESSION* session = WiredTigerRecoveryUnit::get(opCtx)->getSession()->getSession(); - invariantWTOK(WT_OP_CHECK(session->truncate(session, NULL, start, NULL, NULL))); + invariantWTOK(WT_OP_CHECK(session->truncate(session, nullptr, start, nullptr, nullptr))); _changeNumRecords(opCtx, -numRecords(opCtx)); _increaseDataSize(opCtx, -dataSize(opCtx)); @@ -1714,7 +1714,7 @@ public: DataSizeChange(WiredTigerRecordStore* rs, int64_t amount) : _rs(rs), _amount(amount) {} virtual void commit(boost::optional<Timestamp>) {} virtual void rollback() { - _rs->_increaseDataSize(NULL, -_amount); + _rs->_increaseDataSize(nullptr, -_amount); } private: diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.h b/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.h index f47db72d8a7..3e2121cdd5d 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.h +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.h @@ -130,7 +130,7 @@ public: virtual bool isCapped() const; virtual int64_t storageSize(OperationContext* opCtx, - BSONObjBuilder* extraInfo = NULL, + BSONObjBuilder* extraInfo = nullptr, int infoLevel = 0) const; // CRUD related diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_record_store_test.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_record_store_test.cpp index f6040a92621..2b59fc2c762 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_record_store_test.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_record_store_test.cpp @@ -144,8 +144,8 @@ TEST(WiredTigerRecordStoreTest, Isolation1) { rs->updateRecord(t2.get(), id1, "c", 2).transitional_ignore(); ASSERT(0); } catch (WriteConflictException&) { - w2.reset(NULL); - t2.reset(NULL); + w2.reset(nullptr); + t2.reset(nullptr); } w1->commit(); // this should succeed diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit_test.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit_test.cpp index 5769add2cb1..0363230e58b 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit_test.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit_test.cpp @@ -146,7 +146,7 @@ public: void getCursor(WiredTigerRecoveryUnit* ru, WT_CURSOR** cursor) { WT_SESSION* wt_session = ru->getSession()->getSession(); invariantWTOK(wt_session->create(wt_session, wt_uri, wt_config)); - invariantWTOK(wt_session->open_cursor(wt_session, wt_uri, NULL, NULL, cursor)); + invariantWTOK(wt_session->open_cursor(wt_session, wt_uri, nullptr, nullptr, cursor)); } void setUp() override { diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_session_cache.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_session_cache.cpp index 5344e0163fc..91a40336e9f 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_session_cache.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_session_cache.cpp @@ -56,11 +56,11 @@ const std::string kWTRepairMsg = WiredTigerSession::WiredTigerSession(WT_CONNECTION* conn, uint64_t epoch, uint64_t cursorEpoch) : _epoch(epoch), _cursorEpoch(cursorEpoch), - _session(NULL), + _session(nullptr), _cursorGen(0), _cursorsOut(0), _idleExpireTime(Date_t::min()) { - invariantWTOK(conn->open_session(conn, NULL, "isolation=snapshot", &_session)); + invariantWTOK(conn->open_session(conn, nullptr, "isolation=snapshot", &_session)); } WiredTigerSession::WiredTigerSession(WT_CONNECTION* conn, @@ -70,16 +70,16 @@ WiredTigerSession::WiredTigerSession(WT_CONNECTION* conn, : _epoch(epoch), _cursorEpoch(cursorEpoch), _cache(cache), - _session(NULL), + _session(nullptr), _cursorGen(0), _cursorsOut(0), _idleExpireTime(Date_t::min()) { - invariantWTOK(conn->open_session(conn, NULL, "isolation=snapshot", &_session)); + invariantWTOK(conn->open_session(conn, nullptr, "isolation=snapshot", &_session)); } WiredTigerSession::~WiredTigerSession() { if (_session) { - invariantWTOK(_session->close(_session, NULL)); + invariantWTOK(_session->close(_session, nullptr)); } } @@ -88,7 +88,7 @@ void _openCursor(WT_SESSION* session, const std::string& uri, const char* config, WT_CURSOR** cursorOut) { - int ret = session->open_cursor(session, uri.c_str(), NULL, config, cursorOut); + int ret = session->open_cursor(session, uri.c_str(), nullptr, config, cursorOut); if (ret == EBUSY) { // This can only happen when trying to open a cursor on the oplog and it is currently locked // by a verify or salvage, because we don't employ database locks to protect the oplog. @@ -116,7 +116,7 @@ WT_CURSOR* WiredTigerSession::getCursor(const std::string& uri, uint64_t id, boo } } - WT_CURSOR* cursor = NULL; + WT_CURSOR* cursor = nullptr; _openCursor(_session, uri, allowOverwrite ? "" : "overwrite=false", &cursor); _cursorsOut++; return cursor; @@ -125,7 +125,7 @@ WT_CURSOR* WiredTigerSession::getCursor(const std::string& uri, uint64_t id, boo WT_CURSOR* WiredTigerSession::getReadOnceCursor(const std::string& uri, bool allowOverwrite) { const char* config = allowOverwrite ? "read_once=true" : "read_once=true,overwrite=false"; - WT_CURSOR* cursor = NULL; + WT_CURSOR* cursor = nullptr; _openCursor(_session, uri, config, &cursor); _cursorsOut++; return cursor; @@ -288,7 +288,7 @@ void WiredTigerSessionCache::waitUntilDurable(bool forceCheckpoint, bool stableC // Initialize on first use. if (!_waitUntilDurableSession) { invariantWTOK( - _conn->open_session(_conn, NULL, "isolation=snapshot", &_waitUntilDurableSession)); + _conn->open_session(_conn, nullptr, "isolation=snapshot", &_waitUntilDurableSession)); } // Use the journal when available, or a checkpoint otherwise. @@ -296,7 +296,7 @@ void WiredTigerSessionCache::waitUntilDurable(bool forceCheckpoint, bool stableC invariantWTOK(_waitUntilDurableSession->log_flush(_waitUntilDurableSession, "sync=on")); LOG(4) << "flushed journal"; } else { - invariantWTOK(_waitUntilDurableSession->checkpoint(_waitUntilDurableSession, NULL)); + invariantWTOK(_waitUntilDurableSession->checkpoint(_waitUntilDurableSession, nullptr)); LOG(4) << "created checkpoint"; } _journalListener->onDurable(token); diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_session_cache_test.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_session_cache_test.cpp index 37ac7eddc4e..7d3326f57db 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_session_cache_test.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_session_cache_test.cpp @@ -46,18 +46,18 @@ using std::stringstream; class WiredTigerConnection { public: - WiredTigerConnection(StringData dbpath, StringData extraStrings) : _conn(NULL) { + WiredTigerConnection(StringData dbpath, StringData extraStrings) : _conn(nullptr) { std::stringstream ss; ss << "create,"; ss << extraStrings; string config = ss.str(); _fastClockSource = std::make_unique<SystemClockSource>(); - int ret = wiredtiger_open(dbpath.toString().c_str(), NULL, config.c_str(), &_conn); + int ret = wiredtiger_open(dbpath.toString().c_str(), nullptr, config.c_str(), &_conn); ASSERT_OK(wtRCToStatus(ret)); ASSERT(_conn); } ~WiredTigerConnection() { - _conn->close(_conn, NULL); + _conn->close(_conn, nullptr); } WT_CONNECTION* getConnection() const { return _conn; diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_standard_index_test.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_standard_index_test.cpp index 6fe47de5eca..0185b30fadd 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_standard_index_test.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_standard_index_test.cpp @@ -56,9 +56,9 @@ using std::string; class MyHarnessHelper final : public SortedDataInterfaceHarnessHelper { public: - MyHarnessHelper() : _dbpath("wt_test"), _conn(NULL) { + MyHarnessHelper() : _dbpath("wt_test"), _conn(nullptr) { const char* config = "create,cache_size=1G,"; - int ret = wiredtiger_open(_dbpath.path().c_str(), NULL, config, &_conn); + int ret = wiredtiger_open(_dbpath.path().c_str(), nullptr, config, &_conn); invariantWTOK(ret); _fastClockSource = std::make_unique<SystemClockSource>(); @@ -67,7 +67,7 @@ public: ~MyHarnessHelper() final { delete _sessionCache; - _conn->close(_conn, NULL); + _conn->close(_conn, nullptr); } std::unique_ptr<SortedDataInterface> newSortedDataInterface(bool unique, bool partial) final { diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_standard_record_store_test.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_standard_record_store_test.cpp index 1c4a436831d..1f790206918 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_standard_record_store_test.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_standard_record_store_test.cpp @@ -242,7 +242,7 @@ TEST(WiredTigerRecordStoreTest, SizeStorer1) { ASSERT_EQUALS(N, rs->numRecords(opCtx.get())); } - rs.reset(NULL); + rs.reset(nullptr); { auto& info = *ss.load(uri); diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_util.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_util.cpp index e426394574f..fb424183586 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_util.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_util.cpp @@ -119,7 +119,7 @@ StatusWith<std::string> WiredTigerUtil::getMetadataRaw(WT_SESSION* session, Stri } else if (ret != 0) { return StatusWith<std::string>(wtRCToStatus(ret)); } - const char* metadata = NULL; + const char* metadata = nullptr; ret = cursor->get_value(cursor, &metadata); if (ret != 0) { return StatusWith<std::string>(wtRCToStatus(ret)); @@ -147,7 +147,7 @@ StatusWith<std::string> WiredTigerUtil::getMetadata(OperationContext* opCtx, Str } else if (ret != 0) { return StatusWith<std::string>(wtRCToStatus(ret)); } - const char* metadata = NULL; + const char* metadata = nullptr; ret = cursor->get_value(cursor, &metadata); if (ret != 0) { return StatusWith<std::string>(wtRCToStatus(ret)); @@ -314,9 +314,9 @@ StatusWith<int64_t> WiredTigerUtil::getStatisticsValue(WT_SESSION* session, const std::string& config, int statisticsKey) { invariant(session); - WT_CURSOR* cursor = NULL; - const char* cursorConfig = config.empty() ? NULL : config.c_str(); - int ret = session->open_cursor(session, uri.c_str(), NULL, cursorConfig, &cursor); + WT_CURSOR* cursor = nullptr; + const char* cursorConfig = config.empty() ? nullptr : config.c_str(); + int ret = session->open_cursor(session, uri.c_str(), nullptr, cursorConfig, &cursor); if (ret != 0) { return StatusWith<int64_t>(ErrorCodes::CursorNotFound, str::stream() << "unable to open cursor at URI " << uri @@ -516,11 +516,11 @@ int WiredTigerUtil::verifyTable(OperationContext* opCtx, // Open a new session with custom error handlers. WT_CONNECTION* conn = WiredTigerRecoveryUnit::get(opCtx)->getSessionCache()->conn(); WT_SESSION* session; - invariantWTOK(conn->open_session(conn, &eventHandler, NULL, &session)); + invariantWTOK(conn->open_session(conn, &eventHandler, nullptr, &session)); ON_BLOCK_EXIT([&] { session->close(session, ""); }); // Do the verify. Weird parens prevent treating "verify" as a macro. - return (session->verify)(session, uri.c_str(), NULL); + return (session->verify)(session, uri.c_str(), nullptr); } bool WiredTigerUtil::useTableLogging(NamespaceString ns, bool replEnabled) { @@ -612,9 +612,9 @@ Status WiredTigerUtil::exportTableToBSON(WT_SESSION* session, const std::vector<std::string>& filter) { invariant(session); invariant(bob); - WT_CURSOR* c = NULL; - const char* cursorConfig = config.empty() ? NULL : config.c_str(); - int ret = session->open_cursor(session, uri.c_str(), NULL, cursorConfig, &c); + WT_CURSOR* c = nullptr; + const char* cursorConfig = config.empty() ? nullptr : config.c_str(); + int ret = session->open_cursor(session, uri.c_str(), nullptr, cursorConfig, &c); if (ret != 0) { return Status(ErrorCodes::CursorNotFound, str::stream() << "unable to open cursor at URI " << uri << ". reason: " diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_util.h b/src/mongo/db/storage/wiredtiger/wiredtiger_util.h index 6c03efc774d..42729da118e 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_util.h +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_util.h @@ -55,7 +55,7 @@ Status wtRCToStatus_slow(int retCode, const char* prefix); /** * converts wiredtiger return codes to mongodb statuses. */ -inline Status wtRCToStatus(int retCode, const char* prefix = NULL) { +inline Status wtRCToStatus(int retCode, const char* prefix = nullptr) { if (MONGO_likely(retCode == 0)) return Status::OK(); @@ -247,7 +247,7 @@ public: */ static int verifyTable(OperationContext* opCtx, const std::string& uri, - std::vector<std::string>* errors = NULL); + std::vector<std::string>* errors = nullptr); static bool useTableLogging(NamespaceString ns, bool replEnabled); @@ -278,12 +278,12 @@ class WiredTigerConfigParser { public: WiredTigerConfigParser(StringData config) { invariantWTOK( - wiredtiger_config_parser_open(NULL, config.rawData(), config.size(), &_parser)); + wiredtiger_config_parser_open(nullptr, config.rawData(), config.size(), &_parser)); } WiredTigerConfigParser(const WT_CONFIG_ITEM& nested) { invariant(nested.type == WT_CONFIG_ITEM::WT_CONFIG_ITEM_STRUCT); - invariantWTOK(wiredtiger_config_parser_open(NULL, nested.str, nested.len, &_parser)); + invariantWTOK(wiredtiger_config_parser_open(nullptr, nested.str, nested.len, &_parser)); } ~WiredTigerConfigParser() { diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_util_test.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_util_test.cpp index 0199cd8a1ed..0a3442459d9 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_util_test.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_util_test.cpp @@ -50,18 +50,18 @@ using std::stringstream; class WiredTigerConnection { public: - WiredTigerConnection(StringData dbpath, StringData extraStrings) : _conn(NULL) { + WiredTigerConnection(StringData dbpath, StringData extraStrings) : _conn(nullptr) { std::stringstream ss; ss << "create,"; ss << extraStrings; string config = ss.str(); _fastClockSource = std::make_unique<SystemClockSource>(); - int ret = wiredtiger_open(dbpath.toString().c_str(), NULL, config.c_str(), &_conn); + int ret = wiredtiger_open(dbpath.toString().c_str(), nullptr, config.c_str(), &_conn); ASSERT_OK(wtRCToStatus(ret)); ASSERT(_conn); } ~WiredTigerConnection() { - _conn->close(_conn, NULL); + _conn->close(_conn, nullptr); } WT_CONNECTION* getConnection() const { return _conn; @@ -111,8 +111,8 @@ public: } virtual void tearDown() { - _opCtx.reset(NULL); - _harnessHelper.reset(NULL); + _opCtx.reset(nullptr); + _harnessHelper.reset(nullptr); } protected: @@ -143,7 +143,7 @@ TEST_F(WiredTigerUtilMetadataTest, GetConfigurationStringInvalidURI) { } TEST_F(WiredTigerUtilMetadataTest, GetConfigurationStringNull) { - const char* config = NULL; + const char* config = nullptr; createSession(config); StatusWith<std::string> result = WiredTigerUtil::getMetadata(getOperationContext(), getURI()); ASSERT_OK(result.getStatus()); @@ -166,7 +166,7 @@ TEST_F(WiredTigerUtilMetadataTest, GetApplicationMetadataInvalidURI) { } TEST_F(WiredTigerUtilMetadataTest, GetApplicationMetadataNull) { - const char* config = NULL; + const char* config = nullptr; createSession(config); StatusWith<BSONObj> result = WiredTigerUtil::getApplicationMetadata(getOperationContext(), getURI()); @@ -282,7 +282,7 @@ TEST(WiredTigerUtilTest, GetStatisticsValueStatisticsDisabled) { harnessHelper.getOplogManager()); WiredTigerSession* session = recoveryUnit.getSession(); WT_SESSION* wtSession = session->getSession(); - ASSERT_OK(wtRCToStatus(wtSession->create(wtSession, "table:mytable", NULL))); + ASSERT_OK(wtRCToStatus(wtSession->create(wtSession, "table:mytable", nullptr))); auto result = WiredTigerUtil::getStatisticsValue(session->getSession(), "statistics:table:mytable", "statistics=(fast)", @@ -297,7 +297,7 @@ TEST(WiredTigerUtilTest, GetStatisticsValueInvalidKey) { harnessHelper.getOplogManager()); WiredTigerSession* session = recoveryUnit.getSession(); WT_SESSION* wtSession = session->getSession(); - ASSERT_OK(wtRCToStatus(wtSession->create(wtSession, "table:mytable", NULL))); + ASSERT_OK(wtRCToStatus(wtSession->create(wtSession, "table:mytable", nullptr))); // Use connection statistics key which does not apply to a table. auto result = WiredTigerUtil::getStatisticsValue(session->getSession(), "statistics:table:mytable", @@ -313,7 +313,7 @@ TEST(WiredTigerUtilTest, GetStatisticsValueValidKey) { harnessHelper.getOplogManager()); WiredTigerSession* session = recoveryUnit.getSession(); WT_SESSION* wtSession = session->getSession(); - ASSERT_OK(wtRCToStatus(wtSession->create(wtSession, "table:mytable", NULL))); + ASSERT_OK(wtRCToStatus(wtSession->create(wtSession, "table:mytable", nullptr))); // Use connection statistics key which does not apply to a table. auto result = WiredTigerUtil::getStatisticsValue(session->getSession(), "statistics:table:mytable", |