From 4c814798c7bc7f6a0f92c21b027b26290622aa2f Mon Sep 17 00:00:00 2001 From: George Hazan Date: Fri, 19 Jun 2015 19:35:42 +0000 Subject: SIZEOF replaced with more secure analog - _countof git-svn-id: http://svn.miranda-ng.org/main/trunk@14270 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- src/core/stdaway/src/awaymsg.cpp | 10 +++++----- src/core/stdaway/src/sendmsg.cpp | 22 +++++++++++----------- 2 files changed, 16 insertions(+), 16 deletions(-) (limited to 'src/core/stdaway') diff --git a/src/core/stdaway/src/awaymsg.cpp b/src/core/stdaway/src/awaymsg.cpp index 7cee287dd1..caaed0f169 100644 --- a/src/core/stdaway/src/awaymsg.cpp +++ b/src/core/stdaway/src/awaymsg.cpp @@ -60,12 +60,12 @@ static INT_PTR CALLBACK ReadAwayMsgDlgProc(HWND hwndDlg, UINT message, WPARAM wP WORD dwStatus = db_get_w(dat->hContact, szProto, "Status", ID_STATUS_OFFLINE); TCHAR *status = pcli->pfnGetStatusModeDescription(dwStatus, 0); - GetWindowText(hwndDlg, format, SIZEOF(format)); - mir_sntprintf(str, SIZEOF(str), format, status, contactName); + GetWindowText(hwndDlg, format, _countof(format)); + mir_sntprintf(str, _countof(str), format, status, contactName); SetWindowText(hwndDlg, str); - GetDlgItemText(hwndDlg, IDC_RETRIEVING, format, SIZEOF(format)); - mir_sntprintf(str, SIZEOF(str), format, status); + GetDlgItemText(hwndDlg, IDC_RETRIEVING, format, _countof(format)); + mir_sntprintf(str, _countof(str), format, status); SetDlgItemText(hwndDlg, IDC_RETRIEVING, str); Window_SetProtoIcon_IcoLib(hwndDlg, szProto, dwStatus); @@ -143,7 +143,7 @@ static int AwayMsgPreBuildMenu(WPARAM hContact, LPARAM) int chatRoom = db_get_b(hContact, szProto, "ChatRoom", 0); if (!chatRoom) { int status = db_get_w(hContact, szProto, "Status", ID_STATUS_OFFLINE); - mir_sntprintf(str, SIZEOF(str), TranslateT("Re&ad %s message"), pcli->pfnGetStatusModeDescription(status, 0)); + mir_sntprintf(str, _countof(str), TranslateT("Re&ad %s message"), pcli->pfnGetStatusModeDescription(status, 0)); mi.ptszName = str; if (CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGRECV) { if (CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_3, 0) & Proto_Status2Flag(status)) { diff --git a/src/core/stdaway/src/sendmsg.cpp b/src/core/stdaway/src/sendmsg.cpp index 68db851844..dc36c8d8cc 100644 --- a/src/core/stdaway/src/sendmsg.cpp +++ b/src/core/stdaway/src/sendmsg.cpp @@ -113,12 +113,12 @@ static TCHAR* GetAwayMessage(int statusMode, char *szProto) if (mm < 0) mm += 60 * 24; t.wMinute = mm % 60; t.wHour = mm / 60; - GetTimeFormat(LOCALE_USER_DEFAULT, TIME_NOSECONDS, &t, NULL, substituteStr, SIZEOF(substituteStr)); + GetTimeFormat(LOCALE_USER_DEFAULT, TIME_NOSECONDS, &t, NULL, substituteStr, _countof(substituteStr)); } - else GetTimeFormat(LOCALE_USER_DEFAULT, TIME_NOSECONDS, NULL, NULL, substituteStr, SIZEOF(substituteStr)); + else GetTimeFormat(LOCALE_USER_DEFAULT, TIME_NOSECONDS, NULL, NULL, substituteStr, _countof(substituteStr)); } else if ( !_tcsnicmp(dbv.ptszVal + i, _T("%date%"), 6)) - GetDateFormat(LOCALE_USER_DEFAULT, DATE_SHORTDATE, NULL, NULL, substituteStr, SIZEOF(substituteStr)); + GetDateFormat(LOCALE_USER_DEFAULT, DATE_SHORTDATE, NULL, NULL, substituteStr, _countof(substituteStr)); else continue; if (mir_tstrlen(substituteStr) > 6) @@ -225,11 +225,11 @@ static INT_PTR CALLBACK SetAwayMsgDlgProc(HWND hwndDlg, UINT message, WPARAM wPa mir_subclassWindow(GetDlgItem(hwndDlg, IDC_MSG), MessageEditSubclassProc); { TCHAR str[256], format[128]; - GetWindowText(hwndDlg, format, SIZEOF(format)); - mir_sntprintf(str, SIZEOF(str), format, pcli->pfnGetStatusModeDescription(dat->statusMode, 0)); + GetWindowText(hwndDlg, format, _countof(format)); + mir_sntprintf(str, _countof(str), format, pcli->pfnGetStatusModeDescription(dat->statusMode, 0)); SetWindowText(hwndDlg, str); } - GetDlgItemText(hwndDlg, IDOK, dat->okButtonFormat, SIZEOF(dat->okButtonFormat)); + GetDlgItemText(hwndDlg, IDOK, dat->okButtonFormat, _countof(dat->okButtonFormat)); { TCHAR *msg = GetAwayMessage(dat->statusMode, dat->szProto); SetDlgItemText(hwndDlg, IDC_MSG, msg); @@ -247,7 +247,7 @@ static INT_PTR CALLBACK SetAwayMsgDlgProc(HWND hwndDlg, UINT message, WPARAM wPa case WM_TIMER: if (--dat->countdown >= 0) { TCHAR str[64]; - mir_sntprintf(str, SIZEOF(str), dat->okButtonFormat, dat->countdown); + mir_sntprintf(str, _countof(str), dat->okButtonFormat, dat->countdown); SetDlgItemText(hwndDlg, IDOK, str); } else { @@ -270,7 +270,7 @@ static INT_PTR CALLBACK SetAwayMsgDlgProc(HWND hwndDlg, UINT message, WPARAM wPa case IDOK: if (dat->countdown < 0) { TCHAR str[1024]; - GetDlgItemText(hwndDlg, IDC_MSG, str, SIZEOF(str)); + GetDlgItemText(hwndDlg, IDC_MSG, str, _countof(str)); ChangeAllProtoMessages(dat->szProto, dat->statusMode, str); db_set_ts(NULL, "SRAway", StatusModeToDbSetting(dat->statusMode, "Msg"), str); DestroyWindow(hwndDlg); @@ -360,7 +360,7 @@ struct AwayMsgInfo struct AwayMsgDlgData { - struct AwayMsgInfo info[SIZEOF(statusModes)]; + struct AwayMsgInfo info[_countof(statusModes)]; int oldPage; }; @@ -376,7 +376,7 @@ static INT_PTR CALLBACK DlgProcAwayMsgOpts(HWND hwndDlg, UINT msg, WPARAM wParam dat = (AwayMsgDlgData*)mir_alloc(sizeof(AwayMsgDlgData)); SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)dat); dat->oldPage = -1; - for (int i = 0; i < SIZEOF(statusModes); i++) { + for (int i = 0; i < _countof(statusModes); i++) { if (!(protoModeMsgFlags & Proto_Status2Flag(statusModes[i]))) continue; @@ -454,7 +454,7 @@ static INT_PTR CALLBACK DlgProcAwayMsgOpts(HWND hwndDlg, UINT msg, WPARAM wParam dat->info[dat->oldPage].ignore = IsDlgButtonChecked(hwndDlg, IDC_DONTREPLY); dat->info[dat->oldPage].noDialog = IsDlgButtonChecked(hwndDlg, IDC_NODIALOG); dat->info[dat->oldPage].usePrevious = IsDlgButtonChecked(hwndDlg, IDC_USEPREVIOUS); - GetDlgItemText(hwndDlg, IDC_MSG, dat->info[dat->oldPage].msg, SIZEOF(dat->info[dat->oldPage].msg)); + GetDlgItemText(hwndDlg, IDC_MSG, dat->info[dat->oldPage].msg, _countof(dat->info[dat->oldPage].msg)); } CheckDlgButton(hwndDlg, IDC_DONTREPLY, (i < 0 ? 0 : dat->info[i].ignore) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hwndDlg, IDC_NODIALOG, (i < 0 ? 0 : dat->info[i].noDialog) ? BST_CHECKED : BST_UNCHECKED); -- cgit v1.2.3