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/stdurl/url.cpp | 4 ++-- src/core/stdurl/urldialogs.cpp | 26 +++++++++++++------------- 2 files changed, 15 insertions(+), 15 deletions(-) (limited to 'src/core/stdurl') diff --git a/src/core/stdurl/url.cpp b/src/core/stdurl/url.cpp index 1dfdfa894b..bd467f3d49 100644 --- a/src/core/stdurl/url.cpp +++ b/src/core/stdurl/url.cpp @@ -49,7 +49,7 @@ static int UrlEventAdded(WPARAM hContact, LPARAM lParam) SkinPlaySound("RecvUrl"); TCHAR szTooltip[256]; - mir_sntprintf(szTooltip, SIZEOF(szTooltip), TranslateT("URL from %s"), pcli->pfnGetContactDisplayName(hContact, 0)); + mir_sntprintf(szTooltip, _countof(szTooltip), TranslateT("URL from %s"), pcli->pfnGetContactDisplayName(hContact, 0)); CLISTEVENT cle = { sizeof(cle) }; cle.flags = CLEF_TCHAR; @@ -82,7 +82,7 @@ static void RestoreUnreadUrlAlerts(void) db_event_get(hDbEvent, &dbei); if ( !(dbei.flags&(DBEF_SENT|DBEF_READ)) && dbei.eventType == EVENTTYPE_URL) { TCHAR toolTip[256]; - mir_sntprintf(toolTip, SIZEOF(toolTip), TranslateT("URL from %s"), pcli->pfnGetContactDisplayName(hContact, 0)); + mir_sntprintf(toolTip, _countof(toolTip), TranslateT("URL from %s"), pcli->pfnGetContactDisplayName(hContact, 0)); cle.hContact = hContact; cle.hDbEvent = hDbEvent; diff --git a/src/core/stdurl/urldialogs.cpp b/src/core/stdurl/urldialogs.cpp index 157725362b..f654cae874 100644 --- a/src/core/stdurl/urldialogs.cpp +++ b/src/core/stdurl/urldialogs.cpp @@ -35,11 +35,10 @@ static void sttUpdateTitle(HWND hwndDlg, MCONTACT hContact) if (hContact) { szProto = GetContactProto(hContact); if (szProto) { - CONTACTINFO ci; + CONTACTINFO ci = { 0 }; int hasName = 0; char buf[128]; memset(&ci, 0, sizeof(ci)); - ci.cbSize = sizeof(ci); ci.hContact = hContact; ci.szProto = szProto; @@ -53,7 +52,7 @@ static void sttUpdateTitle(HWND hwndDlg, MCONTACT hContact) break; case CNFT_DWORD: hasName = 1; - mir_snprintf(buf, SIZEOF(buf), "%u", ci.dVal); + mir_snprintf(buf, _countof(buf), "%u", ci.dVal); break; } } @@ -65,12 +64,12 @@ static void sttUpdateTitle(HWND hwndDlg, MCONTACT hContact) SetDlgItemText(hwndDlg, IDC_NAME, contactName); szStatus = pcli->pfnGetStatusModeDescription(db_get_w(hContact, szProto, "Status", ID_STATUS_OFFLINE), 0); - mir_sntprintf(newtitle, SIZEOF(newtitle), _T("%s %s (%s)"), pszNewTitleStart, contactName, szStatus); + mir_sntprintf(newtitle, _countof(newtitle), _T("%s %s (%s)"), pszNewTitleStart, contactName, szStatus); } } - else mir_tstrncpy(newtitle, pszNewTitleStart, SIZEOF(newtitle)); + else mir_tstrncpy(newtitle, pszNewTitleStart, _countof(newtitle)); - GetWindowText(hwndDlg, oldtitle, SIZEOF(oldtitle)); + GetWindowText(hwndDlg, oldtitle, _countof(oldtitle)); if (mir_tstrcmp(newtitle, oldtitle)) //swt() flickers even if the title hasn't actually changed SetWindowText(hwndDlg, newtitle); @@ -108,13 +107,13 @@ INT_PTR CALLBACK DlgProcUrlRecv(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP db_event_markRead(dat->hContact, dat->hDbEvent); TCHAR *contactName = pcli->pfnGetContactDisplayName(dat->hContact, 0), msg[128]; - mir_sntprintf(msg, SIZEOF(msg), TranslateT("URL from %s"), contactName); + mir_sntprintf(msg, _countof(msg), TranslateT("URL from %s"), contactName); SetWindowText(hwndDlg, msg); SetDlgItemText(hwndDlg, IDC_FROM, contactName); SendDlgItemMessage(hwndDlg, IDOK, BUTTONSETARROW, 1, 0); TCHAR str[128]; - TimeZone_PrintTimeStamp(NULL, dbei.timestamp, _T("t d"), str, SIZEOF(str), 0); + TimeZone_PrintTimeStamp(NULL, dbei.timestamp, _T("t d"), str, _countof(str), 0); SetDlgItemText(hwndDlg, IDC_DATE, str); } @@ -166,7 +165,7 @@ INT_PTR CALLBACK DlgProcUrlRecv(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP HMENU hSubMenu = GetSubMenu(hMenu, 6); TranslateMenu(hSubMenu); GetWindowRect((HWND)lParam, &rc); - GetDlgItemTextA(hwndDlg, IDC_URL, url, SIZEOF(url)); + GetDlgItemTextA(hwndDlg, IDC_URL, url, _countof(url)); switch(TrackPopupMenu(hSubMenu, TPM_RETURNCMD, rc.left, rc.bottom, 0, hwndDlg, NULL)) { case IDM_OPENNEW: CallService(MS_UTILS_OPENURL, OUF_NEWWINDOW, (LPARAM)url); @@ -346,7 +345,7 @@ static void AddBrowserPageToCombo(char *url, HWND hwndCombo) char szExistingUrl[1024]; for (i = SendMessage(hwndCombo, CB_GETCOUNT, 0, 0)-1;i>=0;i--) { - if (SendMessage(hwndCombo, CB_GETLBTEXTLEN, i, 0) >= SIZEOF(szExistingUrl)) + if (SendMessage(hwndCombo, CB_GETLBTEXTLEN, i, 0) >= _countof(szExistingUrl)) continue; SendMessageA(hwndCombo, CB_GETLBTEXT, i, (LPARAM)szExistingUrl); if ( !mir_strcmp(szExistingUrl, url)) return; @@ -382,7 +381,7 @@ static void GetOpenBrowserUrlsForBrowser(const char *szBrowser, HWND hwndDlg, HW } int dataLength = GlobalSize(hData)-offsetof(DDEDATA, Value); DDEDATA *data = (DDEDATA*)GlobalLock(hData); - windowCount = dataLength/sizeof(DWORD); + windowCount = dataLength / sizeof(DWORD); windowId = (PDWORD)mir_alloc(sizeof(DWORD)*windowCount); memcpy(windowId, data->Value, windowCount*sizeof(DWORD)); GlobalUnlock(hData); @@ -402,7 +401,7 @@ static void GetOpenBrowserUrlsForBrowser(const char *szBrowser, HWND hwndDlg, HW for (i=0;ihContact != dat->hContact) break; if (ack->type != ACKTYPE_URL || ack->result != ACKRESULT_SUCCESS) break; - DBEVENTINFO dbei = { sizeof(dbei) }; + DBEVENTINFO dbei = { 0 }; + dbei.cbSize = sizeof(dbei); dbei.eventType = EVENTTYPE_URL; dbei.flags = DBEF_SENT; dbei.szModule = GetContactProto(dat->hContact); -- cgit v1.2.3