From a7c24ca48995cf2bf436156302f96b91bf135409 Mon Sep 17 00:00:00 2001 From: Goraf <22941576+Goraf@users.noreply.github.com> Date: Mon, 13 Nov 2017 15:03:31 +0100 Subject: Code modernize ... * replace 0/NULL with nullptr [using clang-tidy] --- plugins/CrashDumper/src/crshdmp.cpp | 14 +++--- plugins/CrashDumper/src/crshdmp_icons.cpp | 4 +- plugins/CrashDumper/src/dumper.cpp | 84 +++++++++++++++---------------- plugins/CrashDumper/src/exhndlr.cpp | 24 ++++----- plugins/CrashDumper/src/ui.cpp | 16 +++--- plugins/CrashDumper/src/upload.cpp | 4 +- plugins/CrashDumper/src/utils.cpp | 28 +++++------ 7 files changed, 87 insertions(+), 87 deletions(-) (limited to 'plugins/CrashDumper') diff --git a/plugins/CrashDumper/src/crshdmp.cpp b/plugins/CrashDumper/src/crshdmp.cpp index 30ff267f06..f31de55e7c 100644 --- a/plugins/CrashDumper/src/crshdmp.cpp +++ b/plugins/CrashDumper/src/crshdmp.cpp @@ -70,7 +70,7 @@ INT_PTR StoreVersionInfoToFile(WPARAM, LPARAM lParam) wchar_t path[MAX_PATH]; mir_snwprintf(path, TEXT("%s\\VersionInfo.txt"), VersionInfoFolder); - HANDLE hDumpFile = CreateFile(path, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + HANDLE hDumpFile = CreateFile(path, GENERIC_WRITE, 0, nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr); if (hDumpFile != INVALID_HANDLE_VALUE) { CMStringW buffer; PrintVersionInfo(buffer, (unsigned int)lParam | VI_FLAG_PRNVAR); @@ -120,7 +120,7 @@ INT_PTR ViewVersionInfo(WPARAM wParam, LPARAM) } else { DWORD dwFlags = wParam ? (VI_FLAG_PRNVAR | VI_FLAG_PRNDLL) : VI_FLAG_PRNVAR; - hViewWnd = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_VIEWVERSION), NULL, DlgProcView, dwFlags); + hViewWnd = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_VIEWVERSION), nullptr, DlgProcView, dwFlags); } return 0; @@ -144,7 +144,7 @@ INT_PTR OpenUrl(WPARAM wParam, LPARAM) { switch (wParam) { case 0: - ShellExecute(NULL, TEXT("explore"), CrashLogFolder, NULL, NULL, SW_SHOW); + ShellExecute(nullptr, TEXT("explore"), CrashLogFolder, nullptr, nullptr, SW_SHOW); break; case 1: @@ -166,10 +166,10 @@ INT_PTR CopyLinkToClipboard(WPARAM, LPARAM) LPSTR buf = (LPSTR)GlobalLock(hData); memcpy(buf, buffer, bufLen); - OpenClipboard(NULL); + OpenClipboard(nullptr); EmptyClipboard(); - if (SetClipboardData(CF_UNICODETEXT, hData) == NULL) + if (SetClipboardData(CF_UNICODETEXT, hData) == nullptr) GlobalFree(hData); CloseClipboard(); } @@ -213,7 +213,7 @@ int OptionsInit(WPARAM wParam, LPARAM) static int ToolbarModulesLoaded(WPARAM, LPARAM) { - TTBButton ttb = { 0 }; + TTBButton ttb = {}; ttb.pszService = MS_CRASHDUMPER_STORETOCLIP; ttb.name = ttb.pszTooltipUp = LPGEN("Version Information To Clipboard"); ttb.hIconHandleUp = GetIconHandle(IDI_VITOCLIP); @@ -355,7 +355,7 @@ static int PreShutdown(WPARAM, LPARAM) extern "C" int __declspec(dllexport) Load(void) { hMsftedit = LoadLibrary(L"Msftedit.dll"); - if (hMsftedit == NULL) + if (hMsftedit == nullptr) return 1; clsdates = db_get_b(NULL, PluginName, "ClassicDates", 1) != 0; diff --git a/plugins/CrashDumper/src/crshdmp_icons.cpp b/plugins/CrashDumper/src/crshdmp_icons.cpp index d3ccc95dff..cbefe71020 100644 --- a/plugins/CrashDumper/src/crshdmp_icons.cpp +++ b/plugins/CrashDumper/src/crshdmp_icons.cpp @@ -39,7 +39,7 @@ HICON LoadIconEx(int iconId, bool big) if (iconList[i].defIconID == iconId) return IcoLib_GetIconByHandle(iconList[i].hIcolib, big); - return NULL; + return nullptr; } HANDLE GetIconHandle(int iconId) @@ -48,5 +48,5 @@ HANDLE GetIconHandle(int iconId) if (iconList[i].defIconID == iconId) return iconList[i].hIcolib; - return NULL; + return nullptr; } diff --git a/plugins/CrashDumper/src/dumper.cpp b/plugins/CrashDumper/src/dumper.cpp index 2b07c9766c..a96fba0025 100644 --- a/plugins/CrashDumper/src/dumper.cpp +++ b/plugins/CrashDumper/src/dumper.cpp @@ -30,7 +30,7 @@ void CreateMiniDump(HANDLE hDumpFile, PEXCEPTION_POINTERS exc_ptr) exceptionInfo.ClientPointers = false; MiniDumpWriteDump(GetCurrentProcess(), GetCurrentProcessId(), - hDumpFile, MiniDumpNormal, &exceptionInfo, NULL, NULL); + hDumpFile, MiniDumpNormal, &exceptionInfo, nullptr, nullptr); } @@ -48,8 +48,8 @@ void WriteUtfFile(HANDLE hDumpFile, char* bufu) DWORD bytes; static const unsigned char bytemark[] = { 0xEF, 0xBB, 0xBF }; - WriteFile(hDumpFile, bytemark, 3, &bytes, NULL); - WriteFile(hDumpFile, bufu, (DWORD)mir_strlen(bufu), &bytes, NULL); + WriteFile(hDumpFile, bytemark, 3, &bytes, nullptr); + WriteFile(hDumpFile, bufu, (DWORD)mir_strlen(bufu), &bytes, nullptr); } @@ -102,11 +102,11 @@ BOOL CALLBACK LoadedModulesFind64(LPCSTR ModuleName, DWORD64 ModuleBase, ULONG M void GetLinkedModulesInfo(wchar_t *moduleName, CMStringW &buffer) { - HANDLE hDllFile = CreateFile(moduleName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + HANDLE hDllFile = CreateFile(moduleName, GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr); if (hDllFile == INVALID_HANDLE_VALUE) return; - HANDLE hDllMapping = CreateFileMapping(hDllFile, NULL, PAGE_READONLY, 0, 0, NULL); + HANDLE hDllMapping = CreateFileMapping(hDllFile, nullptr, PAGE_READONLY, 0, 0, nullptr); if (hDllMapping == INVALID_HANDLE_VALUE) { CloseHandle(hDllFile); return; @@ -124,8 +124,8 @@ void GetLinkedModulesInfo(wchar_t *moduleName, CMStringW &buffer) IMAGE_DIRECTORY_ENTRY_IMPORT, &tableSize); if (importData) { while (importData->Name) { - char *szImportModule = (char*)ImageRvaToVa(nthdrs, dllAddr, importData->Name, NULL); - if (!SearchPathA(NULL, szImportModule, NULL, NULL, 0, NULL)) + char *szImportModule = (char*)ImageRvaToVa(nthdrs, dllAddr, importData->Name, nullptr); + if (!SearchPathA(nullptr, szImportModule, nullptr, NULL, nullptr, nullptr)) buffer.AppendFormat(format, szImportModule); importData++; //go to next record @@ -136,9 +136,9 @@ void GetLinkedModulesInfo(wchar_t *moduleName, CMStringW &buffer) PIMAGE_EXPORT_DIRECTORY exportData = (PIMAGE_EXPORT_DIRECTORY)ImageDirectoryEntryToData(dllAddr, FALSE, IMAGE_DIRECTORY_ENTRY_EXPORT, &tableSize); if (exportData) { - ULONG* funcAddr = (ULONG*)ImageRvaToVa(nthdrs, dllAddr, exportData->AddressOfNames, NULL); + ULONG* funcAddr = (ULONG*)ImageRvaToVa(nthdrs, dllAddr, exportData->AddressOfNames, nullptr); for (unsigned i = 0; i < exportData->NumberOfNames; ++i) { - char* funcName = (char*)ImageRvaToVa(nthdrs, dllAddr, funcAddr[i], NULL); + char* funcName = (char*)ImageRvaToVa(nthdrs, dllAddr, funcAddr[i], nullptr); if (mir_strcmp(funcName, "DatabasePluginInfo") == 0) { buffer.Append(TEXT(" This dll is a Miranda database plugin, another database is active right now\r\n")); found = true; @@ -163,7 +163,7 @@ void GetLinkedModulesInfo(wchar_t *moduleName, CMStringW &buffer) struct ListItem { - ListItem() : str(), next(NULL) {} + ListItem() : str(), next(nullptr) {} CMStringW str; ListItem *next; @@ -174,10 +174,10 @@ static void GetPluginsString(CMStringW& buffer, unsigned& flags) buffer.AppendFormat(TEXT("Service Mode: %s\r\n"), servicemode ? TEXT("Yes") : TEXT("No")); wchar_t path[MAX_PATH]; - GetModuleFileName(NULL, path, MAX_PATH); + GetModuleFileName(nullptr, path, MAX_PATH); LPTSTR fname = wcsrchr(path, TEXT('\\')); - if (fname == NULL) fname = path; + if (fname == nullptr) fname = path; mir_snwprintf(fname, MAX_PATH - (fname - path), TEXT("\\plugins\\*.dll")); WIN32_FIND_DATA FindFileData; @@ -187,7 +187,7 @@ static void GetPluginsString(CMStringW& buffer, unsigned& flags) size_t count = 0, ucount = 0; CMStringW ubuffer; - ListItem* dlllist = NULL; + ListItem* dlllist = nullptr; static const wchar_t format[] = TEXT("\xa4 %s v.%s%d.%d.%d.%d%s [%s] - %S %s\r\n"); @@ -195,11 +195,11 @@ static void GetPluginsString(CMStringW& buffer, unsigned& flags) bool loaded = false; mir_snwprintf(fname, MAX_PATH - (fname - path), TEXT("\\plugins\\%s"), FindFileData.cFileName); HMODULE hModule = GetModuleHandle(path); - if (hModule == NULL && servicemode) { + if (hModule == nullptr && servicemode) { hModule = LoadLibrary(path); loaded = true; } - if (hModule == NULL) { + if (hModule == nullptr) { if ((flags & VI_FLAG_PRNVAR) && IsPluginEnabled(FindFileData.cFileName)) { wchar_t timebuf[30] = TEXT(""); GetLastWriteTime(&FindFileData.ftLastWriteTime, timebuf, 30); @@ -219,7 +219,7 @@ static void GetPluginsString(CMStringW& buffer, unsigned& flags) } PLUGININFOEX* pi = GetMirInfo(hModule); - if (pi != NULL) { + if (pi != nullptr) { wchar_t timebuf[30] = TEXT(""); GetLastWriteTime(&FindFileData.ftLastWriteTime, timebuf, 30); @@ -251,15 +251,15 @@ static void GetPluginsString(CMStringW& buffer, unsigned& flags) timebuf, pi->shortName ? pi->shortName : "", unica); ListItem* lsttmp = dlllist; - ListItem* lsttmppv = NULL; - while (lsttmp != NULL) { + ListItem* lsttmppv = nullptr; + while (lsttmp != nullptr) { if (lsttmp->str.CompareNoCase(lst->str) > 0) break; lsttmppv = lsttmp; lsttmp = lsttmp->next; } lst->next = lsttmp; - if (lsttmppv == NULL) + if (lsttmppv == nullptr) dlllist = lst; else lsttmppv->next = lst; @@ -277,7 +277,7 @@ static void GetPluginsString(CMStringW& buffer, unsigned& flags) (flags & VI_FLAG_FORMAT) ? TEXT("[b]") : TEXT(""), count, (flags & VI_FLAG_FORMAT) ? TEXT("[/b]") : TEXT("")); ListItem* lsttmp = dlllist; - while (lsttmp != NULL) { + while (lsttmp != nullptr) { buffer.Append(lsttmp->str); ListItem* lsttmp1 = lsttmp->next; delete lsttmp; @@ -353,10 +353,10 @@ static void GetProtocolStrings(CMStringW& buffer) static void GetWeatherStrings(CMStringW& buffer, unsigned flags) { wchar_t path[MAX_PATH]; - GetModuleFileName(NULL, path, MAX_PATH); + GetModuleFileName(nullptr, path, MAX_PATH); LPTSTR fname = wcsrchr(path, TEXT('\\')); - if (fname == NULL) fname = path; + if (fname == nullptr) fname = path; mir_snwprintf(fname, MAX_PATH - (fname - path), TEXT("\\plugins\\weather\\*.ini")); WIN32_FIND_DATA FindFileData; @@ -367,34 +367,34 @@ static void GetWeatherStrings(CMStringW& buffer, unsigned flags) if (FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) continue; mir_snwprintf(fname, MAX_PATH - (fname - path), TEXT("\\plugins\\weather\\%s"), FindFileData.cFileName); - HANDLE hDumpFile = CreateFile(path, GENERIC_READ, FILE_SHARE_READ, NULL, - OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + HANDLE hDumpFile = CreateFile(path, GENERIC_READ, FILE_SHARE_READ, nullptr, + OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr); if (hDumpFile != INVALID_HANDLE_VALUE) { char buf[8192]; DWORD bytes = 0; - ReadFile(hDumpFile, buf, 8190, &bytes, NULL); + ReadFile(hDumpFile, buf, 8190, &bytes, nullptr); buf[bytes] = 0; char* ver = strstr(buf, "Version="); - if (ver != NULL) { + if (ver != nullptr) { char *endid = strchr(ver, '\r'); - if (endid != NULL) *endid = 0; + if (endid != nullptr) *endid = 0; else { endid = strchr(ver, '\n'); - if (endid != NULL) *endid = 0; + if (endid != nullptr) *endid = 0; } ver += 8; } char *id = strstr(buf, "Name="); - if (id != NULL) { + if (id != nullptr) { char *endid = strchr(id, '\r'); - if (endid != NULL) *endid = 0; + if (endid != nullptr) *endid = 0; else { endid = strchr(id, '\n'); - if (endid != NULL) *endid = 0; + if (endid != nullptr) *endid = 0; } id += 5; } @@ -420,10 +420,10 @@ static void GetWeatherStrings(CMStringW& buffer, unsigned flags) static void GetIconStrings(CMStringW& buffer) { wchar_t path[MAX_PATH]; - GetModuleFileName(NULL, path, MAX_PATH); + GetModuleFileName(nullptr, path, MAX_PATH); LPTSTR fname = wcsrchr(path, TEXT('\\')); - if (fname == NULL) fname = path; + if (fname == nullptr) fname = path; mir_snwprintf(fname, MAX_PATH - (fname - path), TEXT("\\Icons\\*.*")); WIN32_FIND_DATA FindFileData; @@ -475,7 +475,7 @@ void PrintVersionInfo(CMStringW& buffer, unsigned flags) buffer.Append(L"\r\n"); wchar_t path[MAX_PATH], mirtime[30]; - GetModuleFileName(NULL, path, MAX_PATH); + GetModuleFileName(nullptr, path, MAX_PATH); GetLastWriteTime(path, mirtime, 30); buffer.AppendFormat(TEXT("Build time: %s\r\n"), mirtime); @@ -543,7 +543,7 @@ void PrintVersionInfo(CMStringW& buffer, unsigned flags) void CreateCrashReport(HANDLE hDumpFile, PEXCEPTION_POINTERS exc_ptr, const wchar_t* msg) { - if (exc_ptr->ContextRecord == NULL || (exc_ptr->ContextRecord->ContextFlags & CONTEXT_CONTROL) == 0) + if (exc_ptr->ContextRecord == nullptr || (exc_ptr->ContextRecord->ContextFlags & CONTEXT_CONTROL) == 0) return; CONTEXT context = *exc_ptr->ContextRecord; @@ -574,7 +574,7 @@ void CreateCrashReport(HANDLE hDumpFile, PEXCEPTION_POINTERS exc_ptr, const wcha const PLUGININFOEX *pluginInfoEx = GetPluginInfoEx(); wchar_t curtime[30]; - GetISO8061Time(NULL, curtime, 30); + GetISO8061Time(nullptr, curtime, 30); CMStringW buffer; buffer.AppendFormat(TEXT("Miranda Crash Report from %s. Crash Dumper v.%d.%d.%d.%d\r\n"), @@ -591,7 +591,7 @@ void CreateCrashReport(HANDLE hDumpFile, PEXCEPTION_POINTERS exc_ptr, const wcha if (&SymSetOptions) SymSetOptions(SYMOPT_UNDNAME | SYMOPT_DEFERRED_LOADS | SYMOPT_LOAD_LINES); - SymInitialize(hProcess, NULL, TRUE); + SymInitialize(hProcess, nullptr, TRUE); buffer.Append(TEXT("\r\nStack Trace:\r\n---------------------------------------------------------------\r\n")); @@ -614,7 +614,7 @@ void CreateCrashReport(HANDLE hDumpFile, PEXCEPTION_POINTERS exc_ptr, const wcha DWORD offsetFromLine = 0; if (!StackWalk64(IMAGE_FILE_MACHINE, hProcess, GetCurrentThread(), &frame, &context, - NULL, SymFunctionTableAccess64, SymGetModuleBase64, NULL)) break; + nullptr, SymFunctionTableAccess64, SymGetModuleBase64, nullptr)) break; if (frame.AddrPC.Offset == frame.AddrReturn.Offset) break; @@ -650,7 +650,7 @@ void CreateCrashReport(HANDLE hDumpFile, PEXCEPTION_POINTERS exc_ptr, const wcha if (crashpos != 0) { HMODULE hModule = (HMODULE)Module.BaseOfImage; PLUGININFOEX *pi = GetMirInfo(hModule); - if (pi != NULL) { + if (pi != nullptr) { static const wchar_t formatc[] = TEXT("\r\nLikely cause of the crash plugin: %S\r\n\r\n"); if (pi->shortName) { @@ -673,15 +673,15 @@ void CreateCrashReport(HANDLE hDumpFile, PEXCEPTION_POINTERS exc_ptr, const wcha PrintVersionInfo(buffer, VI_FLAG_PRNDLL); - int len = WideCharToMultiByte(CP_UTF8, 0, buffer.c_str(), -1, NULL, 0, NULL, NULL); + int len = WideCharToMultiByte(CP_UTF8, 0, buffer.c_str(), -1, nullptr, 0, nullptr, nullptr); char* dst = (char*)(len > 8192 ? malloc(len) : alloca(len)); - WideCharToMultiByte(CP_UTF8, 0, buffer.c_str(), -1, dst, len, NULL, NULL); + WideCharToMultiByte(CP_UTF8, 0, buffer.c_str(), -1, dst, len, nullptr, nullptr); WriteUtfFile(hDumpFile, dst); if (len > 8192) free(dst); - if (db_get_b(0, PluginName, "ShowCrashMessageBox", 1) && msg && MessageBox(NULL, msg, TEXT("Miranda Crash Dumper"), MB_YESNO | MB_ICONERROR | MB_TASKMODAL | MB_DEFBUTTON2 | MB_TOPMOST) == IDYES) + if (db_get_b(0, PluginName, "ShowCrashMessageBox", 1) && msg && MessageBox(nullptr, msg, TEXT("Miranda Crash Dumper"), MB_YESNO | MB_ICONERROR | MB_TASKMODAL | MB_DEFBUTTON2 | MB_TOPMOST) == IDYES) StoreStringToClip(buffer); } diff --git a/plugins/CrashDumper/src/exhndlr.cpp b/plugins/CrashDumper/src/exhndlr.cpp index 92219a5128..14cc07f3b0 100644 --- a/plugins/CrashDumper/src/exhndlr.cpp +++ b/plugins/CrashDumper/src/exhndlr.cpp @@ -18,8 +18,8 @@ void RemoveExceptionHandler(void) if (exchndlrv) RemoveVectoredExceptionHandler(exchndlrv); SetUnhandledExceptionFilter((LPTOP_LEVEL_EXCEPTION_FILTER)exchndlr); - exchndlr = NULL; - exchndlrv = NULL; + exchndlr = nullptr; + exchndlrv = nullptr; } int myDebugFilter(unsigned int code, PEXCEPTION_POINTERS ep) @@ -37,7 +37,7 @@ int myDebugFilter(unsigned int code, PEXCEPTION_POINTERS ep) else mir_snprintf(str + off, _countof(str) - off, "Ordinal: %x ", dlld->dlp.dwOrdinal); - MessageBoxA(NULL, str, "Miranda Crash Dumper", MB_OK | MB_ICONERROR | MB_TASKMODAL | MB_TOPMOST); + MessageBoxA(nullptr, str, "Miranda Crash Dumper", MB_OK | MB_ICONERROR | MB_TASKMODAL | MB_TOPMOST); } return EXCEPTION_EXECUTE_HANDLER; @@ -48,7 +48,7 @@ void myfilterWorker(PEXCEPTION_POINTERS exc_ptr, bool notify) { wchar_t path[MAX_PATH]; SYSTEMTIME st; - HANDLE hDumpFile = NULL; + HANDLE hDumpFile = nullptr; GetLocalTime(&st); CreateDirectoryTreeW(CrashLogFolder); @@ -56,7 +56,7 @@ void myfilterWorker(PEXCEPTION_POINTERS exc_ptr, bool notify) __try { if (dtsubfldr) { mir_snwprintf(path, TEXT("%s\\%02d.%02d.%02d"), CrashLogFolder, st.wYear, st.wMonth, st.wDay); - CreateDirectory(path, NULL); + CreateDirectory(path, nullptr); mir_snwprintf(path, TEXT("%s\\%02d.%02d.%02d\\crash%02d%02d%02d%02d%02d%02d.mdmp"), CrashLogFolder, st.wYear, st.wMonth, st.wDay, st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond); } @@ -64,11 +64,11 @@ void myfilterWorker(PEXCEPTION_POINTERS exc_ptr, bool notify) mir_snwprintf(path, TEXT("%s\\crash%02d%02d%02d%02d%02d%02d.mdmp"), CrashLogFolder, st.wYear, st.wMonth, st.wDay, st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond); - hDumpFile = CreateFile(path, GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL); + hDumpFile = CreateFile(path, GENERIC_WRITE, FILE_SHARE_READ, nullptr, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, nullptr); if (hDumpFile != INVALID_HANDLE_VALUE) CreateMiniDump(hDumpFile, exc_ptr); else if (GetLastError() != ERROR_ALREADY_EXISTS) - MessageBox(NULL, TranslateT("Crash Report write location is not available"), + MessageBox(nullptr, TranslateT("Crash Report write location is not available"), TEXT("Miranda Crash Dumper"), MB_OK | MB_ICONERROR | MB_TASKMODAL | MB_TOPMOST); } @@ -76,14 +76,14 @@ void myfilterWorker(PEXCEPTION_POINTERS exc_ptr, bool notify) { } - bool empty = GetFileSize(hDumpFile, NULL) == 0; + bool empty = GetFileSize(hDumpFile, nullptr) == 0; CloseHandle(hDumpFile); if (empty) DeleteFile(path); __try { if (dtsubfldr) { mir_snwprintf(path, TEXT("%s\\%02d.%02d.%02d"), CrashLogFolder, st.wYear, st.wMonth, st.wDay); - CreateDirectory(path, NULL); + CreateDirectory(path, nullptr); mir_snwprintf(path, TEXT("%s\\%02d.%02d.%02d\\crash%02d%02d%02d%02d%02d%02d.txt"), CrashLogFolder, st.wYear, st.wMonth, st.wDay, st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond); } @@ -91,16 +91,16 @@ void myfilterWorker(PEXCEPTION_POINTERS exc_ptr, bool notify) mir_snwprintf(path, TEXT("%s\\crash%02d%02d%02d%02d%02d%02d.txt"), CrashLogFolder, st.wYear, st.wMonth, st.wDay, st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond); - hDumpFile = CreateFile(path, GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL); + hDumpFile = CreateFile(path, GENERIC_WRITE, FILE_SHARE_READ, nullptr, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, nullptr); mir_snwprintf(path, TranslateT("Miranda crashed. Crash report stored in the folder:\n %s\n\n Would you like store it in the clipboard as well?"), CrashLogFolder); if (hDumpFile != INVALID_HANDLE_VALUE) - CreateCrashReport(hDumpFile, exc_ptr, notify ? path : NULL); + CreateCrashReport(hDumpFile, exc_ptr, notify ? path : nullptr); } __except (myDebugFilter(GetExceptionCode(), GetExceptionInformation())) {} - bool empty1 = GetFileSize(hDumpFile, NULL) == 0; + bool empty1 = GetFileSize(hDumpFile, nullptr) == 0; CloseHandle(hDumpFile); if (empty1) DeleteFile(path); } diff --git a/plugins/CrashDumper/src/ui.cpp b/plugins/CrashDumper/src/ui.cpp index 91fa5f9578..65fa95377b 100644 --- a/plugins/CrashDumper/src/ui.cpp +++ b/plugins/CrashDumper/src/ui.cpp @@ -23,7 +23,7 @@ extern HINSTANCE hInst; HDWP MyResizeWindow(HDWP hDwp, HWND hwndDlg, HWND hwndCtrl, int nHorizontalOffset, int nVerticalOffset, int nWidthOffset, int nHeightOffset) { - if (NULL == hwndDlg) /* Wine fix. */ + if (nullptr == hwndDlg) /* Wine fix. */ return hDwp; // get current bounding rectangle RECT rcinit; @@ -35,7 +35,7 @@ HDWP MyResizeWindow(HDWP hDwp, HWND hwndDlg, HWND hwndCtrl, int nHorizontalOffse pt.y = rcinit.top; ScreenToClient(hwndDlg, &pt); - return DeferWindowPos(hDwp, hwndCtrl, NULL, + return DeferWindowPos(hDwp, hwndCtrl, nullptr, pt.x + nHorizontalOffset, pt.y + nVerticalOffset, rcinit.right - rcinit.left + nWidthOffset, @@ -141,7 +141,7 @@ INT_PTR CALLBACK DlgProcView(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPara if (sel.cpMin == sel.cpMax) EnableMenuItem(hSubMenu, IDM_COPY, MF_BYCOMMAND | MF_GRAYED); - switch (TrackPopupMenu(hSubMenu, TPM_RETURNCMD, pt.x, pt.y, 0, hwndDlg, NULL)) { + switch (TrackPopupMenu(hSubMenu, TPM_RETURNCMD, pt.x, pt.y, 0, hwndDlg, nullptr)) { case IDM_COPY: SendMessage(hView, WM_COPY, 0, 0); break; @@ -162,7 +162,7 @@ INT_PTR CALLBACK DlgProcView(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPara break; case WM_DESTROY: - hViewWnd = NULL; + hViewWnd = nullptr; Window_FreeIcon_IcoLib(hwndDlg); Utils_SaveWindowPosition(hwndDlg, NULL, PluginName, "ViewInfo_"); if (servicemode) @@ -175,9 +175,9 @@ INT_PTR CALLBACK DlgProcView(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPara void DestroyAllWindows(void) { - if (hViewWnd != NULL) { + if (hViewWnd != nullptr) { DestroyWindow(hViewWnd); - hViewWnd = NULL; + hViewWnd = nullptr; } } @@ -280,7 +280,7 @@ LRESULT CALLBACK DlgProcPopup(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) case 3: wchar_t path[MAX_PATH]; mir_snwprintf(path, TEXT("%s\\VersionInfo.txt"), VersionInfoFolder); - ShellExecute(NULL, TEXT("open"), path, NULL, NULL, SW_SHOW); + ShellExecute(nullptr, TEXT("open"), path, nullptr, nullptr, SW_SHOW); break; } @@ -313,5 +313,5 @@ void ShowMessage(int type, const wchar_t* format, ...) PUAddPopupT(&pi); } - else MessageBox(NULL, pi.lptzText, TEXT(PluginName), MB_OK | MB_ICONINFORMATION); + else MessageBox(nullptr, pi.lptzText, TEXT(PluginName), MB_OK | MB_ICONINFORMATION); } diff --git a/plugins/CrashDumper/src/upload.cpp b/plugins/CrashDumper/src/upload.cpp index 49dac93b0e..9b3b501b89 100644 --- a/plugins/CrashDumper/src/upload.cpp +++ b/plugins/CrashDumper/src/upload.cpp @@ -90,7 +90,7 @@ void CreateAuthString(char* auth) bool InternetDownloadFile(const char *szUrl, VerTrnsfr* szReq) { int result = 0xBADBAD; - char* szRedirUrl = NULL; + char* szRedirUrl = nullptr; NETLIBHTTPREQUEST nlhr = { 0 }; // initialize the netlib request @@ -164,7 +164,7 @@ bool InternetDownloadFile(const char *szUrl, VerTrnsfr* szReq) const char* szPref = strstr(szUrl, "://"); szPref = szPref ? szPref + 3 : szUrl; szPath = strchr(szPref, '/'); - rlen = szPath != NULL ? szPath - szUrl : mir_strlen(szUrl); + rlen = szPath != nullptr ? szPath - szUrl : mir_strlen(szUrl); } szRedirUrl = (char*)mir_realloc(szRedirUrl, diff --git a/plugins/CrashDumper/src/utils.cpp b/plugins/CrashDumper/src/utils.cpp index 2fd7e8f815..d46bf807ea 100644 --- a/plugins/CrashDumper/src/utils.cpp +++ b/plugins/CrashDumper/src/utils.cpp @@ -45,7 +45,7 @@ int GetTZOffset(void) void GetISO8061Time(SYSTEMTIME *stLocal, LPTSTR lpszString, DWORD dwSize) { SYSTEMTIME loctime; - if (stLocal == NULL) { + if (stLocal == nullptr) { stLocal = &loctime; GetLocalTime(stLocal); } @@ -94,8 +94,8 @@ typedef PLUGININFOEX * (__cdecl * Miranda_Plugin_Info) (DWORD mirandaVersion); PLUGININFOEX* GetMirInfo(HMODULE hModule) { Miranda_Plugin_Info bpi = (Miranda_Plugin_Info)GetProcAddress(hModule, "MirandaPluginInfoEx"); - if (bpi == NULL) - return NULL; + if (bpi == nullptr) + return nullptr; return bpi(mirandaVersion); } @@ -111,15 +111,15 @@ void GetInternetExplorerVersion(CMStringW &buffer) if (!RegOpenKeyEx(HKEY_LOCAL_MACHINE, TEXT("SOFTWARE\\Microsoft\\Internet Explorer"), 0, KEY_QUERY_VALUE, &hKey)) { size = _countof(ieBuild); - if (RegQueryValueEx(hKey, TEXT("Build"), NULL, NULL, (LPBYTE)ieBuild, &size) != ERROR_SUCCESS) + if (RegQueryValueEx(hKey, TEXT("Build"), nullptr, nullptr, (LPBYTE)ieBuild, &size) != ERROR_SUCCESS) ieBuild[0] = 0; size = _countof(ieVersion); - if (RegQueryValueEx(hKey, TEXT("Version"), NULL, NULL, (LPBYTE)ieVersion, &size) != ERROR_SUCCESS) + if (RegQueryValueEx(hKey, TEXT("Version"), nullptr, nullptr, (LPBYTE)ieVersion, &size) != ERROR_SUCCESS) ieVersion[0] = 0; size = _countof(iVer); - if (RegQueryValueEx(hKey, TEXT("IVer"), NULL, NULL, (LPBYTE)iVer, &size) != ERROR_SUCCESS) + if (RegQueryValueEx(hKey, TEXT("IVer"), nullptr, nullptr, (LPBYTE)iVer, &size) != ERROR_SUCCESS) iVer[0] = 0; RegCloseKey(hKey); @@ -174,12 +174,12 @@ void GetProcessorString(CMStringW &buffer) if (!RegOpenKeyEx(HKEY_LOCAL_MACHINE, TEXT("Hardware\\Description\\System\\CentralProcessor\\0"), 0, KEY_QUERY_VALUE, &hKey)) { size = _countof(cpuName); - if (RegQueryValueEx(hKey, TEXT("ProcessorNameString"), NULL, NULL, (LPBYTE)cpuName, &size) != ERROR_SUCCESS) + if (RegQueryValueEx(hKey, TEXT("ProcessorNameString"), nullptr, nullptr, (LPBYTE)cpuName, &size) != ERROR_SUCCESS) mir_wstrcpy(cpuName, TEXT("Unknown")); size = _countof(cpuIdent); - if (RegQueryValueEx(hKey, TEXT("Identifier"), NULL, NULL, (LPBYTE)cpuIdent, &size) != ERROR_SUCCESS) - if (RegQueryValueEx(hKey, TEXT("VendorIdentifier"), NULL, NULL, (LPBYTE)cpuIdent, &size) != ERROR_SUCCESS) + if (RegQueryValueEx(hKey, TEXT("Identifier"), nullptr, nullptr, (LPBYTE)cpuIdent, &size) != ERROR_SUCCESS) + if (RegQueryValueEx(hKey, TEXT("VendorIdentifier"), nullptr, nullptr, (LPBYTE)cpuIdent, &size) != ERROR_SUCCESS) mir_wstrcpy(cpuIdent, TEXT("Unknown")); RegCloseKey(hKey); @@ -327,7 +327,7 @@ void GetAdminString(CMStringW &buffer) b = AllocateAndInitializeSid(&NtAuthority, 2, SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_ADMINS, 0, 0, 0, 0, 0, 0, &AdministratorsGroup); if (b) { - if (!CheckTokenMembership(NULL, AdministratorsGroup, &b)) + if (!CheckTokenMembership(nullptr, AdministratorsGroup, &b)) b = FALSE; FreeSid(AdministratorsGroup); } @@ -385,11 +385,11 @@ void GetWow64String(CMStringW &buffer) void GetVersionInfo(HMODULE hLib, CMStringW& buffer) { HRSRC hVersion = FindResource(hLib, MAKEINTRESOURCE(VS_VERSION_INFO), RT_VERSION); - if (hVersion != NULL) { + if (hVersion != nullptr) { HGLOBAL hGlobal = LoadResource(hLib, hVersion); - if (hGlobal != NULL) { + if (hGlobal != nullptr) { LPVOID versionInfo = LockResource(hGlobal); - if (versionInfo != NULL) { + if (versionInfo != nullptr) { int vl = *(unsigned short*)versionInfo; unsigned *res = (unsigned*)versionInfo; while (*res != 0xfeef04bd && ((char*)res - (char*)versionInfo) < vl) ++res; @@ -416,7 +416,7 @@ void StoreStringToClip(CMStringW& buffer) GlobalUnlock(hData); - if(OpenClipboard(NULL)) { + if(OpenClipboard(nullptr)) { EmptyClipboard(); -- cgit v1.2.3