Bug 784739 - Switch from NULL to nullptr in toolkit/mozapps/; r=ehsan
authorBirunthan Mohanathas <birunthan@mohanathas.com>
Thu, 10 Oct 2013 16:40:03 -0400
changeset 150825 73ac7e81f31696c9ee3d58c64df2aad49177e911
parent 150824 1b12502d7c23ab8b7c04cf76e458a8972baf18ac
child 150826 4fd346e0e4040e022bdd4745a4f5844030739888
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersehsan
bugs784739
milestone27.0a1
Bug 784739 - Switch from NULL to nullptr in toolkit/mozapps/; r=ehsan
toolkit/mozapps/update/common/pathhash.cpp
toolkit/mozapps/update/common/readstrings.cpp
toolkit/mozapps/update/common/readstrings.h
toolkit/mozapps/update/common/uachelper.cpp
toolkit/mozapps/update/common/updatehelper.cpp
toolkit/mozapps/update/common/updatelogging.cpp
toolkit/mozapps/update/test/TestAUSHelper.cpp
toolkit/mozapps/update/updater/archivereader.cpp
toolkit/mozapps/update/updater/archivereader.h
toolkit/mozapps/update/updater/automounter_gonk.cpp
toolkit/mozapps/update/updater/loaddlls.cpp
toolkit/mozapps/update/updater/progressui_gtk.cpp
toolkit/mozapps/update/updater/progressui_win.cpp
toolkit/mozapps/update/updater/updater.cpp
toolkit/profile/nsToolkitProfileService.cpp
--- a/toolkit/mozapps/update/common/pathhash.cpp
+++ b/toolkit/mozapps/update/common/pathhash.cpp
@@ -37,23 +37,23 @@ BinaryDataToHexString(const BYTE *hash, 
 */
 static BOOL
 CalculateMD5(const char *data, DWORD dataSize, 
              BYTE **hash, DWORD &hashSize)
 {
   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;
     }
   }
 
   if (!CryptCreateHash(hProv, CALG_MD5, 0, 0, &hHash)) {
     return FALSE;
   }
--- a/toolkit/mozapps/update/common/readstrings.cpp
+++ b/toolkit/mozapps/update/common/readstrings.cpp
@@ -57,38 +57,38 @@ NS_strspnp(const char *delims, const cha
 
   return str;
 }
 
 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;
   do {
     for (const char *d = delims; *d != '\0'; ++d) {
       if (*i == *d) {
         *i = '\0';
         *str = ++i;
         return ret;
       }
     }
     ++i;
   } while (*i);
 
-  *str = NULL;
+  *str = nullptr;
   return ret;
 }
 
 /**
  * Find a key in a keyList containing zero-delimited keys ending with "\0\0".
  * Returns a zero-based index of the key in the list, or -1 if the key is not found.
  */
 static int
--- a/toolkit/mozapps/update/common/readstrings.h
+++ b/toolkit/mozapps/update/common/readstrings.h
@@ -2,16 +2,18 @@
 /* vim:set ts=2 sw=2 sts=2 et cindent: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef READSTRINGS_H__
 #define READSTRINGS_H__
 
+#include "mozilla/NullPtr.h"
+
 #define MAX_TEXT_LEN 600
 
 #ifdef XP_WIN
 # include <windows.h>
   typedef WCHAR NS_tchar;
 #else
   typedef char NS_tchar;
 #endif
@@ -33,11 +35,11 @@ int ReadStrings(const NS_tchar *path, St
 
 /**
  * This function reads in localized strings corresponding to the keys from a given .ini
  */
 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__
--- a/toolkit/mozapps/update/common/uachelper.cpp
+++ b/toolkit/mozapps/update/common/uachelper.cpp
@@ -75,42 +75,42 @@ UACHelper::IsVistaOrLater()
  * @param  sessionID  The session ID for the token to obtain
  * @return A handle to the token to obtain which will be primary if enough
  *         permissions exist.  Caller should close the handle.
  */
 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) {
     wtsQueryUserToken(sessionID, &token);
   }
   FreeLibrary(module);
   return token;
 }
 
 /**
  * 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
 UACHelper::OpenLinkedToken(HANDLE token)
 {
   // Magic below...
   // UAC creates 2 tokens.  One is the restricted token which we have.
   // 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)) {
     token = tlt.LinkedToken;
     hNewLinkedToken = token;
   }
   return hNewLinkedToken;
 }
@@ -123,50 +123,50 @@ UACHelper::OpenLinkedToken(HANDLE token)
  * @param  priv   The privilege to adjust.
  * @param  enable Whether to enable or disable it
  * @return TRUE if the token was adjusted to the specified value.
  */
 BOOL 
 UACHelper::SetPrivilege(HANDLE token, LPCTSTR priv, BOOL enable)
 {
   LUID luidOfPriv;
-  if (!LookupPrivilegeValue(NULL, priv, &luidOfPriv)) {
+  if (!LookupPrivilegeValue(nullptr, priv, &luidOfPriv)) {
     return FALSE; 
   }
 
   TOKEN_PRIVILEGES tokenPriv;
   tokenPriv.PrivilegeCount = 1;
   tokenPriv.Privileges[0].Luid = luidOfPriv;
   tokenPriv.Privileges[0].Attributes = enable ? SE_PRIVILEGE_ENABLED : 0;
 
   SetLastError(ERROR_SUCCESS);
   if (!AdjustTokenPrivileges(token, false, &tokenPriv,
-                             sizeof(tokenPriv), NULL, NULL)) {
+                             sizeof(tokenPriv), nullptr, nullptr)) {
     return FALSE; 
   } 
 
   return GetLastError() == ERROR_SUCCESS;
 }
 
 /**
  * For each privilege that is specified, an attempt will be made to 
  * 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
  */
 BOOL
 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();
     if (!OpenProcessToken(process, TOKEN_ALL_ACCESS_P, &obtainedToken)) {
       LOG_WARN(("Could not obtain token for current process, no "
                 "privileges changed. (%d)", GetLastError()));
       return FALSE;
     }
@@ -193,17 +193,17 @@ UACHelper::DisableUnneededPrivileges(HAN
 
 /**
  * Disables privileges for the specified token.
  * The privileges to disable are in PrivsToDisable.
  * In the future there could be new privs and we are not sure if we should
  * 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
 UACHelper::DisablePrivileges(HANDLE token)
 {
   static const size_t PrivsToDisableSize = 
     sizeof(UACHelper::PrivsToDisable) / sizeof(UACHelper::PrivsToDisable[0]);
 
--- a/toolkit/mozapps/update/common/updatehelper.cpp
+++ b/toolkit/mozapps/update/common/updatehelper.cpp
@@ -65,18 +65,18 @@ PathGetSiblingFilePath(LPWSTR destinatio
  * It takes in the path of the callback application to calculate the path
  * of helper.exe.  For service updates this is called from both the system
  * account and the current user account.
  *
  * @param  installationDir The path to the callback application binary.
  * @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
 LaunchWinPostProcess(const WCHAR *installationDir,
                      const WCHAR *updateInfoDir,
                      bool forceSync,
                      HANDLE userToken)
 {
@@ -90,22 +90,22 @@ LaunchWinPostProcess(const WCHAR *instal
   if (!PathAppendSafe(inifile, L"updater.ini")) {
     return FALSE;
   }
 
   WCHAR exefile[MAX_PATH + 1];
   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;
   }
 
   if (!GetPrivateProfileStringW(L"PostUpdateWin", L"ExeAsync", L"TRUE",
                                 exeasync,
                                 sizeof(exeasync)/sizeof(exeasync[0]),
                                 inifile)) {
@@ -156,32 +156,32 @@ LaunchWinPostProcess(const WCHAR *instal
   si.lpDesktop = L"";
   PROCESS_INFORMATION pi = {0};
 
   bool ok;
   if (userToken) {
     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);
   }
   free(cmdline);
   if (ok) {
     if (!async)
       WaitForSingleObject(pi.hProcess, INFINITE);
@@ -198,17 +198,17 @@ LaunchWinPostProcess(const WCHAR *instal
  * @param  installDir the installation directory where
  *         maintenanceservice_installer.exe is located.
  * @return TRUE if successful
  */
 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;
   }
 
   // Open the service
   SC_HANDLE svc = OpenServiceW(manager, SVC_NAME,
                                SERVICE_ALL_ACCESS);
@@ -232,19 +232,19 @@ StartServiceUpdate(LPCWSTR installDir)
   wcsncpy(maintserviceInstallerPath, installDir, MAX_PATH);
   PathAppendSafe(maintserviceInstallerPath,
                  L"maintenanceservice_installer.exe");
   WCHAR cmdLine[64] = { '\0' };
   wcsncpy(cmdLine, L"dummyparam.exe /Upgrade",
           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);
   }
   return svcUpdateProcessStarted;
 }
 
 #endif
@@ -265,17 +265,17 @@ DWORD
 StartServiceCommand(int argc, LPCWSTR* argv)
 {
   DWORD lastState = WaitForServiceStop(SVC_NAME, 5);
   if (lastState != SERVICE_STOPPED) {
     return 20000 + lastState;
   }
 
   // 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)  {
     return 17001;
   }
 
   // Get a handle to the service.
   SC_HANDLE service = OpenServiceW(serviceManager,
@@ -370,24 +370,24 @@ WriteStatusPending(LPCWSTR updateDirPath
   WCHAR updateStatusFilePath[MAX_PATH + 1] = { L'\0' };
   wcsncpy(updateStatusFilePath, updateDirPath, MAX_PATH);
   if (!PathAppendSafe(updateStatusFilePath, L"update.status")) {
     return FALSE;
   }
 
   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);
 }
 
 /**
  * Sets update.status to a specific failure code
  *
  * @param  updateDirPath The path of the update directory
@@ -398,27 +398,27 @@ WriteStatusFailure(LPCWSTR updateDirPath
 {
   WCHAR updateStatusFilePath[MAX_PATH + 1] = { L'\0' };
   wcsncpy(updateStatusFilePath, updateDirPath, MAX_PATH);
   if (!PathAppendSafe(updateStatusFilePath, L"update.status")) {
     return FALSE;
   }
 
   HANDLE statusFile = CreateFileW(updateStatusFilePath, GENERIC_WRITE, 0,
-                                  NULL, CREATE_ALWAYS, 0, NULL);
+                                  nullptr, CREATE_ALWAYS, 0, nullptr);
   if (statusFile == INVALID_HANDLE_VALUE) {
     return FALSE;
   }
   char failure[32];
   sprintf(failure, "failed: %d", errorCode);
 
   DWORD toWrite = strlen(failure);
   DWORD wrote;
   BOOL ok = WriteFile(statusFile, failure,
-                      toWrite, &wrote, NULL);
+                      toWrite, &wrote, nullptr);
   CloseHandle(statusFile);
   return ok && wrote == toWrite;
 }
 
 #endif
 
 /**
  * Waits for a service to enter a stopped state.
@@ -454,17 +454,17 @@ WriteStatusFailure(LPCWSTR updateDirPath
  */
 DWORD
 WaitForServiceStop(LPCWSTR serviceName, DWORD maxWaitSeconds)
 {
   // 0x000000CF is defined above to be not set
   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)  {
     DWORD lastError = GetLastError();
     switch(lastError) {
     case ERROR_ACCESS_DENIED:
       return 0x000000FD;
     case ERROR_DATABASE_DOES_NOT_EXIST:
@@ -669,17 +669,17 @@ IsLocalFile(LPCWSTR file, BOOL &isLocal)
  * @param valueName The name of the value
  * @param retValue  Out parameter which will hold the value
  * @return TRUE on success
 */
 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<LPBYTE>(&retValue),
                                   &regDWORDValueSize);
   return ERROR_SUCCESS == retCode;
 }
 
 /**
  * Determines if the the system's elevation type allows
  * unprmopted elevation.  This may not 100% reflect reality since
@@ -731,51 +731,51 @@ IsUnpromptedElevation(BOOL &isUnprompted
 
     HKEY key;
     if (RegOpenKeyExW(HKEY_CLASSES_ROOT, kDefaultMetroBrowserIDPathKey,
                       0, KEY_READ, &key) != ERROR_SUCCESS) {
       return false;
     }
     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;
     }
     RegCloseKey(key);
     return true;
   }
 
   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();
       return hr;
     }
 
     // Activation is based on the browser's registered app model id
     WCHAR appModelID[256];
     if (!GetDefaultBrowserAppModelID(appModelID, (sizeof(appModelID)/sizeof(WCHAR)))) {
       activateMgr->Release();
       CoUninitialize();
       return hr;
     }
 
     // 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;
     hr = activateMgr->ActivateApplication(appModelID, L"", AO_NOERRORUI,
                                           &processID);
     activateMgr->Release();
     CoUninitialize();
     return hr;
--- a/toolkit/mozapps/update/common/updatelogging.cpp
+++ b/toolkit/mozapps/update/common/updatelogging.cpp
@@ -9,17 +9,17 @@
 
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
 #include <stdarg.h>
 
 #include "updatelogging.h"
 
-UpdateLog::UpdateLog() : logFP(NULL)
+UpdateLog::UpdateLog() : logFP(nullptr)
 {
 }
 
 void UpdateLog::Init(NS_tchar* sourcePath,
                      const NS_tchar* fileName,
                      const NS_tchar* alternateFileName,
                      bool append)
 {
@@ -40,17 +40,17 @@ void UpdateLog::Init(NS_tchar* sourcePat
 }
 
 void UpdateLog::Finish()
 {
   if (!logFP)
     return;
 
   fclose(logFP);
-  logFP = NULL;
+  logFP = nullptr;
 }
 
 void UpdateLog::Flush()
 {
   if (!logFP)
     return;
 
   fflush(logFP);
--- a/toolkit/mozapps/update/test/TestAUSHelper.cpp
+++ b/toolkit/mozapps/update/test/TestAUSHelper.cpp
@@ -47,16 +47,17 @@
 # define NS_tstrcmp strcmp
 # define NS_ttoi atoi
 # define NS_tstat stat
 # define NS_tgetcwd getcwd
 # define NS_tfputs fputs
 # define LOG_S "%s"
 #endif
 
+#include "mozilla/NullPtr.h"
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 
 #ifndef MAXPATHLEN
 # ifdef PATH_MAX
@@ -76,17 +77,17 @@ static void
 WriteMsg(const NS_tchar *path, const char *status)
 {
   FILE* outFP = NS_tfopen(path, NS_T("wb"));
   if (!outFP)
     return;
 
   fprintf(outFP, "%s\n", status);
   fclose(outFP);
-  outFP = NULL;
+  outFP = nullptr;
 }
 
 static bool
 CheckMsg(const NS_tchar *path, const char *expected)
 {
   if (NS_taccess(path, F_OK)) {
     return false;
   }
@@ -113,17 +114,17 @@ CheckMsg(const NS_tchar *path, const cha
   rb += c;
   if (c == 0 && r) {
     return false;
   }
   mbuf[ms.st_size] = '\0';
   rb = mbuf;
 
   fclose(inFP);
-  inFP = NULL;
+  inFP = nullptr;
   return strcmp(rb, expected) == 0;
 }
 
 #ifdef XP_WIN
 /**
  * Verifies the trust of the specified file path.
  *
  * @param  filePath  The file path to check.
@@ -137,31 +138,31 @@ VerifyCertificateTrustForFile(LPCWSTR fi
   ZeroMemory(&fileToCheck, sizeof(fileToCheck));
   fileToCheck.cbStruct = sizeof(WINTRUST_FILE_INFO);
   fileToCheck.pcwszFilePath = filePath;
 
   // Setup what to check, we want to check it is signed and trusted.
   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
 
 int NS_main(int argc, NS_tchar **argv)
 {
 
   if (argc < 3) {
@@ -308,31 +309,31 @@ int NS_main(int argc, NS_tchar **argv)
   int i = 0;
 
   if (NS_tchdir(argv[1]) != 0) {
     return 1;
   }
 
   // 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]);
     NS_tchar outFilePath[MAXPATHLEN];
     NS_tsnprintf(outFilePath, sizeof(outFilePath)/sizeof(outFilePath[0]),
                  NS_T("%s/%s"), cwd, argv[3]);
 
     int seconds = NS_ttoi(argv[5]);
 #ifdef XP_WIN
     HANDLE hFile = INVALID_HANDLE_VALUE;
     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;
       }
     }
 
     WriteMsg(outFilePath, "sleeping");
     while (!CheckMsg(inFilePath, "finish\n") && i++ <= seconds)  {
@@ -358,12 +359,12 @@ int NS_main(int argc, NS_tchar **argv)
                NS_T("%s"), argv[2]);
 
   FILE* logFP = NS_tfopen(logFilePath, NS_T("wb"));
   for (i = 1; i < argc; ++i) {
     fprintf(logFP, LOG_S "\n", argv[i]);
   }
 
   fclose(logFP);
-  logFP = NULL;
+  logFP = nullptr;
 
   return 0;
 } 
--- a/toolkit/mozapps/update/updater/archivereader.cpp
+++ b/toolkit/mozapps/update/updater/archivereader.cpp
@@ -22,18 +22,18 @@
 #if defined(XP_UNIX)
 # include <sys/types.h>
 #elif defined(XP_WIN)
 # include <io.h>
 #endif
 
 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"
 
 /**
  * Obtains the data of the specified resource name and type.
  *
  * @param  name The name ID of the resource
@@ -41,17 +41,17 @@ static char *outbuf = NULL;
  * @param  data Out parameter which sets the pointer to a buffer containing
  *                  the needed data.
  * @param  size Out parameter which sets the size of the returned data buffer 
  * @return TRUE on success
 */
 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;
   }
 
   HRSRC resourceInfoBlockHandle = FindResource(handle, 
                                                MAKEINTRESOURCE(name),
                                                MAKEINTRESOURCE(type));
   if (!resourceInfoBlockHandle) {
@@ -79,17 +79,17 @@ LoadFileInResource(int name, int type, c
  * @param  name      The name ID of the resource
  * @param  type      THe type ID of the resource
  * @return OK on success, CERT_LOAD_ERROR or CERT_VERIFY_ERROR on failure.
 */
 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;
   }
 
   if (mar_verify_signaturesW(archive, &data, &size, 1)) {
     return CERT_VERIFY_ERROR;
   }
 
@@ -178,17 +178,17 @@ ArchiveReader::VerifyProductInformation(
     strncpy(channelCopy, MARChannelID, sizeof(channelCopy) - 1);
     char *channel = strtok(channelCopy, delimiter);
     rv = MAR_CHANNEL_MISMATCH_ERROR;
     while(channel) {
       if (!strcmp(channel, productInfoBlock.MARChannelID)) {
         rv = OK;
         break;
       }
-      channel = strtok(NULL, delimiter);
+      channel = strtok(nullptr, delimiter);
     }
   }
 
   if (rv == OK) {
     /* Compare both versions to ensure we don't have a downgrade
         -1 if appVersion is older than productInfoBlock.productVersion
         1 if appVersion is newer than productInfoBlock.productVersion
         0 if appVersion is the same as productInfoBlock.productVersion
@@ -248,27 +248,27 @@ ArchiveReader::Open(const NS_tchar *path
   return OK;
 }
 
 void
 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;
   }
 }
 
 int
 ArchiveReader::ExtractFile(const char *name, const NS_tchar *dest)
 {
   const MarItem *item = mar_find_item(mArchive, name);
   if (!item)
--- a/toolkit/mozapps/update/updater/archivereader.h
+++ b/toolkit/mozapps/update/updater/archivereader.h
@@ -2,30 +2,31 @@
 /* vim:set ts=2 sw=2 sts=2 et cindent: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef ArchiveReader_h__
 #define ArchiveReader_h__
 
+#include "mozilla/NullPtr.h"
 #include <stdio.h>
 #include "mar.h"
 
 #ifdef XP_WIN
   typedef WCHAR NS_tchar;
 #else
   typedef char NS_tchar;
 #endif
 
 // This class provides an API to extract files from an update archive.
 class ArchiveReader
 {
 public:
-  ArchiveReader() : mArchive(NULL) {}
+  ArchiveReader() : mArchive(nullptr) {}
   ~ArchiveReader() { Close(); }
 
   int Open(const NS_tchar *path);
   int VerifySignature();
   int VerifyProductInformation(const char *MARChannelID, 
                                const char *appVersion);
   void Close();
 
--- a/toolkit/mozapps/update/updater/automounter_gonk.cpp
+++ b/toolkit/mozapps/update/updater/automounter_gonk.cpp
@@ -24,17 +24,17 @@
   __android_log_print(level, LOG_TAG, format, ##__VA_ARGS__)
 
 #define LOGI(format, ...) GONK_LOG(ANDROID_LOG_INFO, format, ##__VA_ARGS__)
 #define LOGE(format, ...) GONK_LOG(ANDROID_LOG_ERROR, format, ##__VA_ARGS__)
 
 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);
   }
 }
 
 GonkAutoMounter::~GonkAutoMounter()
 {
@@ -53,17 +53,17 @@ GonkAutoMounter::Reboot()
   // The android_reboot wrapper provides more safety, doing fancier read-only
   // remounting and attempting to sync() the filesystem first. If this fails
   // our only hope is to force a reboot directly without these protections.
   // For more, see system/core/libcutils/android_reboot.c
   LOGE("Could not remount %s as read-only, forcing a system 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();
 
     if (reboot(RB_AUTOBOOT) != 0) {
       LOGE("CRITICAL: Failed to force restart");
     }
   }
 }
@@ -115,17 +115,17 @@ GonkAutoMounter::RemountSystem(MountAcce
   return true;
 }
 
 bool
 GonkAutoMounter::UpdateMountStatus()
 {
   FILE *mountsFile = NS_tfopen(kGonkMountsPath, "r");
 
-  if (mountsFile == NULL) {
+  if (mountsFile == nullptr) {
     LOGE("Error opening %s: %s", kGonkMountsPath, strerror(errno));
     return false;
   }
 
   // /proc/mounts returns a 0 size from fstat, so we use the same
   // pre-allocated buffer size that ADB does here
   const int mountsMaxSize = 4096;
   char mountData[mountsMaxSize];
@@ -138,17 +138,17 @@ GonkAutoMounter::UpdateMountStatus()
     return false;
   }
 
   char *token, *tokenContext;
   bool foundSystem = false;
 
   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;
       break;
     }
   }
 
   fclose(mountsFile);
@@ -183,17 +183,17 @@ GonkAutoMounter::ProcessMount(const char
 
   free(mDevice);
   mDevice = strdup(mountDev);
   mAccess = Unknown;
 
   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;
       break;
     } else if (strcmp("rw", option) == 0) {
       mAccess = ReadWrite;
       break;
     }
@@ -206,17 +206,17 @@ bool
 GonkAutoMounter::MountSystem(unsigned long flags)
 {
   if (!mDevice) {
     LOGE("No device was found for %s", kGonkSystemPath);
     return false;
   }
 
   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,
          strerror(errno));
     return false;
   }
 
   LOGI("Mounted %s partition as %s", kGonkSystemPath, readOnly);
--- a/toolkit/mozapps/update/updater/loaddlls.cpp
+++ b/toolkit/mozapps/update/updater/loaddlls.cpp
@@ -31,17 +31,17 @@ struct AutoLoadSystemDependencies
     // normal search path.
     GetSystemDirectory(systemDirectory, MAX_PATH + 1);
     size_t systemDirLen = wcslen(systemDirectory);
 
     // Make the system directory path terminate with a slash
     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
     for (size_t i = 0; i < sizeof(delayDLLs) / sizeof(delayDLLs[0]); ++i) {
       size_t fileLen = wcslen(delayDLLs[i]);
       wcsncpy(systemDirectory + systemDirLen, delayDLLs[i], 
               MAX_PATH - systemDirLen);
       if (systemDirLen + fileLen <= MAX_PATH) {
--- a/toolkit/mozapps/update/updater/progressui_gtk.cpp
+++ b/toolkit/mozapps/update/updater/progressui_gtk.cpp
@@ -81,37 +81,37 @@ ShowProgressUI()
   if (!sWin)
     return -1;
 
   static GdkPixbuf *pixbuf;
   char icon_path[PATH_MAX];
   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);
   gtk_window_set_position(GTK_WINDOW(sWin), GTK_WIN_POS_CENTER_ALWAYS);
   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);
 
   GtkWidget *vbox = gtk_vbox_new(TRUE, 6);
   sLabel = gtk_label_new(strings.info);
   gtk_misc_set_alignment(GTK_MISC(sLabel), 0.0f, 0.0f);
   sProgressBar = gtk_progress_bar_new();
 
   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);
   gtk_widget_show_all(sWin);
 
   gtk_main();
   return 0;
 }
--- a/toolkit/mozapps/update/updater/progressui_win.cpp
+++ b/toolkit/mozapps/update/updater/progressui_win.cpp
@@ -42,17 +42,17 @@
 static float sProgress;  // between 0 and 100
 static BOOL  sQuit = FALSE;
 static BOOL sIndeterminate = FALSE;
 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, '.');
   if (!dot || wcsicmp(dot + 1, L"exe"))
     return FALSE;
 
   wcscpy(dot + 1, L"ini");
   return TRUE;
@@ -110,17 +110,18 @@ InitDialog(HWND hDlg)
                       sizeof(szwTitle)/sizeof(szwTitle[0]));
   MultiByteToWideChar(CP_UTF8, 0, sUIStrings.info, -1, szwInfo,
                       sizeof(szwInfo)/sizeof(szwInfo[0]));
 
   SetWindowTextW(hDlg, szwTitle);
   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);
 
   HWND hWndPro = GetDlgItem(hDlg, IDC_PROGRESS);
   SendMessage(hWndPro, PBM_SETRANGE, 0, MAKELPARAM(0, 100));
   if (sIndeterminate) {
     LONG_PTR val = GetWindowLongPtr(hWndPro, GWL_STYLE);
     SetWindowLongPtr(hWndPro, GWL_STYLE, val|PBS_MARQUEE); 
@@ -166,17 +167,17 @@ InitDialog(HWND hDlg)
 
   if (hOldFont)
     SelectObject(hDCInfo, hOldFont);
 
   ReleaseDC(hWndInfo, hDCInfo);
 
   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.
 static LRESULT CALLBACK
 DialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
 {
   switch (message)
   {
@@ -249,18 +250,18 @@ ShowProgressUI(bool indeterminate, bool 
   }
 
   INITCOMMONCONTROLSEX icc = {
     sizeof(INITCOMMONCONTROLSEX),
     ICC_PROGRESS_CLASS
   };
   InitCommonControlsEx(&icc);
 
-  DialogBox(GetModuleHandle(NULL),
-            MAKEINTRESOURCE(IDD_DIALOG), NULL,
+  DialogBox(GetModuleHandle(nullptr),
+            MAKEINTRESOURCE(IDD_DIALOG), nullptr,
             (DLGPROC) DialogProc);
 
   return 0;
 }
 
 void
 QuitProgressUI()
 {
--- a/toolkit/mozapps/update/updater/updater.cpp
+++ b/toolkit/mozapps/update/updater/updater.cpp
@@ -156,22 +156,22 @@ crc32(const unsigned char *buf, unsigned
 
 //-----------------------------------------------------------------------------
 
 // A simple stack based container for a FILE struct that closes the
 // file descriptor from its destructor.
 class AutoFile
 {
 public:
-  AutoFile(FILE* file = NULL)
+  AutoFile(FILE* file = nullptr)
     : mFile(file) {
   }
 
   ~AutoFile() {
-    if (mFile != NULL)
+    if (mFile != nullptr)
       fclose(mFile);
   }
 
   AutoFile &operator=(FILE* file) {
     if (mFile != 0)
       fclose(mFile);
     mFile = file;
     return *this;
@@ -210,17 +210,18 @@ class Thread
 public:
   int Run(ThreadFunc func, void *param)
   {
     mThreadFunc = func;
     mThreadParam = param;
 
     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;
   }
   int Join()
   {
     WaitForSingleObject(mThread, INFINITE);
     CloseHandle(mThread);
     return 0;
@@ -240,17 +241,17 @@ private:
 #elif defined(XP_UNIX)
 #include <pthread.h>
 
 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()
   {
     void *result;
     return pthread_join(thr, &result);
   }
 private:
   pthread_t thr;
@@ -261,17 +262,17 @@ private:
 class Thread
 {
 public:
   int Run(ThreadFunc func, void *param)
   {
     mThreadFunc = func;
     mThreadParam = param;
 
-    mThread = _beginthread(ThreadMain, NULL, 16384, (void *)this);
+    mThread = _beginthread(ThreadMain, nullptr, 16384, (void *)this);
 
     return mThread ? 0 : -1;
   }
   int Join()
   {
     int status;
     waitpid(mThread, &status, 0);
     return 0;
@@ -318,145 +319,145 @@ mmin(size_t a, size_t b)
 {
   return (a > b) ? b : a;
 }
 
 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;
   const NS_tchar *d;
   do {
     for (d = delims; *d != NS_T('\0'); ++d) {
       if (*ret == *d) {
         ++ret;
         break;
       }
     }
   } while (*d);
 
   if (!*ret) {
     *str = ret;
-    return NULL;
+    return nullptr;
   }
 
   NS_tchar *i = ret;
   do {
     for (d = delims; *d != NS_T('\0'); ++d) {
       if (*i == *d) {
         *i = NS_T('\0');
         *str = ++i;
         return ret;
       }
     }
     ++i;
   } while (*i);
 
-  *str = NULL;
+  *str = nullptr;
   return ret;
 }
 
 #ifdef XP_WIN
 /**
  * Coverts a relative update path to a full path for Windows.
  *
  * @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)
 {
   size_t lendestpath = NS_tstrlen(gDestPath);
   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;
 
   NS_tstrcpy(c, gDestPath);
   c += lendestpath;
   NS_tstrcat(c, relpath);
   c += lenrelpath;
   *c = NS_T('\0');
   c++;
   return s;
 }
 #endif
 
 /**
  * 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)
 {
   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
 
   if (isdir) {
     // Directory paths must have a trailing forward slash.
     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
     // ENOENT if the path has a trailing slash.
     path[NS_tstrlen(path) - 1] = NS_T('\0');
   }
 
   // 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;
 }
 
 static NS_tchar*
 get_quoted_path(const NS_tchar *path)
 {
   size_t lenQuote = NS_tstrlen(kQuote);
   size_t lenPath = NS_tstrlen(path);
   size_t len = lenQuote + lenPath + lenQuote + 1;
 
   NS_tchar *s = (NS_tchar *) malloc(len * sizeof(NS_tchar));
   if (!s)
-    return NULL;
+    return nullptr;
 
   NS_tchar *c = s;
   NS_tstrcpy(c, kQuote);
   c += lenQuote;
   NS_tstrcat(c, path);
   c += lenPath;
   NS_tstrcat(c, kQuote);
   c += lenQuote;
@@ -564,27 +565,27 @@ static FILE* ensure_open(const NS_tchar 
   ensure_write_permissions(path);
   FILE* f = NS_tfopen(path, flags);
   if (is_read_only(flags)) {
     // Don't attempt to modify the file permissions if the file is being opened
     // in read-only mode.
     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;
 }
 
 // Ensure that the directory containing this file exists.
 static int ensure_parent_dir(const NS_tchar *path)
 {
   int rv = OK;
@@ -914,17 +915,17 @@ static int backup_discard(const NS_tchar
            backup, path));
       return WRITE_ERROR;
     }
     // The MoveFileEx call to remove the file on OS reboot will fail if the
     // process doesn't have write access to the HKEY_LOCAL_MACHINE registry key
     // 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 {
       LOG(("backup_discard: failed to schedule OS reboot removal of " \
            "file: " LOG_S, path));
     }
   }
 #else
@@ -946,17 +947,17 @@ static void backup_finish(const NS_tchar
 
 //-----------------------------------------------------------------------------
 
 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;
 
   // Do any preprocessing to ensure that the action can be performed.  Execute
   // will be called if this Action and all others return OK from this method.
   virtual int Prepare() = 0;
 
@@ -974,17 +975,17 @@ private:
   Action* mNext;
 
   friend class ActionList;
 };
 
 class RemoveFile : public Action
 {
 public:
-  RemoveFile() : mFile(NULL), mSkip(0) { }
+  RemoveFile() : mFile(nullptr), mSkip(0) { }
 
   int Parse(NS_tchar *line);
   int Prepare();
   int Execute();
   void Finish(int status);
 
 private:
   const NS_tchar *mFile;
@@ -1083,17 +1084,17 @@ RemoveFile::Finish(int status)
   LOG(("FINISH REMOVEFILE " LOG_S, mFile));
 
   backup_finish(mFile, 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
   virtual int Execute();
   virtual void Finish(int status);
 
 private:
   const NS_tchar *mDir;
@@ -1190,17 +1191,17 @@ RemoveDir::Finish(int status)
            mDir, rv, errno));
     }
   }
 }
 
 class AddFile : public Action
 {
 public:
-  AddFile() : mFile(NULL)
+  AddFile() : mFile(nullptr)
             , mAdded(false)
             { }
 
   virtual int Parse(NS_tchar *line);
   virtual int Prepare();
   virtual int Execute();
   virtual void Finish(int status);
 
@@ -1246,17 +1247,17 @@ AddFile::Execute()
     rv = ensure_parent_dir(mFile);
     if (rv)
       return rv;
   }
 
 #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;
   }
 
   rv = gArchiveReader.ExtractFile(sourcefile, mFile);
 #else
   rv = gArchiveReader.ExtractFile(mFile, mFile);
 #endif
@@ -1275,17 +1276,17 @@ AddFile::Finish(int status)
   if (status && mAdded)
     NS_tremove(mFile);
   backup_finish(mFile, status);
 }
 
 class PatchFile : public Action
 {
 public:
-  PatchFile() : mPatchIndex(-1), buf(NULL) { }
+  PatchFile() : mPatchIndex(-1), buf(nullptr) { }
 
   virtual ~PatchFile();
 
   virtual int Parse(NS_tchar *line);
   virtual int Prepare(); // should check for patch file and for checksum here
   virtual int Execute();
   virtual void Finish(int status);
 
@@ -1400,17 +1401,17 @@ PatchFile::Prepare()
 
   FILE *fp = NS_tfopen(spath, NS_T("wb"));
   if (!fp)
     return WRITE_ERROR;
 
 #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;
   }
 
   int rv = gArchiveReader.ExtractFileToStream(sourcefile, fp);
 #else
   int rv = gArchiveReader.ExtractFileToStream(mPatchFile, fp);
 #endif
@@ -1419,24 +1420,24 @@ PatchFile::Prepare()
 }
 
 int
 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
     // be opened for reading to prevent the application from being launched.
     origfile = NS_tfopen(gCallbackBackupPath, NS_T("rb"));
   } else {
     origfile = NS_tfopen(mFile, NS_T("rb"));
   }
@@ -1481,23 +1482,24 @@ PatchFile::Execute()
   // have been tested are:
   // 1. _chsize / _chsize_s reduced fragmentation but though not completely.
   // 2. _get_osfhandle and then setting the size reduced fragmentation though
   //    not completely. There are also reports of _get_osfhandle failing on
   //    mingw.
   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;
     }
     CloseHandle(hfile);
   }
 
   AutoFile ofile = ensure_open(mFile, shouldTruncate ? NS_T("wb+") : NS_T("rb+"), ss.st_mode);
 #elif defined(XP_MACOSX)
@@ -1514,53 +1516,53 @@ PatchFile::Execute()
 
   if (rv != -1) {
     ftruncate(fileno((FILE *)ofile), header.dlen);
   }
 #else
   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;
   }
 
 #ifdef XP_WIN
   if (!shouldTruncate) {
     fseek(ofile, 0, SEEK_SET);
   }
 #endif
 
   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;
 }
 
 void
 PatchFile::Finish(int status)
 {
   LOG(("FINISH PATCH " LOG_S, mFile));
 
   backup_finish(mFile, status);
 }
 
 class AddIfFile : public AddFile
 {
 public:
-  AddIfFile() : mTestFile(NULL) { }
+  AddIfFile() : mTestFile(nullptr) { }
 
   virtual int Parse(NS_tchar *line);
   virtual int Prepare();
   virtual int Execute();
   virtual void Finish(int status);
 
 protected:
   const NS_tchar *mTestFile;
@@ -1583,17 +1585,17 @@ AddIfFile::Parse(NS_tchar *line)
   return AddFile::Parse(line);
 }
 
 int
 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;
   }
 
   return AddFile::Prepare();
 }
 
 int
 AddIfFile::Execute()
@@ -1611,17 +1613,17 @@ AddIfFile::Finish(int status)
     return;
 
   AddFile::Finish(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
   virtual int Execute();
   virtual void Finish(int status);
 
 private:
   const NS_tchar *mTestFile;
@@ -1644,17 +1646,17 @@ PatchIfFile::Parse(NS_tchar *line)
   return PatchFile::Parse(line);
 }
 
 int
 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;
   }
 
   return PatchFile::Prepare();
 }
 
 int
 PatchIfFile::Execute()
@@ -1727,17 +1729,17 @@ LaunchCallbackApp(const NS_tchar *workin
 #if defined(MOZ_METRO)
     // If our callback application is the default metro browser, then
     // launch it now.
     if (IsUpdateFromMetro(argc, argv)) {
       LaunchDefaultMetroBrowser();
       return;
     }
 #endif
-    WinLaunchChild(argv[0], argc, argv, NULL);
+    WinLaunchChild(argv[0], argc, argv, nullptr);
   }
 #else
 # warning "Need implementaton of LaunchCallbackApp"
 #endif
 }
 
 static bool
 WriteStatusFile(const char* aStatus)
@@ -1746,17 +1748,17 @@ WriteStatusFile(const char* aStatus)
   NS_tsnprintf(filename, sizeof(filename)/sizeof(filename[0]),
                NS_T("%s/update.status"), gSourcePath);
 
   // Make sure that the directory for the update status file exists
   if (ensure_parent_dir(filename))
     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)
     return false;
 
   return true;
 }
 
@@ -1793,17 +1795,17 @@ WriteStatusFile(int status)
 static bool
 IsUpdateStatusPendingService()
 {
   NS_tchar filename[MAXPATHLEN];
   NS_tsnprintf(filename, sizeof(filename)/sizeof(filename[0]),
                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 };
   fread(buf, sizeof(buf), 1, file);
 
   const char kPendingService[] = "pending-service";
   const char kAppliedService[] = "applied-service";
 
@@ -1827,17 +1829,17 @@ static bool
 IsUpdateStatusSucceeded(bool &isSucceeded)
 {
   isSucceeded = false;
   NS_tchar filename[MAXPATHLEN];
   NS_tsnprintf(filename, sizeof(filename)/sizeof(filename[0]),
                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 };
   fread(buf, sizeof(buf), 1, file);
 
   const char kSucceeded[] = "succeeded";
   isSucceeded = strncmp(buf, kSucceeded, 
                         sizeof(kSucceeded) - 1) == 0;
@@ -2006,17 +2008,17 @@ ProcessReplaceRequest()
     return rv;
   }
 
   LOG(("Now, remove the tmpDir"));
   rv = ensure_remove_recursive(tmpDir);
   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,
            tmpDir));
     }
 #endif
   }
 
@@ -2139,17 +2141,17 @@ GetUpdateFileName(NS_tchar *fileName, in
 {
 #if defined(MOZ_WIDGET_GONK)  // If an update.link file exists, then it will contain the name
   // of the update file (terminated by a newline).
 
   NS_tchar linkFileName[MAXPATHLEN];
   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;
   }
 
   char dataFileName[MAXPATHLEN];
   size_t bytesRead;
 
@@ -2270,19 +2272,19 @@ UpdateThreadFunc(void *param)
       LOG(("failed: %d", rv));
     }
     else {
 #ifdef XP_MACOSX
       // If the update was successful we need to update the timestamp
       // 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);
       }
       else {
         LOG(("Couldn't get current working directory for setting "
              "access/modification time on application bundle."));
       }
@@ -2346,40 +2348,40 @@ int NS_main(int argc, NS_tchar **argv)
   NS_tchar *slash = NS_tstrrchr(gDestinationPath, NS_SLASH);
   if (slash && !slash[1]) {
     *slash = NS_T('\0');
   }
 
 #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<char*>("MOZ_NO_SERVICE_FALLBACK="));
 
   // We never want the service to be used unless we build with
   // the maintenance service.
 #ifdef MOZ_MAINTENANCE_SERVICE
   useService = IsUpdateStatusPendingService();
   // Our tests run with a different apply directory for each test.
   // We use this registry key on our test slaves to store the 
   // allowed name/issuers.
   testOnlyFallbackKeyExists = DoesFallbackKeyExist();
 #endif
 
   // Remove everything except close window from the context menu
   {
     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);
       RegCloseKey(hkApp);
     }
   }
 #endif
 
@@ -2476,17 +2478,17 @@ int NS_main(int argc, NS_tchar **argv)
       }
     }
   }
 #endif
 
 #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) {
       bool updateFromMetro = false;
 #ifdef MOZ_METRO
       updateFromMetro = IsUpdateFromMetro(argc, argv);
 #endif
       DWORD waitTime = updateFromMetro ?
@@ -2494,17 +2496,17 @@ int NS_main(int argc, NS_tchar **argv)
       DWORD result = WaitForSingleObject(parent, waitTime);
       CloseHandle(parent);
       if (result != WAIT_OBJECT_0 && !updateFromMetro)
         return 1;
     }
   }
 #else
   if (pid > 0)
-    waitpid(pid, NULL, 0);
+    waitpid(pid, nullptr, 0);
 #endif
 
   if (sReplaceRequest) {
 #ifdef XP_WIN
     // On Windows, the current working directory of the process should be changed
     // so that it's not locked.
     NS_tchar tmpDir[MAXPATHLEN];
     if (GetTempPathW(MAXPATHLEN, tmpDir)) {
@@ -2514,17 +2516,17 @@ int NS_main(int argc, NS_tchar **argv)
   }
 
   // The callback is the remaining arguments starting at callbackIndex.
   // The argument specified by callbackIndex is the callback executable and the
   // argument prior to callbackIndex is the working directory.
   const int callbackIndex = 5;
 
 #if defined(XP_WIN)
-  sUsingService = getenv("MOZ_USING_SERVICE") != NULL;
+  sUsingService = getenv("MOZ_USING_SERVICE") != nullptr;
   putenv(const_cast<char*>("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 
   // error to the update.status file. 
   // When fallback is disabled (MOZ_NO_SERVICE_FALLBACK does not exist) then
   // we will instead fallback to not using the service and display a UAC prompt.
   int lastFallbackError = FALLBACKKEY_UNKNOWN_ERROR;
 
@@ -2575,20 +2577,20 @@ int NS_main(int argc, NS_tchar **argv)
       }
       LOG(("Update already in progress! Exiting"));
       return 1;
     }
 
     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]),
                  NS_T("%s/update_elevated.lock"), gSourcePath);
 
 
     // Even if a file has no sharing access, you can still get its attributes
     bool startedFromUnelevatedUpdater =
@@ -2598,35 +2600,35 @@ int NS_main(int argc, NS_tchar **argv)
     // token as the service so the permissions are already dropped.  If we're
     // running from an elevated updater that was started from an unelevated 
     // updater, then we drop the permissions here. We do not drop the 
     // permissions on the originally called updater because we use its token
     // to start the callback application.
     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 || 
         (useService && testOnlyFallbackKeyExists && noServiceFallback)) {
       if (!_waccess(elevatedLockFilePath, F_OK) &&
           NS_tremove(elevatedLockFilePath) != 0) {
         fprintf(stderr, "Unable to create elevated lock file! Exiting\n");
         return 1;
       }
 
       HANDLE elevatedFileHandle;
       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"));
         return 1;
       }
 
       PRUnichar *cmdLine = MakeCommandLine(argc - 1, argv + 1);
       if (!cmdLine) {
@@ -2707,17 +2709,17 @@ int NS_main(int argc, NS_tchar **argv)
             showProgressUI = !InitProgressUIStrings();
           }
 
           // Wait for the service to stop for 5 seconds.  If the service
           // has still not stopped then show an indeterminate progress bar.
           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);
             }
             t1.Join();
           }
 
           lastState = WaitForServiceStop(SVC_NAME, 1);
           if (lastState != SERVICE_STOPPED) {
@@ -2750,17 +2752,17 @@ int NS_main(int argc, NS_tchar **argv)
       // current process is running as.
       // Note that we don't need to do this if we're just staging the
       // update in the background, as the PostUpdate step runs when
       // performing the replacing in that case.
       if (useService && !sBackgroundUpdate) {
         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.");
           }
         }
       }
 
       // If we didn't want to use the service at all, or if an update was 
       // already happening, or launching the service command failed, then 
@@ -2771,17 +2773,17 @@ int NS_main(int argc, NS_tchar **argv)
       if (!useService && !noServiceFallback && 
           updateLockFileHandle == INVALID_HANDLE_VALUE) {
         SHELLEXECUTEINFO sinfo;
         memset(&sinfo, 0, sizeof(SHELLEXECUTEINFO));
         sinfo.cbSize       = sizeof(SHELLEXECUTEINFO);
         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";
         sinfo.nShow        = SW_SHOWNORMAL;
 
         bool result = ShellExecuteEx(&sinfo);
         free(cmdLine);
 
@@ -2920,34 +2922,38 @@ int NS_main(int argc, NS_tchar **argv)
     NS_tchar callbackLongPath[MAXPATHLEN];
     ZeroMemory(callbackLongPath, sizeof(callbackLongPath));
     NS_tchar *targetPath = argv[callbackIndex];
     NS_tchar buffer[MAXPATHLEN * 2] = { NS_T('\0') };
     size_t bufferLeft = MAXPATHLEN * 2;
     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;
       bufferLeft -= commonPrefixLength;
       NS_tstrncpy(p, gDestinationPath + commonPrefixLength, bufferLeft);
 
       size_t len = NS_tstrlen(gDestinationPath + commonPrefixLength);
       p += len;
       bufferLeft -= len;
       *p = NS_T('\\');
       ++p;
       bufferLeft--;
       *p = NS_T('\0');
       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;
     }
     if (!GetLongPathNameW(targetPath, callbackLongPath,
                           sizeof(callbackLongPath)/sizeof(callbackLongPath[0]))) {
       LOG(("NS_main: unable to find callback file: " LOG_S, targetPath));
       LogFinish();
       WriteStatusFile(WRITE_ERROR);
@@ -3002,17 +3008,17 @@ int NS_main(int argc, NS_tchar **argv)
       do {
         // By opening a file handle wihout FILE_SHARE_READ to the callback
         // executable, the OS will prevent launching the process while it is
         // being updated.
         callbackFile = CreateFileW(targetPath,
                                    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;
 
         lastWriteError = GetLastError();
         LOG(("NS_main: callback app open attempt %d failed. " \
              "File: " LOG_S ". Last error: %d", retries,
              targetPath, lastWriteError));
 
@@ -3057,17 +3063,17 @@ int NS_main(int argc, NS_tchar **argv)
     }
   }
 #endif /* XP_WIN */
 
   // Run update process on a background thread.  ShowProgressUI may return
   // 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();
     }
   }
   t.Join();
 
 #ifdef XP_WIN
   if (argc > callbackIndex && !sReplaceRequest) {
@@ -3085,17 +3091,17 @@ int NS_main(int argc, NS_tchar **argv)
     // that are in use and will be removed on OS reboot. The call to remove the
     // directory on OS reboot is done after the calls to remove the files so the
     // files are removed first on OS reboot since the directory must be empty
     // for the directory removal to be successful. The MoveFileEx call to remove
     // the directory on OS reboot will fail if the process doesn't have write
     // 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 {
       LOG(("NS_main: failed to schedule OS reboot removal of " \
            "directory: " LOG_S, DELETE_DIR));
     }
   }
 #endif /* XP_WIN */
@@ -3114,17 +3120,17 @@ int NS_main(int argc, NS_tchar **argv)
       // the PostUpdate process. We do the service update process here 
       // because it's possible we are updating with updater.exe without the 
       // service if the service failed to apply the update. We want to update
       // the service to a newer version in that case. If we are not running
       // through the service, then MOZ_USING_SERVICE will not exist.
       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."));
           }
 
           StartServiceUpdate(installDir);
         }
       }
     }
     EXIT_WHEN_ELEVATED(elevatedLockFilePath, updateLockFileHandle, 0);
@@ -3142,17 +3148,17 @@ int NS_main(int argc, NS_tchar **argv)
   }
 
   return gSucceeded ? 0 : 1;
 }
 
 class ActionList
 {
 public:
-  ActionList() : mFirst(NULL), mLast(NULL), mCount(0) { }
+  ActionList() : mFirst(nullptr), mLast(nullptr), mCount(0) { }
   ~ActionList();
 
   void Append(Action* action);
   int Prepare();
   int Execute();
   void Finish(int status);
 
 private:
@@ -3426,29 +3432,29 @@ int add_dir_entries(const NS_tchar *dirp
   FTSENT *ftsdirEntry;
   NS_tchar searchpath[MAXPATHLEN];
 
   NS_tsnprintf(searchpath, sizeof(searchpath)/sizeof(searchpath[0]), NS_T("%s"),
                dirpath);
   // 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
       case FTS_SL:
       case FTS_SLNONE:
       case FTS_DEFAULT:
         LOG(("add_dir_entries: found a non-standard file: " LOG_S,
              ftsdirEntry->fts_path));
@@ -3528,76 +3534,76 @@ int add_dir_entries(const NS_tchar *dirp
   return rv;
 }
 #endif
 
 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;
   while (r) {
     const size_t count = mmin(SSIZE_MAX, r);
     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;
     rb += c;
   }
   mbuf[ms.st_size] = '\0';
   rb = mbuf;
 
 #ifndef XP_WIN
   return rb;
 #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);
 
   return wrb;
 #endif
 }
 
 int AddPreCompleteActions(ActionList *list)
 {
   if (sIsOSUpdate) {
     return OK;
   }
 
   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.
     return OK;
   }
 
   int rv;
   NS_tchar *line;
@@ -3607,17 +3613,17 @@ int AddPreCompleteActions(ActionList *li
       continue;
 
     NS_tchar *token = mstrtok(kWhitespace, &line);
     if (!token) {
       LOG(("AddPreCompleteActions: token not found in manifest"));
       return PARSE_ERROR;
     }
 
-    Action *action = NULL;
+    Action *action = nullptr;
     if (NS_tstrcmp(token, NS_T("remove")) == 0) { // rm file
       action = new RemoveFile();
     }
     else if (NS_tstrcmp(token, NS_T("remove-cc")) == 0) { // no longer supported
       continue;
     }
     else if (NS_tstrcmp(token, NS_T("rmdir")) == 0) { // rmdir if  empty
       action = new RemoveDir();
@@ -3652,17 +3658,17 @@ int DoUpdate()
     rv = gArchiveReader.ExtractFile("update.manifest", manifest);
     if (rv) {
       LOG(("DoUpdate: error extracting manifest file"));
       return rv;
     }
   }
 
   NS_tchar *rb = GetManifestContents(manifest);
-  if (rb == NULL) {
+  if (rb == nullptr) {
     LOG(("DoUpdate: error opening manifest file: " LOG_S, manifest));
     return READ_ERROR;
   }
 
 
   ActionList list;
   NS_tchar *line;
   bool isFirstAction = true;
@@ -3687,17 +3693,17 @@ int DoUpdate()
           return rv;
       }
       isFirstAction = false;
       continue;
     }
 
     isFirstAction = false;
 
-    Action *action = NULL;
+    Action *action = nullptr;
     if (NS_tstrcmp(token, NS_T("remove")) == 0) { // rm file
       action = new RemoveFile();
     }
     else if (NS_tstrcmp(token, NS_T("rmdir")) == 0) { // rmdir if  empty
       action = new RemoveDir();
     }
     else if (NS_tstrcmp(token, NS_T("rmrfdir")) == 0) { // rmdir recursive
       const NS_tchar *reldirpath = mstrtok(kQuote, &line);
--- a/toolkit/profile/nsToolkitProfileService.cpp
+++ b/toolkit/profile/nsToolkitProfileService.cpp
@@ -1021,17 +1021,17 @@ nsresult
 XRE_GetFileFromPath(const char *aPath, nsIFile* *aResult)
 {
 #if defined(XP_MACOSX)
     int32_t pathLen = strlen(aPath);
     if (pathLen > MAXPATHLEN)
         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;
 
     nsCOMPtr<nsIFile> lf;
     nsresult rv = NS_NewNativeLocalFile(EmptyCString(), true,
                                         getter_AddRefs(lf));
     if (NS_SUCCEEDED(rv)) {