From 50b0404404f89952a6167718d1f2c3a26dcccdf9 Mon Sep 17 00:00:00 2001 From: Birunthan Mohanathas Date: Thu, 10 Oct 2013 16:40:03 -0400 Subject: [PATCH] Bug 784739 - Switch from NULL to nullptr in toolkit/mozapps/; r=ehsan --- toolkit/mozapps/update/common/pathhash.cpp | 4 +- toolkit/mozapps/update/common/readstrings.cpp | 6 +- toolkit/mozapps/update/common/readstrings.h | 4 +- toolkit/mozapps/update/common/uachelper.cpp | 16 +- .../mozapps/update/common/updatehelper.cpp | 60 +++--- .../mozapps/update/common/updatelogging.cpp | 4 +- toolkit/mozapps/update/test/TestAUSHelper.cpp | 21 +- .../mozapps/update/updater/archivereader.cpp | 16 +- .../mozapps/update/updater/archivereader.h | 3 +- .../update/updater/automounter_gonk.cpp | 12 +- toolkit/mozapps/update/updater/loaddlls.cpp | 2 +- .../mozapps/update/updater/progressui_gtk.cpp | 6 +- .../mozapps/update/updater/progressui_win.cpp | 11 +- toolkit/mozapps/update/updater/updater.cpp | 188 +++++++++--------- toolkit/profile/nsToolkitProfileService.cpp | 2 +- 15 files changed, 183 insertions(+), 172 deletions(-) diff --git a/toolkit/mozapps/update/common/pathhash.cpp b/toolkit/mozapps/update/common/pathhash.cpp index f16aa710bfa6..5892e9b3074e 100644 --- a/toolkit/mozapps/update/common/pathhash.cpp +++ b/toolkit/mozapps/update/common/pathhash.cpp @@ -42,13 +42,13 @@ CalculateMD5(const char *data, DWORD dataSize, HCRYPTPROV hProv = 0; HCRYPTHASH hHash = 0; - if (!CryptAcquireContext(&hProv, NULL, NULL, PROV_RSA_FULL, 0)) { + if (!CryptAcquireContext(&hProv, nullptr, nullptr, PROV_RSA_FULL, 0)) { if (NTE_BAD_KEYSET != GetLastError()) { return FALSE; } // Maybe it doesn't exist, try to create it. - if (!CryptAcquireContext(&hProv, NULL, NULL, PROV_RSA_FULL, + if (!CryptAcquireContext(&hProv, nullptr, nullptr, PROV_RSA_FULL, CRYPT_NEWKEYSET)) { return FALSE; } diff --git a/toolkit/mozapps/update/common/readstrings.cpp b/toolkit/mozapps/update/common/readstrings.cpp index b6d7d1a44b4d..c838cce67f54 100644 --- a/toolkit/mozapps/update/common/readstrings.cpp +++ b/toolkit/mozapps/update/common/readstrings.cpp @@ -62,13 +62,13 @@ static char* NS_strtok(const char *delims, char **str) { if (!*str) - return NULL; + return nullptr; char *ret = (char*) NS_strspnp(delims, *str); if (!*ret) { *str = ret; - return NULL; + return nullptr; } char *i = ret; @@ -83,7 +83,7 @@ NS_strtok(const char *delims, char **str) ++i; } while (*i); - *str = NULL; + *str = nullptr; return ret; } diff --git a/toolkit/mozapps/update/common/readstrings.h b/toolkit/mozapps/update/common/readstrings.h index 1b1c252617f8..4be798730550 100644 --- a/toolkit/mozapps/update/common/readstrings.h +++ b/toolkit/mozapps/update/common/readstrings.h @@ -7,6 +7,8 @@ #ifndef READSTRINGS_H__ #define READSTRINGS_H__ +#include "mozilla/NullPtr.h" + #define MAX_TEXT_LEN 600 #ifdef XP_WIN @@ -38,6 +40,6 @@ int ReadStrings(const NS_tchar *path, const char *keyList, unsigned int numStrings, char results[][MAX_TEXT_LEN], - const char *section = NULL); + const char *section = nullptr); #endif // READSTRINGS_H__ diff --git a/toolkit/mozapps/update/common/uachelper.cpp b/toolkit/mozapps/update/common/uachelper.cpp index 301c3dfb230e..aaf9180c45c1 100644 --- a/toolkit/mozapps/update/common/uachelper.cpp +++ b/toolkit/mozapps/update/common/uachelper.cpp @@ -80,7 +80,7 @@ HANDLE UACHelper::OpenUserToken(DWORD sessionID) { HMODULE module = LoadLibraryW(L"wtsapi32.dll"); - HANDLE token = NULL; + HANDLE token = nullptr; LPWTSQueryUserToken wtsQueryUserToken = (LPWTSQueryUserToken)GetProcAddress(module, "WTSQueryUserToken"); if (wtsQueryUserToken) { @@ -94,7 +94,7 @@ UACHelper::OpenUserToken(DWORD sessionID) * Opens a linked token for the specified token. * * @param token The token to get the linked token from - * @return A linked token or NULL if one does not exist. + * @return A linked token or nullptr if one does not exist. * Caller should close the handle. */ HANDLE @@ -105,7 +105,7 @@ UACHelper::OpenLinkedToken(HANDLE token) // the other is the UAC elevated one. Since we are running as a service // as the system account we have access to both. TOKEN_LINKED_TOKEN tlt; - HANDLE hNewLinkedToken = NULL; + HANDLE hNewLinkedToken = nullptr; DWORD len; if (GetTokenInformation(token, (TOKEN_INFORMATION_CLASS)TokenLinkedToken, &tlt, sizeof(TOKEN_LINKED_TOKEN), &len)) { @@ -128,7 +128,7 @@ BOOL UACHelper::SetPrivilege(HANDLE token, LPCTSTR priv, BOOL enable) { LUID luidOfPriv; - if (!LookupPrivilegeValue(NULL, priv, &luidOfPriv)) { + if (!LookupPrivilegeValue(nullptr, priv, &luidOfPriv)) { return FALSE; } @@ -139,7 +139,7 @@ UACHelper::SetPrivilege(HANDLE token, LPCTSTR priv, BOOL enable) SetLastError(ERROR_SUCCESS); if (!AdjustTokenPrivileges(token, false, &tokenPriv, - sizeof(tokenPriv), NULL, NULL)) { + sizeof(tokenPriv), nullptr, nullptr)) { return FALSE; } @@ -151,7 +151,7 @@ UACHelper::SetPrivilege(HANDLE token, LPCTSTR priv, BOOL enable) * drop the privilege. * * @param token The token to adjust the privilege on. - * Pass NULL for current token. + * Pass nullptr for current token. * @param unneededPrivs An array of unneeded privileges. * @param count The size of the array * @return TRUE if there were no errors @@ -161,7 +161,7 @@ UACHelper::DisableUnneededPrivileges(HANDLE token, LPCTSTR *unneededPrivs, size_t count) { - HANDLE obtainedToken = NULL; + HANDLE obtainedToken = nullptr; if (!token) { // Note: This handle is a pseudo-handle and need not be closed HANDLE process = GetCurrentProcess(); @@ -198,7 +198,7 @@ UACHelper::DisableUnneededPrivileges(HANDLE token, * explicitly disable these or not. * * @param token The token to drop the privilege on. - * Pass NULL for current token. + * Pass nullptr for current token. * @return TRUE if there were no errors */ BOOL diff --git a/toolkit/mozapps/update/common/updatehelper.cpp b/toolkit/mozapps/update/common/updatehelper.cpp index 275b7dcaaaf4..b1a3947a0396 100644 --- a/toolkit/mozapps/update/common/updatehelper.cpp +++ b/toolkit/mozapps/update/common/updatehelper.cpp @@ -70,8 +70,8 @@ PathGetSiblingFilePath(LPWSTR destinationBuffer, * @param updateInfoDir The directory where update info is stored. * @param forceSync If true even if the ini file specifies async, the * process will wait for termination of PostUpdate. - * @param userToken The user token to run as, if NULL the current user - * will be used. + * @param userToken The user token to run as, if nullptr the current + * user will be used. * @return TRUE if there was no error starting the process. */ BOOL @@ -95,12 +95,12 @@ LaunchWinPostProcess(const WCHAR *installationDir, WCHAR exearg[MAX_PATH + 1]; WCHAR exeasync[10]; bool async = true; - if (!GetPrivateProfileStringW(L"PostUpdateWin", L"ExeRelPath", NULL, exefile, - MAX_PATH + 1, inifile)) { + if (!GetPrivateProfileStringW(L"PostUpdateWin", L"ExeRelPath", nullptr, + exefile, MAX_PATH + 1, inifile)) { return FALSE; } - if (!GetPrivateProfileStringW(L"PostUpdateWin", L"ExeArg", NULL, exearg, + if (!GetPrivateProfileStringW(L"PostUpdateWin", L"ExeArg", nullptr, exearg, MAX_PATH + 1, inifile)) { return FALSE; } @@ -161,22 +161,22 @@ LaunchWinPostProcess(const WCHAR *installationDir, ok = CreateProcessAsUserW(userToken, exefullpath, cmdline, - NULL, // no special security attributes - NULL, // no special thread attributes - false, // don't inherit filehandles - 0, // No special process creation flags - NULL, // inherit my environment + nullptr, // no special security attributes + nullptr, // no special thread attributes + false, // don't inherit filehandles + 0, // No special process creation flags + nullptr, // inherit my environment workingDirectory, &si, &pi); } else { ok = CreateProcessW(exefullpath, cmdline, - NULL, // no special security attributes - NULL, // no special thread attributes - false, // don't inherit filehandles - 0, // No special process creation flags - NULL, // inherit my environment + nullptr, // no special security attributes + nullptr, // no special thread attributes + false, // don't inherit filehandles + 0, // No special process creation flags + nullptr, // inherit my environment workingDirectory, &si, &pi); @@ -203,7 +203,7 @@ BOOL StartServiceUpdate(LPCWSTR installDir) { // Get a handle to the local computer SCM database - SC_HANDLE manager = OpenSCManager(NULL, NULL, + SC_HANDLE manager = OpenSCManager(nullptr, nullptr, SC_MANAGER_ALL_ACCESS); if (!manager) { return FALSE; @@ -237,9 +237,9 @@ StartServiceUpdate(LPCWSTR installDir) sizeof(cmdLine) / sizeof(cmdLine[0]) - 1); BOOL svcUpdateProcessStarted = CreateProcessW(maintserviceInstallerPath, cmdLine, - NULL, NULL, FALSE, + nullptr, nullptr, FALSE, 0, - NULL, installDir, &si, &pi); + nullptr, installDir, &si, &pi); if (svcUpdateProcessStarted) { CloseHandle(pi.hProcess); CloseHandle(pi.hThread); @@ -270,7 +270,7 @@ StartServiceCommand(int argc, LPCWSTR* argv) } // Get a handle to the SCM database. - SC_HANDLE serviceManager = OpenSCManager(NULL, NULL, + SC_HANDLE serviceManager = OpenSCManager(nullptr, nullptr, SC_MANAGER_CONNECT | SC_MANAGER_ENUMERATE_SERVICE); if (!serviceManager) { @@ -375,14 +375,14 @@ WriteStatusPending(LPCWSTR updateDirPath) const char pending[] = "pending"; HANDLE statusFile = CreateFileW(updateStatusFilePath, GENERIC_WRITE, 0, - NULL, CREATE_ALWAYS, 0, NULL); + nullptr, CREATE_ALWAYS, 0, nullptr); if (statusFile == INVALID_HANDLE_VALUE) { return FALSE; } DWORD wrote; BOOL ok = WriteFile(statusFile, pending, - sizeof(pending) - 1, &wrote, NULL); + sizeof(pending) - 1, &wrote, nullptr); CloseHandle(statusFile); return ok && (wrote == sizeof(pending) - 1); } @@ -403,7 +403,7 @@ WriteStatusFailure(LPCWSTR updateDirPath, int errorCode) } HANDLE statusFile = CreateFileW(updateStatusFilePath, GENERIC_WRITE, 0, - NULL, CREATE_ALWAYS, 0, NULL); + nullptr, CREATE_ALWAYS, 0, nullptr); if (statusFile == INVALID_HANDLE_VALUE) { return FALSE; } @@ -413,7 +413,7 @@ WriteStatusFailure(LPCWSTR updateDirPath, int errorCode) DWORD toWrite = strlen(failure); DWORD wrote; BOOL ok = WriteFile(statusFile, failure, - toWrite, &wrote, NULL); + toWrite, &wrote, nullptr); CloseHandle(statusFile); return ok && wrote == toWrite; } @@ -459,7 +459,7 @@ WaitForServiceStop(LPCWSTR serviceName, DWORD maxWaitSeconds) DWORD lastServiceState = 0x000000CF; // Get a handle to the SCM database. - SC_HANDLE serviceManager = OpenSCManager(NULL, NULL, + SC_HANDLE serviceManager = OpenSCManager(nullptr, nullptr, SC_MANAGER_CONNECT | SC_MANAGER_ENUMERATE_SERVICE); if (!serviceManager) { @@ -674,7 +674,7 @@ static BOOL GetDWORDValue(HKEY key, LPCWSTR valueName, DWORD &retValue) { DWORD regDWORDValueSize = sizeof(DWORD); - LONG retCode = RegQueryValueExW(key, valueName, 0, NULL, + LONG retCode = RegQueryValueExW(key, valueName, 0, nullptr, reinterpret_cast(&retValue), ®DWORDValueSize); return ERROR_SUCCESS == retCode; @@ -736,7 +736,7 @@ IsUnpromptedElevation(BOOL &isUnpromptedElevation) } 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; @@ -748,12 +748,12 @@ IsUnpromptedElevation(BOOL &isUnpromptedElevation) HRESULT LaunchDefaultMetroBrowser() { - CoInitialize(NULL); + CoInitialize(nullptr); HRESULT hr = E_FAIL; // The interface that allows us to activate the browser IApplicationActivationManager *activateMgr; - if (FAILED(hr = CoCreateInstance(CLSID_ApplicationActivationManager, NULL, - CLSCTX_LOCAL_SERVER, + if (FAILED(hr = CoCreateInstance(CLSID_ApplicationActivationManager, + nullptr, CLSCTX_LOCAL_SERVER, IID_IApplicationActivationManager, (void**)&activateMgr))) { CoUninitialize(); @@ -770,7 +770,7 @@ IsUnpromptedElevation(BOOL &isUnpromptedElevation) // Hand off focus rights to the out-of-process activation server. Without // this the metro interface won't launch. - CoAllowSetForegroundWindow(activateMgr, NULL); + CoAllowSetForegroundWindow(activateMgr, nullptr); // Launch default browser in Metro DWORD processID; diff --git a/toolkit/mozapps/update/common/updatelogging.cpp b/toolkit/mozapps/update/common/updatelogging.cpp index 77627c803c80..036c0b175ae6 100644 --- a/toolkit/mozapps/update/common/updatelogging.cpp +++ b/toolkit/mozapps/update/common/updatelogging.cpp @@ -14,7 +14,7 @@ #include "updatelogging.h" -UpdateLog::UpdateLog() : logFP(NULL) +UpdateLog::UpdateLog() : logFP(nullptr) { } @@ -45,7 +45,7 @@ void UpdateLog::Finish() return; fclose(logFP); - logFP = NULL; + logFP = nullptr; } void UpdateLog::Flush() diff --git a/toolkit/mozapps/update/test/TestAUSHelper.cpp b/toolkit/mozapps/update/test/TestAUSHelper.cpp index 854293bd4ae5..88e243e4d131 100644 --- a/toolkit/mozapps/update/test/TestAUSHelper.cpp +++ b/toolkit/mozapps/update/test/TestAUSHelper.cpp @@ -52,6 +52,7 @@ # define LOG_S "%s" #endif +#include "mozilla/NullPtr.h" #include #include #include @@ -81,7 +82,7 @@ WriteMsg(const NS_tchar *path, const char *status) fprintf(outFP, "%s\n", status); fclose(outFP); - outFP = NULL; + outFP = nullptr; } static bool @@ -118,7 +119,7 @@ CheckMsg(const NS_tchar *path, const char *expected) rb = mbuf; fclose(inFP); - inFP = NULL; + inFP = nullptr; return strcmp(rb, expected) == 0; } @@ -142,21 +143,21 @@ VerifyCertificateTrustForFile(LPCWSTR filePath) WINTRUST_DATA trustData; ZeroMemory(&trustData, sizeof(trustData)); trustData.cbStruct = sizeof(trustData); - trustData.pPolicyCallbackData = NULL; - trustData.pSIPClientData = NULL; + trustData.pPolicyCallbackData = nullptr; + trustData.pSIPClientData = nullptr; trustData.dwUIChoice = WTD_UI_NONE; trustData.fdwRevocationChecks = WTD_REVOKE_NONE; trustData.dwUnionChoice = WTD_CHOICE_FILE; trustData.dwStateAction = 0; - trustData.hWVTStateData = NULL; - trustData.pwszURLReference = NULL; + trustData.hWVTStateData = nullptr; + trustData.pwszURLReference = nullptr; // no UI trustData.dwUIContext = 0; trustData.pFile = &fileToCheck; GUID policyGUID = WINTRUST_ACTION_GENERIC_VERIFY_V2; // Check if the file is signed by something that is trusted. - return WinVerifyTrust(NULL, &policyGUID, &trustData); + return WinVerifyTrust(nullptr, &policyGUID, &trustData); } #endif @@ -313,7 +314,7 @@ int NS_main(int argc, NS_tchar **argv) // File in use test helper section if (!NS_tstrcmp(argv[4], NS_T("-s"))) { - NS_tchar *cwd = NS_tgetcwd(NULL, 0); + NS_tchar *cwd = NS_tgetcwd(nullptr, 0); NS_tchar inFilePath[MAXPATHLEN]; NS_tsnprintf(inFilePath, sizeof(inFilePath)/sizeof(inFilePath[0]), NS_T("%s/%s"), cwd, argv[2]); @@ -327,7 +328,7 @@ int NS_main(int argc, NS_tchar **argv) if (argc == 7) { hFile = CreateFileW(argv[6], DELETE | GENERIC_WRITE, 0, - NULL, OPEN_EXISTING, 0, NULL); + nullptr, OPEN_EXISTING, 0, nullptr); if (hFile == INVALID_HANDLE_VALUE) { WriteMsg(outFilePath, "error_locking"); return 1; @@ -363,7 +364,7 @@ int NS_main(int argc, NS_tchar **argv) } fclose(logFP); - logFP = NULL; + logFP = nullptr; return 0; } diff --git a/toolkit/mozapps/update/updater/archivereader.cpp b/toolkit/mozapps/update/updater/archivereader.cpp index 57ab3ee1c372..271905d8947e 100644 --- a/toolkit/mozapps/update/updater/archivereader.cpp +++ b/toolkit/mozapps/update/updater/archivereader.cpp @@ -27,8 +27,8 @@ static int inbuf_size = 262144; static int outbuf_size = 262144; -static char *inbuf = NULL; -static char *outbuf = NULL; +static char *inbuf = nullptr; +static char *outbuf = nullptr; #ifdef XP_WIN #include "resource.h" @@ -46,7 +46,7 @@ static char *outbuf = NULL; BOOL LoadFileInResource(int name, int type, const uint8_t *&data, uint32_t& size) { - HMODULE handle = GetModuleHandle(NULL); + HMODULE handle = GetModuleHandle(nullptr); if (!handle) { return FALSE; } @@ -84,7 +84,7 @@ int VerifyLoadedCert(MarFile *archive, int name, int type) { uint32_t size = 0; - const uint8_t *data = NULL; + const uint8_t *data = nullptr; if (!LoadFileInResource(name, type, data, size) || !data || !size) { return CERT_LOAD_ERROR; } @@ -183,7 +183,7 @@ ArchiveReader::VerifyProductInformation(const char *MARChannelID, rv = OK; break; } - channel = strtok(NULL, delimiter); + channel = strtok(nullptr, delimiter); } } @@ -253,17 +253,17 @@ ArchiveReader::Close() { if (mArchive) { mar_close(mArchive); - mArchive = NULL; + mArchive = nullptr; } if (inbuf) { free(inbuf); - inbuf = NULL; + inbuf = nullptr; } if (outbuf) { free(outbuf); - outbuf = NULL; + outbuf = nullptr; } } diff --git a/toolkit/mozapps/update/updater/archivereader.h b/toolkit/mozapps/update/updater/archivereader.h index 00676d4922a4..e3b82f452c3c 100644 --- a/toolkit/mozapps/update/updater/archivereader.h +++ b/toolkit/mozapps/update/updater/archivereader.h @@ -7,6 +7,7 @@ #ifndef ArchiveReader_h__ #define ArchiveReader_h__ +#include "mozilla/NullPtr.h" #include #include "mar.h" @@ -20,7 +21,7 @@ class ArchiveReader { public: - ArchiveReader() : mArchive(NULL) {} + ArchiveReader() : mArchive(nullptr) {} ~ArchiveReader() { Close(); } int Open(const NS_tchar *path); diff --git a/toolkit/mozapps/update/updater/automounter_gonk.cpp b/toolkit/mozapps/update/updater/automounter_gonk.cpp index 5983b8099de6..2faa10b70b7c 100644 --- a/toolkit/mozapps/update/updater/automounter_gonk.cpp +++ b/toolkit/mozapps/update/updater/automounter_gonk.cpp @@ -29,7 +29,7 @@ const char *kGonkMountsPath = "/proc/mounts"; const char *kGonkSystemPath = "/system"; -GonkAutoMounter::GonkAutoMounter() : mDevice(NULL), mAccess(Unknown) +GonkAutoMounter::GonkAutoMounter() : mDevice(nullptr), mAccess(Unknown) { if (!RemountSystem(ReadWrite)) { LOGE("Could not remount %s as read-write.", kGonkSystemPath); @@ -58,7 +58,7 @@ GonkAutoMounter::Reboot() kGonkSystemPath); LogFlush(); - if (android_reboot(ANDROID_RB_RESTART, 0, NULL) != 0) { + if (android_reboot(ANDROID_RB_RESTART, 0, nullptr) != 0) { LOGE("Safe system reboot failed, attempting to force"); LogFlush(); @@ -120,7 +120,7 @@ GonkAutoMounter::UpdateMountStatus() { FILE *mountsFile = NS_tfopen(kGonkMountsPath, "r"); - if (mountsFile == NULL) { + if (mountsFile == nullptr) { LOGE("Error opening %s: %s", kGonkMountsPath, strerror(errno)); return false; } @@ -143,7 +143,7 @@ GonkAutoMounter::UpdateMountStatus() for (token = strtok_r(mountData, "\n", &tokenContext); token; - token = strtok_r(NULL, "\n", &tokenContext)) + token = strtok_r(nullptr, "\n", &tokenContext)) { if (ProcessMount(token)) { foundSystem = true; @@ -188,7 +188,7 @@ GonkAutoMounter::ProcessMount(const char *mount) char *option, *optionContext; for (option = strtok_r(mountAccess, ",", &optionContext); option; - option = strtok_r(NULL, ",", &optionContext)) + option = strtok_r(nullptr, ",", &optionContext)) { if (strcmp("ro", option) == 0) { mAccess = ReadOnly; @@ -211,7 +211,7 @@ GonkAutoMounter::MountSystem(unsigned long flags) } const char *readOnly = flags & MS_RDONLY ? "read-only" : "read-write"; - int result = mount(mDevice, kGonkSystemPath, "none", flags, NULL); + int result = mount(mDevice, kGonkSystemPath, "none", flags, nullptr); if (result != 0) { LOGE("Error mounting %s as %s: %s", kGonkSystemPath, readOnly, diff --git a/toolkit/mozapps/update/updater/loaddlls.cpp b/toolkit/mozapps/update/updater/loaddlls.cpp index a94152743444..2c33067b230c 100644 --- a/toolkit/mozapps/update/updater/loaddlls.cpp +++ b/toolkit/mozapps/update/updater/loaddlls.cpp @@ -36,7 +36,7 @@ struct AutoLoadSystemDependencies if (systemDirectory[systemDirLen - 1] != L'\\' && systemDirLen) { systemDirectory[systemDirLen] = L'\\'; ++systemDirLen; - // No need to re-NULL terminate + // No need to re-null terminate } // For each known DLL ensure it is loaded from the system32 directory diff --git a/toolkit/mozapps/update/updater/progressui_gtk.cpp b/toolkit/mozapps/update/updater/progressui_gtk.cpp index a070c12c63f4..f3c537047f25 100644 --- a/toolkit/mozapps/update/updater/progressui_gtk.cpp +++ b/toolkit/mozapps/update/updater/progressui_gtk.cpp @@ -86,7 +86,7 @@ ShowProgressUI() snprintf(icon_path, sizeof(icon_path), "%s.png", sProgramPath); g_signal_connect(G_OBJECT(sWin), "delete_event", - G_CALLBACK(OnDeleteEvent), NULL); + G_CALLBACK(OnDeleteEvent), nullptr); gtk_window_set_title(GTK_WINDOW(sWin), strings.title); gtk_window_set_type_hint(GTK_WINDOW(sWin), GDK_WINDOW_TYPE_HINT_DIALOG); @@ -94,7 +94,7 @@ ShowProgressUI() gtk_window_set_resizable(GTK_WINDOW(sWin), FALSE); gtk_window_set_decorated(GTK_WINDOW(sWin), TRUE); gtk_window_set_deletable(GTK_WINDOW(sWin),FALSE); - pixbuf = gdk_pixbuf_new_from_file (icon_path, NULL); + pixbuf = gdk_pixbuf_new_from_file (icon_path, nullptr); gtk_window_set_icon(GTK_WINDOW(sWin), pixbuf); g_object_unref(pixbuf); @@ -106,7 +106,7 @@ ShowProgressUI() gtk_box_pack_start(GTK_BOX(vbox), sLabel, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(vbox), sProgressBar, TRUE, TRUE, 0); - sTimerID = g_timeout_add(TIMER_INTERVAL, UpdateDialog, NULL); + sTimerID = g_timeout_add(TIMER_INTERVAL, UpdateDialog, nullptr); gtk_container_set_border_width(GTK_CONTAINER(sWin), 10); gtk_container_add(GTK_CONTAINER(sWin), vbox); diff --git a/toolkit/mozapps/update/updater/progressui_win.cpp b/toolkit/mozapps/update/updater/progressui_win.cpp index 6ccfc229803f..1eea4691ee46 100644 --- a/toolkit/mozapps/update/updater/progressui_win.cpp +++ b/toolkit/mozapps/update/updater/progressui_win.cpp @@ -47,7 +47,7 @@ static StringTable sUIStrings; static BOOL GetStringsFile(WCHAR filename[MAX_PATH]) { - if (!GetModuleFileNameW(NULL, filename, MAX_PATH)) + if (!GetModuleFileNameW(nullptr, filename, MAX_PATH)) return FALSE; WCHAR *dot = wcsrchr(filename, '.'); @@ -115,7 +115,8 @@ InitDialog(HWND hDlg) SetWindowTextW(GetDlgItem(hDlg, IDC_INFO), szwInfo); // Set dialog icon - HICON hIcon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_DIALOG)); + HICON hIcon = LoadIcon(GetModuleHandle(nullptr), + MAKEINTRESOURCE(IDI_DIALOG)); if (hIcon) SendMessage(hDlg, WM_SETICON, ICON_BIG, (LPARAM) hIcon); @@ -171,7 +172,7 @@ InitDialog(HWND hDlg) CenterDialog(hDlg); // make dialog appear in the center of the screen - SetTimer(hDlg, TIMER_ID, TIMER_INTERVAL, NULL); + SetTimer(hDlg, TIMER_ID, TIMER_INTERVAL, nullptr); } // Message handler for update dialog. @@ -254,8 +255,8 @@ ShowProgressUI(bool indeterminate, bool initUIStrings) }; InitCommonControlsEx(&icc); - DialogBox(GetModuleHandle(NULL), - MAKEINTRESOURCE(IDD_DIALOG), NULL, + DialogBox(GetModuleHandle(nullptr), + MAKEINTRESOURCE(IDD_DIALOG), nullptr, (DLGPROC) DialogProc); return 0; diff --git a/toolkit/mozapps/update/updater/updater.cpp b/toolkit/mozapps/update/updater/updater.cpp index eae3ce3d59c1..495269633ee6 100644 --- a/toolkit/mozapps/update/updater/updater.cpp +++ b/toolkit/mozapps/update/updater/updater.cpp @@ -161,12 +161,12 @@ crc32(const unsigned char *buf, unsigned int len) class AutoFile { public: - AutoFile(FILE* file = NULL) + AutoFile(FILE* file = nullptr) : mFile(file) { } ~AutoFile() { - if (mFile != NULL) + if (mFile != nullptr) fclose(mFile); } @@ -215,7 +215,8 @@ public: unsigned int threadID; - mThread = (HANDLE) _beginthreadex(NULL, 0, ThreadMain, this, 0, &threadID); + mThread = (HANDLE) _beginthreadex(nullptr, 0, ThreadMain, this, 0, + &threadID); return mThread ? 0 : -1; } @@ -245,7 +246,7 @@ class Thread public: int Run(ThreadFunc func, void *param) { - return pthread_create(&thr, NULL, (void* (*)(void *)) func, param); + return pthread_create(&thr, nullptr, (void* (*)(void *)) func, param); } int Join() { @@ -266,7 +267,7 @@ public: mThreadFunc = func; mThreadParam = param; - mThread = _beginthread(ThreadMain, NULL, 16384, (void *)this); + mThread = _beginthread(ThreadMain, nullptr, 16384, (void *)this); return mThread ? 0 : -1; } @@ -323,7 +324,7 @@ static NS_tchar* mstrtok(const NS_tchar *delims, NS_tchar **str) { if (!*str || !**str) - return NULL; + return nullptr; // skip leading "whitespace" NS_tchar *ret = *str; @@ -339,7 +340,7 @@ mstrtok(const NS_tchar *delims, NS_tchar **str) if (!*ret) { *str = ret; - return NULL; + return nullptr; } NS_tchar *i = ret; @@ -354,7 +355,7 @@ mstrtok(const NS_tchar *delims, NS_tchar **str) ++i; } while (*i); - *str = NULL; + *str = nullptr; return ret; } @@ -364,7 +365,7 @@ mstrtok(const NS_tchar *delims, NS_tchar **str) * * @param relpath * The relative path to convert to a full path. - * @return valid filesystem full path or NULL memory allocation fails. + * @return valid filesystem full path or nullptr if memory allocation fails. */ static NS_tchar* get_full_path(const NS_tchar *relpath) @@ -373,7 +374,7 @@ get_full_path(const NS_tchar *relpath) size_t lenrelpath = NS_tstrlen(relpath); NS_tchar *s = (NS_tchar *) malloc((lendestpath + lenrelpath + 1) * sizeof(NS_tchar)); if (!s) - return NULL; + return nullptr; NS_tchar *c = s; @@ -389,13 +390,13 @@ get_full_path(const NS_tchar *relpath) /** * Gets the platform specific path and performs simple checks to the path. If - * the path checks don't pass NULL will be returned. + * the path checks don't pass nullptr will be returned. * * @param line * The line from the manifest that contains the path. * @param isdir * Whether the path is a directory path. Defaults to false. - * @return valid filesystem path or NULL if the path checks fail. + * @return valid filesystem path or nullptr if the path checks fail. */ static NS_tchar* get_valid_path(NS_tchar **line, bool isdir = false) @@ -403,20 +404,20 @@ get_valid_path(NS_tchar **line, bool isdir = false) NS_tchar *path = mstrtok(kQuote, line); if (!path) { LOG(("get_valid_path: unable to determine path: " LOG_S, line)); - return NULL; + return nullptr; } // All paths must be relative from the current working directory if (path[0] == NS_T('/')) { LOG(("get_valid_path: path must be relative: " LOG_S, path)); - return NULL; + return nullptr; } #ifdef XP_WIN // All paths must be relative from the current working directory if (path[0] == NS_T('\\') || path[1] == NS_T(':')) { LOG(("get_valid_path: path must be relative: " LOG_S, path)); - return NULL; + return nullptr; } #endif @@ -425,7 +426,7 @@ get_valid_path(NS_tchar **line, bool isdir = false) if (path[NS_tstrlen(path) - 1] != NS_T('/')) { LOG(("get_valid_path: directory paths must have a trailing forward " \ "slash: " LOG_S, path)); - return NULL; + return nullptr; } // Remove the trailing forward slash because stat on Windows will return @@ -434,9 +435,9 @@ get_valid_path(NS_tchar **line, bool isdir = false) } // Don't allow relative paths that resolve to a parent directory. - if (NS_tstrstr(path, NS_T("..")) != NULL) { + if (NS_tstrstr(path, NS_T("..")) != nullptr) { LOG(("get_valid_path: paths must not contain '..': " LOG_S, path)); - return NULL; + return nullptr; } return path; @@ -451,7 +452,7 @@ get_quoted_path(const NS_tchar *path) NS_tchar *s = (NS_tchar *) malloc(len * sizeof(NS_tchar)); if (!s) - return NULL; + return nullptr; NS_tchar *c = s; NS_tstrcpy(c, kQuote); @@ -569,17 +570,17 @@ static FILE* ensure_open(const NS_tchar *path, const NS_tchar *flags, unsigned i return f; } if (NS_tchmod(path, options) != 0) { - if (f != NULL) { + if (f != nullptr) { fclose(f); } - return NULL; + return nullptr; } struct stat ss; if (NS_tstat(path, &ss) != 0 || ss.st_mode != options) { - if (f != NULL) { + if (f != nullptr) { fclose(f); } - return NULL; + return nullptr; } return f; } @@ -919,7 +920,7 @@ static int backup_discard(const NS_tchar *path) // but this is ok since the installer / uninstaller will delete the // directory containing the file along with its contents after an update is // applied, on reinstall, and on uninstall. - if (MoveFileEx(path, NULL, MOVEFILE_DELAY_UNTIL_REBOOT)) { + if (MoveFileEx(path, nullptr, MOVEFILE_DELAY_UNTIL_REBOOT)) { LOG(("backup_discard: file renamed and will be removed on OS " \ "reboot: " LOG_S, path)); } else { @@ -951,7 +952,7 @@ static int DoUpdate(); class Action { public: - Action() : mProgressCost(1), mNext(NULL) { } + Action() : mProgressCost(1), mNext(nullptr) { } virtual ~Action() { } virtual int Parse(NS_tchar *line) = 0; @@ -979,7 +980,7 @@ private: class RemoveFile : public Action { public: - RemoveFile() : mFile(NULL), mSkip(0) { } + RemoveFile() : mFile(nullptr), mSkip(0) { } int Parse(NS_tchar *line); int Prepare(); @@ -1088,7 +1089,7 @@ RemoveFile::Finish(int status) class RemoveDir : public Action { public: - RemoveDir() : mDir(NULL), mSkip(0) { } + RemoveDir() : mDir(nullptr), mSkip(0) { } virtual int Parse(NS_tchar *line); virtual int Prepare(); // check that the source dir exists @@ -1195,7 +1196,7 @@ RemoveDir::Finish(int status) class AddFile : public Action { public: - AddFile() : mFile(NULL) + AddFile() : mFile(nullptr) , mAdded(false) { } @@ -1251,7 +1252,7 @@ AddFile::Execute() #ifdef XP_WIN char sourcefile[MAXPATHLEN]; if (!WideCharToMultiByte(CP_UTF8, 0, mFile, -1, sourcefile, MAXPATHLEN, - NULL, NULL)) { + nullptr, nullptr)) { LOG(("error converting wchar to utf8: %d", GetLastError())); return STRING_CONVERSION_ERROR; } @@ -1280,7 +1281,7 @@ AddFile::Finish(int status) class PatchFile : public Action { public: - PatchFile() : mPatchIndex(-1), buf(NULL) { } + PatchFile() : mPatchIndex(-1), buf(nullptr) { } virtual ~PatchFile(); @@ -1405,7 +1406,7 @@ PatchFile::Prepare() #ifdef XP_WIN char sourcefile[MAXPATHLEN]; if (!WideCharToMultiByte(CP_UTF8, 0, mPatchFile, -1, sourcefile, MAXPATHLEN, - NULL, NULL)) { + nullptr, nullptr)) { LOG(("error converting wchar to utf8: %d", GetLastError())); return STRING_CONVERSION_ERROR; } @@ -1424,14 +1425,14 @@ PatchFile::Execute() LOG(("EXECUTE PATCH " LOG_S, mFile)); AutoFile pfile = NS_tfopen(spath, NS_T("rb")); - if (pfile == NULL) + if (pfile == nullptr) return READ_ERROR; int rv = MBS_ReadHeader(pfile, &header); if (rv) return rv; - FILE *origfile = NULL; + FILE *origfile = nullptr; #ifdef XP_WIN if (NS_tstrcmp(mFile, gCallbackRelPath) == 0) { // Read from the copy of the callback when patching since the callback can't @@ -1486,13 +1487,14 @@ PatchFile::Execute() HANDLE hfile = CreateFileW(mFile, GENERIC_WRITE, 0, - NULL, + nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, - NULL); + nullptr); if (hfile != INVALID_HANDLE_VALUE) { - if (SetFilePointer(hfile, header.dlen, NULL, FILE_BEGIN) != INVALID_SET_FILE_POINTER && + if (SetFilePointer(hfile, header.dlen, + nullptr, FILE_BEGIN) != INVALID_SET_FILE_POINTER && SetEndOfFile(hfile) != 0) { shouldTruncate = false; } @@ -1519,7 +1521,7 @@ PatchFile::Execute() AutoFile ofile = ensure_open(mFile, NS_T("wb+"), ss.st_mode); #endif - if (ofile == NULL) { + if (ofile == nullptr) { LOG(("unable to create new file: " LOG_S ", err: %d", mFile, errno)); return WRITE_ERROR; } @@ -1533,13 +1535,13 @@ PatchFile::Execute() rv = MBS_ApplyPatch(&header, pfile, buf, ofile); // Go ahead and do a bit of cleanup now to minimize runtime overhead. - // Set pfile to NULL to make AutoFile close the file so it can be deleted on - // Windows. - pfile = NULL; + // Set pfile to nullptr to make AutoFile close the file so it can be deleted + // on Windows. + pfile = nullptr; NS_tremove(spath); spath[0] = NS_T('\0'); free(buf); - buf = NULL; + buf = nullptr; return rv; } @@ -1555,7 +1557,7 @@ PatchFile::Finish(int status) class AddIfFile : public AddFile { public: - AddIfFile() : mTestFile(NULL) { } + AddIfFile() : mTestFile(nullptr) { } virtual int Parse(NS_tchar *line); virtual int Prepare(); @@ -1588,7 +1590,7 @@ AddIfFile::Prepare() { // If the test file does not exist, then skip this action. if (NS_taccess(mTestFile, F_OK)) { - mTestFile = NULL; + mTestFile = nullptr; return OK; } @@ -1616,7 +1618,7 @@ AddIfFile::Finish(int status) class PatchIfFile : public PatchFile { public: - PatchIfFile() : mTestFile(NULL) { } + PatchIfFile() : mTestFile(nullptr) { } virtual int Parse(NS_tchar *line); virtual int Prepare(); // should check for patch file and for checksum here @@ -1649,7 +1651,7 @@ PatchIfFile::Prepare() { // If the test file does not exist, then skip this action. if (NS_taccess(mTestFile, F_OK)) { - mTestFile = NULL; + mTestFile = nullptr; return OK; } @@ -1732,7 +1734,7 @@ LaunchCallbackApp(const NS_tchar *workingDir, return; } #endif - WinLaunchChild(argv[0], argc, argv, NULL); + WinLaunchChild(argv[0], argc, argv, nullptr); } #else # warning "Need implementaton of LaunchCallbackApp" @@ -1751,7 +1753,7 @@ WriteStatusFile(const char* aStatus) return false; AutoFile file = NS_tfopen(filename, NS_T("wb+")); - if (file == NULL) + if (file == nullptr) return false; if (fwrite(aStatus, strlen(aStatus), 1, file) != 1) @@ -1798,7 +1800,7 @@ IsUpdateStatusPendingService() NS_T("%s/update.status"), gSourcePath); AutoFile file = NS_tfopen(filename, NS_T("rb")); - if (file == NULL) + if (file == nullptr) return false; char buf[32] = { 0 }; @@ -1832,7 +1834,7 @@ IsUpdateStatusSucceeded(bool &isSucceeded) NS_T("%s/update.status"), gSourcePath); AutoFile file = NS_tfopen(filename, NS_T("rb")); - if (file == NULL) + if (file == nullptr) return false; char buf[32] = { 0 }; @@ -2011,7 +2013,7 @@ ProcessReplaceRequest() if (rv) { LOG(("Removing tmpDir failed, err: %d", rv)); #ifdef XP_WIN - if (MoveFileExW(tmpDir, NULL, MOVEFILE_DELAY_UNTIL_REBOOT)) { + if (MoveFileExW(tmpDir, nullptr, MOVEFILE_DELAY_UNTIL_REBOOT)) { LOG(("tmpDir will be removed on OS reboot: " LOG_S, tmpDir)); } else { LOG(("Failed to schedule OS reboot removal of directory: " LOG_S, @@ -2144,7 +2146,7 @@ GetUpdateFileName(NS_tchar *fileName, int maxChars) NS_tsnprintf(linkFileName, sizeof(linkFileName)/sizeof(linkFileName[0]), NS_T("%s/update.link"), gSourcePath); AutoFile linkFile = NS_tfopen(linkFileName, NS_T("rb")); - if (linkFile == NULL) { + if (linkFile == nullptr) { NS_tsnprintf(fileName, maxChars, NS_T("%s/update.mar"), gSourcePath); return OK; @@ -2275,9 +2277,9 @@ UpdateThreadFunc(void *param) // on the top-level Mac OS X bundle directory so that Mac OS X's // Launch Services picks up any major changes. Here we assume that // the current working directory is the top-level bundle directory. - char* cwd = getcwd(NULL, 0); + char* cwd = getcwd(nullptr, 0); if (cwd) { - if (utimes(cwd, NULL) != 0) { + if (utimes(cwd, nullptr) != 0) { LOG(("Couldn't set access/modification time on application bundle.")); } free(cwd); @@ -2351,7 +2353,7 @@ int NS_main(int argc, NS_tchar **argv) #ifdef XP_WIN bool useService = false; bool testOnlyFallbackKeyExists = false; - bool noServiceFallback = getenv("MOZ_NO_SERVICE_FALLBACK") != NULL; + bool noServiceFallback = getenv("MOZ_NO_SERVICE_FALLBACK") != nullptr; putenv(const_cast("MOZ_NO_SERVICE_FALLBACK=")); // We never want the service to be used unless we build with @@ -2368,13 +2370,13 @@ int NS_main(int argc, NS_tchar **argv) { HKEY hkApp; RegCreateKeyExW(HKEY_CURRENT_USER, L"Software\\Classes\\Applications", - 0, NULL, REG_OPTION_NON_VOLATILE, KEY_SET_VALUE, NULL, - &hkApp, NULL); + 0, nullptr, REG_OPTION_NON_VOLATILE, KEY_SET_VALUE, nullptr, + &hkApp, nullptr); RegCloseKey(hkApp); if (RegCreateKeyExW(HKEY_CURRENT_USER, L"Software\\Classes\\Applications\\updater.exe", - 0, NULL, REG_OPTION_VOLATILE, KEY_SET_VALUE, NULL, - &hkApp, NULL) == ERROR_SUCCESS) { + 0, nullptr, REG_OPTION_VOLATILE, KEY_SET_VALUE, nullptr, + &hkApp, nullptr) == ERROR_SUCCESS) { RegSetValueExW(hkApp, L"IsHostApp", 0, REG_NONE, 0, 0); RegSetValueExW(hkApp, L"NoOpenWith", 0, REG_NONE, 0, 0); RegSetValueExW(hkApp, L"NoStartPage", 0, REG_NONE, 0, 0); @@ -2481,7 +2483,7 @@ int NS_main(int argc, NS_tchar **argv) #ifdef XP_WIN if (pid > 0) { HANDLE parent = OpenProcess(SYNCHRONIZE, false, (DWORD) pid); - // May return NULL if the parent process has already gone away. + // May return nullptr if the parent process has already gone away. // Otherwise, wait for the parent process to exit before starting the // update. if (parent) { @@ -2499,7 +2501,7 @@ int NS_main(int argc, NS_tchar **argv) } #else if (pid > 0) - waitpid(pid, NULL, 0); + waitpid(pid, nullptr, 0); #endif if (sReplaceRequest) { @@ -2519,7 +2521,7 @@ int NS_main(int argc, NS_tchar **argv) const int callbackIndex = 5; #if defined(XP_WIN) - sUsingService = getenv("MOZ_USING_SERVICE") != NULL; + sUsingService = getenv("MOZ_USING_SERVICE") != nullptr; putenv(const_cast("MOZ_USING_SERVICE=")); // lastFallbackError keeps track of the last error for the service not being // used, in case of an error when fallback is not enabled we write the @@ -2580,10 +2582,10 @@ int NS_main(int argc, NS_tchar **argv) updateLockFileHandle = CreateFileW(updateLockFilePath, GENERIC_READ | GENERIC_WRITE, 0, - NULL, + nullptr, OPEN_ALWAYS, FILE_FLAG_DELETE_ON_CLOSE, - NULL); + nullptr); NS_tsnprintf(elevatedLockFilePath, sizeof(elevatedLockFilePath)/sizeof(elevatedLockFilePath[0]), @@ -2603,7 +2605,7 @@ int NS_main(int argc, NS_tchar **argv) if(startedFromUnelevatedUpdater) { // Disable every privilege we don't need. Processes started using // CreateProcess will use the same token as this process. - UACHelper::DisablePrivileges(NULL); + UACHelper::DisablePrivileges(nullptr); } if (updateLockFileHandle == INVALID_HANDLE_VALUE || @@ -2618,10 +2620,10 @@ int NS_main(int argc, NS_tchar **argv) elevatedFileHandle = CreateFileW(elevatedLockFilePath, GENERIC_READ | GENERIC_WRITE, 0, - NULL, + nullptr, OPEN_ALWAYS, FILE_FLAG_DELETE_ON_CLOSE, - NULL); + nullptr); if (elevatedFileHandle == INVALID_HANDLE_VALUE) { LOG(("Unable to create elevated lock file! Exiting")); @@ -2712,7 +2714,7 @@ int NS_main(int argc, NS_tchar **argv) DWORD lastState = WaitForServiceStop(SVC_NAME, 5); if (lastState != SERVICE_STOPPED) { Thread t1; - if (t1.Run(WaitForServiceFinishThread, NULL) == 0 && + if (t1.Run(WaitForServiceFinishThread, nullptr) == 0 && showProgressUI) { ShowProgressUI(true, false); } @@ -2755,7 +2757,7 @@ int NS_main(int argc, NS_tchar **argv) bool updateStatusSucceeded = false; if (IsUpdateStatusSucceeded(updateStatusSucceeded) && updateStatusSucceeded) { - if (!LaunchWinPostProcess(installDir, gSourcePath, false, NULL)) { + if (!LaunchWinPostProcess(installDir, gSourcePath, false, nullptr)) { fprintf(stderr, "The post update process which runs as the user" " for service update could not be launched."); } @@ -2776,7 +2778,7 @@ int NS_main(int argc, NS_tchar **argv) sinfo.fMask = SEE_MASK_FLAG_NO_UI | SEE_MASK_FLAG_DDEWAIT | SEE_MASK_NOCLOSEPROCESS; - sinfo.hwnd = NULL; + sinfo.hwnd = nullptr; sinfo.lpFile = argv[0]; sinfo.lpParameters = cmdLine; sinfo.lpVerb = L"runas"; @@ -2925,7 +2927,9 @@ int NS_main(int argc, NS_tchar **argv) if (sReplaceRequest) { // In case of replace requests, we should look for the callback file in // the destination directory. - size_t commonPrefixLength = PathCommonPrefixW(argv[callbackIndex], gDestinationPath, NULL); + size_t commonPrefixLength = PathCommonPrefixW(argv[callbackIndex], + gDestinationPath, + nullptr); NS_tchar *p = buffer; NS_tstrncpy(p, argv[callbackIndex], commonPrefixLength); p += commonPrefixLength; @@ -2942,7 +2946,9 @@ int NS_main(int argc, NS_tchar **argv) NS_tchar installDir[MAXPATHLEN]; if (!GetInstallationDir(installDir)) return 1; - size_t callbackPrefixLength = PathCommonPrefixW(argv[callbackIndex], installDir, NULL); + size_t callbackPrefixLength = PathCommonPrefixW(argv[callbackIndex], + installDir, + nullptr); NS_tstrncpy(p, argv[callbackIndex] + max(callbackPrefixLength, commonPrefixLength), bufferLeft); targetPath = buffer; } @@ -3007,7 +3013,7 @@ int NS_main(int argc, NS_tchar **argv) DELETE | GENERIC_WRITE, // allow delete, rename, and write FILE_SHARE_DELETE | FILE_SHARE_WRITE, - NULL, OPEN_EXISTING, 0, NULL); + nullptr, OPEN_EXISTING, 0, nullptr); if (callbackFile != INVALID_HANDLE_VALUE) break; @@ -3062,7 +3068,7 @@ int NS_main(int argc, NS_tchar **argv) // before QuitProgressUI has been called, so wait for UpdateThreadFunc to // terminate. Avoid showing the progress UI for background updates. Thread t; - if (t.Run(UpdateThreadFunc, NULL) == 0) { + if (t.Run(UpdateThreadFunc, nullptr) == 0) { if (!sBackgroundUpdate && !sReplaceRequest) { ShowProgressUI(); } @@ -3090,7 +3096,7 @@ int NS_main(int argc, NS_tchar **argv) // access to the HKEY_LOCAL_MACHINE registry key but this is ok since the // installer / uninstaller will delete the directory along with its contents // after an update is applied, on reinstall, and on uninstall. - if (MoveFileEx(DELETE_DIR, NULL, MOVEFILE_DELAY_UNTIL_REBOOT)) { + if (MoveFileEx(DELETE_DIR, nullptr, MOVEFILE_DELAY_UNTIL_REBOOT)) { LOG(("NS_main: directory will be removed on OS reboot: " LOG_S, DELETE_DIR)); } else { @@ -3119,7 +3125,7 @@ int NS_main(int argc, NS_tchar **argv) if (!sUsingService) { NS_tchar installDir[MAXPATHLEN]; if (GetInstallationDir(installDir)) { - if (!LaunchWinPostProcess(installDir, gSourcePath, false, NULL)) { + if (!LaunchWinPostProcess(installDir, gSourcePath, false, nullptr)) { LOG(("NS_main: The post update process could not be launched.")); } @@ -3147,7 +3153,7 @@ int NS_main(int argc, NS_tchar **argv) class ActionList { public: - ActionList() : mFirst(NULL), mLast(NULL), mCount(0) { } + ActionList() : mFirst(nullptr), mLast(nullptr), mCount(0) { } ~ActionList(); void Append(Action* action); @@ -3431,19 +3437,19 @@ int add_dir_entries(const NS_tchar *dirpath, ActionList *list) // Remove the trailing slash so the paths don't contain double slashes. The // existence of the slash has already been checked in DoUpdate. searchpath[NS_tstrlen(searchpath) - 1] = NS_T('\0'); - char* const pathargv[] = {searchpath, NULL}; + char* const pathargv[] = {searchpath, nullptr}; // FTS_NOCHDIR is used so relative paths from the destination directory are // returned. if (!(ftsdir = fts_open(pathargv, FTS_PHYSICAL | FTS_NOSTAT | FTS_XDEV | FTS_NOCHDIR, - NULL))) + nullptr))) return UNEXPECTED_FILE_OPERATION_ERROR; - while ((ftsdirEntry = fts_read(ftsdir)) != NULL) { + while ((ftsdirEntry = fts_read(ftsdir)) != nullptr) { NS_tchar foundpath[MAXPATHLEN]; NS_tchar *quotedpath; - Action *action = NULL; + Action *action = nullptr; switch (ftsdirEntry->fts_info) { // Filesystem objects that shouldn't be in the application's directories @@ -3533,21 +3539,21 @@ static NS_tchar* GetManifestContents(const NS_tchar *manifest) { AutoFile mfile = NS_tfopen(manifest, NS_T("rb")); - if (mfile == NULL) { + if (mfile == nullptr) { LOG(("GetManifestContents: error opening manifest file: " LOG_S, manifest)); - return NULL; + return nullptr; } struct stat ms; int rv = fstat(fileno((FILE *)mfile), &ms); if (rv) { LOG(("GetManifestContents: error stating manifest file: " LOG_S, manifest)); - return NULL; + return nullptr; } char *mbuf = (char *) malloc(ms.st_size + 1); if (!mbuf) - return NULL; + return nullptr; size_t r = ms.st_size; char *rb = mbuf; @@ -3556,7 +3562,7 @@ GetManifestContents(const NS_tchar *manifest) size_t c = fread(rb, 1, count, mfile); if (c != count) { LOG(("GetManifestContents: error reading manifest file: " LOG_S, manifest)); - return NULL; + return nullptr; } r -= c; @@ -3570,14 +3576,14 @@ GetManifestContents(const NS_tchar *manifest) #else NS_tchar *wrb = (NS_tchar *) malloc((ms.st_size + 1) * sizeof(NS_tchar)); if (!wrb) - return NULL; + return nullptr; if (!MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, rb, -1, wrb, ms.st_size + 1)) { LOG(("GetManifestContents: error converting utf8 to utf16le: %d", GetLastError())); free(mbuf); free(wrb); - return NULL; + return nullptr; } free(mbuf); @@ -3592,7 +3598,7 @@ int AddPreCompleteActions(ActionList *list) } NS_tchar *rb = GetManifestContents(NS_T("precomplete")); - if (rb == NULL) { + if (rb == nullptr) { LOG(("AddPreCompleteActions: error getting contents of precomplete " \ "manifest")); // Applications aren't required to have a precomplete manifest yet. @@ -3612,7 +3618,7 @@ int AddPreCompleteActions(ActionList *list) return PARSE_ERROR; } - Action *action = NULL; + Action *action = nullptr; if (NS_tstrcmp(token, NS_T("remove")) == 0) { // rm file action = new RemoveFile(); } @@ -3657,7 +3663,7 @@ int DoUpdate() } NS_tchar *rb = GetManifestContents(manifest); - if (rb == NULL) { + if (rb == nullptr) { LOG(("DoUpdate: error opening manifest file: " LOG_S, manifest)); return READ_ERROR; } @@ -3692,7 +3698,7 @@ int DoUpdate() isFirstAction = false; - Action *action = NULL; + Action *action = nullptr; if (NS_tstrcmp(token, NS_T("remove")) == 0) { // rm file action = new RemoveFile(); } diff --git a/toolkit/profile/nsToolkitProfileService.cpp b/toolkit/profile/nsToolkitProfileService.cpp index 280d3ea7871b..d76163949041 100644 --- a/toolkit/profile/nsToolkitProfileService.cpp +++ b/toolkit/profile/nsToolkitProfileService.cpp @@ -1026,7 +1026,7 @@ XRE_GetFileFromPath(const char *aPath, nsIFile* *aResult) return NS_ERROR_INVALID_ARG; CFURLRef fullPath = - CFURLCreateFromFileSystemRepresentation(NULL, (const UInt8 *) aPath, + CFURLCreateFromFileSystemRepresentation(nullptr, (const UInt8 *) aPath, pathLen, true); if (!fullPath) return NS_ERROR_FAILURE;