author | Birunthan Mohanathas <birunthan@mohanathas.com> |
Thu, 10 Oct 2013 16:39:09 -0400 | |
changeset 164210 | 18fa6912a68ae485e2f2bec654d18a50d8a7581b |
parent 164209 | 62c48f8645456e6d7eb5988b7a7d96916c91234e |
child 164211 | fc9733225130f30dde5e197bc4885722c9401ad1 |
push id | 3066 |
push user | akeybl@mozilla.com |
push date | Mon, 09 Dec 2013 19:58:46 +0000 |
treeherder | mozilla-beta@a31a0dce83aa [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | ehsan |
bugs | 784739 |
milestone | 27.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/toolkit/crashreporter/InjectCrashReporter.cpp +++ b/toolkit/crashreporter/InjectCrashReporter.cpp @@ -56,19 +56,19 @@ InjectCrashRunnable::Run() CrashGenerationClient::DuplicatePipeToClientProcess( NS_ConvertASCIItoUTF16(GetChildNotificationPipe()).get(), hProcess); if (INVALID_HANDLE_VALUE == hRemotePipe) { NS_WARNING("Unable to duplicate crash reporter pipe to process."); return NS_OK; } - nsAutoHandle hThread(CreateRemoteThread(hProcess, NULL, 0, + nsAutoHandle hThread(CreateRemoteThread(hProcess, nullptr, 0, (LPTHREAD_START_ROUTINE) proc, - (void*) hRemotePipe, 0, NULL)); + (void*) hRemotePipe, 0, nullptr)); if (!hThread) { NS_WARNING("Unable to CreateRemoteThread"); // We have to close the remote pipe or else our crash generation client // will be stuck unable to accept other remote requests. HANDLE toClose = INVALID_HANDLE_VALUE; if (DuplicateHandle(hProcess, hRemotePipe, ::GetCurrentProcess(), &toClose, 0, FALSE,
--- a/toolkit/crashreporter/LoadLibraryRemote.cpp +++ b/toolkit/crashreporter/LoadLibraryRemote.cpp @@ -26,22 +26,22 @@ typedef const unsigned char* FileView; template<> class nsAutoRefTraits<FileView> { public: typedef FileView RawRef; static FileView Void() { - return NULL; + return nullptr; } static void Release(RawRef aView) { - if (NULL != aView) + if (nullptr != aView) UnmapViewOfFile(aView); } }; #ifndef IMAGE_SIZEOF_BASE_RELOCATION // Vista SDKs no longer define IMAGE_SIZEOF_BASE_RELOCATION!? #define IMAGE_SIZEOF_BASE_RELOCATION (sizeof(IMAGE_BASE_RELOCATION)) #endif @@ -62,17 +62,19 @@ typedef BOOL (WINAPI *DllEntryProc)(HINS #ifdef DEBUG_OUTPUT static void OutputLastError(const char *msg) { char* tmp; char *tmpmsg; FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPSTR) &tmp, 0, NULL); + nullptr, GetLastError(), + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), + (LPSTR) &tmp, 0, nullptr); tmpmsg = (char *)LocalAlloc(LPTR, strlen(msg) + strlen(tmp) + 3); sprintf(tmpmsg, "%s: %s", msg, tmp); OutputDebugStringA(tmpmsg); LocalFree(tmpmsg); LocalFree(tmp); } #endif @@ -144,17 +146,17 @@ FinalizeSections(PMEMORYMODULE module, H // Copy the data from local->remote and set the memory protection if (!VirtualAllocEx(hRemoteProcess, remoteAddress, size, MEM_COMMIT, PAGE_READWRITE)) return false; if (!WriteProcessMemory(hRemoteProcess, remoteAddress, localAddress, size, - NULL)) { + nullptr)) { #ifdef DEBUG_OUTPUT OutputLastError("Error writing remote memory.\n"); #endif return false; } if (VirtualProtectEx(hRemoteProcess, remoteAddress, size, protect, &oldProtect) == 0) { #ifdef DEBUG_OUTPUT @@ -232,26 +234,26 @@ BuildImportTable(PMEMORYMODULE module) if (directory->Size > 0) { PIMAGE_IMPORT_DESCRIPTOR importDesc = (PIMAGE_IMPORT_DESCRIPTOR) (codeBase + directory->VirtualAddress); PIMAGE_IMPORT_DESCRIPTOR importEnd = (PIMAGE_IMPORT_DESCRIPTOR) (codeBase + directory->VirtualAddress + directory->Size); for (; importDesc < importEnd && importDesc->Name; importDesc++) { POINTER_TYPE *thunkRef; FARPROC *funcRef; HMODULE handle = GetModuleHandleA((LPCSTR) (codeBase + importDesc->Name)); - if (handle == NULL) { + if (handle == nullptr) { #if DEBUG_OUTPUT OutputLastError("Can't load library"); #endif result = 0; break; } module->modules = (HMODULE *)realloc(module->modules, (module->numModules+1)*(sizeof(HMODULE))); - if (module->modules == NULL) { + if (module->modules == nullptr) { result = 0; break; } module->modules[module->numModules++] = handle; if (importDesc->OriginalFirstThunk) { thunkRef = (POINTER_TYPE *) (codeBase + importDesc->OriginalFirstThunk); funcRef = (FARPROC *) (codeBase + importDesc->FirstThunk); @@ -285,87 +287,87 @@ BuildImportTable(PMEMORYMODULE module) static void* MemoryGetProcAddress(PMEMORYMODULE module, const char *name); void* LoadRemoteLibraryAndGetAddress(HANDLE hRemoteProcess, const WCHAR* library, const char* symbol) { // Map the DLL into memory nsAutoHandle hLibrary( - CreateFile(library, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, - FILE_ATTRIBUTE_NORMAL, NULL)); + CreateFile(library, GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL, nullptr)); if (INVALID_HANDLE_VALUE == hLibrary) { #if DEBUG_OUTPUT OutputLastError("Couldn't CreateFile the library.\n"); #endif - return NULL; + return nullptr; } nsAutoHandle hMapping( - CreateFileMapping(hLibrary, NULL, PAGE_READONLY, 0, 0, NULL)); + CreateFileMapping(hLibrary, nullptr, PAGE_READONLY, 0, 0, nullptr)); if (!hMapping) { #if DEBUG_OUTPUT OutputLastError("Couldn't CreateFileMapping.\n"); #endif - return NULL; + return nullptr; } nsAutoRef<FileView> data( (const unsigned char*) MapViewOfFile(hMapping, FILE_MAP_READ, 0, 0, 0)); if (!data) { #if DEBUG_OUTPUT OutputLastError("Couldn't MapViewOfFile.\n"); #endif - return NULL; + return nullptr; } SIZE_T locationDelta; PIMAGE_DOS_HEADER dos_header = (PIMAGE_DOS_HEADER)data.get(); if (dos_header->e_magic != IMAGE_DOS_SIGNATURE) { #if DEBUG_OUTPUT OutputDebugStringA("Not a valid executable file.\n"); #endif - return NULL; + return nullptr; } PIMAGE_NT_HEADERS old_header = (PIMAGE_NT_HEADERS)(data + dos_header->e_lfanew); if (old_header->Signature != IMAGE_NT_SIGNATURE) { #if DEBUG_OUTPUT OutputDebugStringA("No PE header found.\n"); #endif - return NULL; + return nullptr; } // reserve memory for image of library in this process and the target process - unsigned char* localCode = (unsigned char*) VirtualAlloc(NULL, + unsigned char* localCode = (unsigned char*) VirtualAlloc(nullptr, old_header->OptionalHeader.SizeOfImage, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE); if (!localCode) { #if DEBUG_OUTPUT OutputLastError("Can't reserve local memory."); #endif } - unsigned char* remoteCode = (unsigned char*) VirtualAllocEx(hRemoteProcess, NULL, + unsigned char* remoteCode = (unsigned char*) VirtualAllocEx(hRemoteProcess, nullptr, old_header->OptionalHeader.SizeOfImage, MEM_RESERVE, PAGE_EXECUTE_READ); if (!remoteCode) { #if DEBUG_OUTPUT OutputLastError("Can't reserve remote memory."); #endif } MEMORYMODULE result; result.localCodeBase = localCode; result.remoteCodeBase = remoteCode; result.numModules = 0; - result.modules = NULL; + result.modules = nullptr; // copy PE header to code memcpy(localCode, dos_header, dos_header->e_lfanew + old_header->OptionalHeader.SizeOfHeaders); result.headers = reinterpret_cast<PIMAGE_NT_HEADERS>(localCode + dos_header->e_lfanew); // update position result.headers->OptionalHeader.ImageBase = (POINTER_TYPE)remoteCode; @@ -375,62 +377,62 @@ void* LoadRemoteLibraryAndGetAddress(HAN // adjust base address of imported data locationDelta = (SIZE_T)(remoteCode - old_header->OptionalHeader.ImageBase); if (locationDelta != 0) { PerformBaseRelocation(&result, locationDelta); } // load required dlls and adjust function table of imports if (!BuildImportTable(&result)) { - return NULL; + return nullptr; } // mark memory pages depending on section headers and release // sections that are marked as "discardable" if (!FinalizeSections(&result, hRemoteProcess)) { - return NULL; + return nullptr; } return MemoryGetProcAddress(&result, symbol); } static void* MemoryGetProcAddress(PMEMORYMODULE module, const char *name) { unsigned char *localCodeBase = module->localCodeBase; int idx=-1; DWORD i, *nameRef; WORD *ordinal; PIMAGE_EXPORT_DIRECTORY exports; PIMAGE_DATA_DIRECTORY directory = GET_HEADER_DICTIONARY(module, IMAGE_DIRECTORY_ENTRY_EXPORT); if (directory->Size == 0) { // no export table found - return NULL; + return nullptr; } exports = (PIMAGE_EXPORT_DIRECTORY) (localCodeBase + directory->VirtualAddress); if (exports->NumberOfNames == 0 || exports->NumberOfFunctions == 0) { // DLL doesn't export anything - return NULL; + return nullptr; } // search function name in list of exported names nameRef = (DWORD *) (localCodeBase + exports->AddressOfNames); ordinal = (WORD *) (localCodeBase + exports->AddressOfNameOrdinals); for (i=0; i<exports->NumberOfNames; i++, nameRef++, ordinal++) { if (stricmp(name, (const char *) (localCodeBase + (*nameRef))) == 0) { idx = *ordinal; break; } } if (idx == -1) { // exported symbol not found - return NULL; + return nullptr; } if ((DWORD)idx > exports->NumberOfFunctions) { // name <-> ordinal number don't match - return NULL; + return nullptr; } // AddressOfFunctions contains the RVAs to the "real" functions return module->remoteCodeBase + (*(DWORD *) (localCodeBase + exports->AddressOfFunctions + (idx*4))); }
--- a/toolkit/crashreporter/client/crashreporter.cpp +++ b/toolkit/crashreporter/client/crashreporter.cpp @@ -29,17 +29,17 @@ using std::auto_ptr; namespace CrashReporter { StringTable gStrings; string gSettingsPath; int gArgc; char** gArgv; -static auto_ptr<ofstream> gLogStream(NULL); +static auto_ptr<ofstream> gLogStream(nullptr); static string gDumpFile; static string gExtraFile; static string kExtraDataExtension = ".extra"; void UIError(const string& message) { string errorMessage; @@ -589,23 +589,23 @@ int main(int argc, char** argv) // We need WinMain in order to not be a console app. This function is unused // if we are a console application. int WINAPI wWinMain( HINSTANCE, HINSTANCE, LPWSTR args, int ) { // 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); + nullptr, REG_OPTION_NON_VOLATILE, KEY_SET_VALUE, nullptr, + &hkApp, nullptr); RegCloseKey(hkApp); if (RegCreateKeyExW(HKEY_CURRENT_USER, L"Software\\Classes\\Applications\\crashreporter.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); } } char** argv = static_cast<char**>(malloc(__argc * sizeof(char*)));
--- a/toolkit/crashreporter/client/crashreporter_gtk_common.cpp +++ b/toolkit/crashreporter/client/crashreporter_gtk_common.cpp @@ -133,41 +133,42 @@ void LoadProxyinfo() gconf_client_get_int && gconf_client_get_string)) { dlclose(gconfLib); return; } GConfClient *conf = gconf_client_get_default(); - if (gconf_client_get_bool(conf, HTTP_PROXY_DIR "/use_http_proxy", NULL)) { + if (gconf_client_get_bool(conf, HTTP_PROXY_DIR "/use_http_proxy", nullptr)) { gint port; - gchar *host = NULL, *httpproxy = NULL; + gchar *host = nullptr, *httpproxy = nullptr; - host = gconf_client_get_string(conf, HTTP_PROXY_DIR "/host", NULL); - port = gconf_client_get_int(conf, HTTP_PROXY_DIR "/port", NULL); + host = gconf_client_get_string(conf, HTTP_PROXY_DIR "/host", nullptr); + port = gconf_client_get_int(conf, HTTP_PROXY_DIR "/port", nullptr); if (port && host && *host != '\0') { httpproxy = g_strdup_printf("http://%s:%d/", host, port); gHttpProxy = httpproxy; } g_free(host); g_free(httpproxy); - if(gconf_client_get_bool(conf, HTTP_PROXY_DIR "/use_authentication", NULL)) { - gchar *user, *password, *auth = NULL; + if (gconf_client_get_bool(conf, HTTP_PROXY_DIR "/use_authentication", + nullptr)) { + gchar *user, *password, *auth = nullptr; user = gconf_client_get_string(conf, HTTP_PROXY_DIR "/authentication_user", - NULL); + nullptr); password = gconf_client_get_string(conf, HTTP_PROXY_DIR "/authentication_password", - NULL); + nullptr); if (user && password) { auth = g_strdup_printf("%s:%s", user, password); gAuth = auth; } g_free(user); g_free(password); @@ -204,17 +205,17 @@ gpointer SendThread(gpointer args) } SendCompleted(success, response); // Apparently glib is threadsafe, and will schedule this // on the main thread, see: // http://library.gnome.org/devel/gtk-faq/stable/x499.html g_idle_add(ReportCompleted, (gpointer)success); - return NULL; + return nullptr; } gboolean WindowDeleted(GtkWidget* window, GdkEvent* event, gpointer userData) { SaveSettings(); gtk_main_quit(); @@ -270,17 +271,17 @@ void IncludeURLClicked(GtkButton* sender bool UIInit() { // breakpad probably left us with blocked signals, unblock them here sigset_t signals, old; sigfillset(&signals); sigprocmask(SIG_UNBLOCK, &signals, &old); // tell glib we're going to use threads - g_thread_init(NULL); + g_thread_init(nullptr); if (gtk_init_check(&gArgc, &gArgv)) { gInitialized = true; if (gStrings.find("isRTL") != gStrings.end() && gStrings["isRTL"] == "yes") gtk_widget_set_default_direction(GTK_TEXT_DIR_RTL); @@ -288,17 +289,17 @@ bool UIInit() } return false; } void UIShowDefaultUI() { GtkWidget* errorDialog = - gtk_message_dialog_new(NULL, GTK_DIALOG_MODAL, + gtk_message_dialog_new(nullptr, GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, "%s", gStrings[ST_CRASHREPORTERDEFAULT].c_str()); gtk_window_set_title(GTK_WINDOW(errorDialog), gStrings[ST_CRASHREPORTERTITLE].c_str()); gtk_dialog_run(GTK_DIALOG(errorDialog)); } @@ -307,17 +308,17 @@ void UIError_impl(const string& message) { if (!gInitialized) { // Didn't initialize, this is the best we can do printf("Error: %s\n", message.c_str()); return; } GtkWidget* errorDialog = - gtk_message_dialog_new(NULL, GTK_DIALOG_MODAL, + gtk_message_dialog_new(nullptr, GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, "%s", message.c_str()); gtk_window_set_title(GTK_WINDOW(errorDialog), gStrings[ST_CRASHREPORTERTITLE].c_str()); gtk_dialog_run(GTK_DIALOG(errorDialog)); }
--- a/toolkit/crashreporter/client/crashreporter_linux.cpp +++ b/toolkit/crashreporter/client/crashreporter_linux.cpp @@ -25,19 +25,19 @@ static GtkWidget* gCommentText = 0; static GtkWidget* gEmailMeCheck = 0; static GtkWidget* gEmailEntryLabel = 0; static GtkWidget* gEmailEntry = 0; static bool gEmailFieldHint = true; static bool gCommentFieldHint = true; // handle from dlopen'ing libgnome -static void* gnomeLib = NULL; +static void* gnomeLib = nullptr; // handle from dlopen'ing libgnomeui -static void* gnomeuiLib = NULL; +static void* gnomeuiLib = nullptr; static void LoadSettings() { /* * NOTE! This code needs to stay in sync with the preference checking * code in in nsExceptionHandler.cpp. */ @@ -113,17 +113,17 @@ void SendReport() gStrings[ST_REPORTDURINGSUBMIT].c_str()); #ifdef MOZ_ENABLE_GCONF LoadProxyinfo(); #endif // and spawn a thread to do the sending GError* err; - gSendThreadID = g_thread_create(SendThread, NULL, TRUE, &err); + gSendThreadID = g_thread_create(SendThread, nullptr, TRUE, &err); } static void ShowReportInfo(GtkTextView* viewReportTextView) { GtkTextBuffer* buffer = gtk_text_view_get_buffer(viewReportTextView); GtkTextIter start, end; @@ -173,17 +173,17 @@ static void ViewReportClicked(GtkButton* gpointer userData) { GtkDialog* dialog = GTK_DIALOG(gtk_dialog_new_with_buttons(gStrings[ST_VIEWREPORTTITLE].c_str(), GTK_WINDOW(gWindow), GTK_DIALOG_MODAL, GTK_STOCK_OK, GTK_RESPONSE_OK, - NULL)); + nullptr)); GtkWidget* scrolled = gtk_scrolled_window_new(0, 0); gtk_container_add(GTK_CONTAINER(dialog->vbox), scrolled); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS); gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled), GTK_SHADOW_IN); @@ -230,49 +230,49 @@ static void CommentInsert(GtkTextBuffer* if (strlen(comment) + len > MAX_COMMENT_LENGTH) { g_signal_stop_emission_by_name(buffer, "insert-text"); } } static void UpdateHintText(GtkWidget* widget, gboolean gainedFocus, bool* hintShowing, const char* hintText) { - GtkTextBuffer* buffer = NULL; + GtkTextBuffer* buffer = nullptr; if (GTK_IS_TEXT_VIEW(widget)) buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(widget)); if (gainedFocus) { if (*hintShowing) { - if (buffer == NULL) { // sort of cheating + if (buffer == nullptr) { // sort of cheating gtk_entry_set_text(GTK_ENTRY(widget), ""); } else { // GtkTextView gtk_text_buffer_set_text(buffer, "", 0); } - gtk_widget_modify_text(widget, GTK_STATE_NORMAL, NULL); + gtk_widget_modify_text(widget, GTK_STATE_NORMAL, nullptr); *hintShowing = false; } } else { // lost focus - const char* text = NULL; - if (buffer == NULL) { + const char* text = nullptr; + if (buffer == nullptr) { text = gtk_entry_get_text(GTK_ENTRY(widget)); } else { GtkTextIter start, end; gtk_text_buffer_get_start_iter(buffer, &start); gtk_text_buffer_get_end_iter(buffer, &end); text = gtk_text_buffer_get_text(buffer, &start, &end, TRUE); } - if (text == NULL || text[0] == '\0') { + if (text == nullptr || text[0] == '\0') { *hintShowing = true; - if (buffer == NULL) { + if (buffer == nullptr) { gtk_entry_set_text(GTK_ENTRY(widget), hintText); } else { gtk_text_buffer_set_text(buffer, hintText, -1); } gtk_widget_modify_text(widget, GTK_STATE_NORMAL, >k_widget_get_style(widget)->text[GTK_STATE_INSENSITIVE]); @@ -342,17 +342,17 @@ void TryInitGnome() _gnome_program_init_fn gnome_program_init = (_gnome_program_init_fn)(dlsym(gnomeLib, "gnome_program_init")); _libgnomeui_module_info_get_fn libgnomeui_module_info_get = (_libgnomeui_module_info_get_fn)(dlsym(gnomeuiLib, "libgnomeui_module_info_get")); if (gnome_program_init && libgnomeui_module_info_get) { gnome_program_init("crashreporter", "1.0", libgnomeui_module_info_get(), - gArgc, gArgv, NULL); + gArgc, gArgv, nullptr); } } /* === Crashreporter UI Functions === */ /* * Anything not listed here is in crashreporter_gtk_common.cpp: @@ -499,17 +499,17 @@ bool UIShowCrashUI(const string& dumpfil g_signal_connect(gEmailEntry, "focus-in-event", G_CALLBACK(EmailFocusChange), 0); g_signal_connect(gEmailEntry, "focus-out-event", G_CALLBACK(EmailFocusChange), 0); GtkWidget* progressBox = gtk_hbox_new(FALSE, 6); gtk_box_pack_start(GTK_BOX(vbox), progressBox, TRUE, TRUE, 0); // Get the throbber image from alongside the executable char* dir = g_path_get_dirname(gArgv[0]); - char* path = g_build_filename(dir, "Throbber-small.gif", NULL); + char* path = g_build_filename(dir, "Throbber-small.gif", nullptr); g_free(dir); gThrobber = gtk_image_new_from_file(path); gtk_box_pack_start(GTK_BOX(progressBox), gThrobber, FALSE, FALSE, 0); gProgressLabel = gtk_label_new(gStrings[ST_REPORTPRESUBMIT].c_str()); gtk_box_pack_start(GTK_BOX(progressBox), gProgressLabel, TRUE, TRUE, 0); // force the label to line wrap
--- a/toolkit/crashreporter/client/crashreporter_win.cpp +++ b/toolkit/crashreporter/client/crashreporter_win.cpp @@ -116,18 +116,19 @@ static void DoInitCommonControls() // also get the rich edit control LoadLibrary(L"Msftedit.dll"); } static bool GetBoolValue(HKEY hRegKey, LPCTSTR valueName, DWORD* value) { DWORD type, dataSize; dataSize = sizeof(DWORD); - if (RegQueryValueEx(hRegKey, valueName, NULL, &type, (LPBYTE)value, &dataSize) == ERROR_SUCCESS - && type == REG_DWORD) + if (RegQueryValueEx(hRegKey, valueName, nullptr, + &type, (LPBYTE)value, &dataSize) == ERROR_SUCCESS && + type == REG_DWORD) return true; return false; } // Removes a value from HKEY_LOCAL_MACHINE and HKEY_CURRENT_USER, if it exists. static void RemoveUnusedValues(const wchar_t* key, LPCTSTR valueName) { @@ -197,18 +198,19 @@ static void SetBoolKey(const wchar_t* ke } } static bool GetStringValue(HKEY hRegKey, LPCTSTR valueName, wstring& value) { DWORD type, dataSize; wchar_t buf[2048]; dataSize = sizeof(buf); - if (RegQueryValueEx(hRegKey, valueName, NULL, &type, (LPBYTE)buf, &dataSize) == ERROR_SUCCESS - && type == REG_SZ) { + if (RegQueryValueEx(hRegKey, valueName, nullptr, + &type, (LPBYTE)buf, &dataSize) == ERROR_SUCCESS && + type == REG_SZ) { value = buf; return true; } return false; } static bool GetStringKey(const wchar_t* key, @@ -260,18 +262,18 @@ static string FormatLastError() if(FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_FROM_HMODULE, hInetModule, err, 0, (LPWSTR)&s, 0, - NULL) != 0) { - message += WideToUTF8(s, NULL); + nullptr) != 0) { + message += WideToUTF8(s, nullptr); LocalFree(s); // strip off any trailing newlines string::size_type n = message.find_last_not_of("\r\n"); if (n < message.size() - 1) { message.erase(n+1); } } else { @@ -316,27 +318,27 @@ static void GetThemeSizes(HWND hwnd) HANDLE buttonTheme = openTheme(hwnd, L"Button"); if (!buttonTheme) { FreeLibrary(themeDLL); return; } HDC hdc = GetDC(hwnd); SIZE s; - getThemePartSize(buttonTheme, hdc, BP_CHECKBOX, 0, NULL, TS_DRAW, &s); + getThemePartSize(buttonTheme, hdc, BP_CHECKBOX, 0, nullptr, TS_DRAW, &s); gCheckboxPadding = s.cx; closeTheme(buttonTheme); FreeLibrary(themeDLL); } // Gets the position of a window relative to another window's client area static void GetRelativeRect(HWND hwnd, HWND hwndParent, RECT* r) { GetWindowRect(hwnd, r); - MapWindowPoints(NULL, hwndParent, (POINT*)r, 2); + MapWindowPoints(nullptr, hwndParent, (POINT*)r, 2); } static void SetDlgItemVisible(HWND hwndDlg, UINT item, bool visible) { HWND hwnd = GetDlgItem(hwndDlg, item); ShowWindow(hwnd, visible ? SW_SHOW : SW_HIDE); } @@ -492,21 +494,22 @@ static void MaybeSendReport(HWND hwndDlg EnableWindow(GetDlgItem(hwndDlg, IDC_RESTARTBUTTON), false); SetDlgItemText(hwndDlg, IDC_PROGRESSTEXT, Str(ST_REPORTDURINGSUBMIT).c_str()); MaybeResizeProgressText(hwndDlg); // start throbber // play entire AVI, and loop Animate_Play(GetDlgItem(hwndDlg, IDC_THROBBER), 0, -1, -1); SetDlgItemVisible(hwndDlg, IDC_THROBBER, true); - gThreadHandle = NULL; + gThreadHandle = nullptr; gSendData.hDlg = hwndDlg; gSendData.queryParameters = gQueryParameters; - gThreadHandle = CreateThread(NULL, 0, SendThreadProc, &gSendData, 0, NULL); + gThreadHandle = CreateThread(nullptr, 0, SendThreadProc, &gSendData, 0, + nullptr); } static void RestartApplication() { wstring cmdLine; for (unsigned int i = 0; i < gRestartArgs.size(); i++) { cmdLine += L"\"" + UTF8ToWide(gRestartArgs[i]) + L"\" "; @@ -516,18 +519,18 @@ static void RestartApplication() PROCESS_INFORMATION pi; ZeroMemory(&si, sizeof(si)); si.cb = sizeof(si); si.dwFlags = STARTF_USESHOWWINDOW; si.wShowWindow = SW_SHOWNORMAL; ZeroMemory(&pi, sizeof(pi)); - if (CreateProcess(NULL, (LPWSTR)cmdLine.c_str(), NULL, NULL, FALSE, 0, - NULL, NULL, &si, &pi)) { + if (CreateProcess(nullptr, (LPWSTR)cmdLine.c_str(), nullptr, nullptr, FALSE, + 0, nullptr, nullptr, &si, &pi)) { CloseHandle(pi.hProcess); CloseHandle(pi.hThread); } } static void ShowReportInfo(HWND hwndDlg) { wstring description; @@ -588,17 +591,17 @@ static void UpdateComment(HWND hwndDlg) static BOOL CALLBACK ViewReportDialogProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_INITDIALOG: { SetWindowText(hwndDlg, Str(ST_VIEWREPORTTITLE).c_str()); SetDlgItemText(hwndDlg, IDOK, Str(ST_OK).c_str()); SendDlgItemMessage(hwndDlg, IDC_VIEWREPORTTEXT, - EM_SETTARGETDEVICE, (WPARAM)NULL, 0); + EM_SETTARGETDEVICE, (WPARAM)nullptr, 0); ShowReportInfo(hwndDlg); SetFocus(GetDlgItem(hwndDlg, IDOK)); return FALSE; } case WM_COMMAND: { if (HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDOK) EndDialog(hwndDlg, 0); @@ -609,17 +612,18 @@ static BOOL CALLBACK ViewReportDialogPro } // Return the number of bytes this string will take encoded // in UTF-8 static inline int BytesInUTF8(wchar_t* str) { // Just count size of buffer for UTF-8, minus one // (we don't need to count the null terminator) - return WideCharToMultiByte(CP_UTF8, 0, str, -1, NULL, 0, NULL, NULL) - 1; + return WideCharToMultiByte(CP_UTF8, 0, str, -1, + nullptr, 0, nullptr, nullptr) - 1; } // Calculate the length of the text in this edit control (in bytes, // in the UTF-8 encoding) after replacing the current selection // with |insert|. static int NewTextLength(HWND hwndEdit, wchar_t* insert) { wchar_t current[MAX_COMMENT_LENGTH + 1]; @@ -643,19 +647,19 @@ static int NewTextLength(HWND hwndEdit, // - replaced selection length return BytesInUTF8(current) + BytesInUTF8(insert) - selectionLength; } // Window procedure for subclassing edit controls static LRESULT CALLBACK EditSubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { - static WNDPROC super = NULL; + static WNDPROC super = nullptr; - if (super == NULL) + if (super == nullptr) super = (WNDPROC)GetWindowLongPtr(hwnd, GWLP_USERDATA); switch (uMsg) { case WM_PAINT: { HDC hdc; PAINTSTRUCT ps; RECT r; wchar_t windowText[1024]; @@ -835,35 +839,35 @@ static void SubmitReportChecked(HWND hwn static INT_PTR DialogBoxParamMaybeRTL(UINT idd, HWND hwndParent, DLGPROC dlgProc, LPARAM param) { INT_PTR rv = 0; if (gRTLlayout) { // We need to toggle the WS_EX_LAYOUTRTL style flag on the dialog // template. - HRSRC hDialogRC = FindResource(NULL, MAKEINTRESOURCE(idd), + HRSRC hDialogRC = FindResource(nullptr, MAKEINTRESOURCE(idd), RT_DIALOG); - HGLOBAL hDlgTemplate = LoadResource(NULL, hDialogRC); + HGLOBAL hDlgTemplate = LoadResource(nullptr, hDialogRC); DLGTEMPLATEEX* pDlgTemplate = (DLGTEMPLATEEX*)LockResource(hDlgTemplate); - unsigned long sizeDlg = SizeofResource(NULL, hDialogRC); + unsigned long sizeDlg = SizeofResource(nullptr, hDialogRC); HGLOBAL hMyDlgTemplate = GlobalAlloc(GPTR, sizeDlg); DLGTEMPLATEEX* pMyDlgTemplate = (DLGTEMPLATEEX*)GlobalLock(hMyDlgTemplate); memcpy(pMyDlgTemplate, pDlgTemplate, sizeDlg); pMyDlgTemplate->exStyle |= WS_EX_LAYOUTRTL; - rv = DialogBoxIndirectParam(NULL, (LPCDLGTEMPLATE)pMyDlgTemplate, + rv = DialogBoxIndirectParam(nullptr, (LPCDLGTEMPLATE)pMyDlgTemplate, hwndParent, dlgProc, param); GlobalUnlock(hMyDlgTemplate); GlobalFree(hMyDlgTemplate); } else { - rv = DialogBoxParam(NULL, MAKEINTRESOURCE(idd), hwndParent, + rv = DialogBoxParam(nullptr, MAKEINTRESOURCE(idd), hwndParent, dlgProc, param); } return rv; } static BOOL CALLBACK CrashReporterDialogProc(HWND hwndDlg, UINT message, @@ -877,17 +881,17 @@ static BOOL CALLBACK CrashReporterDialog switch (message) { case WM_INITDIALOG: { GetThemeSizes(hwndDlg); RECT r; GetClientRect(hwndDlg, &r); sHeight = r.bottom - r.top; SetWindowText(hwndDlg, Str(ST_CRASHREPORTERTITLE).c_str()); - HICON hIcon = LoadIcon(GetModuleHandle(NULL), + HICON hIcon = LoadIcon(GetModuleHandle(nullptr), MAKEINTRESOURCE(IDI_MAINICON)); SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM)hIcon); SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)hIcon); // resize the "View Report" button based on the string length RECT rect; HWND hwnd = GetDlgItem(hwndDlg, IDC_VIEWREPORTBUTTON); GetRelativeRect(hwnd, hwndDlg, &rect); @@ -1023,17 +1027,17 @@ static BOOL CALLBACK CrashReporterDialog MoveWindow(hwndRestart, restartRect.left, restartRect.top, restartRect.right - restartRect.left, restartRect.bottom - restartRect.top, TRUE); // Resize the description text last, in case the window was resized // before this. SendDlgItemMessage(hwndDlg, IDC_DESCRIPTIONTEXT, - EM_SETEVENTMASK, (WPARAM)NULL, + EM_SETEVENTMASK, (WPARAM)nullptr, ENM_REQUESTRESIZE); wstring description = Str(ST_CRASHREPORTERHEADER); description += L"\n\n"; description += Str(ST_CRASHREPORTERDESCRIPTION); SetDlgItemText(hwndDlg, IDC_DESCRIPTIONTEXT, description.c_str()); @@ -1044,17 +1048,17 @@ static BOOL CALLBACK CrashReporterDialog fmt.dwEffects = CFE_BOLD; SendDlgItemMessage(hwndDlg, IDC_DESCRIPTIONTEXT, EM_SETSEL, 0, Str(ST_CRASHREPORTERHEADER).length()); SendDlgItemMessage(hwndDlg, IDC_DESCRIPTIONTEXT, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&fmt); SendDlgItemMessage(hwndDlg, IDC_DESCRIPTIONTEXT, EM_SETSEL, 0, 0); // Force redraw. SendDlgItemMessage(hwndDlg, IDC_DESCRIPTIONTEXT, - EM_SETTARGETDEVICE, (WPARAM)NULL, 0); + EM_SETTARGETDEVICE, (WPARAM)nullptr, 0); // Force resize. SendDlgItemMessage(hwndDlg, IDC_DESCRIPTIONTEXT, EM_REQUESTRESIZE, 0, 0); // if no URL was given, hide the URL checkbox if (gQueryParameters.find(L"URL") == gQueryParameters.end()) { RECT urlCheckRect, emailCheckRect; GetWindowRect(GetDlgItem(hwndDlg, IDC_INCLUDEURLCHECK), &urlCheckRect); @@ -1083,17 +1087,17 @@ static BOOL CALLBACK CrashReporterDialog UpdateEmail(hwndDlg); SetFocus(GetDlgItem(hwndDlg, IDC_SUBMITREPORTCHECK)); return FALSE; } case WM_SIZE: { ReflowDialog(hwndDlg, HIWORD(lParam) - sHeight); sHeight = HIWORD(lParam); - InvalidateRect(hwndDlg, NULL, TRUE); + InvalidateRect(hwndDlg, nullptr, TRUE); return FALSE; } case WM_NOTIFY: { NMHDR* notification = reinterpret_cast<NMHDR*>(lParam); if (notification->code == EN_REQUESTRESIZE) { // Resizing the rich edit control to fit the description text. REQRESIZE* reqresize = reinterpret_cast<REQRESIZE*>(lParam); RECT newSize = reqresize->rc; @@ -1155,17 +1159,17 @@ static BOOL CALLBACK CrashReporterDialog SetDlgItemVisible(hwndDlg, IDC_THROBBER, false); SetDlgItemText(hwndDlg, IDC_PROGRESSTEXT, success ? Str(ST_REPORTSUBMITSUCCESS).c_str() : Str(ST_SUBMITFAILED).c_str()); MaybeResizeProgressText(hwndDlg); // close dialog after 5 seconds - SetTimer(hwndDlg, 0, 5000, NULL); + SetTimer(hwndDlg, 0, 5000, nullptr); // return TRUE; } case WM_LBUTTONDOWN: { HWND hwndEmail = GetDlgItem(hwndDlg, IDC_EMAILTEXT); POINT p = { LOWORD(lParam), HIWORD(lParam) }; // if the email edit control is clicked, enable it, @@ -1193,63 +1197,65 @@ static BOOL CALLBACK CrashReporterDialog return FALSE; } } return FALSE; } static wstring UTF8ToWide(const string& utf8, bool *success) { - wchar_t* buffer = NULL; + wchar_t* buffer = nullptr; int buffer_size = MultiByteToWideChar(CP_UTF8, 0, utf8.c_str(), - -1, NULL, 0); + -1, nullptr, 0); if(buffer_size == 0) { if (success) *success = false; return L""; } buffer = new wchar_t[buffer_size]; - if(buffer == NULL) { + if(buffer == nullptr) { if (success) *success = false; return L""; } MultiByteToWideChar(CP_UTF8, 0, utf8.c_str(), -1, buffer, buffer_size); wstring str = buffer; delete [] buffer; if (success) *success = true; return str; } -static string WideToMBCP(const wstring& wide, unsigned int cp, bool* success = nullptr) +static string WideToMBCP(const wstring& wide, + unsigned int cp, + bool* success = nullptr) { - char* buffer = NULL; + char* buffer = nullptr; int buffer_size = WideCharToMultiByte(cp, 0, wide.c_str(), - -1, NULL, 0, NULL, NULL); + -1, nullptr, 0, nullptr, nullptr); if(buffer_size == 0) { if (success) *success = false; return ""; } buffer = new char[buffer_size]; - if(buffer == NULL) { + if(buffer == nullptr) { if (success) *success = false; return ""; } WideCharToMultiByte(cp, 0, wide.c_str(), - -1, buffer, buffer_size, NULL, NULL); + -1, buffer, buffer_size, nullptr, nullptr); string mb = buffer; delete [] buffer; if (success) *success = true; return mb; } @@ -1273,27 +1279,27 @@ bool UIInit() } void UIShutdown() { } void UIShowDefaultUI() { - MessageBox(NULL, Str(ST_CRASHREPORTERDEFAULT).c_str(), + MessageBox(nullptr, Str(ST_CRASHREPORTERDEFAULT).c_str(), L"Crash Reporter", MB_OK | MB_ICONSTOP); } bool UIShowCrashUI(const string& dumpFile, const StringTable& queryParameters, const string& sendURL, const vector<string>& restartArgs) { - gSendData.hDlg = NULL; + gSendData.hDlg = nullptr; gSendData.dumpFile = UTF8ToWide(dumpFile); gSendData.sendURL = UTF8ToWide(sendURL); for (StringTable::const_iterator i = queryParameters.begin(); i != queryParameters.end(); i++) { gQueryParameters[UTF8ToWide(i->first)] = UTF8ToWide(i->second); } @@ -1310,34 +1316,34 @@ bool UIShowCrashUI(const string& dumpFil gURLParameter = gQueryParameters[L"URL"]; gRestartArgs = restartArgs; if (gStrings.find("isRTL") != gStrings.end() && gStrings["isRTL"] == "yes") gRTLlayout = true; - return 1 == DialogBoxParamMaybeRTL(IDD_SENDDIALOG, NULL, + return 1 == DialogBoxParamMaybeRTL(IDD_SENDDIALOG, nullptr, (DLGPROC)CrashReporterDialogProc, 0); } void UIError_impl(const string& message) { wstring title = Str(ST_CRASHREPORTERTITLE); if (title.empty()) title = L"Crash Reporter Error"; - MessageBox(NULL, UTF8ToWide(message).c_str(), title.c_str(), + MessageBox(nullptr, UTF8ToWide(message).c_str(), title.c_str(), MB_OK | MB_ICONSTOP); } bool UIGetIniPath(string& path) { wchar_t fileName[MAX_PATH]; - if (GetModuleFileName(NULL, fileName, MAX_PATH)) { + if (GetModuleFileName(nullptr, fileName, MAX_PATH)) { // get crashreporter ini wchar_t* s = wcsrchr(fileName, '.'); if (s) { wcscpy(s, L".ini"); path = WideToUTF8(fileName); return true; } } @@ -1345,19 +1351,19 @@ bool UIGetIniPath(string& path) return false; } bool UIGetSettingsPath(const string& vendor, const string& product, string& settings_path) { wchar_t path[MAX_PATH]; - HRESULT hRes = SHGetFolderPath(NULL, + HRESULT hRes = SHGetFolderPath(nullptr, CSIDL_APPDATA, - NULL, + nullptr, 0, path); if (FAILED(hRes)) { // This provides a fallback for getting the path to APPDATA by querying the // registry when the call to SHGetFolderPath is unable to provide this path // (Bug 513958). HKEY key; DWORD type, size, dwRes; @@ -1366,17 +1372,17 @@ bool UIGetSettingsPath(const string& ven 0, KEY_READ, &key); if (dwRes != ERROR_SUCCESS) return false; dwRes = RegQueryValueExW(key, L"AppData", - NULL, + nullptr, &type, (LPBYTE)&path, &size); ::RegCloseKey(key); // The call to RegQueryValueExW must succeed, the type must be REG_SZ, the // buffer size must not equal 0, and the buffer size be a multiple of 2. if (dwRes != ERROR_SUCCESS || type != REG_SZ || size == 0 || size % 2 != 0) return false; @@ -1388,17 +1394,17 @@ bool UIGetSettingsPath(const string& ven PathAppend(path, UTF8ToWide(product).c_str()); PathAppend(path, L"Crash Reports"); settings_path = WideToUTF8(path); return true; } bool UIEnsurePathExists(const string& path) { - if (CreateDirectory(UTF8ToWide(path).c_str(), NULL) == 0) { + if (CreateDirectory(UTF8ToWide(path).c_str(), nullptr) == 0) { if (GetLastError() != ERROR_ALREADY_EXISTS) return false; } return true; } bool UIFileExists(const string& path)
--- a/toolkit/crashreporter/injector/injector.cpp +++ b/toolkit/crashreporter/injector/injector.cpp @@ -21,20 +21,20 @@ extern "C" BOOL WINAPI DummyEntryPoint(H // support.microsoft.com/kb/94248 extern "C" BOOL WINAPI _CRT_INIT(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved); extern "C" __declspec(dllexport) DWORD Start(void* context) { // Because the remote DLL injector does not call DllMain, we have to // initialize the CRT manually - _CRT_INIT(NULL, DLL_PROCESS_ATTACH, NULL); + _CRT_INIT(nullptr, DLL_PROCESS_ATTACH, nullptr); HANDLE hCrashPipe = reinterpret_cast<HANDLE>(context); ExceptionHandler* e = new (std::nothrow) - ExceptionHandler(wstring(), NULL, NULL, NULL, + ExceptionHandler(wstring(), nullptr, nullptr, nullptr, ExceptionHandler::HANDLER_ALL, - MiniDumpNormal, hCrashPipe, NULL); + MiniDumpNormal, hCrashPipe, nullptr); if (e) e->set_handle_debug_exceptions(true); return 1; }
--- a/toolkit/crashreporter/nsExceptionHandler.cpp +++ b/toolkit/crashreporter/nsExceptionHandler.cpp @@ -248,17 +248,17 @@ static const int kMagicChildCrashReportF // |dumpMapLock| must protect all access to |pidToMinidump|. static Mutex* dumpMapLock; struct ChildProcessData : public nsUint32HashKey { ChildProcessData(KeyTypePointer aKey) : nsUint32HashKey(aKey) , sequence(0) #ifdef MOZ_CRASHREPORTER_INJECTOR - , callback(NULL) + , callback(nullptr) #endif { } nsCOMPtr<nsIFile> minidump; // Each crashing process is assigned an increasing sequence number to // indicate which process crashed first. uint32_t sequence; #ifdef MOZ_CRASHREPORTER_INJECTOR @@ -315,17 +315,17 @@ static LPTOP_LEVEL_EXCEPTION_FILTER WINA patched_SetUnhandledExceptionFilter (LPTOP_LEVEL_EXCEPTION_FILTER lpTopLevelExceptionFilter) { if (!gBlockUnhandledExceptionFilter) { // don't intercept return stub_SetUnhandledExceptionFilter(lpTopLevelExceptionFilter); } // intercept attempts to change the filter - return NULL; + return nullptr; } #endif #ifdef XP_MACOSX static cpu_type_t pref_cpu_types[2] = { #if defined(__i386__) CPU_TYPE_X86, #elif defined(__x86_64__) @@ -436,21 +436,21 @@ bool MinidumpCallback( p -= 4; #endif Concat(p, extraFileExtension, &size); if (headlessClient) { // Leave a marker indicating that there was a crash. #if defined(XP_WIN32) HANDLE hFile = CreateFile(crashMarkerFilename, GENERIC_WRITE, 0, - NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, - NULL); + nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, + nullptr); if(hFile != INVALID_HANDLE_VALUE) { DWORD nBytes; - WriteFile(hFile, minidumpPath, 2*wcslen(minidumpPath), &nBytes, NULL); + WriteFile(hFile, minidumpPath, 2*wcslen(minidumpPath), &nBytes, nullptr); CloseHandle(hFile); } #elif defined(XP_UNIX) int fd = sys_open(crashMarkerFilename, O_WRONLY | O_CREAT | O_TRUNC, 0600); if (fd != -1) { ssize_t ignored = sys_write(fd, minidumpPath, my_strlen(minidumpPath)); @@ -467,20 +467,20 @@ bool MinidumpCallback( oomAllocationSizeBufferLen = my_strlen(oomAllocationSizeBuffer); } // calculate time since last crash (if possible), and store // the time of this crash. time_t crashTime; #ifdef XP_LINUX struct kernel_timeval tv; - sys_gettimeofday(&tv, NULL); + sys_gettimeofday(&tv, nullptr); crashTime = tv.tv_sec; #else - crashTime = time(NULL); + crashTime = time(nullptr); #endif time_t timeSinceLastCrash = 0; // stringified versions of the above char crashTimeString[32]; int crashTimeStringLen = 0; char timeSinceLastCrashString[32]; int timeSinceLastCrashStringLen = 0; @@ -490,21 +490,21 @@ bool MinidumpCallback( timeSinceLastCrash = crashTime - lastCrashTime; XP_TTOA(timeSinceLastCrash, timeSinceLastCrashString, 10); timeSinceLastCrashStringLen = my_strlen(timeSinceLastCrashString); } // write crash time to file if (lastCrashTimeFilename[0] != 0) { #if defined(XP_WIN32) HANDLE hFile = CreateFile(lastCrashTimeFilename, GENERIC_WRITE, 0, - NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, - NULL); + nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, + nullptr); if(hFile != INVALID_HANDLE_VALUE) { DWORD nBytes; - WriteFile(hFile, crashTimeString, crashTimeStringLen, &nBytes, NULL); + WriteFile(hFile, crashTimeString, crashTimeStringLen, &nBytes, nullptr); CloseHandle(hFile); } #elif defined(XP_UNIX) int fd = sys_open(lastCrashTimeFilename, O_WRONLY | O_CREAT | O_TRUNC, 0600); if (fd != -1) { ssize_t ignored = sys_write(fd, crashTimeString, crashTimeStringLen); @@ -513,70 +513,70 @@ bool MinidumpCallback( } #endif } #if defined(XP_WIN32) if (!crashReporterAPIData->IsEmpty()) { // write out API data HANDLE hFile = CreateFile(extraDataPath, GENERIC_WRITE, 0, - NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, - NULL); + nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, + nullptr); if(hFile != INVALID_HANDLE_VALUE) { DWORD nBytes; WriteFile(hFile, crashReporterAPIData->get(), - crashReporterAPIData->Length(), &nBytes, NULL); + crashReporterAPIData->Length(), &nBytes, nullptr); WriteFile(hFile, kCrashTimeParameter, kCrashTimeParameterLen, - &nBytes, NULL); - WriteFile(hFile, crashTimeString, crashTimeStringLen, &nBytes, NULL); - WriteFile(hFile, "\n", 1, &nBytes, NULL); + &nBytes, nullptr); + WriteFile(hFile, crashTimeString, crashTimeStringLen, &nBytes, nullptr); + WriteFile(hFile, "\n", 1, &nBytes, nullptr); if (timeSinceLastCrash != 0) { WriteFile(hFile, kTimeSinceLastCrashParameter, - kTimeSinceLastCrashParameterLen, &nBytes, NULL); + kTimeSinceLastCrashParameterLen, &nBytes, nullptr); WriteFile(hFile, timeSinceLastCrashString, timeSinceLastCrashStringLen, - &nBytes, NULL); - WriteFile(hFile, "\n", 1, &nBytes, NULL); + &nBytes, nullptr); + WriteFile(hFile, "\n", 1, &nBytes, nullptr); } if (isGarbageCollecting) { WriteFile(hFile, kIsGarbageCollectingParameter, kIsGarbageCollectingParameterLen, - &nBytes, NULL); - WriteFile(hFile, isGarbageCollecting ? "1" : "0", 1, &nBytes, NULL); - WriteFile(hFile, "\n", 1, &nBytes, NULL); + &nBytes, nullptr); + WriteFile(hFile, isGarbageCollecting ? "1" : "0", 1, &nBytes, nullptr); + WriteFile(hFile, "\n", 1, &nBytes, nullptr); } // Try to get some information about memory. MEMORYSTATUSEX statex; statex.dwLength = sizeof(statex); if (GlobalMemoryStatusEx(&statex)) { char buffer[128]; int bufferLen; -#define WRITE_STATEX_FIELD(field, paramName, conversionFunc) \ - WriteFile(hFile, k##paramName##Parameter, \ - k##paramName##ParameterLen, &nBytes, NULL); \ - conversionFunc(statex.field, buffer, 10); \ - bufferLen = strlen(buffer); \ - WriteFile(hFile, buffer, bufferLen, &nBytes, NULL); \ - WriteFile(hFile, "\n", 1, &nBytes, NULL); +#define WRITE_STATEX_FIELD(field, paramName, conversionFunc) \ + WriteFile(hFile, k##paramName##Parameter, \ + k##paramName##ParameterLen, &nBytes, nullptr); \ + conversionFunc(statex.field, buffer, 10); \ + bufferLen = strlen(buffer); \ + WriteFile(hFile, buffer, bufferLen, &nBytes, nullptr); \ + WriteFile(hFile, "\n", 1, &nBytes, nullptr); WRITE_STATEX_FIELD(dwMemoryLoad, SysMemory, ltoa); WRITE_STATEX_FIELD(ullTotalVirtual, TotalVirtualMemory, _ui64toa); WRITE_STATEX_FIELD(ullAvailVirtual, AvailableVirtualMemory, _ui64toa); WRITE_STATEX_FIELD(ullAvailPageFile, AvailablePageFile, _ui64toa); WRITE_STATEX_FIELD(ullAvailPhys, AvailablePhysicalMemory, _ui64toa); #undef WRITE_STATEX_FIELD } if (oomAllocationSizeBufferLen) { WriteFile(hFile, kOOMAllocationSizeParameter, - kOOMAllocationSizeParameterLen, &nBytes, NULL); + kOOMAllocationSizeParameterLen, &nBytes, nullptr); WriteFile(hFile, oomAllocationSizeBuffer, oomAllocationSizeBufferLen, - &nBytes, NULL); - WriteFile(hFile, "\n", 1, &nBytes, NULL); + &nBytes, nullptr); + WriteFile(hFile, "\n", 1, &nBytes, nullptr); } CloseHandle(hFile); } } if (!doReport) { return returnValue; } @@ -593,18 +593,18 @@ bool MinidumpCallback( PROCESS_INFORMATION pi; ZeroMemory(&si, sizeof(si)); si.cb = sizeof(si); si.dwFlags = STARTF_USESHOWWINDOW; si.wShowWindow = SW_SHOWNORMAL; ZeroMemory(&pi, sizeof(pi)); - if (CreateProcess(NULL, (LPWSTR)cmdLine, NULL, NULL, FALSE, 0, - NULL, NULL, &si, &pi)) { + if (CreateProcess(nullptr, (LPWSTR)cmdLine, nullptr, nullptr, FALSE, 0, + nullptr, nullptr, &si, &pi)) { CloseHandle( pi.hProcess ); CloseHandle( pi.hThread ); } // we're not really in a position to do anything if the CreateProcess fails TerminateProcess(GetCurrentProcess(), 1); #elif defined(XP_UNIX) if (!crashReporterAPIData->IsEmpty()) { // write out API data @@ -644,26 +644,26 @@ bool MinidumpCallback( if (!doReport) { return returnValue; } #ifdef XP_MACOSX char* const my_argv[] = { crashReporterPath, minidumpPath, - NULL + nullptr }; - char **env = NULL; + char **env = nullptr; char ***nsEnv = _NSGetEnviron(); if (nsEnv) env = *nsEnv; - int result = posix_spawnp(NULL, + int result = posix_spawnp(nullptr, my_argv[0], - NULL, + nullptr, &spawnattr, my_argv, env); if (result != 0) return false; #else // !XP_MACOSX @@ -716,17 +716,17 @@ static void* gBreakpadReservedVM; * the minidump will allow us to collect a minidump. */ static const SIZE_T kReserveSize = 0xc00000; // 12 MB static void ReserveBreakpadVM() { if (!gBreakpadReservedVM) { - gBreakpadReservedVM = VirtualAlloc(NULL, kReserveSize, MEM_RESERVE, 0); + gBreakpadReservedVM = VirtualAlloc(nullptr, kReserveSize, MEM_RESERVE, 0); } } static void FreeBreakpadVM() { if (gBreakpadReservedVM) { VirtualFree(gBreakpadReservedVM, kReserveSize, MEM_RELEASE); @@ -874,17 +874,17 @@ nsresult SetExceptionHandler(nsIFile* aX #endif } // get temp path to use for minidump path #if defined(XP_WIN32) nsString tempPath; // first figure out buffer size - int pathLen = GetTempPath(0, NULL); + int pathLen = GetTempPath(0, nullptr); if (pathLen == 0) return NS_ERROR_FAILURE; tempPath.SetLength(pathLen); GetTempPath(pathLen, (LPWSTR)tempPath.BeginWriting()); #elif defined(XP_MACOSX) nsCString tempPath; FSRef fsRef; @@ -935,17 +935,17 @@ nsresult SetExceptionHandler(nsIFile* aX #ifdef XP_WIN32 ReserveBreakpadVM(); MINIDUMP_TYPE minidump_type = MiniDumpNormal; // Try to determine what version of dbghelp.dll we're using. // MinidumpWithFullMemoryInfo is only available in 6.1.x or newer. - DWORD version_size = GetFileVersionInfoSizeW(L"dbghelp.dll", NULL); + DWORD version_size = GetFileVersionInfoSizeW(L"dbghelp.dll", nullptr); if (version_size > 0) { std::vector<BYTE> buffer(version_size); if (GetFileVersionInfoW(L"dbghelp.dll", 0, version_size, &buffer[0])) { UINT len; VS_FIXEDFILEINFO* file_info; @@ -988,22 +988,22 @@ nsresult SetExceptionHandler(nsIFile* aX #else Filter, #endif MinidumpCallback, nullptr, #ifdef XP_WIN32 google_breakpad::ExceptionHandler::HANDLER_ALL, minidump_type, - (const wchar_t*) NULL, - NULL); + (const wchar_t*) nullptr, + nullptr); #else true #ifdef XP_MACOSX - , NULL + , nullptr #endif #ifdef XP_LINUX , -1 #endif ); #endif // XP_WIN32 if (!gExceptionHandler) @@ -1022,17 +1022,17 @@ nsresult SetExceptionHandler(nsIFile* aX #ifdef DEBUG if (!ok) printf_stderr ("SetUnhandledExceptionFilter hook failed; crash reporter is vulnerable.\n"); #endif #endif // store application start time char timeString[32]; - time_t startupTime = time(NULL); + time_t startupTime = time(nullptr); XP_TTOA(startupTime, timeString, 10); AnnotateCrashReport(NS_LITERAL_CSTRING("StartupTime"), nsDependentCString(timeString)); #if defined(XP_MACOSX) // On OS X, many testers like to see the OS crash reporting dialog // since it offers immediate stack traces. We allow them to set // a default to pass exceptions to the OS handler. @@ -1175,17 +1175,17 @@ GetOrInit(nsIFile* aDir, const nsACStrin return rv; } // Init the "install time" data. We're taking an easy way out here // and just setting this to "the time when this version was first run". static nsresult InitInstallTime(nsACString& aInstallTime) { - time_t t = time(NULL); + time_t t = time(nullptr); char buf[16]; sprintf(buf, "%ld", t); aInstallTime = buf; return NS_OK; } // Annotate the crash report with a Unique User ID and time @@ -1245,17 +1245,17 @@ nsresult SetupExtraData(nsIFile* aAppDat AnnotateCrashReport(NS_LITERAL_CSTRING("InstallTime"), data); // this is a little different, since we can't init it with anything, // since it's stored at crash time, and we can't annotate the // crash report with the stored value, since we really want // (now - LastCrash), so we just get a value if it exists, // and store it in a time_t value. if(NS_SUCCEEDED(GetOrInit(dataDirectory, NS_LITERAL_CSTRING("LastCrash"), - data, NULL))) { + data, nullptr))) { lastCrashTime = (time_t)atol(data.get()); } // not really the best place to init this, but I have the path I need here nsCOMPtr<nsIFile> lastCrashFile; rv = dataDirectory->Clone(getter_AddRefs(lastCrashFile)); NS_ENSURE_SUCCESS(rv, rv); @@ -1841,17 +1841,17 @@ static nsresult PrefSubmitReports(bool* nsCOMPtr<nsIINIParserWriter> iniWriter = do_QueryInterface(iniParser); NS_ENSURE_TRUE(iniWriter, NS_ERROR_FAILURE); rv = iniWriter->SetString(NS_LITERAL_CSTRING("Crash Reporter"), NS_LITERAL_CSTRING("SubmitReport"), *aSubmitReports ? NS_LITERAL_CSTRING("1") : NS_LITERAL_CSTRING("0")); NS_ENSURE_SUCCESS(rv, rv); - rv = iniWriter->WriteFile(NULL, 0); + rv = iniWriter->WriteFile(nullptr, 0); return rv; } nsAutoCString submitReportValue; rv = iniParser->GetString(NS_LITERAL_CSTRING("Crash Reporter"), NS_LITERAL_CSTRING("SubmitReport"), submitReportValue); @@ -1959,17 +1959,17 @@ GetMinidumpLimboDir(nsIFile** dir) } else { #ifndef XP_LINUX CreateFileFromPath(gExceptionHandler->dump_path(), dir); #else CreateFileFromPath(gExceptionHandler->minidump_descriptor().directory(), dir); #endif - return NULL != *dir; + return nullptr != *dir; } } bool GetMinidumpForID(const nsAString& id, nsIFile** minidump) { if (!GetMinidumpLimboDir(minidump)) return false; @@ -2010,17 +2010,17 @@ GetExtraFileForMinidump(nsIFile* minidum return false; leafName.Replace(leafName.Length() - 3, 3, NS_LITERAL_STRING("extra")); rv = extraF->SetLeafName(leafName); if (NS_FAILED(rv)) return false; - *extraFile = NULL; + *extraFile = nullptr; extraF.swap(*extraFile); return true; } bool AppendExtraData(const nsAString& id, const AnnotationTable& data) { nsCOMPtr<nsIFile> extraFile; @@ -2028,17 +2028,17 @@ AppendExtraData(const nsAString& id, con return false; return AppendExtraData(extraFile, data); } //----------------------------------------------------------------------------- // Helpers for AppendExtraData() // struct Blacklist { - Blacklist() : mItems(NULL), mLen(0) { } + Blacklist() : mItems(nullptr), mLen(0) { } Blacklist(const char** items, int len) : mItems(items), mLen(len) { } bool Contains(const nsACString& key) const { for (int i = 0; i < mLen; ++i) if (key.EqualsASCII(mItems[i])) return true; return false; } @@ -2093,17 +2093,17 @@ WriteExtraData(nsIFile* extraFile, 0600, &fd); if (NS_FAILED(rv)) return false; EnumerateAnnotationsContext ctx = { blacklist, fd }; data.EnumerateRead(EnumerateAnnotations, &ctx); if (writeCrashTime) { - time_t crashTime = time(NULL); + time_t crashTime = time(nullptr); char crashTimeString[32]; XP_TTOA(crashTime, crashTimeString, 10); WriteAnnotation(fd, nsDependentCString("CrashTime"), nsDependentCString(crashTimeString)); } @@ -2128,17 +2128,17 @@ WriteExtraForMinidump(nsIFile* minidump, return false; if (!WriteExtraData(extra, *crashReporterAPIData_Hash, blacklist, true /*write crash time*/, true /*truncate*/)) return false; - *extraFile = NULL; + *extraFile = nullptr; extra.swap(*extraFile); return true; } // It really only makes sense to call this function when // ShouldReport() is true. static bool @@ -2203,30 +2203,30 @@ OnChildProcessDumpRequested(void* aConte #endif { MutexAutoLock lock(*dumpMapLock); ChildProcessData* pd = pidToMinidump->PutEntry(pid); MOZ_ASSERT(!pd->minidump); pd->minidump = minidump; pd->sequence = ++crashSequence; #ifdef MOZ_CRASHREPORTER_INJECTOR - runCallback = NULL != pd->callback; + runCallback = nullptr != pd->callback; #endif } #ifdef MOZ_CRASHREPORTER_INJECTOR if (runCallback) NS_DispatchToMainThread(new ReportInjectedCrash(pid)); #endif } } static bool OOPInitialized() { - return pidToMinidump != NULL; + return pidToMinidump != nullptr; } #ifdef XP_MACOSX static bool ChildFilter(void *context) { mozilla::DisableWritePoisoning(); return true; } #endif @@ -2234,61 +2234,61 @@ static bool ChildFilter(void *context) { void OOPInit() { if (OOPInitialized()) return; MOZ_ASSERT(NS_IsMainThread()); - NS_ABORT_IF_FALSE(gExceptionHandler != NULL, + NS_ABORT_IF_FALSE(gExceptionHandler != nullptr, "attempt to initialize OOP crash reporter before in-process crashreporter!"); #if defined(XP_WIN) childCrashNotifyPipe = PR_smprintf("\\\\.\\pipe\\gecko-crash-server-pipe.%i", static_cast<int>(::GetCurrentProcessId())); const std::wstring dumpPath = gExceptionHandler->dump_path(); crashServer = new CrashGenerationServer( NS_ConvertASCIItoUTF16(childCrashNotifyPipe).get(), - NULL, // default security attributes - NULL, NULL, // we don't care about process connect here - OnChildProcessDumpRequested, NULL, - NULL, NULL, // we don't care about process exit here - NULL, NULL, // we don't care about upload request here + nullptr, // default security attributes + nullptr, nullptr, // we don't care about process connect here + OnChildProcessDumpRequested, nullptr, + nullptr, nullptr, // we don't care about process exit here + nullptr, nullptr, // we don't care about upload request here true, // automatically generate dumps &dumpPath); #elif defined(XP_LINUX) if (!CrashGenerationServer::CreateReportChannel(&serverSocketFd, &clientSocketFd)) NS_RUNTIMEABORT("can't create crash reporter socketpair()"); const std::string dumpPath = gExceptionHandler->minidump_descriptor().directory(); crashServer = new CrashGenerationServer( serverSocketFd, - OnChildProcessDumpRequested, NULL, - NULL, NULL, // we don't care about process exit here + OnChildProcessDumpRequested, nullptr, + nullptr, nullptr, // we don't care about process exit here true, &dumpPath); #elif defined(XP_MACOSX) childCrashNotifyPipe = PR_smprintf("gecko-crash-server-pipe.%i", static_cast<int>(getpid())); const std::string dumpPath = gExceptionHandler->dump_path(); crashServer = new CrashGenerationServer( childCrashNotifyPipe, ChildFilter, - NULL, - OnChildProcessDumpRequested, NULL, - NULL, NULL, + nullptr, + OnChildProcessDumpRequested, nullptr, + nullptr, nullptr, true, // automatically generate dumps dumpPath); #endif if (!crashServer->Start()) NS_RUNTIMEABORT("can't start crash reporter server()"); pidToMinidump = new ChildMinidumpMap(); @@ -2309,27 +2309,27 @@ OOPDeinit() #ifdef MOZ_CRASHREPORTER_INJECTOR if (sInjectorThread) { sInjectorThread->Shutdown(); NS_RELEASE(sInjectorThread); } #endif delete crashServer; - crashServer = NULL; + crashServer = nullptr; delete dumpMapLock; - dumpMapLock = NULL; + dumpMapLock = nullptr; delete pidToMinidump; - pidToMinidump = NULL; + pidToMinidump = nullptr; #if defined(XP_WIN) PR_Free(childCrashNotifyPipe); - childCrashNotifyPipe = NULL; + childCrashNotifyPipe = nullptr; #endif } #if defined(XP_WIN) || defined(XP_MACOSX) // Parent-side API for children const char* GetChildNotificationPipe() { @@ -2483,22 +2483,22 @@ SetRemoteExceptionHandler(const nsACStri if (crashPipe.Equals(kNullNotifyPipe)) return true; NS_ABORT_IF_FALSE(!gExceptionHandler, "crash client already init'd"); gExceptionHandler = new google_breakpad:: ExceptionHandler(L"", FPEFilter, - NULL, // no minidump callback - NULL, // no callback context + nullptr, // no minidump callback + nullptr, // no callback context google_breakpad::ExceptionHandler::HANDLER_ALL, MiniDumpNormal, NS_ConvertASCIItoUTF16(crashPipe).BeginReading(), - NULL); + nullptr); #ifdef XP_WIN gExceptionHandler->set_handle_debug_exceptions(true); #endif // we either do remote or nothing, no fallback to regular crash reporting return gExceptionHandler->IsOutOfProcess(); } @@ -2532,20 +2532,20 @@ SetRemoteExceptionHandler() #ifndef XP_LINUX xpstring path = ""; #else // MinidumpDescriptor requires a non-empty path. google_breakpad::MinidumpDescriptor path("."); #endif gExceptionHandler = new google_breakpad:: ExceptionHandler(path, - NULL, // no filter callback - NULL, // no minidump callback - NULL, // no callback context - true, // install signal handlers + nullptr, // no filter callback + nullptr, // no minidump callback + nullptr, // no callback context + true, // install signal handlers kMagicChildCrashReportFd); if (gDelayedAnnotations) { for (uint32_t i = 0; i < gDelayedAnnotations->Length(); i++) { gDelayedAnnotations->ElementAt(i)->Run(); } delete gDelayedAnnotations; } @@ -2564,19 +2564,19 @@ SetRemoteExceptionHandler(const nsACStri if (crashPipe.Equals(kNullNotifyPipe)) return true; NS_ABORT_IF_FALSE(!gExceptionHandler, "crash client already init'd"); gExceptionHandler = new google_breakpad:: ExceptionHandler("", Filter, - NULL, // no minidump callback - NULL, // no callback context - true, // install signal handlers + nullptr, // no minidump callback + nullptr, // no callback context + true, // install signal handlers crashPipe.BeginReading()); // we either do remote or nothing, no fallback to regular crash reporting return gExceptionHandler->IsOutOfProcess(); } #endif // XP_WIN @@ -2831,17 +2831,17 @@ CreateAdditionalChildMinidump(ProcessHan return true; } bool UnsetRemoteExceptionHandler() { delete gExceptionHandler; - gExceptionHandler = NULL; + gExceptionHandler = nullptr; return true; } #if defined(MOZ_WIDGET_ANDROID) void AddLibraryMapping(const char* library_name, uintptr_t start_address, size_t mapping_length, size_t file_offset)
--- a/toolkit/crashreporter/nsExceptionHandler.h +++ b/toolkit/crashreporter/nsExceptionHandler.h @@ -77,21 +77,21 @@ nsresult SetSubmitReports(bool aSubmitRe // Out-of-process crash reporter API. // Initializes out-of-process crash reporting. This method must be called // before the platform-specifi notificationpipe APIs are called. void OOPInit(); // Return true if a dump was found for |childPid|, and return the // path in |dump|. The caller owns the last reference to |dump| if it -// is non-NULL. The sequence parameter will be filled with an ordinal +// is non-nullptr. The sequence parameter will be filled with an ordinal // indicating which remote process crashed first. bool TakeMinidumpForChild(uint32_t childPid, nsIFile** dump, - uint32_t* aSequence = NULL); + uint32_t* aSequence = nullptr); #if defined(XP_WIN) typedef HANDLE ProcessHandle; typedef DWORD ThreadId; #elif defined(XP_MACOSX) typedef task_t ProcessHandle; typedef mach_port_t ThreadId; #else
--- a/toolkit/crashreporter/test/dumputils.cpp +++ b/toolkit/crashreporter/test/dumputils.cpp @@ -43,17 +43,17 @@ DumpHasInstructionPointerMemory(const ch uint64_t instruction_pointer; if (!context->GetInstructionPointer(&instruction_pointer)) { return false; } MinidumpMemoryRegion* region = memory_list->GetMemoryRegionForAddress(instruction_pointer); - return region != NULL; + return region != nullptr; } // This function tests for a very specific condition. It finds // an address in a file, "crash-addr", in the CWD. It checks // that the minidump has a memory region starting at that // address. The region must be 32 bytes long and contain the // values 0 to 31 as bytes, in ascending order. extern "C"