diff options
author | A. Jesse Jiryu Davis <jesse@mongodb.com> | 2019-06-14 22:04:06 -0400 |
---|---|---|
committer | A. Jesse Jiryu Davis <jesse@mongodb.com> | 2019-06-17 14:30:10 -0400 |
commit | 6633498e9cecbeeb85b10ccbd6492f117d94d07a (patch) | |
tree | ce78669a1827528ae2b397c25b9cfb8f98d19713 /src | |
parent | 0fbe3ed263ba7950efe8aa423bca919139cec5b5 (diff) | |
download | mongo-6633498e9cecbeeb85b10ccbd6492f117d94d07a.tar.gz |
SERVER-41071 Replace more NULLs with nullptr
Diffstat (limited to 'src')
30 files changed, 134 insertions, 133 deletions
diff --git a/src/mongo/base/checked_cast.h b/src/mongo/base/checked_cast.h index 074b432fab7..df62cd41b3b 100644 --- a/src/mongo/base/checked_cast.h +++ b/src/mongo/base/checked_cast.h @@ -61,7 +61,7 @@ struct checked_cast_impl<true> { template <typename T, typename U> static T cast(U* u) { if (!u) { - return NULL; + return nullptr; } T t = dynamic_cast<T>(u); invariant(t); diff --git a/src/mongo/client/cyrus_sasl_client_session.cpp b/src/mongo/client/cyrus_sasl_client_session.cpp index 36d7d588142..e6ddd6e3a7f 100644 --- a/src/mongo/client/cyrus_sasl_client_session.cpp +++ b/src/mongo/client/cyrus_sasl_client_session.cpp @@ -136,7 +136,7 @@ MONGO_INITIALIZER_WITH_PREREQUISITES(CyrusSaslClientContext, ("NativeSaslClientContext", "CyrusSaslAllocatorsAndMutexes")) (InitializerContext* context) { static sasl_callback_t saslClientGlobalCallbacks[] = { - {SASL_CB_LOG, SaslCallbackFn(saslClientLogSwallow), NULL /* context */}, + {SASL_CB_LOG, SaslCallbackFn(saslClientLogSwallow), nullptr /* context */}, {SASL_CB_LIST_END}}; // If the client application has previously called sasl_client_init(), the callbacks passed @@ -147,7 +147,7 @@ MONGO_INITIALIZER_WITH_PREREQUISITES(CyrusSaslClientContext, if (result != SASL_OK) { return Status(ErrorCodes::UnknownError, str::stream() << "Could not initialize sasl client components (" - << sasl_errstring(result, NULL, NULL) + << sasl_errstring(result, nullptr, nullptr) << ")"); } @@ -204,7 +204,7 @@ int saslClientGetPassword(sasl_conn_t* conn, return SASL_BADPARAM; sasl_secret_t* secret = session->getPasswordAsSecret(); - if (secret == NULL) { + if (secret == nullptr) { saslSetError(conn, "No password data provided"); return SASL_FAIL; } @@ -221,7 +221,7 @@ int saslClientGetPassword(sasl_conn_t* conn, } // namespace CyrusSaslClientSession::CyrusSaslClientSession() - : SaslClientSession(), _saslConnection(NULL), _step(0), _success(false) { + : SaslClientSession(), _saslConnection(nullptr), _step(0), _success(false) { const sasl_callback_t callbackTemplate[maxCallbacks] = { {SASL_CB_AUTHNAME, SaslCallbackFn(saslClientGetSimple), this}, {SASL_CB_USER, SaslCallbackFn(saslClientGetSimple), this}, @@ -254,28 +254,28 @@ sasl_secret_t* CyrusSaslClientSession::getPasswordAsSecret() { } Status CyrusSaslClientSession::initialize() { - if (_saslConnection != NULL) + if (_saslConnection != nullptr) return Status(ErrorCodes::AlreadyInitialized, "Cannot reinitialize CyrusSaslClientSession."); int result = sasl_client_new(getParameter(parameterServiceName).toString().c_str(), getParameter(parameterServiceHostname).toString().c_str(), - NULL, - NULL, + nullptr, + nullptr, _callbacks, 0, &_saslConnection); if (SASL_OK != result) { return Status(ErrorCodes::UnknownError, - str::stream() << sasl_errstring(result, NULL, NULL)); + str::stream() << sasl_errstring(result, nullptr, nullptr)); } return Status::OK(); } Status CyrusSaslClientSession::step(StringData inputData, std::string* outputData) { - const char* output = NULL; + const char* output = nullptr; unsigned outputSize = 0xFFFFFFFF; int result; @@ -283,7 +283,7 @@ Status CyrusSaslClientSession::step(StringData inputData, std::string* outputDat const char* actualMechanism; result = sasl_client_start(_saslConnection, getParameter(parameterMechanism).toString().c_str(), - NULL, + nullptr, &output, &outputSize, &actualMechanism); @@ -291,7 +291,7 @@ Status CyrusSaslClientSession::step(StringData inputData, std::string* outputDat result = sasl_client_step(_saslConnection, inputData.rawData(), static_cast<unsigned>(inputData.size()), - NULL, + nullptr, &output, &outputSize); } diff --git a/src/mongo/client/sasl_sspi.cpp b/src/mongo/client/sasl_sspi.cpp index fa011a458a0..b917b016844 100644 --- a/src/mongo/client/sasl_sspi.cpp +++ b/src/mongo/client/sasl_sspi.cpp @@ -89,12 +89,12 @@ void HandleLastError(const sasl_utils_t* utils, DWORD errCode, const char* msg) char* err; if (!FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, + nullptr, errCode, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPSTR)&err, 0, - NULL)) { + nullptr)) { return; } @@ -150,10 +150,10 @@ int sspiClientMechNew(void* glob_context, // Fetch password, if available. authIdentity.PasswordLength = 0; - authIdentity.Password = NULL; + authIdentity.Password = nullptr; std::wstring utf16Password; - sasl_secret_t* password = NULL; + sasl_secret_t* password = nullptr; sasl_getsecret_t* pass_cb; void* pass_context; ret = cparams->utils->getcallback( @@ -174,13 +174,13 @@ int sspiClientMechNew(void* glob_context, std::unique_ptr<SspiConnContext> pcctx(new SspiConnContext()); pcctx->userPlusRealm = userPlusRealm; TimeStamp ignored; - SECURITY_STATUS status = AcquireCredentialsHandleW(NULL, // principal + SECURITY_STATUS status = AcquireCredentialsHandleW(nullptr, // principal const_cast<LPWSTR>(L"kerberos"), SECPKG_CRED_OUTBOUND, - NULL, // LOGON id + nullptr, // LOGON id &authIdentity, // auth data - NULL, // get key fn - NULL, // get key arg + nullptr, // get key fn + nullptr, // get key arg &pcctx->cred, &ignored); if (status != SEC_E_OK) { @@ -191,7 +191,7 @@ int sspiClientMechNew(void* glob_context, pcctx->haveCred = true; // Compose target name token. First, verify that a hostname has been provided. - if (cparams->serverFQDN == NULL || strlen(cparams->serverFQDN) == 0) { + if (cparams->serverFQDN == nullptr || strlen(cparams->serverFQDN) == 0) { saslSetError(cparams->utils, "SSPI: no serverFQDN"); return SASL_FAIL; } @@ -246,9 +246,9 @@ int sspiValidateServerSecurityLayerOffering(SspiConnContext* pcctx, wrapBufs[1].cbBuffer = 0; wrapBufs[1].BufferType = SECBUFFER_DATA; - wrapBufs[1].pvBuffer = NULL; + wrapBufs[1].pvBuffer = nullptr; - SECURITY_STATUS status = DecryptMessage(&pcctx->ctx, &wrapBufDesc, 0, NULL); + SECURITY_STATUS status = DecryptMessage(&pcctx->ctx, &wrapBufDesc, 0, nullptr); if (status != SEC_E_OK) { HandleLastError(cparams->utils, status, "DecryptMessage"); return SASL_FAIL; @@ -359,7 +359,7 @@ int sspiClientMechStep(void* conn_context, unsigned* clientoutlen, sasl_out_params_t* oparams) throw() { SspiConnContext* pcctx = static_cast<SspiConnContext*>(conn_context); - *clientout = NULL; + *clientout = nullptr; *clientoutlen = 0; if (pcctx->authComplete) { @@ -386,24 +386,24 @@ int sspiClientMechStep(void* conn_context, outbuf.ulVersion = SECBUFFER_VERSION; outbuf.cBuffers = 1; outbuf.pBuffers = outBufs; - outBufs[0].pvBuffer = NULL; + outBufs[0].pvBuffer = nullptr; outBufs[0].cbBuffer = 0; outBufs[0].BufferType = SECBUFFER_TOKEN; ULONG contextAttr = 0; SECURITY_STATUS status = InitializeSecurityContextW(&pcctx->cred, - pcctx->haveCtxt ? &pcctx->ctx : NULL, + pcctx->haveCtxt ? &pcctx->ctx : nullptr, const_cast<wchar_t*>(pcctx->nameToken.c_str()), ISC_REQ_ALLOCATE_MEMORY | ISC_REQ_MUTUAL_AUTH, 0, SECURITY_NETWORK_DREP, - (pcctx->haveCtxt ? &inbuf : NULL), + (pcctx->haveCtxt ? &inbuf : nullptr), 0, &pcctx->ctx, &outbuf, &contextAttr, - NULL); + nullptr); if (status != SEC_E_OK && status != SEC_I_CONTINUE_NEEDED) { HandleLastError(cparams->utils, status, "InitializeSecurityContext"); @@ -415,7 +415,7 @@ int sspiClientMechStep(void* conn_context, if (status == SEC_E_OK) { // Send back nothing and wait for the server to reply with the security capabilities - *clientout = NULL; + *clientout = nullptr; *clientoutlen = 0; pcctx->authComplete = true; return SASL_CONTINUE; @@ -443,15 +443,15 @@ sasl_client_plug_t sspiClientPlugin[] = { SASL_SEC_NOACTIVE | SASL_SEC_NOANONYMOUS | SASL_SEC_MUTUAL_AUTH | SASL_SEC_PASS_CREDENTIALS, /* security_flags */ SASL_FEAT_NEEDSERVERFQDN | SASL_FEAT_WANT_CLIENT_FIRST | SASL_FEAT_ALLOWS_PROXY, - NULL, /* required prompt ids, NULL = user/pass only */ - NULL, /* global state for mechanism */ + nullptr, /* required prompt ids, nullptr = user/pass only */ + nullptr, /* global state for mechanism */ sspiClientMechNew, sspiClientMechStep, sspiClientMechDispose, sspiClientMechFree, - NULL, - NULL, - NULL}}; + nullptr, + nullptr, + nullptr}}; int sspiClientPluginInit(const sasl_utils_t* utils, int max_version, @@ -483,7 +483,7 @@ MONGO_INITIALIZER_WITH_PREREQUISITES(SaslSspiClientPlugin, return Status(ErrorCodes::UnknownError, str::stream() << "could not add SASL Client SSPI plugin " << sspiPluginName << ": " - << sasl_errstring(ret, NULL, NULL)); + << sasl_errstring(ret, nullptr, nullptr)); } return Status::OK(); @@ -497,7 +497,7 @@ MONGO_INITIALIZER_WITH_PREREQUISITES(SaslPlainClientPlugin, return Status(ErrorCodes::UnknownError, str::stream() << "Could not add SASL Client PLAIN plugin " << sspiPluginName << ": " - << sasl_errstring(ret, NULL, NULL)); + << sasl_errstring(ret, nullptr, nullptr)); } return Status::OK(); diff --git a/src/mongo/db/exec/geo_near.cpp b/src/mongo/db/exec/geo_near.cpp index 5fa04b917db..f3f08bd3be8 100644 --- a/src/mongo/db/exec/geo_near.cpp +++ b/src/mongo/db/exec/geo_near.cpp @@ -595,7 +595,7 @@ StatusWith<NearStage::CoveredInterval*> // const Collection* collection) { // The search is finished if we searched at least once and all the way to the edge if (_currBounds.getInner() >= 0 && _currBounds.getOuter() == _fullBounds.getOuter()) { - return StatusWith<CoveredInterval*>(NULL); + return StatusWith<CoveredInterval*>(nullptr); } // @@ -1015,7 +1015,7 @@ StatusWith<NearStage::CoveredInterval*> // const Collection* collection) { // The search is finished if we searched at least once and all the way to the edge if (_currBounds.getInner() >= 0 && _currBounds.getOuter() == _fullBounds.getOuter()) { - return StatusWith<CoveredInterval*>(NULL); + return StatusWith<CoveredInterval*>(nullptr); } // diff --git a/src/mongo/db/exec/near.cpp b/src/mongo/db/exec/near.cpp index 1b56d9838e0..91a3a60317a 100644 --- a/src/mongo/db/exec/near.cpp +++ b/src/mongo/db/exec/near.cpp @@ -146,7 +146,7 @@ PlanStage::StageState NearStage::bufferNext(WorkingSetID* toReturn, Status* erro return PlanStage::FAILURE; } - if (NULL == intervalStatus.getValue()) { + if (nullptr == intervalStatus.getValue()) { _searchState = SearchState_Finished; return PlanStage::IS_EOF; } diff --git a/src/mongo/db/repl/isself.cpp b/src/mongo/db/repl/isself.cpp index f864cbb13de..13df4f52b5f 100644 --- a/src/mongo/db/repl/isself.cpp +++ b/src/mongo/db/repl/isself.cpp @@ -275,7 +275,7 @@ std::vector<std::string> getBoundAddrs(const bool ipv6enabled) { GAA_FLAG_SKIP_ANYCAST | // only want unicast addrs GAA_FLAG_SKIP_MULTICAST | GAA_FLAG_SKIP_DNS_SERVER, - NULL, + nullptr, adapters, &adaptersLen); @@ -293,8 +293,8 @@ std::vector<std::string> getBoundAddrs(const bool ipv6enabled) { return out; } - for (IP_ADAPTER_ADDRESSES* adapter = adapters; adapter != NULL; adapter = adapter->Next) { - for (IP_ADAPTER_UNICAST_ADDRESS* addr = adapter->FirstUnicastAddress; addr != NULL; + for (IP_ADAPTER_ADDRESSES* adapter = adapters; adapter != nullptr; adapter = adapter->Next) { + for (IP_ADAPTER_UNICAST_ADDRESS* addr = adapter->FirstUnicastAddress; addr != nullptr; addr = addr->Next) { short family = reinterpret_cast<SOCKADDR_STORAGE*>(addr->Address.lpSockaddr)->ss_family; diff --git a/src/mongo/db/server_options_helpers.cpp b/src/mongo/db/server_options_helpers.cpp index 01c0f1c0c8c..bc0a1eddc04 100644 --- a/src/mongo/db/server_options_helpers.cpp +++ b/src/mongo/db/server_options_helpers.cpp @@ -91,7 +91,7 @@ CODE facilitynames[] = {{"auth", LOG_AUTH}, {"cron", LOG_CRON}, {"daemon {"syslog", LOG_SYSLOG}, {"user", LOG_USER}, {"uucp", LOG_UUCP}, {"local0", LOG_LOCAL0}, {"local1", LOG_LOCAL1}, {"local2", LOG_LOCAL2}, {"local3", LOG_LOCAL3}, {"local4", LOG_LOCAL4}, {"local5", LOG_LOCAL5}, - {"local6", LOG_LOCAL6}, {"local7", LOG_LOCAL7}, {NULL, -1}}; + {"local6", LOG_LOCAL6}, {"local7", LOG_LOCAL7}, {nullptr, -1}}; #endif // !defined(INTERNAL_NOPRI) #endif // defined(SYSLOG_NAMES) diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_util.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_util.cpp index fb424183586..0d2d8b7bd5e 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_util.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_util.cpp @@ -337,7 +337,7 @@ StatusWith<int64_t> WiredTigerUtil::getStatisticsValue(WT_SESSION* session, } int64_t value; - ret = cursor->get_value(cursor, NULL, NULL, &value); + ret = cursor->get_value(cursor, nullptr, nullptr, &value); if (ret != 0) { return StatusWith<int64_t>( ErrorCodes::BadValue, @@ -627,7 +627,7 @@ Status WiredTigerUtil::exportTableToBSON(WT_SESSION* session, std::map<string, BSONObjBuilder*> subs; const char* desc; uint64_t value; - while (c->next(c) == 0 && c->get_value(c, &desc, NULL, &value) == 0) { + while (c->next(c) == 0 && c->get_value(c, &desc, nullptr, &value) == 0) { StringData key(desc); StringData prefix; diff --git a/src/mongo/dbtests/query_stage_near.cpp b/src/mongo/dbtests/query_stage_near.cpp index 4af68aad624..df400c3bd1f 100644 --- a/src/mongo/dbtests/query_stage_near.cpp +++ b/src/mongo/dbtests/query_stage_near.cpp @@ -110,7 +110,7 @@ public: WorkingSet* workingSet, const Collection* collection) { if (_pos == static_cast<int>(_intervals.size())) - return StatusWith<CoveredInterval*>(NULL); + return StatusWith<CoveredInterval*>(nullptr); const MockInterval& interval = *_intervals[_pos++]; diff --git a/src/mongo/logger/console.cpp b/src/mongo/logger/console.cpp index ce8c053779c..ebf8049ac71 100644 --- a/src/mongo/logger/console.cpp +++ b/src/mongo/logger/console.cpp @@ -174,7 +174,7 @@ private: while (unwrittenCount > 0) { DWORD written; BOOL success = - WriteConsoleW(_consoleHandle, unwrittenBegin, unwrittenCount, &written, NULL); + WriteConsoleW(_consoleHandle, unwrittenBegin, unwrittenCount, &written, nullptr); if (!success) { return false; } diff --git a/src/mongo/logger/rotatable_file_writer.cpp b/src/mongo/logger/rotatable_file_writer.cpp index fa22a7f1e4a..a8bd27a0fc4 100644 --- a/src/mongo/logger/rotatable_file_writer.cpp +++ b/src/mongo/logger/rotatable_file_writer.cpp @@ -138,10 +138,10 @@ bool Win32FileStreambuf::open(StringData fileName, bool append) { _fileHandle = CreateFileW(utf8ToWide(fileName).c_str(), // lpFileName GENERIC_WRITE, // dwDesiredAccess FILE_SHARE_DELETE | FILE_SHARE_READ, // dwShareMode - NULL, // lpSecurityAttributes + nullptr, // lpSecurityAttributes OPEN_ALWAYS, // dwCreationDisposition FILE_ATTRIBUTE_NORMAL, // dwFlagsAndAttributes - NULL // hTemplateFile + nullptr // hTemplateFile ); @@ -152,11 +152,11 @@ bool Win32FileStreambuf::open(StringData fileName, bool append) { zero.QuadPart = 0LL; if (append) { - if (SetFilePointerEx(_fileHandle, zero, NULL, FILE_END)) { + if (SetFilePointerEx(_fileHandle, zero, nullptr, FILE_END)) { return true; } } else { - if (SetFilePointerEx(_fileHandle, zero, NULL, FILE_BEGIN) && SetEndOfFile(_fileHandle)) { + if (SetFilePointerEx(_fileHandle, zero, nullptr, FILE_BEGIN) && SetEndOfFile(_fileHandle)) { return true; } } @@ -171,7 +171,7 @@ std::streamsize Win32FileStreambuf::xsputn(const char* s, std::streamsize count) while (count > totalBytesWritten) { DWORD bytesWritten; - if (!WriteFile(_fileHandle, s, count - totalBytesWritten, &bytesWritten, NULL)) { + if (!WriteFile(_fileHandle, s, count - totalBytesWritten, &bytesWritten, nullptr)) { break; } diff --git a/src/mongo/platform/posix_fadvise.cpp b/src/mongo/platform/posix_fadvise.cpp index cd4ed2c9ddb..689d5de94b0 100644 --- a/src/mongo/platform/posix_fadvise.cpp +++ b/src/mongo/platform/posix_fadvise.cpp @@ -57,7 +57,7 @@ int posix_fadvise(int fd, off_t offset, off_t len, int advice) { MONGO_INITIALIZER_GENERAL(SolarisPosixFadvise, MONGO_NO_PREREQUISITES, ("default")) (InitializerContext* context) { void* functionAddress = dlsym(RTLD_DEFAULT, "posix_fadvise"); - if (functionAddress != NULL) { + if (functionAddress != nullptr) { mongo::pal::posix_fadvise_switcher = reinterpret_cast<mongo::pal::PosixFadviseFunc>(functionAddress); } diff --git a/src/mongo/platform/strcasestr.cpp b/src/mongo/platform/strcasestr.cpp index eacf9fc0773..a9c5a9ce09d 100644 --- a/src/mongo/platform/strcasestr.cpp +++ b/src/mongo/platform/strcasestr.cpp @@ -71,7 +71,7 @@ const char* STRCASESTR_EMULATION_NAME(const char* haystack, const char* needle) // If not found, return NULL const char* haystackLowerStart = haystackLower.c_str(); const char* location = strstr(haystackLowerStart, needleLower.c_str()); - return location ? (haystack + (location - haystackLowerStart)) : NULL; + return location ? (haystack + (location - haystackLowerStart)) : nullptr; } #if defined(__sun) @@ -99,7 +99,7 @@ namespace mongo { MONGO_INITIALIZER_GENERAL(SolarisStrCaseCmp, MONGO_NO_PREREQUISITES, ("default")) (InitializerContext* context) { void* functionAddress = dlsym(RTLD_DEFAULT, "strcasestr"); - if (functionAddress != NULL) { + if (functionAddress != nullptr) { mongo::pal::strcasestr_switcher = reinterpret_cast<mongo::pal::StrCaseStrFunc>(functionAddress); } diff --git a/src/mongo/shell/dbshell.cpp b/src/mongo/shell/dbshell.cpp index 4282d05a525..1a5018cf499 100644 --- a/src/mongo/shell/dbshell.cpp +++ b/src/mongo/shell/dbshell.cpp @@ -780,7 +780,7 @@ int _main(int argc, char* argv[], char** envp) { rcGlobalLocation = "/etc/mongorc.js"; #else wchar_t programDataPath[MAX_PATH]; - if (S_OK == SHGetFolderPathW(NULL, CSIDL_COMMON_APPDATA, NULL, 0, programDataPath)) { + if (S_OK == SHGetFolderPathW(nullptr, CSIDL_COMMON_APPDATA, nullptr, 0, programDataPath)) { rcGlobalLocation = str::stream() << toUtf8String(programDataPath) << "\\MongoDB\\mongorc.js"; } @@ -861,7 +861,7 @@ int _main(int argc, char* argv[], char** envp) { if (getenv("HOME") != nullptr) rcLocation = str::stream() << getenv("HOME") << "/.mongorc.js"; #else - if (getenv("HOMEDRIVE") != NULL && getenv("HOMEPATH") != NULL) + if (getenv("HOMEDRIVE") != nullptr && getenv("HOMEPATH") != nullptr) rcLocation = str::stream() << toUtf8String(_wgetenv(L"HOMEDRIVE")) << toUtf8String(_wgetenv(L"HOMEPATH")) << "\\.mongorc.js"; diff --git a/src/mongo/shell/linenoise.cpp b/src/mongo/shell/linenoise.cpp index f4fdc340e79..501103aae4a 100644 --- a/src/mongo/shell/linenoise.cpp +++ b/src/mongo/shell/linenoise.cpp @@ -2792,7 +2792,7 @@ mongo::Status linenoiseHistorySave(const char* filename) { } #else fp = fopen(filename, "wt"); - if (fp == NULL) { + if (fp == nullptr) { const auto ewd = mongo::errnoWithDescription(); return linenoiseFileError(mongo::ErrorCodes::FileOpenFailed, "fopen()", filename, ewd); } diff --git a/src/mongo/shell/shell_utils_launcher.cpp b/src/mongo/shell/shell_utils_launcher.cpp index c25acf297f7..60a78f9a38d 100644 --- a/src/mongo/shell/shell_utils_launcher.cpp +++ b/src/mongo/shell/shell_utils_launcher.cpp @@ -911,7 +911,7 @@ inline void kill_wrapper(ProcessId pid, int sig, int port, const BSONObj& opt) { std::string eventName = getShutdownSignalName(pid.asUInt32()); HANDLE event = OpenEventA(EVENT_MODIFY_STATE, FALSE, eventName.c_str()); - if (event == NULL) { + if (event == nullptr) { int gle = GetLastError(); if (gle != ERROR_FILE_NOT_FOUND) { const auto ewd = errnoWithDescription(); diff --git a/src/mongo/util/concurrency/spin_lock.cpp b/src/mongo/util/concurrency/spin_lock.cpp index d797d3cb762..cbd72e9f9d6 100644 --- a/src/mongo/util/concurrency/spin_lock.cpp +++ b/src/mongo/util/concurrency/spin_lock.cpp @@ -69,7 +69,7 @@ void SpinLock::_lockSlowPath() { t.tv_nsec = 5000000; while (!_tryLock()) { - nanosleep(&t, NULL); + nanosleep(&t, nullptr); } } diff --git a/src/mongo/util/exception_filter_win32.cpp b/src/mongo/util/exception_filter_win32.cpp index dfb631b1196..5f404d2bf8a 100644 --- a/src/mongo/util/exception_filter_win32.cpp +++ b/src/mongo/util/exception_filter_win32.cpp @@ -60,7 +60,7 @@ namespace { void doMinidumpWithException(struct _EXCEPTION_POINTERS* exceptionInfo) { WCHAR moduleFileName[MAX_PATH]; - DWORD ret = GetModuleFileNameW(NULL, &moduleFileName[0], ARRAYSIZE(moduleFileName)); + DWORD ret = GetModuleFileNameW(nullptr, &moduleFileName[0], ARRAYSIZE(moduleFileName)); if (ret == 0) { int gle = GetLastError(); log() << "GetModuleFileName failed " << errnoWithDescription(gle); @@ -69,7 +69,7 @@ void doMinidumpWithException(struct _EXCEPTION_POINTERS* exceptionInfo) { wcscpy_s(moduleFileName, L"mongo"); } else { WCHAR* dotStr = wcschr(&moduleFileName[0], L'.'); - if (dotStr != NULL) { + if (dotStr != nullptr) { *dotStr = L'\0'; } } @@ -85,7 +85,7 @@ void doMinidumpWithException(struct _EXCEPTION_POINTERS* exceptionInfo) { dumpName += L".mdmp"; HANDLE hFile = CreateFileW( - dumpName.c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + dumpName.c_str(), GENERIC_WRITE, 0, nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr); if (INVALID_HANDLE_VALUE == hFile) { DWORD lasterr = GetLastError(); log() << "failed to open minidump file " << toUtf8String(dumpName.c_str()) << " : " @@ -111,9 +111,9 @@ void doMinidumpWithException(struct _EXCEPTION_POINTERS* exceptionInfo) { GetCurrentProcessId(), hFile, miniDumpType, - exceptionInfo != NULL ? &aMiniDumpInfo : NULL, - NULL, - NULL); + exceptionInfo != nullptr ? &aMiniDumpInfo : nullptr, + nullptr, + nullptr); if (FALSE == bstatus) { DWORD lasterr = GetLastError(); log() << "failed to create minidump : " << errnoWithDescription(lasterr); diff --git a/src/mongo/util/file.cpp b/src/mongo/util/file.cpp index 6cb07dcba9b..9096a11b23e 100644 --- a/src/mongo/util/file.cpp +++ b/src/mongo/util/file.cpp @@ -66,9 +66,9 @@ File::~File() { intmax_t File::freeSpace(const std::string& path) { ULARGE_INTEGER avail; if (GetDiskFreeSpaceExW(toWideString(path.c_str()).c_str(), - &avail, // bytes available to caller - NULL, // ptr to returned total size - NULL)) { // ptr to returned total free + &avail, // bytes available to caller + nullptr, // ptr to returned total size + nullptr)) { // ptr to returned total free return avail.QuadPart; } DWORD dosError = GetLastError(); @@ -106,10 +106,10 @@ void File::open(const char* filename, bool readOnly, bool direct) { _handle = CreateFileW(toNativeString(filename).c_str(), // filename (readOnly ? 0 : GENERIC_WRITE) | GENERIC_READ, // desired access FILE_SHARE_WRITE | FILE_SHARE_READ, // share mode - NULL, // security + nullptr, // security OPEN_ALWAYS, // create or open FILE_ATTRIBUTE_NORMAL, // file attributes - NULL); // template + nullptr); // template _bad = !is_open(); if (_bad) { DWORD dosError = GetLastError(); @@ -121,7 +121,7 @@ void File::open(const char* filename, bool readOnly, bool direct) { void File::read(fileofs o, char* data, unsigned len) { LARGE_INTEGER li; li.QuadPart = o; - if (SetFilePointerEx(_handle, li, NULL, FILE_BEGIN) == 0) { + if (SetFilePointerEx(_handle, li, nullptr, FILE_BEGIN) == 0) { _bad = true; DWORD dosError = GetLastError(); log() << "In File::read(), SetFilePointerEx for '" << _name @@ -154,7 +154,7 @@ void File::truncate(fileofs size) { } LARGE_INTEGER li; li.QuadPart = size; - if (SetFilePointerEx(_handle, li, NULL, FILE_BEGIN) == 0) { + if (SetFilePointerEx(_handle, li, nullptr, FILE_BEGIN) == 0) { _bad = true; DWORD dosError = GetLastError(); log() << "In File::truncate(), SetFilePointerEx for '" << _name @@ -173,7 +173,7 @@ void File::truncate(fileofs size) { void File::write(fileofs o, const char* data, unsigned len) { LARGE_INTEGER li; li.QuadPart = o; - if (SetFilePointerEx(_handle, li, NULL, FILE_BEGIN) == 0) { + if (SetFilePointerEx(_handle, li, nullptr, FILE_BEGIN) == 0) { _bad = true; DWORD dosError = GetLastError(); log() << "In File::write(), SetFilePointerEx for '" << _name @@ -182,7 +182,7 @@ void File::write(fileofs o, const char* data, unsigned len) { return; } DWORD bytesWritten; - if (WriteFile(_handle, data, len, &bytesWritten, NULL) == 0) { + if (WriteFile(_handle, data, len, &bytesWritten, nullptr) == 0) { _bad = true; DWORD dosError = GetLastError(); log() << "In File::write(), WriteFile for '" << _name << "' tried to write " << len diff --git a/src/mongo/util/net/private/socket_poll.cpp b/src/mongo/util/net/private/socket_poll.cpp index 28bfed452de..7726aa3c077 100644 --- a/src/mongo/util/net/private/socket_poll.cpp +++ b/src/mongo/util/net/private/socket_poll.cpp @@ -39,7 +39,7 @@ namespace mongo { typedef int(WSAAPI* WSAPollFunction)(pollfd* fdarray, ULONG nfds, INT timeout); -static WSAPollFunction wsaPollFunction = NULL; +static WSAPollFunction wsaPollFunction = nullptr; MONGO_INITIALIZER(DynamicLinkWin32Poll)(InitializerContext* context) { HINSTANCE wsaPollLib = LoadLibraryW(L"Ws2_32.dll"); @@ -51,7 +51,7 @@ MONGO_INITIALIZER(DynamicLinkWin32Poll)(InitializerContext* context) { } bool isPollSupported() { - return wsaPollFunction != NULL; + return wsaPollFunction != nullptr; } int socketPoll(pollfd* fdarray, unsigned long nfds, int timeout) { diff --git a/src/mongo/util/net/sock_test.cpp b/src/mongo/util/net/sock_test.cpp index bb246175eef..d9b3ec8ee84 100644 --- a/src/mongo/util/net/sock_test.cpp +++ b/src/mongo/util/net/sock_test.cpp @@ -62,7 +62,7 @@ SocketPair socketPair(const int type, const int protocol = 0); namespace detail { void awaitAccept(SOCKET* acceptSock, SOCKET listenSock, Notification<void>& notify) { *acceptSock = INVALID_SOCKET; - const SOCKET result = ::accept(listenSock, NULL, 0); + const SOCKET result = ::accept(listenSock, nullptr, 0); if (result != INVALID_SOCKET) { *acceptSock = result; } @@ -98,7 +98,7 @@ SocketPair socketPair(const int type, const int protocol) { hints.ai_socktype = type; hints.ai_flags = AI_PASSIVE; - int result = ::getaddrinfo(NULL, "0", &hints, &res); + int result = ::getaddrinfo(nullptr, "0", &hints, &res); if (result != 0) { closesocket(listenSock); return SocketPair(); @@ -135,7 +135,7 @@ SocketPair socketPair(const int type, const int protocol) { connectHints.ai_socktype = type; std::stringstream portStream; portStream << ntohs(bindAddr.sin_port); - result = ::getaddrinfo(NULL, portStream.str().c_str(), &connectHints, &connectRes); + result = ::getaddrinfo(nullptr, portStream.str().c_str(), &connectHints, &connectRes); if (result != 0) { closesocket(listenSock); ::freeaddrinfo(res); diff --git a/src/mongo/util/net/ssl_manager_openssl.cpp b/src/mongo/util/net/ssl_manager_openssl.cpp index 3c178b9f0b2..e716aacf584 100644 --- a/src/mongo/util/net/ssl_manager_openssl.cpp +++ b/src/mongo/util/net/ssl_manager_openssl.cpp @@ -184,7 +184,7 @@ bool enableECDHE(SSL_CTX* const ctx) { // this call could actually enable auto ecdh. We also ensure the OpenSSL version is sufficiently // old to protect against future versions where SSL_CTX_set_ecdh_auto could be removed and 94 // ctrl code could be repurposed. - if (SSL_CTX_ctrl(ctx, 94, 1, NULL) != 1) { + if (SSL_CTX_ctrl(ctx, 94, 1, nullptr) != 1) { // If manually setting the configuration option failed, use a hard coded curve if (!useDefaultECKey(ctx)) { warning() << "Failed to enable ECDHE due to a lack of support from system libraries."; @@ -1206,20 +1206,20 @@ Status importCertStoreToX509_STORE(const wchar_t* storeName, X509_STORE* verifyStore) { HCERTSTORE systemStore = CertOpenStore(CERT_STORE_PROV_SYSTEM_W, 0, - NULL, + nullptr, storeLocation | CERT_STORE_READONLY_FLAG, const_cast<LPWSTR>(storeName)); - if (systemStore == NULL) { + if (systemStore == nullptr) { return {ErrorCodes::InvalidSSLConfiguration, str::stream() << "error opening system CA store: " << errnoWithDescription()}; } auto systemStoreGuard = makeGuard([systemStore]() { CertCloseStore(systemStore, 0); }); - PCCERT_CONTEXT certCtx = NULL; - while ((certCtx = CertEnumCertificatesInStore(systemStore, certCtx)) != NULL) { + PCCERT_CONTEXT certCtx = nullptr; + while ((certCtx = CertEnumCertificatesInStore(systemStore, certCtx)) != nullptr) { auto certBytes = static_cast<const unsigned char*>(certCtx->pbCertEncoded); - X509* x509Obj = d2i_X509(NULL, &certBytes, certCtx->cbCertEncoded); - if (x509Obj == NULL) { + X509* x509Obj = d2i_X509(nullptr, &certBytes, certCtx->cbCertEncoded); + if (x509Obj == nullptr) { return {ErrorCodes::InvalidSSLConfiguration, str::stream() << "Error parsing X509 object from Windows certificate store" << SSLManagerInterface::getSSLErrorMessage(ERR_get_error())}; diff --git a/src/mongo/util/ntservice.cpp b/src/mongo/util/ntservice.cpp index 11eba4b9d72..c5133a9c99a 100644 --- a/src/mongo/util/ntservice.cpp +++ b/src/mongo/util/ntservice.cpp @@ -57,9 +57,9 @@ namespace mongo { namespace ntservice { namespace { bool _startService = false; -SERVICE_STATUS_HANDLE _statusHandle = NULL; +SERVICE_STATUS_HANDLE _statusHandle = nullptr; wstring _serviceName; -ServiceCallback _serviceCallback = NULL; +ServiceCallback _serviceCallback = nullptr; } // namespace static void installServiceOrDie(const wstring& serviceName, @@ -279,19 +279,19 @@ void installServiceOrDie(const wstring& serviceName, std::vector<std::string> serviceArgv = constructServiceArgv(argv); char exePath[1024]; - GetModuleFileNameA(NULL, exePath, sizeof exePath); + GetModuleFileNameA(nullptr, exePath, sizeof exePath); serviceArgv.at(0) = exePath; std::string commandLine = constructUtf8WindowsCommandLine(serviceArgv); - SC_HANDLE schSCManager = ::OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS); - if (schSCManager == NULL) { + SC_HANDLE schSCManager = ::OpenSCManager(nullptr, nullptr, SC_MANAGER_ALL_ACCESS); + if (schSCManager == nullptr) { DWORD err = ::GetLastError(); log() << "Error connecting to the Service Control Manager: " << windows::GetErrMsg(err); quickExit(EXIT_NTSERVICE_ERROR); } - SC_HANDLE schService = NULL; + SC_HANDLE schService = nullptr; int retryCount = 10; while (true) { @@ -299,7 +299,7 @@ void installServiceOrDie(const wstring& serviceName, // TODO: Check to see if service is in "Deleting" status, suggest the user close down // Services MMC snap-ins. schService = ::OpenService(schSCManager, serviceName.c_str(), SERVICE_ALL_ACCESS); - if (schService != NULL) { + if (schService != nullptr) { log() << "There is already a service named '" << toUtf8String(serviceName) << (retryCount > 0 ? "', sleeping and retrying" : "', aborting"); ::CloseServiceHandle(schService); @@ -329,12 +329,12 @@ void installServiceOrDie(const wstring& serviceName, SERVICE_AUTO_START, // start type SERVICE_ERROR_NORMAL, // error control commandLineWide.c_str(), // command line - NULL, // load order group - NULL, // tag id + nullptr, // load order group + nullptr, // tag id L"\0\0", // dependencies - NULL, // user account - NULL); // user account password - if (schService == NULL) { + nullptr, // user account + nullptr); // user account password + if (schService == nullptr) { DWORD err = ::GetLastError(); log() << "Error creating service: " << windows::GetErrMsg(err); ::CloseServiceHandle(schSCManager); @@ -364,13 +364,13 @@ void installServiceOrDie(const wstring& serviceName, SERVICE_NO_CHANGE, // service type SERVICE_NO_CHANGE, // start type SERVICE_NO_CHANGE, // error control - NULL, // path - NULL, // load order group - NULL, // tag id - NULL, // dependencies + nullptr, // path + nullptr, // load order group + nullptr, // tag id + nullptr, // dependencies actualServiceUser.c_str(), // user account servicePassword.c_str(), // user account password - NULL); // service display name + nullptr); // service display name if (!serviceInstalled) { log() << "Setting service login failed, service has 'LocalService' permissions"; } @@ -438,15 +438,15 @@ void installServiceOrDie(const wstring& serviceName, void removeServiceOrDie(const wstring& serviceName) { log() << "Trying to remove Windows service '" << toUtf8String(serviceName) << "'"; - SC_HANDLE schSCManager = ::OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS); - if (schSCManager == NULL) { + SC_HANDLE schSCManager = ::OpenSCManager(nullptr, nullptr, SC_MANAGER_ALL_ACCESS); + if (schSCManager == nullptr) { DWORD err = ::GetLastError(); log() << "Error connecting to the Service Control Manager: " << windows::GetErrMsg(err); quickExit(EXIT_NTSERVICE_ERROR); } SC_HANDLE schService = ::OpenService(schSCManager, serviceName.c_str(), SERVICE_ALL_ACCESS); - if (schService == NULL) { + if (schService == nullptr) { log() << "Could not find a service named '" << toUtf8String(serviceName) << "' to remove"; ::CloseServiceHandle(schSCManager); quickExit(EXIT_NTSERVICE_ERROR); @@ -484,7 +484,7 @@ void removeServiceOrDie(const wstring& serviceName) { } bool reportStatus(DWORD reportState, DWORD waitHint, DWORD exitCode) { - if (_statusHandle == NULL) + if (_statusHandle == nullptr) return false; static DWORD checkPoint = 1; @@ -551,7 +551,7 @@ static void serviceStop() { } static void WINAPI initService(DWORD argc, LPTSTR* argv) { - _statusHandle = RegisterServiceCtrlHandlerEx(_serviceName.c_str(), serviceCtrl, NULL); + _statusHandle = RegisterServiceCtrlHandlerEx(_serviceName.c_str(), serviceCtrl, nullptr); if (!_statusHandle) return; @@ -615,7 +615,7 @@ void startService() { SERVICE_TABLE_ENTRYW dispTable[] = { {const_cast<LPWSTR>(_serviceName.c_str()), (LPSERVICE_MAIN_FUNCTION)initService}, - {NULL, NULL}}; + {nullptr, nullptr}}; log() << "Trying to start Windows service '" << toUtf8String(_serviceName) << "'"; if (StartServiceCtrlDispatcherW(dispTable)) { diff --git a/src/mongo/util/processinfo_osx.cpp b/src/mongo/util/processinfo_osx.cpp index a11a8a5974a..0ed7de3a1f9 100644 --- a/src/mongo/util/processinfo_osx.cpp +++ b/src/mongo/util/processinfo_osx.cpp @@ -145,11 +145,11 @@ Variant getSysctlByName(const char* sysctlName) { // NB: sysctlbyname is called once to determine the buffer length, and once to copy // the sysctl value. Retry if the buffer length grows between calls. do { - status = sysctlbyname(sysctlName, NULL, &len, NULL, 0); + status = sysctlbyname(sysctlName, nullptr, &len, nullptr, 0); if (status == -1) break; value.resize(len); - status = sysctlbyname(sysctlName, &*value.begin(), &len, NULL, 0); + status = sysctlbyname(sysctlName, &*value.begin(), &len, nullptr, 0); } while (status == -1 && errno == ENOMEM); if (status == -1) { // unrecoverable error from sysctlbyname @@ -168,7 +168,7 @@ template <> long long getSysctlByName<NumberVal>(const char* sysctlName) { long long value = 0; size_t len = sizeof(value); - if (sysctlbyname(sysctlName, &value, &len, NULL, 0) < 0) { + if (sysctlbyname(sysctlName, &value, &len, nullptr, 0) < 0) { log() << "Unable to resolve sysctl " << sysctlName << " (number) "; } if (len > 8) { diff --git a/src/mongo/util/signal_handlers.cpp b/src/mongo/util/signal_handlers.cpp index f6f81234c11..2f361b363e5 100644 --- a/src/mongo/util/signal_handlers.cpp +++ b/src/mongo/util/signal_handlers.cpp @@ -131,8 +131,8 @@ BOOL WINAPI CtrlHandler(DWORD fdwCtrlType) { void eventProcessingThread() { std::string eventName = getShutdownSignalName(ProcessId::getCurrent().asUInt32()); - HANDLE event = CreateEventA(NULL, TRUE, FALSE, eventName.c_str()); - if (event == NULL) { + HANDLE event = CreateEventA(nullptr, TRUE, FALSE, eventName.c_str()); + if (event == nullptr) { warning() << "eventProcessingThread CreateEvent failed: " << errnoWithDescription(); return; } diff --git a/src/mongo/util/signal_handlers_synchronous.cpp b/src/mongo/util/signal_handlers_synchronous.cpp index 90b758d40fc..e1cd8371177 100644 --- a/src/mongo/util/signal_handlers_synchronous.cpp +++ b/src/mongo/util/signal_handlers_synchronous.cpp @@ -73,7 +73,7 @@ const char* strsignal(int signalNum) { } void endProcessWithSignal(int signalNum) { - RaiseException(EXIT_ABRUPT, EXCEPTION_NONCONTINUABLE, 0, NULL); + RaiseException(EXIT_ABRUPT, EXCEPTION_NONCONTINUABLE, 0, nullptr); } #else diff --git a/src/mongo/util/text.cpp b/src/mongo/util/text.cpp index df084ac1bae..f01ed7797a4 100644 --- a/src/mongo/util/text.cpp +++ b/src/mongo/util/text.cpp @@ -154,7 +154,7 @@ std::string toUtf8String(const std::wstring& wide) { // Calculate necessary buffer size int len = ::WideCharToMultiByte( - CP_UTF8, 0, wide.c_str(), static_cast<int>(wide.size()), NULL, 0, NULL, NULL); + CP_UTF8, 0, wide.c_str(), static_cast<int>(wide.size()), nullptr, 0, nullptr, nullptr); // Perform actual conversion if (len > 0) { @@ -165,8 +165,8 @@ std::string toUtf8String(const std::wstring& wide) { static_cast<int>(wide.size()), &buffer[0], static_cast<int>(buffer.size()), - NULL, - NULL); + nullptr, + nullptr); if (len > 0) { verify(len == static_cast<int>(buffer.size())); return std::string(&buffer[0], buffer.size()); @@ -182,7 +182,7 @@ std::wstring toWideString(const char* utf8String) { 0, // Flags utf8String, // Input string -1, // Count, -1 for NUL-terminated - NULL, // No output buffer + nullptr, // No output buffer 0 // Zero means "compute required size" ); if (bufferSize == 0) { @@ -212,7 +212,7 @@ bool writeUtf8ToWindowsConsole(const char* utf8String, unsigned int utf8StringSi 0, // Flags utf8String, // Input string utf8StringSize, // Input string length - NULL, // No output buffer + nullptr, // No output buffer 0 // Zero means "compute required size" ); if (bufferSize == 0) { @@ -240,7 +240,7 @@ bool writeUtf8ToWindowsConsole(const char* utf8String, unsigned int utf8StringSi utf16Pointer, numberOfCharactersThisPass, &numberOfCharactersWritten, - NULL); + nullptr); if (0 == success) { DWORD dosError = GetLastError(); static bool errorMessageShown = false; @@ -265,7 +265,7 @@ bool writeUtf8ToWindowsConsole(const char* utf8String, unsigned int utf8StringSi } WindowsCommandLine::WindowsCommandLine(int argc, wchar_t* argvW[], wchar_t* envpW[]) - : _argv(NULL), _envp(NULL) { + : _argv(nullptr), _envp(nullptr) { // Construct UTF-8 copy of arguments std::vector<std::string> utf8args; std::vector<size_t> utf8argLength; @@ -307,7 +307,7 @@ WindowsCommandLine::WindowsCommandLine(int argc, wchar_t* argvW[], wchar_t* envp strcpy_s(_envp[i], utf8envLength[i], utf8envs[i].c_str()); blockPtr += utf8envLength[i]; } - _envp[i] = NULL; + _envp[i] = nullptr; } WindowsCommandLine::~WindowsCommandLine() { diff --git a/src/mongo/util/text_test.cpp b/src/mongo/util/text_test.cpp index 77d6561e795..cee02a05c19 100644 --- a/src/mongo/util/text_test.cpp +++ b/src/mongo/util/text_test.cpp @@ -56,16 +56,17 @@ TEST(WindowsCommandLineConstruction, EmptyCommandLine) { } TEST(WindowsCommandLineConstruction, NothingToQuote) { - ASSERT_EQUALS("abc d \"\" e", constructUtf8WindowsCommandLine(svec("abc", "d", "", "e", NULL))); + ASSERT_EQUALS("abc d \"\" e", + constructUtf8WindowsCommandLine(svec("abc", "d", "", "e", nullptr))); } TEST(WindowsCommandLineConstruction, ThingsToQuote) { ASSERT_EQUALS("a\\\\\\b \"de fg\" h", - constructUtf8WindowsCommandLine(svec("a\\\\\\b", "de fg", "h", NULL))); + constructUtf8WindowsCommandLine(svec("a\\\\\\b", "de fg", "h", nullptr))); ASSERT_EQUALS("\"a\\\\b c\" d e", - constructUtf8WindowsCommandLine(svec("a\\\\b c", "d", "e", NULL))); - ASSERT_EQUALS("\"a \\\\\" \\", constructUtf8WindowsCommandLine(svec("a \\", "\\", NULL))); - ASSERT_EQUALS("\"\\\\\\\\\\\"\"", constructUtf8WindowsCommandLine(svec("\\\\\"", NULL))); + constructUtf8WindowsCommandLine(svec("a\\\\b c", "d", "e", nullptr))); + ASSERT_EQUALS("\"a \\\\\" \\", constructUtf8WindowsCommandLine(svec("a \\", "\\", nullptr))); + ASSERT_EQUALS("\"\\\\\\\\\\\"\"", constructUtf8WindowsCommandLine(svec("\\\\\"", nullptr))); } TEST(WindowsCommandLineConstruction, RegressionSERVER_7252) { @@ -88,5 +89,5 @@ TEST(WindowsCommandLineConstruction, RegressionSERVER_7252) { "C:\\mongo\\logs\\mongo_config.log.txt", "--configsvr", "--service", - NULL))); + nullptr))); } diff --git a/src/mongo/util/time_support.cpp b/src/mongo/util/time_support.cpp index b40ebcb19ee..77277b56cb2 100644 --- a/src/mongo/util/time_support.cpp +++ b/src/mongo/util/time_support.cpp @@ -874,7 +874,7 @@ static unsigned long long resyncTime() { unsigned long long curTimeMicros64() { // Windows 8/2012 & later support a <1us time function - if (GetSystemTimePreciseAsFileTimeFunc != NULL) { + if (GetSystemTimePreciseAsFileTimeFunc != nullptr) { FILETIME time; GetSystemTimePreciseAsFileTimeFunc(&time); return fileTimeToMicroseconds(time); diff --git a/src/mongo/util/winutil.h b/src/mongo/util/winutil.h index bab5d8256a7..f6ef4592e23 100644 --- a/src/mongo/util/winutil.h +++ b/src/mongo/util/winutil.h @@ -50,12 +50,12 @@ namespace windows { inline std::string GetErrMsg(DWORD err) { LPTSTR errMsg; ::FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, - NULL, + nullptr, err, 0, (LPTSTR)&errMsg, 0, - NULL); + nullptr); std::string errMsgStr = toUtf8String(errMsg); ::LocalFree(errMsg); // FormatMessage() appends a newline to the end of error messages, we trim it because std::endl |