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/SeenPlugin/src/file.cpp | 2 +- plugins/SeenPlugin/src/history.cpp | 14 +++++++------- plugins/SeenPlugin/src/main.cpp | 4 ++-- plugins/SeenPlugin/src/menu.cpp | 6 +++--- plugins/SeenPlugin/src/missed.cpp | 12 ++++++------ plugins/SeenPlugin/src/options.cpp | 12 ++++++------ plugins/SeenPlugin/src/userinfo.cpp | 2 +- plugins/SeenPlugin/src/utils.cpp | 26 +++++++++++++------------- 8 files changed, 39 insertions(+), 39 deletions(-) (limited to 'plugins/SeenPlugin/src') diff --git a/plugins/SeenPlugin/src/file.cpp b/plugins/SeenPlugin/src/file.cpp index 411d85a71e..ac3d85b774 100644 --- a/plugins/SeenPlugin/src/file.cpp +++ b/plugins/SeenPlugin/src/file.cpp @@ -56,7 +56,7 @@ void UninitFileOutput() void FileWrite(MCONTACT hcontact) { FILE *log = _wfopen(ParseString(g_ptszFileName, hcontact), L"a"); - if (log != NULL) { + if (log != nullptr) { fputws(ParseString(g_ptszFileStamp, hcontact), log); fputs("\r\n", log); fclose(log); diff --git a/plugins/SeenPlugin/src/history.cpp b/plugins/SeenPlugin/src/history.cpp index 28a959d7d4..176168dd61 100644 --- a/plugins/SeenPlugin/src/history.cpp +++ b/plugins/SeenPlugin/src/history.cpp @@ -104,7 +104,7 @@ HDWP MyResizeWindow(HDWP hDwp, HWND hwndDlg, HWND hwndControl, POINT pt; RECT rcinit; - if (NULL == hwndDlg) /* Wine fix. */ + if (nullptr == hwndDlg) /* Wine fix. */ return hDwp; // get current bounding rectangle GetWindowRect(hwndControl, &rcinit); @@ -115,7 +115,7 @@ HDWP MyResizeWindow(HDWP hDwp, HWND hwndDlg, HWND hwndControl, ScreenToClient(hwndDlg, &pt); // resize control - return DeferWindowPos(hDwp, hwndControl, NULL, + return DeferWindowPos(hDwp, hwndControl, nullptr, pt.x + nHorizontalOffset, pt.y + nVerticalOffset, rcinit.right - rcinit.left + nWidthOffset, @@ -132,7 +132,7 @@ HDWP MyHorizCenterWindow(HDWP hDwp, HWND hwndDlg, HWND hwndControl, POINT pt; RECT rcinit; - if (NULL == hwndDlg) /* Wine fix. */ + if (nullptr == hwndDlg) /* Wine fix. */ return hDwp; // get current bounding rectangle GetWindowRect(hwndControl, &rcinit); @@ -143,7 +143,7 @@ HDWP MyHorizCenterWindow(HDWP hDwp, HWND hwndDlg, HWND hwndControl, ScreenToClient(hwndDlg, &pt); // resize control - return DeferWindowPos(hDwp, hwndControl, NULL, + return DeferWindowPos(hDwp, hwndControl, nullptr, (int)((nClientWidth - (rcinit.right - rcinit.left)) / 2), pt.y + nVerticalOffset, rcinit.right - rcinit.left, @@ -223,7 +223,7 @@ INT_PTR CALLBACK HistoryDlgProc(HWND hwndDlg, UINT Message, WPARAM wparam, LPARA RECT rc; GetWindowRect(GetDlgItem(hwndDlg, IDC_USERMENU), &rc); HMENU hMenu = Menu_BuildContactMenu(hContact); - TrackPopupMenu(hMenu, 0, rc.left, rc.bottom, 0, hwndDlg, NULL); + TrackPopupMenu(hMenu, 0, rc.left, rc.bottom, 0, hwndDlg, nullptr); DestroyMenu(hMenu); } break; @@ -285,8 +285,8 @@ INT_PTR CALLBACK HistoryDlgProc(HWND hwndDlg, UINT Message, WPARAM wparam, LPARA void ShowHistory(MCONTACT hContact, BYTE isAlert) { HWND hHistoryDlg = WindowList_Find(hWindowList, hContact); - if (hHistoryDlg == NULL) { - hHistoryDlg = CreateDialogParam(hInstance, MAKEINTRESOURCE(IDD_HISTORY), NULL, HistoryDlgProc, hContact); + if (hHistoryDlg == nullptr) { + hHistoryDlg = CreateDialogParam(hInstance, MAKEINTRESOURCE(IDD_HISTORY), nullptr, HistoryDlgProc, hContact); LoadHistoryList(hContact, hHistoryDlg, IDC_HISTORYLIST); WindowList_Add(hWindowList, hHistoryDlg, hContact); } diff --git a/plugins/SeenPlugin/src/main.cpp b/plugins/SeenPlugin/src/main.cpp index ac6672a246..172897d4ef 100644 --- a/plugins/SeenPlugin/src/main.cpp +++ b/plugins/SeenPlugin/src/main.cpp @@ -22,7 +22,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. CLIST_INTERFACE *pcli; HINSTANCE hInstance; -HANDLE ehmissed = NULL, ehuserinfo = NULL, ehmissed_proto = NULL; +HANDLE ehmissed = nullptr, ehuserinfo = nullptr, ehmissed_proto = nullptr; HANDLE g_hShutdownEvent; MWindowList g_pUserInfo; @@ -89,7 +89,7 @@ extern "C" __declspec(dllexport) int Load(void) pcli = Clist_GetInterface(); g_pUserInfo = WindowList_Create(); - g_hShutdownEvent = CreateEvent(0, TRUE, FALSE, 0); + g_hShutdownEvent = CreateEvent(nullptr, TRUE, FALSE, nullptr); HookEvent(ME_SYSTEM_MODULESLOADED, MainInit); HookEvent(ME_SYSTEM_PRESHUTDOWN, OnShutdown); diff --git a/plugins/SeenPlugin/src/menu.cpp b/plugins/SeenPlugin/src/menu.cpp index c8e9777004..4a385b67d6 100644 --- a/plugins/SeenPlugin/src/menu.cpp +++ b/plugins/SeenPlugin/src/menu.cpp @@ -20,8 +20,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "stdafx.h" -HANDLE hLSUserDet = NULL; -HGENMENU hmenuitem = NULL; +HANDLE hLSUserDet = nullptr; +HGENMENU hmenuitem = nullptr; void InitHistoryDialog(void); @@ -50,7 +50,7 @@ int BuildContactMenu(WPARAM hContact, LPARAM) ptszName = ParseString(DEFAULT_MENUSTAMP, hContact); int flags = 0; - HICON hIcon = NULL; + HICON hIcon = nullptr; if (!mir_wstrcmp(ptszName, TranslateT(""))) { if (IsWatchedProtocol(szProto)) flags |= CMIF_GRAYED; diff --git a/plugins/SeenPlugin/src/missed.cpp b/plugins/SeenPlugin/src/missed.cpp index a3ce568a16..bdce23791a 100644 --- a/plugins/SeenPlugin/src/missed.cpp +++ b/plugins/SeenPlugin/src/missed.cpp @@ -70,7 +70,7 @@ INT_PTR CALLBACK MissedDlgProc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM lparam htemp = GetDlgItem(hdlg, IDC_CONTACTS); GetWindowRect(htemp, &rcinit); - SetWindowPos(htemp, NULL, 0, 0, rcinit.right - rcinit.left, mcs.count*(rcinit.bottom - rcinit.top) / 2, SWP_NOZORDER | SWP_NOMOVE | SWP_NOACTIVATE); + SetWindowPos(htemp, nullptr, 0, 0, rcinit.right - rcinit.left, mcs.count*(rcinit.bottom - rcinit.top) / 2, SWP_NOZORDER | SWP_NOMOVE | SWP_NOACTIVATE); GetWindowRect(htemp, &rcresized); htemp = GetDlgItem(hdlg, IDOK); @@ -81,7 +81,7 @@ INT_PTR CALLBACK MissedDlgProc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM lparam ScreenToClient(hdlg, &pt); MoveWindow(htemp, pt.x, pt.y + (rcresized.bottom - rcinit.bottom), (rcb.right - rcb.left), (rcb.bottom - rcb.top), FALSE); GetWindowRect(hdlg, &rcd); - SetWindowPos(hdlg, NULL, 0, 0, rcd.right - rcd.left, rcd.bottom - rcd.top + (rcresized.bottom - rcinit.bottom), SWP_NOZORDER | SWP_NOMOVE | SWP_NOACTIVATE); + SetWindowPos(hdlg, nullptr, 0, 0, rcd.right - rcd.left, rcd.bottom - rcd.top + (rcresized.bottom - rcinit.bottom), SWP_NOZORDER | SWP_NOMOVE | SWP_NOACTIVATE); SetDlgItemText(hdlg, IDC_CONTACTS, (LPCTSTR)lparam); ShowWindow(hdlg, SW_SHOWNOACTIVATE); @@ -114,7 +114,7 @@ int ShowMissed(void) buf.AppendChar('\n'); } - CreateDialogParam(hInstance, MAKEINTRESOURCE(IDD_MISSED), NULL, MissedDlgProc, (LPARAM)buf.c_str()); + CreateDialogParam(hInstance, MAKEINTRESOURCE(IDD_MISSED), nullptr, MissedDlgProc, (LPARAM)buf.c_str()); return 0; } @@ -168,7 +168,7 @@ int ModeChange_mo(WPARAM, LPARAM lparam) case ID_STATUS_AWAY: case ID_STATUS_DND: case ID_STATUS_NA: - if (ehmissed == NULL) { + if (ehmissed == nullptr) { memset(&mcs, 0, sizeof(mcs)); CheckIfOnline(); ehmissed = HookEvent(ME_CLIST_CONTACTICONCHANGED, Test); @@ -176,9 +176,9 @@ int ModeChange_mo(WPARAM, LPARAM lparam) break; default: - if (ehmissed != NULL) { + if (ehmissed != nullptr) { UnhookEvent(ehmissed); - ehmissed = NULL; + ehmissed = nullptr; ShowMissed(); ResetMissed(); } diff --git a/plugins/SeenPlugin/src/options.cpp b/plugins/SeenPlugin/src/options.cpp index bdbd8aa407..5c2f665fbb 100644 --- a/plugins/SeenPlugin/src/options.cpp +++ b/plugins/SeenPlugin/src/options.cpp @@ -88,7 +88,7 @@ INT_PTR CALLBACK OptsPopupsDlgProc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM lp GetColorsFromDWord(&ppd.colorBack, &ppd.colorText, temp); SendDlgItemMessage(hdlg, idBack, CPM_SETCOLOUR, 0, ppd.colorBack); SendDlgItemMessage(hdlg, idText, CPM_SETCOLOUR, 0, ppd.colorText); - ppd.lchIcon = Skin_LoadProtoIcon(NULL, idBack); + ppd.lchIcon = Skin_LoadProtoIcon(nullptr, idBack); GetDlgItemText(hdlg, IDC_POPUPSTAMP, szstamp, _countof(szstamp)); wcsncpy(ppd.lptzContactName, ParseString(szstamp, NULL), MAX_CONTACTNAME); @@ -225,7 +225,7 @@ INT_PTR CALLBACK OptsSettingsDlgProc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM SetWindowLongPtr(GetDlgItem(hdlg, IDC_PROTOCOLLIST), GWL_STYLE, GetWindowLongPtr(GetDlgItem(hdlg, IDC_PROTOCOLLIST), GWL_STYLE) | TVS_CHECKBOXES); { TVINSERTSTRUCT tvis; - tvis.hParent = NULL; + tvis.hParent = nullptr; tvis.hInsertAfter = TVI_LAST; tvis.item.mask = TVIF_TEXT | TVIF_HANDLE | TVIF_STATE | TVIF_PARAM; tvis.item.stateMask = TVIS_STATEIMAGEMASK; @@ -301,12 +301,12 @@ INT_PTR CALLBACK OptsSettingsDlgProc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM GetDlgItemText(hdlg, IDC_HISTORYSTAMP, szstamp, _countof(szstamp)); db_set_ws(NULL, S_MOD, "HistoryStamp", szstamp); - db_set_w(NULL, S_MOD, "HistoryMax", (WORD)(GetDlgItemInt(hdlg, IDC_HISTORYSIZE, NULL, FALSE) + 1)); + db_set_w(NULL, S_MOD, "HistoryMax", (WORD)(GetDlgItemInt(hdlg, IDC_HISTORYSIZE, nullptr, FALSE) + 1)); BOOL bchecked = IsDlgButtonChecked(hdlg, IDC_MENUITEM); if (db_get_b(NULL, S_MOD, "MenuItem", 1) != bchecked) { db_set_b(NULL, S_MOD, "MenuItem", bchecked); - if (hmenuitem == NULL && bchecked) + if (hmenuitem == nullptr && bchecked) InitMenuitem(); } @@ -370,7 +370,7 @@ INT_PTR CALLBACK OptsSettingsDlgProc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM tvItem.mask = TVIF_HANDLE | TVIF_STATE | TVIF_PARAM; tvItem.stateMask = TVIS_STATEIMAGEMASK; - while (hItem != NULL) { + while (hItem != nullptr) { tvItem.hItem = hItem; TreeView_GetItem(hwndTreeView, &tvItem); protocol = (char*)tvItem.lParam; @@ -415,7 +415,7 @@ INT_PTR CALLBACK OptsSettingsDlgProc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM TVITEM tvItem; tvItem.mask = TVIF_HANDLE | TVIF_PARAM; - while (hItem != NULL) { + while (hItem != nullptr) { tvItem.hItem = hItem; TreeView_GetItem(hwndTreeView, &tvItem); mir_free((void *)tvItem.lParam); diff --git a/plugins/SeenPlugin/src/userinfo.cpp b/plugins/SeenPlugin/src/userinfo.cpp index 7582e5ec8a..19d2aebd16 100644 --- a/plugins/SeenPlugin/src/userinfo.cpp +++ b/plugins/SeenPlugin/src/userinfo.cpp @@ -24,7 +24,7 @@ LRESULT CALLBACK EditProc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM lparam) { switch (msg) { case WM_SETCURSOR: - SetCursor(LoadCursor(NULL, IDC_ARROW)); + SetCursor(LoadCursor(nullptr, IDC_ARROW)); return 1; } return mir_callNextSubclass(hdlg, EditProc, msg, wparam, lparam); diff --git a/plugins/SeenPlugin/src/utils.cpp b/plugins/SeenPlugin/src/utils.cpp index e9e043d824..ef90cd1273 100644 --- a/plugins/SeenPlugin/src/utils.cpp +++ b/plugins/SeenPlugin/src/utils.cpp @@ -24,7 +24,7 @@ void FileWrite(MCONTACT); void HistoryWrite(MCONTACT hcontact); extern HANDLE g_hShutdownEvent; -char *courProtoName = 0; +char *courProtoName = nullptr; void LoadWatchedProtos() { @@ -41,7 +41,7 @@ void LoadWatchedProtos() if (szProtos == NULL) return; - for (char *p = strtok(szProtos, "\n"); p != NULL; p = strtok(NULL, "\n")) + for (char *p = strtok(szProtos, "\n"); p != nullptr; p = strtok(nullptr, "\n")) arWatchedProtos.insert(mir_strdup(p)); } @@ -57,14 +57,14 @@ void UnloadWatchedProtos() int IsWatchedProtocol(const char* szProto) { - if (szProto == NULL) + if (szProto == nullptr) return 0; PROTOACCOUNT *pd = Proto_GetAccount(szProto); - if (pd == NULL || CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_2, 0) == 0) + if (pd == nullptr || CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_2, 0) == 0) return 0; - return arWatchedProtos.find((char*)szProto) != NULL; + return arWatchedProtos.find((char*)szProto) != nullptr; } BOOL isYahoo(char *protoname) @@ -504,12 +504,12 @@ void myPlaySound(MCONTACT hcontact, WORD newStatus, WORD oldStatus) { if (CallService(MS_IGNORE_ISIGNORED, (WPARAM)hcontact, IGNOREEVENT_USERONLINE)) return; //oldStatus and hcontact are not used yet - char *soundname = NULL; + char *soundname = nullptr; if ((newStatus == ID_STATUS_ONLINE) || (newStatus == ID_STATUS_FREECHAT)) soundname = "LastSeenTrackedStatusOnline"; else if (newStatus == ID_STATUS_OFFLINE) soundname = "LastSeenTrackedStatusOffline"; else if (oldStatus == ID_STATUS_OFFLINE) soundname = "LastSeenTrackedStatusFromOffline"; else soundname = "LastSeenTrackedStatusChange"; - if (soundname != NULL) + if (soundname != nullptr) Skin_PlaySound(soundname); } @@ -556,7 +556,7 @@ int UpdateValues(WPARAM hContact, LPARAM lparam) DBWriteTimeTS(cws->value.dVal, hContact); HWND hwnd = WindowList_Find(g_pUserInfo, hContact); - if (hwnd != NULL) + if (hwnd != nullptr) SendMessage(hwnd, WM_REFRESH_UI, hContact, 0); return 0; } @@ -586,7 +586,7 @@ int UpdateValues(WPARAM hContact, LPARAM lparam) mir_snprintf(str, "OffTime-%s", szProto); DWORD t = db_get_dw(NULL, S_MOD, str, 0); if (!t) - t = time(NULL); + t = time(nullptr); DBWriteTimeTS(t, hContact); } @@ -613,7 +613,7 @@ int UpdateValues(WPARAM hContact, LPARAM lparam) if (cws->value.wVal == prevStatus && !db_get_b(hContact, S_MOD, "Offline", 0)) return 0; - DBWriteTimeTS(time(NULL), hContact); + DBWriteTimeTS(time(nullptr), hContact); if (g_bFileActive) FileWrite(hContact); if (prevStatus != cws->value.wVal) myPlaySound(hContact, cws->value.wVal, prevStatus); @@ -631,7 +631,7 @@ int UpdateValues(WPARAM hContact, LPARAM lparam) if (CallProtoService(cws->szModule, PS_GETSTATUS, 0, 0) > ID_STATUS_OFFLINE) { mir_cslock lck(csContacts); logthread_info *p = arContacts.find((logthread_info*)&hContact); - if (p == NULL) { + if (p == nullptr) { p = (logthread_info*)mir_calloc(sizeof(logthread_info)); p->hContact = hContact; mir_strncpy(p->sProtoName, cws->szModule, _countof(p->sProtoName)); @@ -681,7 +681,7 @@ int ModeChange(WPARAM, LPARAM lparam) if (!IsWatchedProtocol(courProtoName) && strncmp(courProtoName, "MetaContacts", 12)) return 0; - DBWriteTimeTS(time(NULL), NULL); + DBWriteTimeTS(time(nullptr), NULL); // isetting=CallProtoService(ack->szModule,PS_GETSTATUS,0,0); WORD isetting = (WORD)ack->lParam; @@ -718,7 +718,7 @@ int ModeChange(WPARAM, LPARAM lparam) if (g_bFileActive) FileWrite(NULL); - courProtoName = NULL; + courProtoName = nullptr; return 0; } -- cgit v1.2.3