Bug 784739 - Switch from NULL to nullptr in browser/metro. r=ehsan

This commit is contained in:
Birunthan Mohanathas 2013-08-21 12:13:50 -04:00
parent 43d038b169
commit 5e6d61b852
4 changed files with 73 additions and 61 deletions

View File

@ -23,7 +23,7 @@ Log(const wchar_t *fmt, ...)
#if !defined(SHOW_CONSOLE)
return;
#endif
va_list a = NULL;
va_list a = nullptr;
wchar_t szDebugString[1024];
if(!lstrlenW(fmt))
return;
@ -34,8 +34,8 @@ Log(const wchar_t *fmt, ...)
return;
DWORD len;
WriteConsoleW(sCon, szDebugString, lstrlenW(szDebugString), &len, NULL);
WriteConsoleW(sCon, L"\n", 1, &len, NULL);
WriteConsoleW(sCon, szDebugString, lstrlenW(szDebugString), &len, nullptr);
WriteConsoleW(sCon, L"\n", 1, &len, nullptr);
if (IsDebuggerPresent()) {
OutputDebugStringW(szDebugString);
@ -53,7 +53,7 @@ SetupConsole()
int fd = _open_osfhandle(reinterpret_cast<intptr_t>(sCon), 0);
fp = _fdopen(fd, "w");
*stdout = *fp;
setvbuf(stdout, NULL, _IONBF, 0);
setvbuf(stdout, nullptr, _IONBF, 0);
}
#endif
@ -104,19 +104,19 @@ IsDX10Available()
CComPtr<ID3D10Device1> device;
// Try for DX10.1
if (FAILED(createD3DDevice(adapter1, D3D10_DRIVER_TYPE_HARDWARE, NULL,
if (FAILED(createD3DDevice(adapter1, D3D10_DRIVER_TYPE_HARDWARE, nullptr,
D3D10_CREATE_DEVICE_BGRA_SUPPORT |
D3D10_CREATE_DEVICE_PREVENT_INTERNAL_THREADING_OPTIMIZATIONS,
D3D10_FEATURE_LEVEL_10_1,
D3D10_1_SDK_VERSION, &device))) {
// Try for DX10
if (FAILED(createD3DDevice(adapter1, D3D10_DRIVER_TYPE_HARDWARE, NULL,
if (FAILED(createD3DDevice(adapter1, D3D10_DRIVER_TYPE_HARDWARE, nullptr,
D3D10_CREATE_DEVICE_BGRA_SUPPORT |
D3D10_CREATE_DEVICE_PREVENT_INTERNAL_THREADING_OPTIMIZATIONS,
D3D10_FEATURE_LEVEL_10_0,
D3D10_1_SDK_VERSION, &device))) {
// Try for DX9.3 (we fall back to cairo and cairo has support for D3D 9.3)
if (FAILED(createD3DDevice(adapter1, D3D10_DRIVER_TYPE_HARDWARE, NULL,
if (FAILED(createD3DDevice(adapter1, D3D10_DRIVER_TYPE_HARDWARE, nullptr,
D3D10_CREATE_DEVICE_BGRA_SUPPORT |
D3D10_CREATE_DEVICE_PREVENT_INTERNAL_THREADING_OPTIMIZATIONS,
D3D10_FEATURE_LEVEL_9_3,

View File

@ -49,7 +49,7 @@ static bool GetModulePath(CStringW& aPathBuffer)
WCHAR buffer[MAX_PATH];
memset(buffer, 0, sizeof(buffer));
if (!GetModuleFileName(NULL, buffer, MAX_PATH)) {
if (!GetModuleFileName(nullptr, buffer, MAX_PATH)) {
Log(L"GetModuleFileName failed.");
return false;
}
@ -68,7 +68,7 @@ template <class T>void SafeRelease(T **ppT)
{
if (*ppT) {
(*ppT)->Release();
*ppT = NULL;
*ppT = nullptr;
}
}
@ -89,8 +89,8 @@ public:
CExecuteCommandVerb() :
mRef(1),
mShellItemArray(NULL),
mUnkSite(NULL),
mShellItemArray(nullptr),
mUnkSite(nullptr),
mTargetIsFileSystemLink(false),
mTargetIsDefaultBrowser(false),
mTargetIsBrowser(false),
@ -176,9 +176,9 @@ public:
#ifdef SHOW_CONSOLE
Log(L"SetSelection param count: %d", count);
for (DWORD idx = 0; idx < count; idx++) {
IShellItem* item = NULL;
IShellItem* item = nullptr;
if (SUCCEEDED(aArray->GetItemAt(idx, &item))) {
LPWSTR str = NULL;
LPWSTR str = nullptr;
if (FAILED(item->GetDisplayName(SIGDN_FILESYSPATH, &str))) {
if (FAILED(item->GetDisplayName(SIGDN_URL, &str))) {
Log(L"Failed to get a shell item array item.");
@ -193,7 +193,7 @@ public:
}
#endif
IShellItem* item = NULL;
IShellItem* item = nullptr;
if (FAILED(aArray->GetItemAt(0, &item))) {
return E_FAIL;
}
@ -211,7 +211,7 @@ public:
IFACEMETHODIMP GetSelection(REFIID aRefID, void **aInt)
{
*aInt = NULL;
*aInt = nullptr;
return mShellItemArray ? mShellItemArray->QueryInterface(aRefID, aInt) : E_FAIL;
}
@ -235,7 +235,7 @@ public:
IFACEMETHODIMP GetSite(REFIID aRefID, void **aInt)
{
*aInt = NULL;
*aInt = nullptr;
return mUnkSite ? mUnkSite->QueryInterface(aRefID, aInt) : E_FAIL;
}
@ -252,14 +252,14 @@ public:
}
HRESULT hr;
IServiceProvider* pSvcProvider = NULL;
IServiceProvider* pSvcProvider = nullptr;
hr = mUnkSite->QueryInterface(IID_IServiceProvider, (void**)&pSvcProvider);
if (!pSvcProvider) {
Log(L"Couldn't get IServiceProvider service from explorer. (%X)", hr);
return S_OK;
}
IExecuteCommandHost* pHost = NULL;
IExecuteCommandHost* pHost = nullptr;
// If we can't get this it's a conventional desktop launch
hr = pSvcProvider->QueryService(SID_ExecuteCommandHost,
IID_IExecuteCommandHost, (void**)&pHost);
@ -340,7 +340,7 @@ public:
{
IApplicationAssociationRegistration* pAAR;
HRESULT hr = CoCreateInstance(CLSID_ApplicationAssociationRegistration,
NULL,
nullptr,
CLSCTX_INPROC,
IID_IApplicationAssociationRegistration,
(void**)&pAAR);
@ -416,7 +416,7 @@ static bool GetDefaultBrowserPath(CStringW& aPathBuffer)
if (FAILED(AssocQueryStringW(ASSOCF_NOTRUNCATE | ASSOCF_INIT_IGNOREUNKNOWN,
ASSOCSTR_EXECUTABLE,
kDefaultMetroBrowserIDPathKey, NULL,
kDefaultMetroBrowserIDPathKey, nullptr,
buffer, &length))) {
Log(L"AssocQueryString failed.");
return false;
@ -451,7 +451,7 @@ static bool GetDefaultBrowserAppModelID(WCHAR* aIDBuffer,
}
DWORD len = aCharLength * sizeof(WCHAR);
memset(aIDBuffer, 0, len);
if (RegQueryValueExW(key, L"AppUserModelID", NULL, NULL,
if (RegQueryValueExW(key, L"AppUserModelID", nullptr, nullptr,
(LPBYTE)aIDBuffer, &len) != ERROR_SUCCESS || !len) {
RegCloseKey(key);
return false;
@ -513,7 +513,7 @@ bool CExecuteCommandVerb::SetTargetPath(IShellItem* aItem)
CComPtr<IDataObject> object;
// Check the underlying data object first to insure we get
// absolute uri. See chromium bug 157184.
if (SUCCEEDED(aItem->BindToHandler(NULL, BHID_DataObject,
if (SUCCEEDED(aItem->BindToHandler(nullptr, BHID_DataObject,
IID_IDataObject,
reinterpret_cast<void**>(&object))) &&
GetPlainText(object, cstrText)) {
@ -537,7 +537,7 @@ bool CExecuteCommandVerb::SetTargetPath(IShellItem* aItem)
Log(L"No data object or data object has no text.");
// Use the shell item display name
LPWSTR str = NULL;
LPWSTR str = nullptr;
mTargetIsFileSystemLink = true;
if (FAILED(aItem->GetDisplayName(SIGDN_FILESYSPATH, &str))) {
mTargetIsFileSystemLink = false;
@ -596,12 +596,12 @@ void CExecuteCommandVerb::LaunchDesktopBrowser()
SHELLEXECUTEINFOW seinfo;
memset(&seinfo, 0, sizeof(seinfo));
seinfo.cbSize = sizeof(SHELLEXECUTEINFOW);
seinfo.fMask = NULL;
seinfo.hwnd = NULL;
seinfo.lpVerb = NULL;
seinfo.fMask = 0;
seinfo.hwnd = nullptr;
seinfo.lpVerb = nullptr;
seinfo.lpFile = browserPath;
seinfo.lpParameters = params;
seinfo.lpDirectory = NULL;
seinfo.lpDirectory = nullptr;
seinfo.nShow = SW_SHOWNORMAL;
ShellExecuteExW(&seinfo);
@ -635,9 +635,9 @@ IFACEMETHODIMP CExecuteCommandVerb::Execute()
}
// Launch into Metro
IApplicationActivationManager* activateMgr = NULL;
IApplicationActivationManager* activateMgr = nullptr;
DWORD processID;
if (FAILED(CoCreateInstance(CLSID_ApplicationActivationManager, NULL,
if (FAILED(CoCreateInstance(CLSID_ApplicationActivationManager, nullptr,
CLSCTX_LOCAL_SERVER,
IID_IApplicationActivationManager,
(void**)&activateMgr))) {
@ -657,7 +657,7 @@ IFACEMETHODIMP CExecuteCommandVerb::Execute()
// Hand off focus rights to the out-of-process activation server. Without
// this the metro interface won't launch.
hr = CoAllowSetForegroundWindow(activateMgr, NULL);
hr = CoAllowSetForegroundWindow(activateMgr, nullptr);
if (FAILED(hr)) {
Log(L"CoAllowSetForegroundWindow result %X", hr);
activateMgr->Release();
@ -727,7 +727,7 @@ ClassFactory::Register(CLSCTX aClass, REGCLS aUse)
STDMETHODIMP
ClassFactory::QueryInterface(REFIID riid, void **ppv)
{
IUnknown *punk = NULL;
IUnknown *punk = nullptr;
if (riid == IID_IUnknown || riid == IID_IClassFactory) {
punk = static_cast<IClassFactory*>(this);
}
@ -743,7 +743,7 @@ ClassFactory::QueryInterface(REFIID riid, void **ppv)
STDMETHODIMP
ClassFactory::CreateInstance(IUnknown *punkOuter, REFIID riid, void **ppv)
{
*ppv = NULL;
*ppv = nullptr;
if (punkOuter)
return CLASS_E_NOAGGREGATION;
return mUnkObject->QueryInterface(riid, ppv);
@ -771,7 +771,7 @@ int APIENTRY wWinMain(HINSTANCE, HINSTANCE, PWSTR pszCmdLine, int)
if (!wcslen(pszCmdLine) || StrStrI(pszCmdLine, L"-Embedding"))
{
CoInitialize(NULL);
CoInitialize(nullptr);
CExecuteCommandVerb *pHandler = new CExecuteCommandVerb();
if (!pHandler)
@ -784,13 +784,13 @@ int APIENTRY wWinMain(HINSTANCE, HINSTANCE, PWSTR pszCmdLine, int)
ClassFactory classFactory(ppi);
ppi->Release();
ppi = NULL;
ppi = nullptr;
// REGCLS_SINGLEUSE insures we only get used once and then discarded.
if (FAILED(classFactory.Register(CLSCTX_LOCAL_SERVER, REGCLS_SINGLEUSE)))
return -1;
if (!SetTimer(NULL, 1, HEARTBEAT_MSEC, NULL)) {
if (!SetTimer(nullptr, 1, HEARTBEAT_MSEC, nullptr)) {
Log(L"Failed to set timer, can't process request.");
return -1;
}

View File

@ -37,10 +37,13 @@ HRESULT
SetShortcutProps(LPCWSTR aShortcutPath, LPCWSTR aAppModelID, bool aSetID, bool aSetMode)
{
HRESULT hres;
::CoInitialize(NULL);
::CoInitialize(nullptr);
IPropertyStore *m_pps = NULL;
if (FAILED(hres = SHGetPropertyStoreFromParsingName(aShortcutPath, NULL, GPS_READWRITE, IID_PPV_ARGS(&m_pps)))) {
IPropertyStore *m_pps = nullptr;
if (FAILED(hres = SHGetPropertyStoreFromParsingName(aShortcutPath,
nullptr,
GPS_READWRITE,
IID_PPV_ARGS(&m_pps)))) {
printf("SHGetPropertyStoreFromParsingName failed\n");
goto Exit;
}
@ -79,10 +82,13 @@ HRESULT
PrintShortcutProps(LPCWSTR aTargetPath)
{
HRESULT hres;
::CoInitialize(NULL);
::CoInitialize(nullptr);
IPropertyStore *m_pps = NULL;
if (FAILED(hres = SHGetPropertyStoreFromParsingName(aTargetPath, NULL, GPS_READWRITE, IID_PPV_ARGS(&m_pps)))) {
IPropertyStore *m_pps = nullptr;
if (FAILED(hres = SHGetPropertyStoreFromParsingName(aTargetPath,
nullptr,
GPS_READWRITE,
IID_PPV_ARGS(&m_pps)))) {
printf("SHGetPropertyStoreFromParsingName failed\n");
goto Exit;
}
@ -125,9 +131,9 @@ CreateLink(LPCWSTR aTargetPath, LPCWSTR aShortcutPath, LPCWSTR aDescription)
wprintf(L"creating shortcut: '%s'\n", aShortcutPath);
CoInitialize(NULL);
CoInitialize(nullptr);
hres = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,
hres = CoCreateInstance(CLSID_ShellLink, nullptr, CLSCTX_INPROC_SERVER,
IID_IShellLink, (LPVOID*)&psl);
if (FAILED(hres)) {
CoUninitialize();
@ -140,7 +146,7 @@ CreateLink(LPCWSTR aTargetPath, LPCWSTR aShortcutPath, LPCWSTR aDescription)
psl->SetDescription(L"");
}
IPersistFile* ppf = NULL;
IPersistFile* ppf = nullptr;
hres = psl->QueryInterface(IID_IPersistFile, (LPVOID*)&ppf);
if (SUCCEEDED(hres)) {
@ -261,7 +267,9 @@ int wmain(int argc, WCHAR* argv[])
}
if (createShortcutFound) {
if (FAILED(hres = CreateLink(targetPathStr, shortcutPathStr, (descriptionFound ? descriptionStr : NULL)))) {
if (FAILED(hres = CreateLink(targetPathStr,
shortcutPathStr,
(descriptionFound ? descriptionStr : nullptr)))) {
printf("failed creating shortcut HRESULT=%X\n", hres);
return -1;
}
@ -275,7 +283,9 @@ int wmain(int argc, WCHAR* argv[])
}
if (appModelIDFound || modeFound) {
if (FAILED(hres = SetShortcutProps(target, (appModelIDFound ? appModelIDStr : NULL), appModelIDFound, modeFound))) {
if (FAILED(hres = SetShortcutProps(target,
(appModelIDFound ? appModelIDStr : nullptr),
appModelIDFound, modeFound))) {
printf("failed adding property HRESULT=%X\n", hres);
return -1;
}

View File

@ -50,7 +50,7 @@ CString sFirefoxPath;
static void Log(const wchar_t *fmt, ...)
{
va_list a = NULL;
va_list a = nullptr;
wchar_t szDebugString[1024];
if(!lstrlenW(fmt))
return;
@ -66,7 +66,7 @@ static void Log(const wchar_t *fmt, ...)
static void Fail(bool aRequestRetry, const wchar_t *fmt, ...)
{
va_list a = NULL;
va_list a = nullptr;
wchar_t szDebugString[1024];
if(!lstrlenW(fmt))
return;
@ -93,7 +93,7 @@ static bool GetModulePath(CStringW& aPathBuffer)
WCHAR buffer[MAX_PATH];
memset(buffer, 0, sizeof(buffer));
if (!GetModuleFileName(NULL, buffer, MAX_PATH)) {
if (!GetModuleFileName(nullptr, buffer, MAX_PATH)) {
Fail(false, L"GetModuleFileName failed.");
return false;
}
@ -145,7 +145,7 @@ static bool GetDefaultBrowserAppModelID(WCHAR* aIDBuffer,
}
DWORD len = aCharLength * sizeof(WCHAR);
memset(aIDBuffer, 0, len);
if (RegQueryValueExW(key, L"AppUserModelID", NULL, NULL,
if (RegQueryValueExW(key, L"AppUserModelID", nullptr, nullptr,
(LPBYTE)aIDBuffer, &len) != ERROR_SUCCESS || !len) {
RegCloseKey(key);
return false;
@ -174,7 +174,7 @@ static bool SetupTestOutputPipe()
SECURITY_ATTRIBUTES saAttr;
saAttr.nLength = sizeof(SECURITY_ATTRIBUTES);
saAttr.bInheritHandle = TRUE;
saAttr.lpSecurityDescriptor = NULL;
saAttr.lpSecurityDescriptor = nullptr;
gTestOutputPipe =
CreateNamedPipeW(L"\\\\.\\pipe\\metrotestharness",
@ -182,7 +182,7 @@ static bool SetupTestOutputPipe()
PIPE_TYPE_BYTE|PIPE_WAIT,
1,
PIPE_BUFFER_SIZE,
PIPE_BUFFER_SIZE, 0, NULL);
PIPE_BUFFER_SIZE, 0, nullptr);
if (gTestOutputPipe == INVALID_HANDLE_VALUE) {
Log(L"Failed to create named logging pipe.");
@ -194,7 +194,8 @@ static bool SetupTestOutputPipe()
static void ReadPipe()
{
DWORD numBytesRead;
while (ReadFile(gTestOutputPipe, buffer, PIPE_BUFFER_SIZE, &numBytesRead, NULL) &&
while (ReadFile(gTestOutputPipe, buffer, PIPE_BUFFER_SIZE,
&numBytesRead, nullptr) &&
numBytesRead) {
buffer[numBytesRead] = '\0';
printf("%s", buffer);
@ -209,7 +210,7 @@ static int Launch()
// The interface that allows us to activate the browser
CComPtr<IApplicationActivationManager> activateMgr;
if (FAILED(CoCreateInstance(CLSID_ApplicationActivationManager, NULL,
if (FAILED(CoCreateInstance(CLSID_ApplicationActivationManager, nullptr,
CLSCTX_LOCAL_SERVER,
IID_IApplicationActivationManager,
(void**)&activateMgr))) {
@ -229,7 +230,7 @@ static int Launch()
// Hand off focus rights if the terminal has focus to the out-of-process
// activation server (explorer.exe). Without this the metro interface
// won't launch.
hr = CoAllowSetForegroundWindow(activateMgr, NULL);
hr = CoAllowSetForegroundWindow(activateMgr, nullptr);
if (FAILED(hr)) {
// Log but don't fail. This has happened on vms with certain terminals run by
// QA during mozmill testing.
@ -264,7 +265,7 @@ static int Launch()
} else {
// Use the module path
char path[MAX_PATH];
if (!GetModuleFileNameA(NULL, path, MAX_PATH)) {
if (!GetModuleFileNameA(nullptr, path, MAX_PATH)) {
Fail(false, L"GetModuleFileNameA errorno=%d", GetLastError());
return FAILURE;
}
@ -289,9 +290,9 @@ static int Launch()
Log(L"Writing out tests.ini to: '%s'", CStringW(testFilePath));
HANDLE hTestFile = CreateFileA(testFilePath, GENERIC_WRITE,
0, NULL, CREATE_ALWAYS,
0, nullptr, CREATE_ALWAYS,
FILE_ATTRIBUTE_NORMAL,
NULL);
nullptr);
if (hTestFile == INVALID_HANDLE_VALUE) {
Fail(false, L"CreateFileA errorno=%d", GetLastError());
return FAILURE;
@ -306,7 +307,8 @@ static int Launch()
asciiParams += sAppParams;
asciiParams.Trim();
Log(L"Browser command line args: '%s'", CString(asciiParams));
if (!WriteFile(hTestFile, asciiParams, asciiParams.GetLength(), NULL, 0)) {
if (!WriteFile(hTestFile, asciiParams, asciiParams.GetLength(),
nullptr, 0)) {
CloseHandle(hTestFile);
Fail(false, L"WriteFile errorno=%d", GetLastError());
return FAILURE;
@ -347,7 +349,7 @@ static int Launch()
} else if (waitResult == WAIT_OBJECT_0 + 1) {
ReadPipe();
} else if (waitResult == WAIT_OBJECT_0 + 2 &&
PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
PeekMessage(&msg, nullptr, 0, 0, PM_REMOVE)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
@ -363,7 +365,7 @@ static int Launch()
int wmain(int argc, WCHAR* argv[])
{
CoInitialize(NULL);
CoInitialize(nullptr);
int idx;
bool firefoxParam = false;