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/KeyboardNotify/src/EnumProc.cpp | 2 +- plugins/KeyboardNotify/src/flash.cpp | 2 +- plugins/KeyboardNotify/src/ignore.cpp | 10 +++--- plugins/KeyboardNotify/src/keyboard.cpp | 6 ++-- plugins/KeyboardNotify/src/main.cpp | 58 ++++++++++++++++----------------- plugins/KeyboardNotify/src/options.cpp | 22 ++++++------- 6 files changed, 50 insertions(+), 50 deletions(-) (limited to 'plugins/KeyboardNotify') diff --git a/plugins/KeyboardNotify/src/EnumProc.cpp b/plugins/KeyboardNotify/src/EnumProc.cpp index e1056113e4..d14af76609 100644 --- a/plugins/KeyboardNotify/src/EnumProc.cpp +++ b/plugins/KeyboardNotify/src/EnumProc.cpp @@ -26,7 +26,7 @@ extern PROCESS_LIST ProcessList; BOOL areThereProcessesRunning(void) { - HANDLE hSnapShot = NULL; + HANDLE hSnapShot = nullptr; PROCESSENTRY32 procentry; BOOL bFlag; diff --git a/plugins/KeyboardNotify/src/flash.cpp b/plugins/KeyboardNotify/src/flash.cpp index 6f56a9552d..2a47c528b7 100644 --- a/plugins/KeyboardNotify/src/flash.cpp +++ b/plugins/KeyboardNotify/src/flash.cpp @@ -339,7 +339,7 @@ void previewFlashing(BOOL buttonState) return; bPreviewSemaphore = TRUE; - mir_forkthread(PreviewThread, 0); + mir_forkthread(PreviewThread, nullptr); } diff --git a/plugins/KeyboardNotify/src/ignore.cpp b/plugins/KeyboardNotify/src/ignore.cpp index 1890ee3e6c..23a0e0d907 100644 --- a/plugins/KeyboardNotify/src/ignore.cpp +++ b/plugins/KeyboardNotify/src/ignore.cpp @@ -175,7 +175,7 @@ static void SetAllContactIcons(HWND hwndList) HANDLE hItem = (HANDLE)SendMessage(hwndList, CLM_FINDCONTACT, hContact, 0); if(hItem && SendMessage(hwndList, CLM_GETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(IGNOREEVENT_MAX, 0)) == EMPTY_EXTRA_ICON) { char *szProto = GetContactProto(hContact); - if(szProto == NULL) + if(szProto == nullptr) protoCaps = 0; else protoCaps = CallProtoService(szProto, PS_GETCAPS,PFLAGNUM_1, 0); @@ -231,7 +231,7 @@ INT_PTR CALLBACK DlgProcIgnoreOptions(HWND hwndDlg, UINT msg, WPARAM, LPARAM lPa } SetAllContactIcons(GetDlgItem(hwndDlg, IDC_LIST)); - SetListGroupIcons(GetDlgItem(hwndDlg, IDC_LIST),(HANDLE)SendDlgItemMessage(hwndDlg, IDC_LIST, CLM_GETNEXTITEM, CLGN_ROOT, 0), hItemAll, NULL); + SetListGroupIcons(GetDlgItem(hwndDlg, IDC_LIST),(HANDLE)SendDlgItemMessage(hwndDlg, IDC_LIST, CLM_GETNEXTITEM, CLGN_ROOT, 0), hItemAll, nullptr); return TRUE; case WM_SETFOCUS: SetFocus(GetDlgItem(hwndDlg, IDC_LIST)); @@ -246,7 +246,7 @@ INT_PTR CALLBACK DlgProcIgnoreOptions(HWND hwndDlg, UINT msg, WPARAM, LPARAM lPa SetAllContactIcons(GetDlgItem(hwndDlg, IDC_LIST)); //fall through case CLN_CONTACTMOVED: - SetListGroupIcons(GetDlgItem(hwndDlg, IDC_LIST), (HANDLE)SendDlgItemMessage(hwndDlg, IDC_LIST, CLM_GETNEXTITEM, CLGN_ROOT, 0), hItemAll, NULL); + SetListGroupIcons(GetDlgItem(hwndDlg, IDC_LIST), (HANDLE)SendDlgItemMessage(hwndDlg, IDC_LIST, CLM_GETNEXTITEM, CLGN_ROOT, 0), hItemAll, nullptr); break; case CLN_OPTIONSCHANGED: ResetListOptions(GetDlgItem(hwndDlg, IDC_LIST)); @@ -263,7 +263,7 @@ INT_PTR CALLBACK DlgProcIgnoreOptions(HWND hwndDlg, UINT msg, WPARAM, LPARAM lPa if(nm->iColumn == -1) break; HANDLE hItem = (HANDLE)SendDlgItemMessage(hwndDlg, IDC_LIST, CLM_HITTEST, (WPARAM)&hitFlags, MAKELPARAM(nm->pt.x, nm->pt.y)); - if(hItem == NULL) + if(hItem == nullptr) break; if (!(hitFlags & CLCHT_ONITEMEXTRA)) break; @@ -283,7 +283,7 @@ INT_PTR CALLBACK DlgProcIgnoreOptions(HWND hwndDlg, UINT msg, WPARAM, LPARAM lPa iImage = 0; SetIconsForColumn(GetDlgItem(hwndDlg, IDC_LIST), hItem, hItemAll, nm->iColumn, iImage); } - SetListGroupIcons(GetDlgItem(hwndDlg, IDC_LIST),(HANDLE)SendDlgItemMessage(hwndDlg, IDC_LIST, CLM_GETNEXTITEM, CLGN_ROOT, 0), hItemAll, NULL); + SetListGroupIcons(GetDlgItem(hwndDlg, IDC_LIST),(HANDLE)SendDlgItemMessage(hwndDlg, IDC_LIST, CLM_GETNEXTITEM, CLGN_ROOT, 0), hItemAll, nullptr); SendMessage(GetParent(GetParent(hwndDlg)), PSM_CHANGED, 0, 0); break; } diff --git a/plugins/KeyboardNotify/src/keyboard.cpp b/plugins/KeyboardNotify/src/keyboard.cpp index eaa613c661..d8ea3dbfff 100644 --- a/plugins/KeyboardNotify/src/keyboard.cpp +++ b/plugins/KeyboardNotify/src/keyboard.cpp @@ -45,7 +45,7 @@ BOOL OpenKeyboardDevice() DefineDosDevice(DDD_RAW_TARGET_PATH, aux1, aux2); mir_snwprintf(aux1, L"\\\\.\\Kbd%d", i); - hKbdDev[i] = CreateFile(aux1, GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL); + hKbdDev[i] = CreateFile(aux1, GENERIC_WRITE, 0, nullptr, OPEN_EXISTING, 0, nullptr); } while (hKbdDev[i] != INVALID_HANDLE_VALUE && ++i < MAX_KBDHANDLES); @@ -66,7 +66,7 @@ BOOL ToggleKeyboardLights(BYTE byte) InputBuffer.LedFlags = byte; for (i=0; i < MAX_KBDHANDLES && hKbdDev[i] != INVALID_HANDLE_VALUE; i++) - result |= DeviceIoControl(hKbdDev[i], IOCTL_KEYBOARD_SET_INDICATORS, &InputBuffer, DataLength, NULL, 0, &ReturnedLength, NULL); + result |= DeviceIoControl(hKbdDev[i], IOCTL_KEYBOARD_SET_INDICATORS, &InputBuffer, DataLength, nullptr, 0, &ReturnedLength, nullptr); return result; } @@ -81,7 +81,7 @@ void CloseKeyboardDevice() CloseHandle(hKbdDev[i]); mir_snwprintf(aux, L"Kbd%d", i); - DefineDosDevice(DDD_REMOVE_DEFINITION, aux, NULL); + DefineDosDevice(DDD_REMOVE_DEFINITION, aux, nullptr); } while (hKbdDev[i] != INVALID_HANDLE_VALUE && ++i < MAX_KBDHANDLES); } diff --git a/plugins/KeyboardNotify/src/main.cpp b/plugins/KeyboardNotify/src/main.cpp index e68a3cac24..59a3b82e83 100644 --- a/plugins/KeyboardNotify/src/main.cpp +++ b/plugins/KeyboardNotify/src/main.cpp @@ -32,17 +32,17 @@ CLIST_INTERFACE *pcli; int hLangpack; DWORD IDThread = 0; -HANDLE hThread = NULL; +HANDLE hThread = nullptr; HANDLE hFlashEvent; HANDLE hExitEvent; -HHOOK hMirandaMouseHook = NULL; -HHOOK hMirandaKeyBoardHook = NULL; -HHOOK hMirandaWndProcHook = NULL; +HHOOK hMirandaMouseHook = nullptr; +HHOOK hMirandaKeyBoardHook = nullptr; +HHOOK hMirandaWndProcHook = nullptr; UINT hReminderTimer = 0; -HHOOK hMouseHook = NULL; -HHOOK hKeyBoardHook = NULL; +HHOOK hMouseHook = nullptr; +HHOOK hKeyBoardHook = nullptr; BYTE bEmulateKeypresses = 0; DWORD dwLastInput = 0; POINT lastGlobalMousePos = { 0, 0 }; @@ -77,8 +77,8 @@ BYTE bTrillianLedsURL; BYTE bTrillianLedsFile; BYTE bTrillianLedsOther; -PROTOCOL_LIST ProtoList = { 0, NULL }; -PROCESS_LIST ProcessList = { 0, NULL }; +PROTOCOL_LIST ProtoList = { 0, nullptr }; +PROCESS_LIST ProcessList = { 0, nullptr }; int nWaitDelay; unsigned int nExternCount = 0; @@ -529,7 +529,7 @@ void createProcessList(void) void destroyProcessList(void) { - if (ProcessList.szFileName == NULL) + if (ProcessList.szFileName == nullptr) return; for (int i = 0; i < ProcessList.count; i++) @@ -538,7 +538,7 @@ void destroyProcessList(void) mir_free(ProcessList.szFileName); ProcessList.count = 0; - ProcessList.szFileName = NULL; + ProcessList.szFileName = nullptr; } //========================== Windows hooks ========================== @@ -623,26 +623,26 @@ static LRESULT CALLBACK MirandaWndProcHookFunction(int code, WPARAM wParam, LPAR int HookWindowsHooks() { if (wReminderCheck) - hReminderTimer = SetTimer(NULL, 0, wReminderCheck * 60000, ReminderTimer); + hReminderTimer = SetTimer(nullptr, 0, wReminderCheck * 60000, ReminderTimer); if (bFlashUntil & UNTIL_REATTENDED) { switch (bMirandaOrWindows) { case ACTIVE_WINDOWS: if (bEmulateKeypresses) { - if (hMouseHook == NULL) - hMouseHook = SetWindowsHookEx(WH_MOUSE, MouseHookFunction, 0, GetCurrentThreadId()); - if (hKeyBoardHook == NULL) - hKeyBoardHook = SetWindowsHookEx(WH_KEYBOARD, KeyBoardHookFunction, 0, GetCurrentThreadId()); + if (hMouseHook == nullptr) + hMouseHook = SetWindowsHookEx(WH_MOUSE, MouseHookFunction, nullptr, GetCurrentThreadId()); + if (hKeyBoardHook == nullptr) + hKeyBoardHook = SetWindowsHookEx(WH_KEYBOARD, KeyBoardHookFunction, nullptr, GetCurrentThreadId()); } break; case ACTIVE_MIRANDA: - if (hMirandaMouseHook == NULL) - hMirandaMouseHook = SetWindowsHookEx(WH_MOUSE, MirandaMouseHookFunction, NULL, GetCurrentThreadId()); - if (hMirandaKeyBoardHook == NULL) - hMirandaKeyBoardHook = SetWindowsHookEx(WH_KEYBOARD, MirandaKeyBoardHookFunction, NULL, GetCurrentThreadId()); - if (hMirandaWndProcHook == NULL) - hMirandaWndProcHook = SetWindowsHookEx(WH_CALLWNDPROC, MirandaWndProcHookFunction, NULL, GetCurrentThreadId()); + if (hMirandaMouseHook == nullptr) + hMirandaMouseHook = SetWindowsHookEx(WH_MOUSE, MirandaMouseHookFunction, nullptr, GetCurrentThreadId()); + if (hMirandaKeyBoardHook == nullptr) + hMirandaKeyBoardHook = SetWindowsHookEx(WH_KEYBOARD, MirandaKeyBoardHookFunction, nullptr, GetCurrentThreadId()); + if (hMirandaWndProcHook == nullptr) + hMirandaWndProcHook = SetWindowsHookEx(WH_CALLWNDPROC, MirandaWndProcHookFunction, nullptr, GetCurrentThreadId()); } } @@ -652,7 +652,7 @@ int HookWindowsHooks() int UnhookWindowsHooks() { if (hReminderTimer) - KillTimer(NULL, hReminderTimer); + KillTimer(nullptr, hReminderTimer); if (hMouseHook) UnhookWindowsHookEx(hMouseHook); if (hKeyBoardHook) @@ -665,7 +665,7 @@ int UnhookWindowsHooks() UnhookWindowsHookEx(hMirandaWndProcHook); hReminderTimer = 0; - hMouseHook = hKeyBoardHook = hMirandaMouseHook = hMirandaKeyBoardHook = hMirandaWndProcHook = NULL; + hMouseHook = hKeyBoardHook = hMirandaMouseHook = hMirandaKeyBoardHook = hMirandaWndProcHook = nullptr; return 0; } @@ -781,7 +781,7 @@ void createProtocolList(void) for (int i = 0; i < ProtoList.protoCount; i++) { ProtoList.protoInfo[i].xstatus.count = 0; - ProtoList.protoInfo[i].xstatus.enabled = NULL; + ProtoList.protoInfo[i].xstatus.enabled = nullptr; ProtoList.protoInfo[i].szProto = mir_strdup(proto[i]->szModuleName); if (!ProtoList.protoInfo[i].szProto) { ProtoList.protoInfo[i].enabled = FALSE; @@ -801,7 +801,7 @@ void createProtocolList(void) static void destroyProtocolList(void) { - if (ProtoList.protoInfo == NULL) + if (ProtoList.protoInfo == nullptr) return; for (int i = 0; i < ProtoList.protoCount; i++) { @@ -813,7 +813,7 @@ static void destroyProtocolList(void) mir_free(ProtoList.protoInfo); ProtoList.protoCount = 0; - ProtoList.protoInfo = NULL; + ProtoList.protoInfo = nullptr; } @@ -911,11 +911,11 @@ static int ModulesLoaded(WPARAM, LPARAM) // Create some synchronisation objects createEventPrefix(eventPrefix, MAX_PATH - 11); mir_snwprintf(eventName, L"%s/FlashEvent", eventPrefix); - hFlashEvent = CreateEvent(NULL, FALSE, FALSE, eventName); + hFlashEvent = CreateEvent(nullptr, FALSE, FALSE, eventName); mir_snwprintf(eventName, L"%s/ExitEvent", eventPrefix); - hExitEvent = CreateEvent(NULL, FALSE, FALSE, eventName); + hExitEvent = CreateEvent(nullptr, FALSE, FALSE, eventName); - hThread = mir_forkthread(FlashThreadFunction, 0); + hThread = mir_forkthread(FlashThreadFunction, nullptr); HookEvent(ME_MC_ENABLED, OnMetaChanged); HookEvent(ME_DB_EVENT_ADDED, PluginMessageEventHook); diff --git a/plugins/KeyboardNotify/src/options.cpp b/plugins/KeyboardNotify/src/options.cpp index c53a626859..7425a67cc3 100644 --- a/plugins/KeyboardNotify/src/options.cpp +++ b/plugins/KeyboardNotify/src/options.cpp @@ -93,7 +93,7 @@ void importThemes(const wchar_t *filename, BOOL overrideExisting) size_t i; wchar_t buffer[MAX_PATH + 1], theme[MAX_PATH + 1], *str; - while (fgetws(buffer, MAX_PATH, fImport) != NULL) { + while (fgetws(buffer, MAX_PATH, fImport) != nullptr) { for (str = buffer; *str && isspace(*str); str++); //ltrim if (!*str || *str == ';') //empty line or comment continue; @@ -125,7 +125,7 @@ static void createProcessListAux(void) else for (int i = 0; i < ProcessListAux.count; i++) if (!ProcessList.szFileName[i]) - ProcessListAux.szFileName[i] = NULL; + ProcessListAux.szFileName[i] = nullptr; else { ProcessListAux.szFileName[i] = mir_wstrdup(ProcessList.szFileName[i]); } @@ -134,7 +134,7 @@ static void createProcessListAux(void) static void destroyProcessListAux(void) { - if (ProcessListAux.szFileName == NULL) + if (ProcessListAux.szFileName == nullptr) return; for (int i = 0; i < ProcessListAux.count; i++) { if (ProcessListAux.szFileName[i]) { @@ -143,7 +143,7 @@ static void destroyProcessListAux(void) } mir_free(ProcessListAux.szFileName); ProcessListAux.count = 0; - ProcessListAux.szFileName = NULL; + ProcessListAux.szFileName = nullptr; } static void createXstatusListAux(void) @@ -153,7 +153,7 @@ static void createXstatusListAux(void) for (int i = 0; i < ProtoList.protoCount; i++) { XstatusListAux[i].count = ProtoList.protoInfo[i].xstatus.count; if (!XstatusListAux[i].count) - XstatusListAux[i].enabled = NULL; + XstatusListAux[i].enabled = nullptr; else { XstatusListAux[i].enabled = (BOOL *)mir_alloc(XstatusListAux[i].count * sizeof(BOOL)); if (!XstatusListAux[i].enabled) @@ -173,7 +173,7 @@ static void destroyXstatusListAux(void) if (XstatusListAux[i].enabled) mir_free(XstatusListAux[i].enabled); mir_free(XstatusListAux); - XstatusListAux = NULL; + XstatusListAux = nullptr; } } @@ -286,7 +286,7 @@ static INT_PTR CALLBACK DlgProcXstatusList(HWND hwndDlg, UINT msg, WPARAM wParam TranslateDialogDefault(hwndDlg); { WPARAM j; - TVINSERTSTRUCT tvis = { 0 }; + TVINSERTSTRUCT tvis = {}; TVITEM tvi = { 0 }; HTREEITEM hSectionItem, hItem; HWND hwndTree = GetDlgItem(hwndDlg, IDC_TREE_XSTATUS); @@ -304,7 +304,7 @@ static INT_PTR CALLBACK DlgProcXstatusList(HWND hwndDlg, UINT msg, WPARAM wParam HIMAGELIST hImageList = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), ILC_COLOR32 | ILC_MASK, imageCount, imageCount); TreeView_SetImageList(hwndTree, hImageList, TVSIL_NORMAL); - HICON hIconAux = (HICON)LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_BLANK), IMAGE_ICON, 0, 0, 0); + HICON hIconAux = (HICON)LoadImage(GetModuleHandle(nullptr), MAKEINTRESOURCE(IDI_BLANK), IMAGE_ICON, 0, 0, 0); if (hIconAux) { ImageList_AddIcon(hImageList, hIconAux); DestroyIcon(hIconAux); @@ -320,7 +320,7 @@ static INT_PTR CALLBACK DlgProcXstatusList(HWND hwndDlg, UINT msg, WPARAM wParam PROTOACCOUNT **protos; Proto_EnumAccounts(&count, &protos); - tvis.hParent = NULL; + tvis.hParent = nullptr; tvis.hInsertAfter = TVI_LAST; tvis.item.mask = TVIF_TEXT | TVIF_PARAM | TVIF_STATE | TVIF_IMAGE | TVIF_SELECTEDIMAGE; tvis.item.pszText = protos[i]->tszAccountName; @@ -1161,7 +1161,7 @@ static INT_PTR CALLBACK DlgProcThemeOptions(HWND hwndDlg, UINT msg, WPARAM wPara path[0] = '\0'; ofn.lStructSize = sizeof(OPENFILENAME); ofn.hwndOwner = hwndDlg; - ofn.hInstance = NULL; + ofn.hInstance = nullptr; mir_wstrcpy(filter, TranslateT("Keyboard Notify Theme")); mir_wstrcat(filter, L" (*.knt)"); pfilter = filter + mir_wstrlen(filter) + 1; @@ -1189,7 +1189,7 @@ static INT_PTR CALLBACK DlgProcThemeOptions(HWND hwndDlg, UINT msg, WPARAM wPara path[0] = '\0'; ofn.lStructSize = sizeof(OPENFILENAME); ofn.hwndOwner = hwndDlg; - ofn.hInstance = NULL; + ofn.hInstance = nullptr; mir_wstrcpy(filter, TranslateT("Keyboard Notify Theme")); mir_wstrcat(filter, L" (*.knt)"); pfilter = filter + mir_wstrlen(filter) + 1; -- cgit v1.2.3