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/client | |
parent | b3c26131f6ab3f919beca658341e737de5d45683 (diff) | |
download | mongo-47b380f03e8898f4706ff01fa2be64dfb72e0dba.tar.gz |
SERVER-41071 Replace NULL and 0 with nullptr
Diffstat (limited to 'src/mongo/client')
-rw-r--r-- | src/mongo/client/connection_pool.cpp | 2 | ||||
-rw-r--r-- | src/mongo/client/connection_string_connect.cpp | 2 | ||||
-rw-r--r-- | src/mongo/client/connpool.cpp | 6 | ||||
-rw-r--r-- | src/mongo/client/connpool.h | 4 | ||||
-rw-r--r-- | src/mongo/client/dbclient_base.cpp | 6 | ||||
-rw-r--r-- | src/mongo/client/dbclient_base.h | 20 | ||||
-rw-r--r-- | src/mongo/client/dbclient_connection.h | 8 | ||||
-rw-r--r-- | src/mongo/client/dbclient_cursor.cpp | 2 | ||||
-rw-r--r-- | src/mongo/client/dbclient_cursor.h | 2 | ||||
-rw-r--r-- | src/mongo/client/dbclient_rs.cpp | 46 | ||||
-rw-r--r-- | src/mongo/client/dbclient_rs.h | 12 | ||||
-rw-r--r-- | src/mongo/client/index_spec.cpp | 4 | ||||
-rw-r--r-- | src/mongo/client/query.h | 4 | ||||
-rw-r--r-- | src/mongo/client/replica_set_monitor.cpp | 2 | ||||
-rw-r--r-- | src/mongo/client/replica_set_monitor_read_preference_test.cpp | 8 |
15 files changed, 64 insertions, 64 deletions
diff --git a/src/mongo/client/connection_pool.cpp b/src/mongo/client/connection_pool.cpp index 643817aa9c6..dfe098e1c9d 100644 --- a/src/mongo/client/connection_pool.cpp +++ b/src/mongo/client/connection_pool.cpp @@ -273,7 +273,7 @@ ConnectionPool::ConnectionPtr& ConnectionPool::ConnectionPtr::operator=(Connecti void ConnectionPool::ConnectionPtr::done(Date_t now) { _pool->releaseConnection(_connInfo, now); - _pool = NULL; + _pool = nullptr; } } // namespace mongo diff --git a/src/mongo/client/connection_string_connect.cpp b/src/mongo/client/connection_string_connect.cpp index 76844368edc..81e3bdaef4f 100644 --- a/src/mongo/client/connection_string_connect.cpp +++ b/src/mongo/client/connection_string_connect.cpp @@ -44,7 +44,7 @@ namespace mongo { stdx::mutex ConnectionString::_connectHookMutex; -ConnectionString::ConnectionHook* ConnectionString::_connectHook = NULL; +ConnectionString::ConnectionHook* ConnectionString::_connectHook = nullptr; std::unique_ptr<DBClientBase> ConnectionString::connect(StringData applicationName, std::string& errmsg, diff --git a/src/mongo/client/connpool.cpp b/src/mongo/client/connpool.cpp index d4d58addcfc..5901f695014 100644 --- a/src/mongo/client/connpool.cpp +++ b/src/mongo/client/connpool.cpp @@ -572,7 +572,7 @@ bool DBConnectionPool::poolKeyCompare::operator()(const PoolKey& a, const PoolKe } bool DBConnectionPool::isConnectionGood(const string& hostName, DBClientBase* conn) { - if (conn == NULL) { + if (conn == nullptr) { return false; } @@ -642,13 +642,13 @@ void ScopedDbConnection::done() { } globalConnPool.release(_host, _conn); - _conn = NULL; + _conn = nullptr; } void ScopedDbConnection::kill() { globalConnPool.decrementEgress(_host, _conn); delete _conn; - _conn = NULL; + _conn = nullptr; } void ScopedDbConnection::_setSocketTimeout() { diff --git a/src/mongo/client/connpool.h b/src/mongo/client/connpool.h index 24e2cd70dd4..9fbf65214db 100644 --- a/src/mongo/client/connpool.h +++ b/src/mongo/client/connpool.h @@ -457,7 +457,7 @@ public: explicit ScopedDbConnection(const ConnectionString& host, double socketTimeout = 0); explicit ScopedDbConnection(const MongoURI& host, double socketTimeout = 0); - ScopedDbConnection() : _host(""), _conn(0), _socketTimeoutSecs(0) {} + ScopedDbConnection() : _host(""), _conn(nullptr), _socketTimeoutSecs(0) {} /* @param conn - bind to an existing connection */ ScopedDbConnection(const std::string& host, DBClientBase* conn, double socketTimeout = 0) @@ -488,7 +488,7 @@ public: } bool ok() const { - return _conn != NULL; + return _conn != nullptr; } std::string getHost() const { diff --git a/src/mongo/client/dbclient_base.cpp b/src/mongo/client/dbclient_base.cpp index dcf30fa1881..3c896123850 100644 --- a/src/mongo/client/dbclient_base.cpp +++ b/src/mongo/client/dbclient_base.cpp @@ -287,7 +287,7 @@ bool DBClientBase::runCommand(const string& dbname, BSONObj cmd, BSONObj& info, */ bool DBClientBase::simpleCommand(const string& dbname, BSONObj* info, const string& command) { BSONObj o; - if (info == 0) + if (info == nullptr) info = &o; BSONObjBuilder b; b.append(command, 1); @@ -532,7 +532,7 @@ bool DBClientBase::isMaster(bool& isMaster, BSONObj* info) { } BSONObj o; - if (info == 0) + if (info == nullptr) info = &o; bool ok = runCommand("admin", bob.obj(), *info); isMaster = info->getField("ismaster").trueValue(); @@ -543,7 +543,7 @@ bool DBClientBase::createCollection( const string& ns, long long size, bool capped, int max, BSONObj* info) { verify(!capped || size); BSONObj o; - if (info == 0) + if (info == nullptr) info = &o; BSONObjBuilder b; string db = nsToDatabase(ns); diff --git a/src/mongo/client/dbclient_base.h b/src/mongo/client/dbclient_base.h index 558cc3efa8e..a7cdfc43c3b 100644 --- a/src/mongo/client/dbclient_base.h +++ b/src/mongo/client/dbclient_base.h @@ -77,21 +77,21 @@ class DBClientQueryInterface { Query query, int nToReturn = 0, int nToSkip = 0, - const BSONObj* fieldsToReturn = 0, + const BSONObj* fieldsToReturn = nullptr, int queryOptions = 0, int batchSize = 0) = 0; virtual unsigned long long query(std::function<void(const BSONObj&)> f, const NamespaceStringOrUUID& nsOrUuid, Query query, - const BSONObj* fieldsToReturn = 0, + const BSONObj* fieldsToReturn = nullptr, int queryOptions = 0, int batchSize = 0) = 0; virtual unsigned long long query(std::function<void(DBClientCursorBatchIterator&)> f, const NamespaceStringOrUUID& nsOrUuid, Query query, - const BSONObj* fieldsToReturn = 0, + const BSONObj* fieldsToReturn = nullptr, int queryOptions = 0, int batchSize = 0) = 0; }; @@ -118,7 +118,7 @@ public: */ virtual BSONObj findOne(const std::string& ns, const Query& query, - const BSONObj* fieldsToReturn = 0, + const BSONObj* fieldsToReturn = nullptr, int queryOptions = 0); /** query N objects from the database into an array. makes sense mostly when you want a small @@ -129,7 +129,7 @@ public: Query query, int nToReturn, int nToSkip = 0, - const BSONObj* fieldsToReturn = 0, + const BSONObj* fieldsToReturn = nullptr, int queryOptions = 0); /** @@ -368,7 +368,7 @@ public: returns true if command invoked successfully. */ - virtual bool isMaster(bool& isMaster, BSONObj* info = 0); + virtual bool isMaster(bool& isMaster, BSONObj* info = nullptr); /** Create a new collection in the database. Normally, collection creation is automatic. You @@ -390,7 +390,7 @@ public: long long size = 0, bool capped = false, int max = 0, - BSONObj* info = 0); + BSONObj* info = nullptr); /** Get error result from the last write operation (insert/update/delete) on this connection. db doesn't change the command's behavior - it is just for auth checks. @@ -583,7 +583,7 @@ public: Query query, int nToReturn = 0, int nToSkip = 0, - const BSONObj* fieldsToReturn = 0, + const BSONObj* fieldsToReturn = nullptr, int queryOptions = 0, int batchSize = 0) override; @@ -605,14 +605,14 @@ public: unsigned long long query(std::function<void(const BSONObj&)> f, const NamespaceStringOrUUID& nsOrUuid, Query query, - const BSONObj* fieldsToReturn = 0, + const BSONObj* fieldsToReturn = nullptr, int queryOptions = QueryOption_Exhaust, int batchSize = 0) final; unsigned long long query(std::function<void(DBClientCursorBatchIterator&)> f, const NamespaceStringOrUUID& nsOrUuid, Query query, - const BSONObj* fieldsToReturn = 0, + const BSONObj* fieldsToReturn = nullptr, int queryOptions = QueryOption_Exhaust, int batchSize = 0) override; diff --git a/src/mongo/client/dbclient_connection.h b/src/mongo/client/dbclient_connection.h index dc2f9ae7f6c..5b2976a134f 100644 --- a/src/mongo/client/dbclient_connection.h +++ b/src/mongo/client/dbclient_connection.h @@ -154,7 +154,7 @@ public: Query query = Query(), int nToReturn = 0, int nToSkip = 0, - const BSONObj* fieldsToReturn = 0, + const BSONObj* fieldsToReturn = nullptr, int queryOptions = 0, int batchSize = 0) override { checkConnection(); @@ -227,12 +227,12 @@ public: return _serverAddress; } - void say(Message& toSend, bool isRetry = false, std::string* actualServer = 0) override; + void say(Message& toSend, bool isRetry = false, std::string* actualServer = nullptr) override; bool recv(Message& m, int lastRequestId) override; void checkResponse(const std::vector<BSONObj>& batch, bool networkError, - bool* retry = NULL, - std::string* host = NULL) override; + bool* retry = nullptr, + std::string* host = nullptr) override; bool call(Message& toSend, Message& response, bool assertOk, diff --git a/src/mongo/client/dbclient_cursor.cpp b/src/mongo/client/dbclient_cursor.cpp index 3e049f786e5..16be475d4b0 100644 --- a/src/mongo/client/dbclient_cursor.cpp +++ b/src/mongo/client/dbclient_cursor.cpp @@ -490,7 +490,7 @@ void DBClientCursor::attach(AScopedConnection* conn) { } conn->done(); - _client = 0; + _client = nullptr; _lazyHost = ""; } diff --git a/src/mongo/client/dbclient_cursor.h b/src/mongo/client/dbclient_cursor.h index e5b69b10b50..ad3a2c89583 100644 --- a/src/mongo/client/dbclient_cursor.h +++ b/src/mongo/client/dbclient_cursor.h @@ -94,7 +94,7 @@ public: /** * peek ahead and see if an error occurred, and get the error if so. */ - bool peekError(BSONObj* error = NULL); + bool peekError(BSONObj* error = nullptr); /** iterate the rest of the cursor and return the number if items diff --git a/src/mongo/client/dbclient_rs.cpp b/src/mongo/client/dbclient_rs.cpp index 033f39b0bef..b7e2044f93c 100644 --- a/src/mongo/client/dbclient_rs.cpp +++ b/src/mongo/client/dbclient_rs.cpp @@ -298,7 +298,7 @@ DBClientConnection* DBClientReplicaSet::checkMaster() { MongoURI masterUri = _uri.cloneURIForServer(_masterHost); string errmsg; - DBClientConnection* newConn = NULL; + DBClientConnection* newConn = nullptr; boost::optional<double> socketTimeout; if (_so_timeout > 0.0) socketTimeout = _so_timeout; @@ -313,7 +313,7 @@ DBClientConnection* DBClientReplicaSet::checkMaster() { errmsg = ex.toString(); } - if (newConn == NULL || !errmsg.empty()) { + if (newConn == nullptr || !errmsg.empty()) { const std::string message = str::stream() << "can't connect to new replica set master [" << _masterHost.toString() << "]" << (errmsg.empty() ? "" : ", err: ") << errmsg; @@ -398,7 +398,7 @@ DBClientConnection& DBClientReplicaSet::slaveConn() { uassert(16369, str::stream() << "No good nodes available for set: " << _getMonitor()->getName(), - conn != NULL); + conn != nullptr); return *conn; } @@ -493,7 +493,7 @@ void DBClientReplicaSet::logout(const string& dbname, BSONObj& info) { * needed when we actually have something cached and is last known to be * working. */ - if (_lastSlaveOkConn.get() != NULL && !_lastSlaveOkConn->isFailed()) { + if (_lastSlaveOkConn.get() != nullptr && !_lastSlaveOkConn->isFailed()) { try { BSONObj dummy; _lastSlaveOkConn->logout(dbname, dummy); @@ -536,8 +536,8 @@ unique_ptr<DBClientCursor> DBClientReplicaSet::query(const NamespaceStringOrUUID LOG(3) << "dbclient_rs query using secondary or tagged node selection in " << _getMonitor()->getName() << ", read pref is " << readPref->toString() << " (primary : " - << (_master.get() != NULL ? _master->getServerAddress() : "[not cached]") - << ", lastTagged : " << (_lastSlaveOkConn.get() != NULL + << (_master.get() != nullptr ? _master->getServerAddress() : "[not cached]") + << ", lastTagged : " << (_lastSlaveOkConn.get() != nullptr ? _lastSlaveOkConn->getServerAddress() : "[not cached]") << ")" << endl; @@ -548,7 +548,7 @@ unique_ptr<DBClientCursor> DBClientReplicaSet::query(const NamespaceStringOrUUID try { DBClientConnection* conn = selectNodeUsingTags(readPref); - if (conn == NULL) { + if (conn == nullptr) { break; } @@ -588,8 +588,8 @@ BSONObj DBClientReplicaSet::findOne(const string& ns, LOG(3) << "dbclient_rs findOne using secondary or tagged node selection in " << _getMonitor()->getName() << ", read pref is " << readPref->toString() << " (primary : " - << (_master.get() != NULL ? _master->getServerAddress() : "[not cached]") - << ", lastTagged : " << (_lastSlaveOkConn.get() != NULL + << (_master.get() != nullptr ? _master->getServerAddress() : "[not cached]") + << ", lastTagged : " << (_lastSlaveOkConn.get() != nullptr ? _lastSlaveOkConn->getServerAddress() : "[not cached]") << ")" << endl; @@ -600,7 +600,7 @@ BSONObj DBClientReplicaSet::findOne(const string& ns, try { DBClientConnection* conn = selectNodeUsingTags(readPref); - if (conn == NULL) { + if (conn == nullptr) { break; } @@ -647,7 +647,7 @@ void DBClientReplicaSet::isntMaster() { unique_ptr<DBClientCursor> DBClientReplicaSet::checkSlaveQueryResult( unique_ptr<DBClientCursor> result) { - if (result.get() == NULL) + if (result.get() == nullptr) return result; BSONObj error; @@ -733,7 +733,7 @@ DBClientConnection* DBClientReplicaSet::selectNodeUsingTags( // that returning NULL means none of the nodes were good, which is not the case here. uassert(16532, str::stream() << "Failed to connect to " << _lastSlaveOkHost.toString(), - newConn != NULL); + newConn != nullptr); _lastSlaveOkConn = std::shared_ptr<DBClientConnection>(newConn, std::move(dtor)); _lastSlaveOkConn->setParentReplSetName(_setName); @@ -767,8 +767,8 @@ void DBClientReplicaSet::say(Message& toSend, bool isRetry, string* actualServer LOG(3) << "dbclient_rs say using secondary or tagged node selection in " << _getMonitor()->getName() << ", read pref is " << readPref->toString() << " (primary : " - << (_master.get() != NULL ? _master->getServerAddress() : "[not cached]") - << ", lastTagged : " << (_lastSlaveOkConn.get() != NULL + << (_master.get() != nullptr ? _master->getServerAddress() : "[not cached]") + << ", lastTagged : " << (_lastSlaveOkConn.get() != nullptr ? _lastSlaveOkConn->getServerAddress() : "[not cached]") << ")" << endl; @@ -780,11 +780,11 @@ void DBClientReplicaSet::say(Message& toSend, bool isRetry, string* actualServer try { DBClientConnection* conn = selectNodeUsingTags(readPref); - if (conn == NULL) { + if (conn == nullptr) { break; } - if (actualServer != NULL) { + if (actualServer != nullptr) { *actualServer = conn->getServerAddress(); } @@ -985,7 +985,7 @@ bool DBClientReplicaSet::call(Message& toSend, Message& response, bool assertOk, string* actualServer) { - const char* ns = 0; + const char* ns = nullptr; if (toSend.operation() == dbQuery) { // TODO: might be possible to do this faster by changing api @@ -998,8 +998,8 @@ bool DBClientReplicaSet::call(Message& toSend, LOG(3) << "dbclient_rs call using secondary or tagged node selection in " << _getMonitor()->getName() << ", read pref is " << readPref->toString() << " (primary : " - << (_master.get() != NULL ? _master->getServerAddress() : "[not cached]") - << ", lastTagged : " << (_lastSlaveOkConn.get() != NULL + << (_master.get() != nullptr ? _master->getServerAddress() : "[not cached]") + << ", lastTagged : " << (_lastSlaveOkConn.get() != nullptr ? _lastSlaveOkConn->getServerAddress() : "[not cached]") << ")" << endl; @@ -1008,11 +1008,11 @@ bool DBClientReplicaSet::call(Message& toSend, try { DBClientConnection* conn = selectNodeUsingTags(readPref); - if (conn == NULL) { + if (conn == nullptr) { return false; } - if (actualServer != NULL) { + if (actualServer != nullptr) { *actualServer = conn->getServerAddress(); } @@ -1068,7 +1068,7 @@ void DBClientReplicaSet::_invalidateLastSlaveOkCache(const Status& status) { void DBClientReplicaSet::reset() { resetSlaveOkConn(); - _lazyState._lastClient = NULL; + _lazyState._lastClient = nullptr; _lastReadPref.reset(); } @@ -1089,7 +1089,7 @@ void DBClientReplicaSet::resetMaster() { void DBClientReplicaSet::resetSlaveOkConn() { if (_lastSlaveOkConn.get() == _master.get()) { _lastSlaveOkConn.reset(); - } else if (_lastSlaveOkConn.get() != NULL) { + } else if (_lastSlaveOkConn.get() != nullptr) { if (_authPooledSecondaryConn) { logoutAll(_lastSlaveOkConn.get()); } else { diff --git a/src/mongo/client/dbclient_rs.h b/src/mongo/client/dbclient_rs.h index 506a3cf6f16..92e2a93acb0 100644 --- a/src/mongo/client/dbclient_rs.h +++ b/src/mongo/client/dbclient_rs.h @@ -93,14 +93,14 @@ public: Query query, int nToReturn = 0, int nToSkip = 0, - const BSONObj* fieldsToReturn = 0, + const BSONObj* fieldsToReturn = nullptr, int queryOptions = 0, int batchSize = 0) override; /** throws userassertion "no master found" */ BSONObj findOne(const std::string& ns, const Query& query, - const BSONObj* fieldsToReturn = 0, + const BSONObj* fieldsToReturn = nullptr, int queryOptions = 0) override; void insert(const std::string& ns, BSONObj obj, int flags = 0) override; @@ -136,12 +136,12 @@ public: // ---- callback pieces ------- - void say(Message& toSend, bool isRetry = false, std::string* actualServer = 0) override; + void say(Message& toSend, bool isRetry = false, std::string* actualServer = nullptr) override; bool recv(Message& toRecv, int lastRequestId) override; void checkResponse(const std::vector<BSONObj>& batch, bool networkError, - bool* retry = NULL, - std::string* targetHost = NULL) override; + bool* retry = nullptr, + std::string* targetHost = nullptr) override; /* this is the callback from our underlying connections to notify us that we got a "not master" * error. @@ -345,7 +345,7 @@ protected: */ class LazyState { public: - LazyState() : _lastClient(NULL), _lastOp(-1), _secondaryQueryOk(false), _retries(0) {} + LazyState() : _lastClient(nullptr), _lastOp(-1), _secondaryQueryOk(false), _retries(0) {} DBClientConnection* _lastClient; int _lastOp; bool _secondaryQueryOk; diff --git a/src/mongo/client/index_spec.cpp b/src/mongo/client/index_spec.cpp index c5d3061d781..4562a8fe17f 100644 --- a/src/mongo/client/index_spec.cpp +++ b/src/mongo/client/index_spec.cpp @@ -46,8 +46,8 @@ namespace { const int kIndexTypeNumbers[] = {IndexSpec::kIndexValAscending, IndexSpec::kIndexValDescending}; -const char* const kIndexTypeStrings[] = {NULL, - NULL, +const char* const kIndexTypeStrings[] = {nullptr, + nullptr, IndexSpec::kIndexValText, IndexSpec::kIndexValGeo2D, IndexSpec::kIndexValGeoHaystack, diff --git a/src/mongo/client/query.h b/src/mongo/client/query.h index c8adf396cfe..24444e853e8 100644 --- a/src/mongo/client/query.h +++ b/src/mongo/client/query.h @@ -131,8 +131,8 @@ public: /** * @return true if this query has an orderby, hint, or some other field */ - bool isComplex(bool* hasDollar = 0) const; - static bool isComplex(const BSONObj& obj, bool* hasDollar = 0); + bool isComplex(bool* hasDollar = nullptr) const; + static bool isComplex(const BSONObj& obj, bool* hasDollar = nullptr); BSONObj getFilter() const; BSONObj getSort() const; diff --git a/src/mongo/client/replica_set_monitor.cpp b/src/mongo/client/replica_set_monitor.cpp index cca254b4007..d134f935070 100644 --- a/src/mongo/client/replica_set_monitor.cpp +++ b/src/mongo/client/replica_set_monitor.cpp @@ -1200,7 +1200,7 @@ std::vector<HostAndPort> SetState::getMatchingHosts(const ReadPreferenceSetting& Node* SetState::findNode(const HostAndPort& host) { const Nodes::iterator it = std::lower_bound(nodes.begin(), nodes.end(), host, compareHosts); if (it == nodes.end() || it->host != host) - return NULL; + return nullptr; return &(*it); } diff --git a/src/mongo/client/replica_set_monitor_read_preference_test.cpp b/src/mongo/client/replica_set_monitor_read_preference_test.cpp index 3f738d6cd41..374a3f5f9c5 100644 --- a/src/mongo/client/replica_set_monitor_read_preference_test.cpp +++ b/src/mongo/client/replica_set_monitor_read_preference_test.cpp @@ -589,7 +589,7 @@ public: virtual ~MultiTagsTest() = default; const TagSet& getMatchesFirstTagSet() { - if (matchFirstTags.get() != NULL) { + if (matchFirstTags.get() != nullptr) { return *matchFirstTags; } @@ -604,7 +604,7 @@ public: } const TagSet& getMatchesSecondTagSet() { - if (matchSecondTags.get() != NULL) { + if (matchSecondTags.get() != nullptr) { return *matchSecondTags; } @@ -621,7 +621,7 @@ public: } const TagSet& getMatchesLastTagSet() { - if (matchLastTags.get() != NULL) { + if (matchLastTags.get() != nullptr) { return *matchLastTags; } @@ -642,7 +642,7 @@ public: } const TagSet& getMatchesPriTagSet() { - if (matchPriTags.get() != NULL) { + if (matchPriTags.get() != nullptr) { return *matchPriTags; } |