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 --- plugins/FileAsMessage/src/dialog.cpp | 22 +++++++++++----------- plugins/FileAsMessage/src/main.cpp | 6 +++--- plugins/FileAsMessage/src/optionsdlg.cpp | 6 +++--- 3 files changed, 17 insertions(+), 17 deletions(-) (limited to 'plugins/FileAsMessage') diff --git a/plugins/FileAsMessage/src/dialog.cpp b/plugins/FileAsMessage/src/dialog.cpp index c958e08dcc..1edaf90842 100644 --- a/plugins/FileAsMessage/src/dialog.cpp +++ b/plugins/FileAsMessage/src/dialog.cpp @@ -193,7 +193,7 @@ void FILEECHO::setState(DWORD state) iState = state; int indx; - for (indx = 0; indx < SIZEOF(controlEnabled); indx++) + for (indx = 0; indx < _countof(controlEnabled); indx++) { EnableWindow(GetDlgItem(hDlg, controlEnabled[indx][0]), (iState & controlEnabled[indx][1]) != 0); } @@ -243,9 +243,9 @@ void FILEECHO::updateTitle() contactName = (char*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, hContact, 0); if (iState == STATE_OPERATE && chunkCount != 0) - mir_snprintf(newtitle, SIZEOF(newtitle), "%d%% - %s: %s", chunkSent * 100 / chunkCount, Translate(szFEMode[inSend]), contactName); + mir_snprintf(newtitle, _countof(newtitle), "%d%% - %s: %s", chunkSent * 100 / chunkCount, Translate(szFEMode[inSend]), contactName); else - mir_snprintf(newtitle, SIZEOF(newtitle), "%s: %s", Translate(szFEMode[inSend]), contactName); + mir_snprintf(newtitle, _countof(newtitle), "%s: %s", Translate(szFEMode[inSend]), contactName); SetWindowText(hDlg, newtitle); } @@ -412,9 +412,9 @@ void FILEECHO::sendReq() if (*p == '\\') mir_strcpy(filename, p + 1); - mir_snprintf(sendbuf, SIZEOF(sendbuf), Translate("Size: %d bytes"), fileSize); + mir_snprintf(sendbuf, _countof(sendbuf), Translate("Size: %d bytes"), fileSize); SetDlgItemText(hDlg, IDC_FILESIZE, sendbuf); - mir_snprintf(sendbuf, SIZEOF(sendbuf), "?%c%c%d:%d \n" NOPLUGIN_MESSAGE, asBinary + '0', codeSymb, chunkCount, fileSize); + mir_snprintf(sendbuf, _countof(sendbuf), "?%c%c%d:%d \n" NOPLUGIN_MESSAGE, asBinary + '0', codeSymb, chunkCount, fileSize); sendCmd(0, CMD_REQ, sendbuf, filename); SetDlgItemText(hDlg, IDC_STATUS, Translate("Request sent. Awaiting of acceptance..")); @@ -429,7 +429,7 @@ void FILEECHO::incomeRequest(char *param) char *p = strchr(param, '?'); if (p == NULL) return; *p++ = 0; CallService(MS_FILE_GETRECEIVEDFILESFOLDER, hContact, (LPARAM)buf); - mir_strncat(buf, param, SIZEOF(buf) - mir_strlen(buf)); + mir_strncat(buf, param, _countof(buf) - mir_strlen(buf)); free(filename); filename = mir_strdup(buf); // p == &c @@ -618,7 +618,7 @@ void FILEECHO::onSendTimer() } char prefix[128]; - mir_snprintf(prefix, SIZEOF(prefix), "%X,%X,%X>", chunkIndx + 1, chunkPos[chunkIndx], chksum); + mir_snprintf(prefix, _countof(prefix), "%X,%X,%X>", chunkIndx + 1, chunkPos[chunkIndx], chksum); #ifdef DEBUG overhead += mir_tstrlen((char*)buffer); #endif @@ -869,7 +869,7 @@ void CreateDirectoryTree(char *szDir) DWORD dwAttributes; char *pszLastBackslash, szTestDir[MAX_PATH]; - mir_strncpy(szTestDir, szDir, SIZEOF(szTestDir)); + mir_strncpy(szTestDir, szDir, _countof(szTestDir)); if ((dwAttributes = GetFileAttributes(szTestDir)) != 0xffffffff && (dwAttributes & FILE_ATTRIBUTE_DIRECTORY)) return; pszLastBackslash = strrchr(szTestDir, '\\'); @@ -1151,7 +1151,7 @@ INT_PTR CALLBACK DialogProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) memset(&ofn, 0, sizeof(ofn)); *str = 0; - GetDlgItemText(hDlg, IDC_FILENAME, str, SIZEOF(str)); + GetDlgItemText(hDlg, IDC_FILENAME, str, _countof(str)); //ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400; ofn.lStructSize = sizeof(ofn); ofn.hwndOwner = hDlg; @@ -1159,7 +1159,7 @@ INT_PTR CALLBACK DialogProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) ofn.lpstrFile = str; ofn.Flags = dat->inSend ? OFN_FILEMUSTEXIST : 0; ofn.lpstrTitle = dat->inSend ? Translate("Select a file") : Translate("Save as"); - ofn.nMaxFile = SIZEOF(str); + ofn.nMaxFile = _countof(str); ofn.nMaxFileTitle = MAX_PATH; if (!GetOpenFileName(&ofn)) break; if (!dat->inSend && dat->iState == STATE_FINISHED) break; @@ -1169,7 +1169,7 @@ INT_PTR CALLBACK DialogProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) if (size != -1) mir_snprintf(str, Translate("Size: %d bytes"), size); else - mir_strncpy(str, Translate("Can't get a file size"), SIZEOF(str)); + mir_strncpy(str, Translate("Can't get a file size"), _countof(str)); SetDlgItemText(hDlg, IDC_FILESIZE, str); break; diff --git a/plugins/FileAsMessage/src/main.cpp b/plugins/FileAsMessage/src/main.cpp index 6892863329..1e405a38c4 100644 --- a/plugins/FileAsMessage/src/main.cpp +++ b/plugins/FileAsMessage/src/main.cpp @@ -42,7 +42,7 @@ int iIconId[5] = { 3, 2, 4, 1, 0 }; // int OnSkinIconsChanged(WPARAM wParam, LPARAM lParam) { - for (int indx = 0; indx < SIZEOF(hIcons); indx++) + for (int indx = 0; indx < _countof(hIcons); indx++) hIcons[indx] = IcoLib_GetIconByHandle(iconList[indx].hIcolib); WindowList_Broadcast(hFileList, WM_FE_SKINCHANGE, 0, 0); @@ -169,7 +169,7 @@ extern "C" __declspec(dllexport) PLUGININFOEX *MirandaPluginInfoEx(DWORD dwVersi static int OnModulesLoaded(WPARAM wparam, LPARAM lparam) { - for (int indx = 0; indx < SIZEOF(hIcons); indx++) + for (int indx = 0; indx < _countof(hIcons); indx++) hIcons[indx] = IcoLib_GetIconByHandle(iconList[indx].hIcolib); hHookSkinIconsChanged = HookEvent(ME_SKIN2_ICONSCHANGED, OnSkinIconsChanged); @@ -191,7 +191,7 @@ extern "C" __declspec(dllexport) int Load(void) InitCRC32(); - Icon_Register(hInst, "fileAsMessage", iconList, SIZEOF(iconList)); + Icon_Register(hInst, "fileAsMessage", iconList, _countof(iconList)); hFileList = WindowList_Create(); diff --git a/plugins/FileAsMessage/src/optionsdlg.cpp b/plugins/FileAsMessage/src/optionsdlg.cpp index df20bc5ade..d8b34e5e38 100644 --- a/plugins/FileAsMessage/src/optionsdlg.cpp +++ b/plugins/FileAsMessage/src/optionsdlg.cpp @@ -43,7 +43,7 @@ INT_PTR CALLBACK OptionsDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l { TranslateDialogDefault(hwndDlg); - for (int indx = 0; indx < SIZEOF(settingId); indx++) + for (int indx = 0; indx < _countof(settingId); indx++) if (settingId[indx] > 0) SendDlgItemMessage(hwndDlg, settingId[indx], CPM_SETCOLOUR, 0, db_get_dw(NULL, SERVICE_NAME, settingName[indx], settingDefault[indx])); else @@ -59,7 +59,7 @@ INT_PTR CALLBACK OptionsDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l if (//MAKEWPARAM(IDC_AUTO, BN_CLICKED) != wParam || MAKEWPARAM(IDC_ALPHANUM, BN_CLICKED) != wParam) { - for (int indx = 0; indx < SIZEOF(settingId); indx++) + for (int indx = 0; indx < _countof(settingId); indx++) { if (LOWORD(wParam) == abs(settingId[indx])) { @@ -88,7 +88,7 @@ INT_PTR CALLBACK OptionsDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l int value; BOOL succ; - for (int indx = 0; indx < SIZEOF(settingId); indx++) + for (int indx = 0; indx < _countof(settingId); indx++) { if (settingId[indx] > 0) value = SendDlgItemMessage(hwndDlg, settingId[indx], CPM_GETCOLOUR, 0, 0); -- cgit v1.2.3