refactor: replace remaining NULL with nullptr (#40053)

refactor: use nullptr everywhere
This commit is contained in:
Milan Burda 2023-10-03 21:26:35 +02:00 committed by GitHub
parent 9d0e6d09f0
commit 04b2ba84cd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
34 changed files with 98 additions and 93 deletions

View file

@ -114,8 +114,8 @@ base::win::ScopedHICON ReadICOFromPath(int size, const base::FilePath& path) {
// Load the icon from file.
return base::win::ScopedHICON(
static_cast<HICON>(LoadImage(NULL, image_path.value().c_str(), IMAGE_ICON,
size, size, LR_LOADFROMFILE)));
static_cast<HICON>(LoadImage(nullptr, image_path.value().c_str(),
IMAGE_ICON, size, size, LR_LOADFROMFILE)));
}
#endif
@ -214,7 +214,7 @@ HICON NativeImage::GetHICON(int size) {
// Then convert the image to ICO.
if (image_.IsEmpty())
return NULL;
return nullptr;
auto& hicon = hicons_[size];
hicon = IconUtil::CreateHICONFromSkBitmap(image_.AsBitmap());

View file

@ -62,7 +62,7 @@ v8::Local<v8::Promise> NativeImage::CreateThumbnailFromPath(
hr = pThumbnailCache->GetThumbnail(
pItem.Get(), size.width(),
WTS_FLAGS::WTS_SCALETOREQUESTEDSIZE | WTS_FLAGS::WTS_SCALEUP, &pThumbnail,
NULL, NULL);
nullptr, nullptr);
if (FAILED(hr)) {
promise.RejectWithErrorMessage(
@ -71,7 +71,7 @@ v8::Local<v8::Promise> NativeImage::CreateThumbnailFromPath(
}
// Init HBITMAP
HBITMAP hBitmap = NULL;
HBITMAP hBitmap = nullptr;
hr = pThumbnail->GetSharedBitmap(&hBitmap);
if (FAILED(hr)) {
promise.RejectWithErrorMessage("Failed to extract bitmap from thumbnail");

View file

@ -15,9 +15,9 @@ struct Converter<electron::NativeWindow*> {
static bool FromV8(v8::Isolate* isolate,
v8::Local<v8::Value> val,
electron::NativeWindow** out) {
// null would be transferred to NULL.
// null would be transferred to nullptr.
if (val->IsNull()) {
*out = NULL;
*out = nullptr;
return true;
}

View file

@ -25,7 +25,8 @@ NodeBindingsWin::NodeBindingsWin(BrowserEnvironment browser_env)
if (event_loop->iocp && event_loop->iocp != INVALID_HANDLE_VALUE)
CloseHandle(event_loop->iocp);
event_loop->iocp = CreateIoCompletionPort(INVALID_HANDLE_VALUE, NULL, 0, 2);
event_loop->iocp =
CreateIoCompletionPort(INVALID_HANDLE_VALUE, nullptr, 0, 2);
}
}
@ -44,7 +45,7 @@ void NodeBindingsWin::PollEvents() {
timeout);
// Give the event back so libuv can deal with it.
if (overlapped != NULL)
if (overlapped != nullptr)
PostQueuedCompletionStatus(event_loop->iocp, bytes, key, overlapped);
}

View file

@ -34,9 +34,9 @@ std::string OpenURL(NSURL* ns_url, bool activate) {
CFURLRef ref =
LSCopyDefaultApplicationURLForURL(cf_url, kLSRolesAll, nullptr);
// If no application could be found, NULL is returned and outError
// (if not NULL) is populated with kLSApplicationNotFoundErr.
if (ref == NULL)
// If no application could be found, nullptr is returned and outError
// (if not nullptr) is populated with kLSApplicationNotFoundErr.
if (ref == nullptr)
return "No application in the Launch Services database matches the input "
"criteria.";
@ -72,7 +72,7 @@ std::string OpenPathOnThread(const base::FilePath& full_path) {
withAppBundleIdentifier:nil
options:launch_options
additionalEventParamDescriptor:nil
launchIdentifiers:NULL];
launchIdentifiers:nil];
return success ? "" : "Failed to open path";
}

View file

@ -117,7 +117,7 @@ HRESULT DeleteFileProgressSink::PreDeleteItem(DWORD dwFlags, IShellItem*) {
}
HRESULT DeleteFileProgressSink::QueryInterface(REFIID riid, LPVOID* ppvObj) {
// Always set out parameter to NULL, validating it first.
// Always set out parameter to nullptr, validating it first.
if (!ppvObj)
return E_INVALIDARG;
*ppvObj = nullptr;
@ -285,16 +285,16 @@ void ShowItemInFolderOnWorkerThread(const base::FilePath& full_path) {
return;
base::win::ScopedCoMem<ITEMIDLIST> dir_item;
hr = desktop->ParseDisplayName(NULL, NULL,
hr = desktop->ParseDisplayName(nullptr, nullptr,
const_cast<wchar_t*>(dir.value().c_str()),
NULL, &dir_item, NULL);
nullptr, &dir_item, nullptr);
if (FAILED(hr))
return;
base::win::ScopedCoMem<ITEMIDLIST> file_item;
hr = desktop->ParseDisplayName(
NULL, NULL, const_cast<wchar_t*>(full_path.value().c_str()), NULL,
&file_item, NULL);
nullptr, nullptr, const_cast<wchar_t*>(full_path.value().c_str()),
nullptr, &file_item, nullptr);
if (FAILED(hr))
return;
@ -305,7 +305,8 @@ void ShowItemInFolderOnWorkerThread(const base::FilePath& full_path) {
// found" even though the file is there. In these cases, ShellExecute()
// seems to work as a fallback (although it won't select the file).
if (hr == ERROR_FILE_NOT_FOUND) {
ShellExecute(NULL, L"open", dir.value().c_str(), NULL, NULL, SW_SHOW);
ShellExecute(nullptr, L"open", dir.value().c_str(), nullptr, nullptr,
SW_SHOW);
} else {
LOG(WARNING) << " " << __func__ << "(): Can't open full_path = \""
<< full_path.value() << "\""
@ -380,7 +381,7 @@ bool MoveItemToTrashWithError(const base::FilePath& path,
// Create an IShellItem from the supplied source path.
Microsoft::WRL::ComPtr<IShellItem> delete_item;
if (FAILED(SHCreateItemFromParsingName(path.value().c_str(), NULL,
if (FAILED(SHCreateItemFromParsingName(path.value().c_str(), nullptr,
IID_PPV_ARGS(&delete_item)))) {
*error = "Failed to parse path";
return false;
@ -433,8 +434,8 @@ bool GetFolderPath(int key, base::FilePath* result) {
switch (key) {
case electron::DIR_RECENT:
if (FAILED(SHGetFolderPath(NULL, CSIDL_RECENT, NULL, SHGFP_TYPE_CURRENT,
system_buffer))) {
if (FAILED(SHGetFolderPath(nullptr, CSIDL_RECENT, nullptr,
SHGFP_TYPE_CURRENT, system_buffer))) {
return false;
}
*result = base::FilePath(system_buffer);