Merge: Codechange: Use null pointer literal instead of the NULL macro
This commit is contained in:
@@ -72,7 +72,7 @@ public:
|
||||
* A crash log is always generated when it's generated.
|
||||
* @param ep the data related to the exception.
|
||||
*/
|
||||
CrashLogWindows(EXCEPTION_POINTERS *ep = NULL) :
|
||||
CrashLogWindows(EXCEPTION_POINTERS *ep = nullptr) :
|
||||
ep(ep)
|
||||
{
|
||||
this->crashlog[0] = '\0';
|
||||
@@ -87,7 +87,7 @@ public:
|
||||
static CrashLogWindows *current;
|
||||
};
|
||||
|
||||
/* static */ CrashLogWindows *CrashLogWindows::current = NULL;
|
||||
/* static */ CrashLogWindows *CrashLogWindows::current = nullptr;
|
||||
|
||||
/* virtual */ char *CrashLogWindows::LogOSVersion(char *buffer, const char *last) const
|
||||
{
|
||||
@@ -120,7 +120,7 @@ public:
|
||||
" Message: %s\n\n",
|
||||
(int)ep->ExceptionRecord->ExceptionCode,
|
||||
(size_t)ep->ExceptionRecord->ExceptionAddress,
|
||||
message == NULL ? "<none>" : message
|
||||
message == nullptr ? "<none>" : message
|
||||
);
|
||||
}
|
||||
|
||||
@@ -162,7 +162,7 @@ static void GetFileInfo(DebugFileInfo *dfi, const TCHAR *filename)
|
||||
HANDLE file;
|
||||
memset(dfi, 0, sizeof(*dfi));
|
||||
|
||||
file = CreateFile(filename, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0);
|
||||
file = CreateFile(filename, GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, 0, 0);
|
||||
if (file != INVALID_HANDLE_VALUE) {
|
||||
byte buffer[1024];
|
||||
DWORD numread;
|
||||
@@ -171,7 +171,7 @@ static void GetFileInfo(DebugFileInfo *dfi, const TCHAR *filename)
|
||||
uint32 crc = (uint32)-1;
|
||||
|
||||
for (;;) {
|
||||
if (ReadFile(file, buffer, sizeof(buffer), &numread, NULL) == 0 || numread == 0) {
|
||||
if (ReadFile(file, buffer, sizeof(buffer), &numread, nullptr) == 0 || numread == 0) {
|
||||
break;
|
||||
}
|
||||
filesize += numread;
|
||||
@@ -180,7 +180,7 @@ static void GetFileInfo(DebugFileInfo *dfi, const TCHAR *filename)
|
||||
dfi->size = filesize;
|
||||
dfi->crc32 = crc ^ (uint32)-1;
|
||||
|
||||
if (GetFileTime(file, NULL, NULL, &write_time)) {
|
||||
if (GetFileTime(file, nullptr, nullptr, &write_time)) {
|
||||
FileTimeToSystemTime(&write_time, &dfi->file_time);
|
||||
}
|
||||
CloseHandle(file);
|
||||
@@ -223,7 +223,7 @@ static char *PrintModuleInfo(char *output, const char *last, HMODULE mod)
|
||||
BOOL res;
|
||||
|
||||
HANDLE proc = OpenProcess(PROCESS_ALL_ACCESS, FALSE, GetCurrentProcessId());
|
||||
if (proc != NULL) {
|
||||
if (proc != nullptr) {
|
||||
res = EnumProcessModules(proc, modules, sizeof(modules), &needed);
|
||||
CloseHandle(proc);
|
||||
if (res) {
|
||||
@@ -234,7 +234,7 @@ static char *PrintModuleInfo(char *output, const char *last, HMODULE mod)
|
||||
}
|
||||
}
|
||||
}
|
||||
output = PrintModuleInfo(output, last, NULL);
|
||||
output = PrintModuleInfo(output, last, nullptr);
|
||||
return output + seprintf(output, last, "\n");
|
||||
}
|
||||
|
||||
@@ -371,7 +371,7 @@ char *CrashLogWindows::AppendDecodedStacktrace(char *buffer, const char *last) c
|
||||
if (LoadLibraryList((Function*)&proc, dbg_import)) {
|
||||
/* Initialize symbol handler. */
|
||||
HANDLE hCur = GetCurrentProcess();
|
||||
proc.pSymInitialize(hCur, NULL, TRUE);
|
||||
proc.pSymInitialize(hCur, nullptr, TRUE);
|
||||
/* Load symbols only when needed, fail silently on errors, demangle symbol names. */
|
||||
proc.pSymSetOptions(SYMOPT_DEFERRED_LOADS | SYMOPT_FAIL_CRITICAL_ERRORS | SYMOPT_UNDNAME);
|
||||
|
||||
@@ -408,7 +408,7 @@ char *CrashLogWindows::AppendDecodedStacktrace(char *buffer, const char *last) c
|
||||
#else
|
||||
IMAGE_FILE_MACHINE_I386,
|
||||
#endif
|
||||
hCur, GetCurrentThread(), &frame, &ctx, NULL, proc.pSymFunctionTableAccess64, proc.pSymGetModuleBase64, NULL)) break;
|
||||
hCur, GetCurrentThread(), &frame, &ctx, nullptr, proc.pSymFunctionTableAccess64, proc.pSymGetModuleBase64, nullptr)) break;
|
||||
|
||||
if (frame.AddrPC.Offset == frame.AddrReturn.Offset) {
|
||||
buffer += seprintf(buffer, last, " <infinite loop>\n");
|
||||
@@ -417,7 +417,7 @@ char *CrashLogWindows::AppendDecodedStacktrace(char *buffer, const char *last) c
|
||||
|
||||
/* Get module name. */
|
||||
const char *mod_name = "???";
|
||||
const char *image_name = NULL;
|
||||
const char *image_name = nullptr;
|
||||
|
||||
IMAGEHLP_MODULE64 module;
|
||||
module.SizeOfStruct = sizeof(module);
|
||||
@@ -440,17 +440,17 @@ char *CrashLogWindows::AppendDecodedStacktrace(char *buffer, const char *last) c
|
||||
if (proc.pSymGetLineFromAddr64(hCur, frame.AddrPC.Offset, &line_offs, &line)) {
|
||||
buffer += seprintf(buffer, last, " (%s:%d)", line.FileName, line.LineNumber);
|
||||
}
|
||||
} else if (image_name != NULL) {
|
||||
} else if (image_name != nullptr) {
|
||||
#if defined (WITH_BFD)
|
||||
/* subtract one to get the line before the return address, i.e. the function call line */
|
||||
sym_info_bfd bfd_info(static_cast<bfd_vma>(frame.AddrPC.Offset) - 1);
|
||||
lookup_addr_bfd(image_name, bfd_info);
|
||||
if (bfd_info.function_name != NULL) {
|
||||
if (bfd_info.function_name != nullptr) {
|
||||
const char *func_name = bfd_info.function_name;
|
||||
#if defined(WITH_DEMANGLE)
|
||||
int status = -1;
|
||||
char *demangled = abi::__cxa_demangle(func_name, NULL, 0, &status);
|
||||
if (demangled != NULL && status == 0) {
|
||||
char *demangled = abi::__cxa_demangle(func_name, nullptr, 0, &status);
|
||||
if (demangled != nullptr && status == 0) {
|
||||
func_name = demangled;
|
||||
}
|
||||
#endif
|
||||
@@ -465,7 +465,7 @@ char *CrashLogWindows::AppendDecodedStacktrace(char *buffer, const char *last) c
|
||||
buffer += seprintf(buffer, last, " + %I64u", frame.AddrPC.Offset - static_cast<DWORD64>(bfd_info.function_addr));
|
||||
}
|
||||
}
|
||||
if (bfd_info.file_name != NULL) {
|
||||
if (bfd_info.file_name != nullptr) {
|
||||
buffer += seprintf(buffer, last, " (%s:%d)", bfd_info.file_name, bfd_info.line);
|
||||
}
|
||||
#endif
|
||||
@@ -483,16 +483,16 @@ char *CrashLogWindows::AppendDecodedStacktrace(char *buffer, const char *last) c
|
||||
{
|
||||
int ret = 0;
|
||||
HMODULE dbghelp = LoadLibrary(_T("dbghelp.dll"));
|
||||
if (dbghelp != NULL) {
|
||||
if (dbghelp != nullptr) {
|
||||
typedef BOOL (WINAPI *MiniDumpWriteDump_t)(HANDLE, DWORD, HANDLE,
|
||||
MINIDUMP_TYPE,
|
||||
CONST PMINIDUMP_EXCEPTION_INFORMATION,
|
||||
CONST PMINIDUMP_USER_STREAM_INFORMATION,
|
||||
CONST PMINIDUMP_CALLBACK_INFORMATION);
|
||||
MiniDumpWriteDump_t funcMiniDumpWriteDump = (MiniDumpWriteDump_t)GetProcAddress(dbghelp, "MiniDumpWriteDump");
|
||||
if (funcMiniDumpWriteDump != NULL) {
|
||||
if (funcMiniDumpWriteDump != nullptr) {
|
||||
seprintf(filename, filename_last, "%scrash.dmp", _personal_dir);
|
||||
HANDLE file = CreateFile(OTTD2FS(filename), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, 0);
|
||||
HANDLE file = CreateFile(OTTD2FS(filename), GENERIC_WRITE, 0, nullptr, CREATE_ALWAYS, 0, 0);
|
||||
HANDLE proc = GetCurrentProcess();
|
||||
DWORD procid = GetCurrentProcessId();
|
||||
MINIDUMP_EXCEPTION_INFORMATION mdei;
|
||||
@@ -510,7 +510,7 @@ char *CrashLogWindows::AppendDecodedStacktrace(char *buffer, const char *last) c
|
||||
mdei.ExceptionPointers = ep;
|
||||
mdei.ClientPointers = false;
|
||||
|
||||
funcMiniDumpWriteDump(proc, procid, file, MiniDumpWithDataSegs, &mdei, &musi, NULL);
|
||||
funcMiniDumpWriteDump(proc, procid, file, MiniDumpWithDataSegs, &mdei, &musi, nullptr);
|
||||
ret = 1;
|
||||
} else {
|
||||
ret = -1;
|
||||
@@ -528,23 +528,23 @@ static void ShowCrashlogWindow();
|
||||
* Stack pointer for use when 'starting' the crash handler.
|
||||
* Not static as gcc's inline assembly needs it that way.
|
||||
*/
|
||||
void *_safe_esp = NULL;
|
||||
void *_safe_esp = nullptr;
|
||||
|
||||
static LONG WINAPI ExceptionHandler(EXCEPTION_POINTERS *ep)
|
||||
{
|
||||
_in_event_loop_post_crash = true;
|
||||
|
||||
if (CrashLogWindows::current != NULL) {
|
||||
if (CrashLogWindows::current != nullptr) {
|
||||
CrashLog::AfterCrashLogCleanup();
|
||||
ExitProcess(2);
|
||||
}
|
||||
|
||||
const char *abort_reason = CrashLog::GetAbortCrashlogReason();
|
||||
if (abort_reason != NULL) {
|
||||
if (abort_reason != nullptr) {
|
||||
TCHAR _emergency_crash[512];
|
||||
_sntprintf(_emergency_crash, lengthof(_emergency_crash),
|
||||
_T("A serious fault condition occurred in the game. The game will shut down.\n"), OTTD2FS(abort_reason));
|
||||
MessageBox(NULL, _emergency_crash, _T("Fatal Application Failure"), MB_ICONERROR);
|
||||
MessageBox(nullptr, _emergency_crash, _T("Fatal Application Failure"), MB_ICONERROR);
|
||||
ExitProcess(3);
|
||||
}
|
||||
|
||||
@@ -559,7 +559,7 @@ static LONG WINAPI ExceptionHandler(EXCEPTION_POINTERS *ep)
|
||||
/* Close any possible log files */
|
||||
CloseConsoleLogIfActive();
|
||||
|
||||
if ((VideoDriver::GetInstance() == NULL || VideoDriver::GetInstance()->HasGUI()) && _safe_esp != NULL) {
|
||||
if ((VideoDriver::GetInstance() == nullptr || VideoDriver::GetInstance()->HasGUI()) && _safe_esp != nullptr) {
|
||||
#ifdef _M_AMD64
|
||||
ep->ContextRecord->Rip = (DWORD64)ShowCrashlogWindow;
|
||||
ep->ContextRecord->Rsp = (DWORD64)_safe_esp;
|
||||
@@ -576,7 +576,7 @@ static LONG WINAPI ExceptionHandler(EXCEPTION_POINTERS *ep)
|
||||
|
||||
static void CDECL CustomAbort(int signal)
|
||||
{
|
||||
RaiseException(0xE1212012, 0, 0, NULL);
|
||||
RaiseException(0xE1212012, 0, 0, nullptr);
|
||||
}
|
||||
|
||||
/* static */ void CrashLog::InitialiseCrashLog()
|
||||
@@ -728,5 +728,5 @@ static void ShowCrashlogWindow()
|
||||
{
|
||||
ShowCursor(TRUE);
|
||||
ShowWindow(GetActiveWindow(), FALSE);
|
||||
DialogBox(GetModuleHandle(NULL), MAKEINTRESOURCE(100), NULL, CrashDialogFunc);
|
||||
DialogBox(GetModuleHandle(nullptr), MAKEINTRESOURCE(100), nullptr, CrashDialogFunc);
|
||||
}
|
||||
|
Reference in New Issue
Block a user