Bug 784739 - Switch from NULL to nullptr in toolkit/crashreporter/; r=ehsan

This commit is contained in:
Birunthan Mohanathas 2013-10-10 16:39:09 -04:00
parent 12171ef634
commit 053f76bb30
10 changed files with 194 additions and 185 deletions

View File

@ -61,9 +61,9 @@ InjectCrashRunnable::Run()
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");

View File

@ -31,12 +31,12 @@ public:
typedef FileView RawRef;
static FileView Void()
{
return NULL;
return nullptr;
}
static void Release(RawRef aView)
{
if (NULL != aView)
if (nullptr != aView)
UnmapViewOfFile(aView);
}
};
@ -67,7 +67,9 @@ 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);
@ -149,7 +151,7 @@ FinalizeSections(PMEMORYMODULE module, HANDLE hRemoteProcess)
remoteAddress,
localAddress,
size,
NULL)) {
nullptr)) {
#ifdef DEBUG_OUTPUT
OutputLastError("Error writing remote memory.\n");
#endif
@ -237,7 +239,7 @@ BuildImportTable(PMEMORYMODULE module)
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
@ -246,7 +248,7 @@ BuildImportTable(PMEMORYMODULE module)
}
module->modules = (HMODULE *)realloc(module->modules, (module->numModules+1)*(sizeof(HMODULE)));
if (module->modules == NULL) {
if (module->modules == nullptr) {
result = 0;
break;
}
@ -290,22 +292,22 @@ void* LoadRemoteLibraryAndGetAddress(HANDLE hRemoteProcess,
{
// 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(
@ -314,7 +316,7 @@ void* LoadRemoteLibraryAndGetAddress(HANDLE hRemoteProcess,
#if DEBUG_OUTPUT
OutputLastError("Couldn't MapViewOfFile.\n");
#endif
return NULL;
return nullptr;
}
SIZE_T locationDelta;
@ -324,7 +326,7 @@ void* LoadRemoteLibraryAndGetAddress(HANDLE hRemoteProcess,
#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);
@ -332,11 +334,11 @@ void* LoadRemoteLibraryAndGetAddress(HANDLE hRemoteProcess,
#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);
@ -346,7 +348,7 @@ void* LoadRemoteLibraryAndGetAddress(HANDLE hRemoteProcess,
#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);
@ -360,7 +362,7 @@ void* LoadRemoteLibraryAndGetAddress(HANDLE hRemoteProcess,
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);
@ -380,13 +382,13 @@ void* LoadRemoteLibraryAndGetAddress(HANDLE hRemoteProcess,
// 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);
@ -402,13 +404,13 @@ static void* MemoryGetProcAddress(PMEMORYMODULE module, const char *name)
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
@ -423,12 +425,12 @@ static void* MemoryGetProcAddress(PMEMORYMODULE module, const char *name)
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

View File

@ -34,7 +34,7 @@ string gSettingsPath;
int gArgc;
char** gArgv;
static auto_ptr<ofstream> gLogStream(NULL);
static auto_ptr<ofstream> gLogStream(nullptr);
static string gDumpFile;
static string gExtraFile;
@ -594,13 +594,13 @@ int WINAPI wWinMain( HINSTANCE, HINSTANCE, LPWSTR args, int )
{
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);

View File

@ -138,12 +138,12 @@ void LoadProxyinfo()
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);
@ -153,16 +153,17 @@ void LoadProxyinfo()
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);
@ -209,7 +210,7 @@ gpointer SendThread(gpointer args)
// http://library.gnome.org/devel/gtk-faq/stable/x499.html
g_idle_add(ReportCompleted, (gpointer)success);
return NULL;
return nullptr;
}
gboolean WindowDeleted(GtkWidget* window,
@ -275,7 +276,7 @@ bool UIInit()
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;
@ -293,7 +294,7 @@ bool UIInit()
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());
@ -312,7 +313,7 @@ void UIError_impl(const string& message)
}
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());

View File

@ -30,9 +30,9 @@ 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()
{
@ -118,7 +118,7 @@ void SendReport()
// 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)
@ -178,7 +178,7 @@ static void ViewReportClicked(GtkButton* button,
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);
@ -235,26 +235,26 @@ static void CommentInsert(GtkTextBuffer* buffer,
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 {
@ -264,10 +264,10 @@ static void UpdateHintText(GtkWidget* widget, gboolean gainedFocus,
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 {
@ -347,7 +347,7 @@ void TryInitGnome()
if (gnome_program_init && libgnomeui_module_info_get) {
gnome_program_init("crashreporter", "1.0", libgnomeui_module_info_get(),
gArgc, gArgv, NULL);
gArgc, gArgv, nullptr);
}
}
@ -504,7 +504,7 @@ bool UIShowCrashUI(const string& dumpfile,
// 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);

View File

@ -121,8 +121,9 @@ 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;
@ -202,8 +203,9 @@ 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;
}
@ -265,8 +267,8 @@ static string FormatLastError()
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");
@ -321,7 +323,7 @@ static void GetThemeSizes(HWND hwnd)
}
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);
@ -331,7 +333,7 @@ static void GetThemeSizes(HWND hwnd)
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)
@ -497,11 +499,12 @@ static void MaybeSendReport(HWND hwndDlg)
// 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()
@ -521,8 +524,8 @@ static void RestartApplication()
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);
}
@ -593,7 +596,7 @@ static BOOL CALLBACK ViewReportDialogProc(HWND hwndDlg, UINT message,
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;
@ -614,7 +617,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,
@ -648,9 +652,9 @@ static int NewTextLength(HWND hwndEdit, wchar_t* insert)
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) {
@ -840,11 +844,11 @@ static INT_PTR DialogBoxParamMaybeRTL(UINT idd, HWND hwndParent,
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);
@ -852,13 +856,13 @@ static INT_PTR DialogBoxParamMaybeRTL(UINT idd, HWND hwndParent,
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);
}
@ -882,7 +886,7 @@ static BOOL CALLBACK CrashReporterDialogProc(HWND hwndDlg, UINT message,
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);
@ -1028,7 +1032,7 @@ static BOOL CALLBACK CrashReporterDialogProc(HWND hwndDlg, UINT message,
// 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);
@ -1049,7 +1053,7 @@ static BOOL CALLBACK CrashReporterDialogProc(HWND hwndDlg, UINT message,
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);
@ -1088,7 +1092,7 @@ static BOOL CALLBACK CrashReporterDialogProc(HWND hwndDlg, UINT message,
case WM_SIZE: {
ReflowDialog(hwndDlg, HIWORD(lParam) - sHeight);
sHeight = HIWORD(lParam);
InvalidateRect(hwndDlg, NULL, TRUE);
InvalidateRect(hwndDlg, nullptr, TRUE);
return FALSE;
}
case WM_NOTIFY: {
@ -1160,7 +1164,7 @@ static BOOL CALLBACK CrashReporterDialogProc(HWND hwndDlg, UINT message,
Str(ST_SUBMITFAILED).c_str());
MaybeResizeProgressText(hwndDlg);
// close dialog after 5 seconds
SetTimer(hwndDlg, 0, 5000, NULL);
SetTimer(hwndDlg, 0, 5000, nullptr);
//
return TRUE;
}
@ -1198,9 +1202,9 @@ static BOOL CALLBACK CrashReporterDialogProc(HWND hwndDlg, UINT message,
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;
@ -1208,7 +1212,7 @@ static wstring UTF8ToWide(const string& utf8, bool *success)
}
buffer = new wchar_t[buffer_size];
if(buffer == NULL) {
if(buffer == nullptr) {
if (success)
*success = false;
return L"";
@ -1225,11 +1229,13 @@ static wstring UTF8ToWide(const string& utf8, bool *success)
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;
@ -1237,14 +1243,14 @@ static string WideToMBCP(const wstring& wide, unsigned int cp, bool* success = n
}
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;
@ -1278,7 +1284,7 @@ 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);
}
@ -1288,7 +1294,7 @@ bool UIShowCrashUI(const string& dumpFile,
const string& sendURL,
const vector<string>& restartArgs)
{
gSendData.hDlg = NULL;
gSendData.hDlg = nullptr;
gSendData.dumpFile = UTF8ToWide(dumpFile);
gSendData.sendURL = UTF8ToWide(sendURL);
@ -1315,7 +1321,7 @@ bool UIShowCrashUI(const string& dumpFile,
gStrings["isRTL"] == "yes")
gRTLlayout = true;
return 1 == DialogBoxParamMaybeRTL(IDD_SENDDIALOG, NULL,
return 1 == DialogBoxParamMaybeRTL(IDD_SENDDIALOG, nullptr,
(DLGPROC)CrashReporterDialogProc, 0);
}
@ -1325,14 +1331,14 @@ void UIError_impl(const string& message)
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) {
@ -1350,9 +1356,9 @@ bool UIGetSettingsPath(const string& vendor,
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)) {
@ -1371,7 +1377,7 @@ bool UIGetSettingsPath(const string& vendor,
dwRes = RegQueryValueExW(key,
L"AppData",
NULL,
nullptr,
&type,
(LPBYTE)&path,
&size);
@ -1393,7 +1399,7 @@ bool UIGetSettingsPath(const string& vendor,
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;
}

View File

@ -26,14 +26,14 @@ __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;

View File

@ -253,7 +253,7 @@ struct ChildProcessData : public nsUint32HashKey
: nsUint32HashKey(aKey)
, sequence(0)
#ifdef MOZ_CRASHREPORTER_INJECTOR
, callback(NULL)
, callback(nullptr)
#endif
{ }
@ -320,7 +320,7 @@ patched_SetUnhandledExceptionFilter (LPTOP_LEVEL_EXCEPTION_FILTER lpTopLevelExce
}
// intercept attempts to change the filter
return NULL;
return nullptr;
}
#endif
@ -441,11 +441,11 @@ bool MinidumpCallback(
// 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)
@ -472,10 +472,10 @@ bool MinidumpCallback(
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
@ -495,11 +495,11 @@ bool MinidumpCallback(
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)
@ -518,28 +518,28 @@ bool MinidumpCallback(
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.
@ -549,13 +549,13 @@ bool MinidumpCallback(
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);
@ -568,10 +568,10 @@ bool MinidumpCallback(
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);
}
@ -598,8 +598,8 @@ bool MinidumpCallback(
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 );
}
@ -649,16 +649,16 @@ bool MinidumpCallback(
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);
@ -721,7 +721,7 @@ static void
ReserveBreakpadVM()
{
if (!gBreakpadReservedVM) {
gBreakpadReservedVM = VirtualAlloc(NULL, kReserveSize, MEM_RESERVE, 0);
gBreakpadReservedVM = VirtualAlloc(nullptr, kReserveSize, MEM_RESERVE, 0);
}
}
@ -879,7 +879,7 @@ nsresult SetExceptionHandler(nsIFile* aXREDirectory,
nsString tempPath;
// first figure out buffer size
int pathLen = GetTempPath(0, NULL);
int pathLen = GetTempPath(0, nullptr);
if (pathLen == 0)
return NS_ERROR_FAILURE;
@ -940,7 +940,7 @@ nsresult SetExceptionHandler(nsIFile* aXREDirectory,
// 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",
@ -993,12 +993,12 @@ nsresult SetExceptionHandler(nsIFile* aXREDirectory,
#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
@ -1027,7 +1027,7 @@ nsresult SetExceptionHandler(nsIFile* aXREDirectory,
// 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));
@ -1180,7 +1180,7 @@ GetOrInit(nsIFile* aDir, const nsACString& filename,
static nsresult
InitInstallTime(nsACString& aInstallTime)
{
time_t t = time(NULL);
time_t t = time(nullptr);
char buf[16];
sprintf(buf, "%ld", t);
aInstallTime = buf;
@ -1250,7 +1250,7 @@ nsresult SetupExtraData(nsIFile* aAppDataDirectory,
// (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());
}
@ -1846,7 +1846,7 @@ static nsresult PrefSubmitReports(bool* aSubmitReports, bool writePref)
*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;
}
@ -1964,7 +1964,7 @@ GetMinidumpLimboDir(nsIFile** dir)
CreateFileFromPath(gExceptionHandler->minidump_descriptor().directory(),
dir);
#endif
return NULL != *dir;
return nullptr != *dir;
}
}
@ -2015,7 +2015,7 @@ GetExtraFileForMinidump(nsIFile* minidump, nsIFile** extraFile)
if (NS_FAILED(rv))
return false;
*extraFile = NULL;
*extraFile = nullptr;
extraF.swap(*extraFile);
return true;
}
@ -2033,7 +2033,7 @@ AppendExtraData(const nsAString& id, const AnnotationTable& 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 {
@ -2098,7 +2098,7 @@ WriteExtraData(nsIFile* extraFile,
data.EnumerateRead(EnumerateAnnotations, &ctx);
if (writeCrashTime) {
time_t crashTime = time(NULL);
time_t crashTime = time(nullptr);
char crashTimeString[32];
XP_TTOA(crashTime, crashTimeString, 10);
@ -2133,7 +2133,7 @@ WriteExtraForMinidump(nsIFile* minidump,
true /*truncate*/))
return false;
*extraFile = NULL;
*extraFile = nullptr;
extra.swap(*extraFile);
return true;
@ -2208,7 +2208,7 @@ OnChildProcessDumpRequested(void* aContext,
pd->minidump = minidump;
pd->sequence = ++crashSequence;
#ifdef MOZ_CRASHREPORTER_INJECTOR
runCallback = NULL != pd->callback;
runCallback = nullptr != pd->callback;
#endif
}
#ifdef MOZ_CRASHREPORTER_INJECTOR
@ -2221,7 +2221,7 @@ OnChildProcessDumpRequested(void* aContext,
static bool
OOPInitialized()
{
return pidToMinidump != NULL;
return pidToMinidump != nullptr;
}
#ifdef XP_MACOSX
@ -2239,7 +2239,7 @@ OOPInit()
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)
@ -2250,11 +2250,11 @@ OOPInit()
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);
@ -2267,8 +2267,8 @@ OOPInit()
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);
@ -2281,9 +2281,9 @@ OOPInit()
crashServer = new CrashGenerationServer(
childCrashNotifyPipe,
ChildFilter,
NULL,
OnChildProcessDumpRequested, NULL,
NULL, NULL,
nullptr,
OnChildProcessDumpRequested, nullptr,
nullptr, nullptr,
true, // automatically generate dumps
dumpPath);
#endif
@ -2314,17 +2314,17 @@ OOPDeinit()
#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
}
@ -2488,12 +2488,12 @@ SetRemoteExceptionHandler(const nsACString& crashPipe)
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
@ -2537,10 +2537,10 @@ SetRemoteExceptionHandler()
#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) {
@ -2569,9 +2569,9 @@ SetRemoteExceptionHandler(const nsACString& crashPipe)
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
@ -2836,7 +2836,7 @@ bool
UnsetRemoteExceptionHandler()
{
delete gExceptionHandler;
gExceptionHandler = NULL;
gExceptionHandler = nullptr;
return true;
}

View File

@ -82,11 +82,11 @@ 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;

View File

@ -48,7 +48,7 @@ DumpHasInstructionPointerMemory(const char* dump_file)
MinidumpMemoryRegion* region =
memory_list->GetMemoryRegionForAddress(instruction_pointer);
return region != NULL;
return region != nullptr;
}
// This function tests for a very specific condition. It finds