diff options
author | George Hazan <george.hazan@gmail.com> | 2015-06-19 19:35:42 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2015-06-19 19:35:42 +0000 |
commit | 4c814798c7bc7f6a0f92c21b027b26290622aa2f (patch) | |
tree | 9bbfb38bd639f352300aa16ff7c45f5a9b2dba6d /src/core/stduserinfo | |
parent | f0f0cd088f1ec3a85abee825ddbc214f3f6b92c3 (diff) |
SIZEOF replaced with more secure analog - _countof
git-svn-id: http://svn.miranda-ng.org/main/trunk@14270 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'src/core/stduserinfo')
-rw-r--r-- | src/core/stduserinfo/src/contactinfo.cpp | 26 | ||||
-rw-r--r-- | src/core/stduserinfo/src/stdinfo.cpp | 16 | ||||
-rw-r--r-- | src/core/stduserinfo/src/userinfo.cpp | 10 |
3 files changed, 26 insertions, 26 deletions
diff --git a/src/core/stduserinfo/src/contactinfo.cpp b/src/core/stduserinfo/src/contactinfo.cpp index 7636f6b231..88e41465dd 100644 --- a/src/core/stduserinfo/src/contactinfo.cpp +++ b/src/core/stduserinfo/src/contactinfo.cpp @@ -112,9 +112,9 @@ static INT_PTR CALLBACK EditUserPhoneDlgProc(HWND hwndDlg, UINT msg, WPARAM wPar EnableWindow(GetDlgItem(hwndDlg, IDOK), TRUE);
{
char szPhone[96], szArea[32], szNumber[64];
- GetDlgItemTextA(hwndDlg, IDC_AREA, szArea, SIZEOF(szArea));
- GetDlgItemTextA(hwndDlg, IDC_NUMBER, szNumber, SIZEOF(szNumber));
- mir_snprintf(szPhone, SIZEOF(szPhone), "+%u (%s) %s", SendDlgItemMessage(hwndDlg, IDC_COUNTRY, CB_GETITEMDATA, SendDlgItemMessage(hwndDlg, IDC_COUNTRY, CB_GETCURSEL, 0, 0), 0), szArea, szNumber);
+ GetDlgItemTextA(hwndDlg, IDC_AREA, szArea, _countof(szArea));
+ GetDlgItemTextA(hwndDlg, IDC_NUMBER, szNumber, _countof(szNumber));
+ mir_snprintf(szPhone, _countof(szPhone), "+%u (%s) %s", SendDlgItemMessage(hwndDlg, IDC_COUNTRY, CB_GETITEMDATA, SendDlgItemMessage(hwndDlg, IDC_COUNTRY, CB_GETCURSEL, 0, 0), 0), szArea, szNumber);
noRecursion = 1;
SetDlgItemTextA(hwndDlg, IDC_PHONE, szPhone);
noRecursion = 0;
@@ -127,7 +127,7 @@ static INT_PTR CALLBACK EditUserPhoneDlgProc(HWND hwndDlg, UINT msg, WPARAM wPar {
char szText[256], *pText = NULL, *pArea, *pNumber;
int i, isValid = 1;
- GetDlgItemTextA(hwndDlg, IDC_PHONE, szText, SIZEOF(szText));
+ GetDlgItemTextA(hwndDlg, IDC_PHONE, szText, _countof(szText));
if (szText[0] != '+')
isValid = 0;
@@ -190,7 +190,7 @@ static int IsOverEmail(HWND hwndDlg, TCHAR* szEmail, int cchEmail) ListView_GetSubItemRect(hwndEmails, hti.iItem, 1, LVIR_LABEL, &rc);
TCHAR szText[256]; szText[0] = 0;
- ListView_GetItemText(hwndEmails, hti.iItem, 1, szText, SIZEOF(szText));
+ ListView_GetItemText(hwndEmails, hti.iItem, 1, szText, _countof(szText));
HDC hdc = GetDC(hwndEmails);
SelectObject(hdc, hEmailFont);
@@ -282,7 +282,7 @@ INT_PTR CALLBACK ContactDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP break;
lvi.pszText = idstr2;
- mir_sntprintf(idstr2, SIZEOF(idstr2), _T("%d"), i+2);
+ mir_sntprintf(idstr2, _countof(idstr2), _T("%d"), i+2);
}
ListView_InsertItem(GetDlgItem(hwndDlg, IDC_EMAILS), &lvi);
ListView_SetItemText(GetDlgItem(hwndDlg, IDC_EMAILS), lvi.iItem, 1, dbv.ptszVal);
@@ -296,7 +296,7 @@ INT_PTR CALLBACK ContactDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP if (db_get_ts(hContact, "UserInfo", idstr, &dbv))
break;
lvi.pszText = idstr2;
- mir_sntprintf(idstr2, SIZEOF(idstr2), TranslateT("Custom %d"), i+1);
+ mir_sntprintf(idstr2, _countof(idstr2), TranslateT("Custom %d"), i+1);
ListView_InsertItem(GetDlgItem(hwndDlg, IDC_EMAILS), &lvi);
ListView_SetItemText(GetDlgItem(hwndDlg, IDC_EMAILS), lvi.iItem, 1, dbv.ptszVal);
db_free(&dbv);
@@ -357,7 +357,7 @@ INT_PTR CALLBACK ContactDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP if (db_get_ts(hContact, "UserInfo", idstr, &dbv))
break;
lvi.pszText = idstr2;
- mir_sntprintf(idstr2, SIZEOF(idstr2), TranslateT("Custom %d"), i+1);
+ mir_sntprintf(idstr2, _countof(idstr2), TranslateT("Custom %d"), i+1);
ListView_InsertItem(GetDlgItem(hwndDlg, IDC_PHONES), &lvi);
if (mir_tstrlen(dbv.ptszVal)>4 && !mir_tstrcmp(dbv.ptszVal+mir_tstrlen(dbv.ptszVal)-4, _T(" SMS"))) {
ListView_SetItemText(GetDlgItem(hwndDlg, IDC_PHONES), lvi.iItem, 2, _T("y"));
@@ -400,7 +400,7 @@ INT_PTR CALLBACK ContactDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP if (nm->iSubItem == 1 && nm->nmcd.hdr.idFrom == IDC_EMAILS) {
HFONT hoFont;
TCHAR szText[256] = {0};
- ListView_GetItemText(nm->nmcd.hdr.hwndFrom, nm->nmcd.dwItemSpec, nm->iSubItem, szText, SIZEOF(szText));
+ ListView_GetItemText(nm->nmcd.hdr.hwndFrom, nm->nmcd.dwItemSpec, nm->iSubItem, szText, _countof(szText));
hoFont = (HFONT)SelectObject(nm->nmcd.hdc, hEmailFont);
SetTextColor(nm->nmcd.hdc, RGB(0, 0, 255));
DrawText(nm->nmcd.hdc, szText, -1, &rc, DT_END_ELLIPSIS|DT_LEFT|DT_NOPREFIX|DT_SINGLELINE|DT_TOP);
@@ -416,7 +416,7 @@ INT_PTR CALLBACK ContactDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP static int iconResources[3] = {SKINICON_OTHER_RENAME, SKINICON_OTHER_DELETE};
if (nm->iSubItem == 2 && nm->nmcd.hdr.idFrom == IDC_PHONES) {
TCHAR szText[2];
- ListView_GetItemText(nm->nmcd.hdr.hwndFrom, nm->nmcd.dwItemSpec, nm->iSubItem, szText, SIZEOF(szText));
+ ListView_GetItemText(nm->nmcd.hdr.hwndFrom, nm->nmcd.dwItemSpec, nm->iSubItem, szText, _countof(szText));
if (szText[0]) hIcon = Skin_LoadIcon(SKINICON_OTHER_SMS);
}
else hIcon = Skin_LoadIcon(iconResources[nm->iSubItem-3+(nm->nmcd.hdr.idFrom == IDC_EMAILS)]);
@@ -440,9 +440,9 @@ INT_PTR CALLBACK ContactDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP char *szIdTemplate = (nm->hdr.idFrom == IDC_PHONES) ? "MyPhone%d" : "Mye-mail%d";
LVHITTESTINFO hti;
- if (IsOverEmail(hwndDlg, szEmail, SIZEOF(szEmail))) {
+ if (IsOverEmail(hwndDlg, szEmail, _countof(szEmail))) {
TCHAR szExec[264];
- mir_sntprintf(szExec, SIZEOF(szExec), _T("mailto:%s"), szEmail);
+ mir_sntprintf(szExec, _countof(szExec), _T("mailto:%s"), szEmail);
ShellExecute(hwndDlg, _T("open"), szExec, NULL, NULL, SW_SHOW);
break;
}
@@ -493,7 +493,7 @@ INT_PTR CALLBACK ContactDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP DBVARIANT dbv;
mir_snprintf(idstr, szIdTemplate, lvi.lParam);
if (db_get_s(hContact, "UserInfo", idstr, &dbv)) break;
- mir_strncpy(szText, dbv.pszVal, SIZEOF(szText));
+ mir_strncpy(szText, dbv.pszVal, _countof(szText));
db_free(&dbv);
if (IDOK != DialogBoxParam(hInst, MAKEINTRESOURCE(nm->hdr.idFrom == IDC_PHONES?IDD_ADDPHONE:IDD_ADDEMAIL), hwndDlg, nm->hdr.idFrom == IDC_PHONES?EditUserPhoneDlgProc:EditUserEmailDlgProc, (LPARAM)szText))
break;
diff --git a/src/core/stduserinfo/src/stdinfo.cpp b/src/core/stduserinfo/src/stdinfo.cpp index 3ad3f9432c..0ac9910f84 100644 --- a/src/core/stduserinfo/src/stdinfo.cpp +++ b/src/core/stduserinfo/src/stdinfo.cpp @@ -89,7 +89,7 @@ static void SetValue(HWND hwndDlg, int idCtrl, MCONTACT hContact, char *szModule else if (special == SVS_MONTH) {
if (dbv.bVal > 0 && dbv.bVal <= 12) {
pstr = str;
- GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_SABBREVMONTHNAME1-1 + dbv.bVal, str, SIZEOF(str));
+ GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_SABBREVMONTHNAME1-1 + dbv.bVal, str, _countof(str));
}
else unspecified = 1;
}
@@ -111,7 +111,7 @@ static void SetValue(HWND hwndDlg, int idCtrl, MCONTACT hContact, char *szModule WORD wSave = dbv.wVal;
if (wSave == (WORD)-1) {
char szSettingName[100];
- mir_snprintf(szSettingName, SIZEOF(szSettingName), "%sName", szSetting);
+ mir_snprintf(szSettingName, _countof(szSettingName), "%sName", szSetting);
if (!db_get_ts(hContact, szModule, szSettingName, &dbv)) {
ptstr = dbv.ptszVal;
unspecified = false;
@@ -221,8 +221,8 @@ static INT_PTR CALLBACK SummaryDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP case IDC_EMAIL:
if (IsWindowEnabled(GetDlgItem(hwndDlg, IDC_EMAIL))) {
TCHAR szExec[264], szEmail[256];
- GetDlgItemText(hwndDlg, IDC_EMAIL, szEmail, SIZEOF(szEmail));
- mir_sntprintf(szExec, SIZEOF(szExec), _T("mailto:%s"), szEmail);
+ GetDlgItemText(hwndDlg, IDC_EMAIL, szEmail, _countof(szEmail));
+ mir_sntprintf(szExec, _countof(szExec), _T("mailto:%s"), szEmail);
ShellExecute(hwndDlg, _T("open"), szExec, NULL, NULL, SW_SHOW);
}
break;
@@ -250,7 +250,7 @@ static INT_PTR CALLBACK LocationDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, L MCONTACT hContact = (MCONTACT)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
if (hContact != NULL) {
TCHAR szTime[80];
- if (printDateTimeByContact(hContact, _T("s"), szTime, SIZEOF(szTime), TZF_KNOWNONLY)) {
+ if (printDateTimeByContact(hContact, _T("s"), szTime, _countof(szTime), TZF_KNOWNONLY)) {
EnableWindow(GetDlgItem(hwndDlg, IDC_LOCALTIME), FALSE);
SetDlgItemText(hwndDlg, IDC_LOCALTIME, TranslateT("<not specified>"));
}
@@ -344,7 +344,7 @@ static INT_PTR CALLBACK WorkDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA case IDC_WEBPAGE:
if (IsWindowEnabled(GetDlgItem(hwndDlg, IDC_WEBPAGE))) {
char szPage[256];
- GetDlgItemTextA(hwndDlg, IDC_WEBPAGE, szPage, SIZEOF(szPage));
+ GetDlgItemTextA(hwndDlg, IDC_WEBPAGE, szPage, _countof(szPage));
CallService(MS_UTILS_OPENURL, OUF_NEWWINDOW, (LPARAM)szPage);
}
}
@@ -482,7 +482,7 @@ static INT_PTR CALLBACK BackgroundDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, case IDC_WEBPAGE:
if (IsWindowEnabled(GetDlgItem(hwndDlg, IDC_WEBPAGE))) {
char szPage[256];
- GetDlgItemTextA(hwndDlg, IDC_WEBPAGE, szPage, SIZEOF(szPage));
+ GetDlgItemTextA(hwndDlg, IDC_WEBPAGE, szPage, _countof(szPage));
CallService(MS_UTILS_OPENURL, OUF_NEWWINDOW, (LPARAM)szPage);
}
break;
@@ -545,7 +545,7 @@ static INT_PTR CALLBACK NotesDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR MCONTACT hContact = (MCONTACT)((LPPSHNOTIFY)lParam)->lParam;
if (GetWindowTextLength(GetDlgItem(hwndDlg, IDC_MYNOTES))) {
char text[2048];
- GetDlgItemTextA(hwndDlg, IDC_MYNOTES, text, SIZEOF(text));
+ GetDlgItemTextA(hwndDlg, IDC_MYNOTES, text, _countof(text));
db_set_s(hContact, "UserInfo", "MyNotes", text);
}
else db_unset(hContact, "UserInfo", "MyNotes");
diff --git a/src/core/stduserinfo/src/userinfo.cpp b/src/core/stduserinfo/src/userinfo.cpp index b195b5bb05..872312f824 100644 --- a/src/core/stduserinfo/src/userinfo.cpp +++ b/src/core/stduserinfo/src/userinfo.cpp @@ -254,8 +254,8 @@ static INT_PTR CALLBACK DlgProcDetails(HWND hwndDlg, UINT msg, WPARAM wParam, LP else
name = pcli->pfnGetContactDisplayName(dat->hContact, 0);
- GetWindowText(hwndDlg, oldTitle, SIZEOF(oldTitle));
- mir_sntprintf(newTitle, SIZEOF(newTitle), oldTitle, name);
+ GetWindowText(hwndDlg, oldTitle, _countof(oldTitle));
+ mir_sntprintf(newTitle, _countof(newTitle), oldTitle, name);
SetWindowText(hwndDlg, newTitle);
//////////////////////////////////////////////////////////////////////
@@ -341,7 +341,7 @@ static INT_PTR CALLBACK DlgProcDetails(HWND hwndDlg, UINT msg, WPARAM wParam, LP //////////////////////////////////////////////////////////////////////
dat->updateAnimFrame = 0;
- GetDlgItemText(hwndDlg, IDC_UPDATING, dat->szUpdating, SIZEOF(dat->szUpdating));
+ GetDlgItemText(hwndDlg, IDC_UPDATING, dat->szUpdating, _countof(dat->szUpdating));
SendMessage(hwndDlg, M_CHECKONLINE, 0, 0);
if (!CallContactService(dat->hContact, PSS_GETINFO, SGIF_ONOPEN, 0)) {
EnableWindow(GetDlgItem(hwndDlg, IDC_UPDATE), FALSE);
@@ -355,7 +355,7 @@ static INT_PTR CALLBACK DlgProcDetails(HWND hwndDlg, UINT msg, WPARAM wParam, LP case WM_TIMER:
TCHAR str[128];
- mir_sntprintf(str, SIZEOF(str), _T("%.*s%s%.*s"), dat->updateAnimFrame % 10, _T("........."), dat->szUpdating, dat->updateAnimFrame % 10, _T("........."));
+ mir_sntprintf(str, _countof(str), _T("%.*s%s%.*s"), dat->updateAnimFrame % 10, _T("........."), dat->szUpdating, dat->updateAnimFrame % 10, _T("........."));
SetDlgItemText(hwndDlg, IDC_UPDATING, str);
if (++dat->updateAnimFrame == UPDATEANIMFRAMES)
dat->updateAnimFrame = 0;
@@ -584,7 +584,7 @@ static INT_PTR CALLBACK DlgProcDetails(HWND hwndDlg, UINT msg, WPARAM wParam, LP tvi.mask = TVIF_TEXT;
tvi.hItem = dat->opd[dat->currentPage].hItem;
tvi.pszText = name;
- tvi.cchTextMax = SIZEOF(name);
+ tvi.cchTextMax = _countof(name);
TreeView_GetItem(GetDlgItem(hwndDlg, IDC_PAGETREE), &tvi);
db_set_ts(NULL, "UserInfo", "LastTab", name);
|