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/FTPFileYM/src/dialog.cpp | 4 ++-- plugins/FTPFileYM/src/ftpfile.cpp | 4 ++-- plugins/FTPFileYM/src/job_generic.cpp | 6 +++--- plugins/FTPFileYM/src/job_packer.cpp | 12 ++++++------ plugins/FTPFileYM/src/job_upload.cpp | 20 ++++++++++---------- plugins/FTPFileYM/src/options.cpp | 14 +++++++------- plugins/FTPFileYM/src/serverlist.cpp | 2 +- 7 files changed, 31 insertions(+), 31 deletions(-) (limited to 'plugins/FTPFileYM/src') diff --git a/plugins/FTPFileYM/src/dialog.cpp b/plugins/FTPFileYM/src/dialog.cpp index 4322f9d5c1..c16bd30ea5 100644 --- a/plugins/FTPFileYM/src/dialog.cpp +++ b/plugins/FTPFileYM/src/dialog.cpp @@ -133,7 +133,7 @@ void UploadDialog::Tab::select() void UploadDialog::Tab::labelCompleted() { TCHAR buff[64], buff2[256]; - mir_sntprintf(buff2, SIZEOF(buff2), _T("* %s"), Utils::getTextFragment(this->job->stzFileName, 20, buff)); + mir_sntprintf(buff2, _countof(buff2), _T("* %s"), Utils::getTextFragment(this->job->stzFileName, 20, buff)); TCITEM tab = {0}; tab.mask = TCIF_TEXT; @@ -301,7 +301,7 @@ INT_PTR CALLBACK UploadDialog::UploadDlgProc(HWND hwndDlg, UINT msg, WPARAM wPar bool bChecked = (tab->iOptAutoDelete == -1) ? true : false; TCHAR buff[256]; - for (int i = 0; i < SIZEOF(times); i++) + for (int i = 0; i < _countof(times); i++) { if (i == 3 || i == 7) AppendMenu(hTimeMenu, MF_SEPARATOR, 0, 0); diff --git a/plugins/FTPFileYM/src/ftpfile.cpp b/plugins/FTPFileYM/src/ftpfile.cpp index ef6ffd166a..5b69b107fa 100644 --- a/plugins/FTPFileYM/src/ftpfile.cpp +++ b/plugins/FTPFileYM/src/ftpfile.cpp @@ -84,7 +84,7 @@ static IconItem iconList[] = static void InitIcolib() { - Icon_Register(hInst, LPGEN("FTP File"), iconList, SIZEOF(iconList), MODULE); + Icon_Register(hInst, LPGEN("FTP File"), iconList, _countof(iconList), MODULE); } void InitMenuItems() @@ -112,7 +112,7 @@ void InitMenuItems() for (int i = 0; i < ServerList::FTP_COUNT; i++) { if (DB::getStringF(0, MODULE, "Name%d", i, stzName)) - mir_sntprintf(stzName, SIZEOF(stzName), TranslateT("FTP Server %d"), i + 1); + mir_sntprintf(stzName, _countof(stzName), TranslateT("FTP Server %d"), i + 1); mi.flags = CMIF_TCHAR; mi.hParentMenu = 0; diff --git a/plugins/FTPFileYM/src/job_generic.cpp b/plugins/FTPFileYM/src/job_generic.cpp index 9fa21c5a5b..5683564719 100644 --- a/plugins/FTPFileYM/src/job_generic.cpp +++ b/plugins/FTPFileYM/src/job_generic.cpp @@ -54,7 +54,7 @@ int GenericJob::openFileDialog() ofn.nFilterIndex = 1; ofn.lpstrFile = this->stzFilePath; ofn.lpstrTitle = TranslateT("FTP File - Select files"); - ofn.nMaxFile = SIZEOF(this->stzFilePath); + ofn.nMaxFile = _countof(this->stzFilePath); ofn.Flags = OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST | OFN_ALLOWMULTISELECT | OFN_EXPLORER | OFN_NOCHANGEDIR; return GetOpenFileName(&ofn); } @@ -85,7 +85,7 @@ void GenericJob::getFilesFromOpenDialog() TCHAR *ptr = this->stzFilePath + length + 1; while (ptr[0]) { - mir_sntprintf(stzFile, SIZEOF(stzFile), _T("%s\\%s"), this->stzFilePath, ptr); + mir_sntprintf(stzFile, _countof(stzFile), _T("%s\\%s"), this->stzFilePath, ptr); this->addFile(stzFile); ptr += mir_tstrlen(ptr) + 1; } @@ -113,7 +113,7 @@ int GenericJob::getFilesFromFolder(TCHAR *stzFolder) { if (!(ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) { - mir_sntprintf(stzFile, SIZEOF(stzFile), _T("%s\\%s"), stzFolder, ffd.cFileName); + mir_sntprintf(stzFile, _countof(stzFile), _T("%s\\%s"), stzFolder, ffd.cFileName); this->addFile(stzFile); } diff --git a/plugins/FTPFileYM/src/job_packer.cpp b/plugins/FTPFileYM/src/job_packer.cpp index 11fe8c22fe..13b3b80844 100644 --- a/plugins/FTPFileYM/src/job_packer.cpp +++ b/plugins/FTPFileYM/src/job_packer.cpp @@ -55,9 +55,9 @@ void PackerJob::getZipFilePath() if (stzFileName[0] == '\0') mir_tstrcpy(stzFileName, _T("archive")); - GetTempPath(SIZEOF(buff), buff); + GetTempPath(_countof(buff), buff); - mir_sntprintf(this->stzFilePath, SIZEOF(this->stzFilePath), _T("%s%s.zip"), buff, stzFileName); + mir_sntprintf(this->stzFilePath, _countof(this->stzFilePath), _T("%s%s.zip"), buff, stzFileName); mir_tstrcpy(this->stzFileName, Utils::getFileNameFromPath(this->stzFilePath)); if (opt.bSetZipName) @@ -254,10 +254,10 @@ void PackerJob::updateStats() this->lastUpdateTick = dwNewTick; double speed = ((double)this->uiReaded / 1024)/(time(NULL) - this->startTS); - mir_sntprintf(this->tab->stzSpeed, SIZEOF(this->tab->stzSpeed), TranslateT("%0.1f kB/s"), speed); + mir_sntprintf(this->tab->stzSpeed, _countof(this->tab->stzSpeed), TranslateT("%0.1f kB/s"), speed); double perc = this->uiFileSize ? ((double)this->uiReaded / this->uiFileSize) * 100 : 0; - mir_sntprintf(this->tab->stzComplet, SIZEOF(this->tab->stzComplet), TranslateT("%0.1f%% (%d kB/%d kB)"), perc, (int)this->uiReaded/1024, (int)this->uiFileSize/1024); + mir_sntprintf(this->tab->stzComplet, _countof(this->tab->stzComplet), TranslateT("%0.1f%% (%d kB/%d kB)"), perc, (int)this->uiReaded/1024, (int)this->uiFileSize/1024); TCHAR buff[256]; long s = (this->uiFileSize - this->uiReaded) / (long)(speed * 1024); @@ -268,7 +268,7 @@ void PackerJob::updateStats() if (d > 0) mir_sntprintf(buff, _T("%dd %02d:%02d:%02d"), d, h, m, s); else mir_sntprintf(buff, _T("%02d:%02d:%02d"), h, m, s); - mir_sntprintf(this->tab->stzRemain, SIZEOF(this->tab->stzRemain), TranslateT("%s (%d kB/%d kB)"), buff, (this->uiFileSize - this->uiReaded)/1024, this->uiFileSize/1024); + mir_sntprintf(this->tab->stzRemain, _countof(this->tab->stzRemain), TranslateT("%s (%d kB/%d kB)"), buff, (this->uiFileSize - this->uiReaded)/1024, this->uiFileSize/1024); this->refreshTab(false); } @@ -338,7 +338,7 @@ void PackerJob::closeAllTabs() void PackerJob::createToolTip() { TCHAR *server = mir_a2t(this->ftp->szServer); - mir_sntprintf(uDlg->stzToolTipText, SIZEOF(uDlg->stzToolTipText), + mir_sntprintf(uDlg->stzToolTipText, _countof(uDlg->stzToolTipText), TranslateT("Status: %s\r\nFile: %s\r\nServer: %s"), this->getStatusString(), this->stzFileName, diff --git a/plugins/FTPFileYM/src/job_upload.cpp b/plugins/FTPFileYM/src/job_upload.cpp index 11601a67d4..88fa9b34e0 100644 --- a/plugins/FTPFileYM/src/job_upload.cpp +++ b/plugins/FTPFileYM/src/job_upload.cpp @@ -35,14 +35,14 @@ UploadJob::UploadJob(UploadJob *job) : GenericJob(job),fp(NULL),uiSent(0),uiTotalSent(0),uiFileSize(0) { mir_strcpy(this->szFileLink, job->szFileLink); - for (int i = 0; i < SIZEOF(this->lastSpeed); i++) + for (int i = 0; i < _countof(this->lastSpeed); i++) this->lastSpeed[i] = 0; } UploadJob::UploadJob(PackerJob *job) : GenericJob(job),fp(NULL),uiSent(0),uiTotalSent(0),uiFileSize(0) { - for (int i = 0; i < SIZEOF(this->lastSpeed); i++) + for (int i = 0; i < _countof(this->lastSpeed); i++) this->lastSpeed[i] = 0; Utils::makeSafeString(job->stzFileName, this->szSafeFileName); @@ -385,19 +385,19 @@ void UploadJob::updateStats() if (this->uiSent && (time(NULL) > this->startTS)) { double speed = ((double)this->uiSent / 1024)/(time(NULL) - this->startTS); this->avgSpeed = speed; - for (int i = 0; i < SIZEOF(this->lastSpeed); i++) { + for (int i = 0; i < _countof(this->lastSpeed); i++) { this->avgSpeed += (this->lastSpeed[i] == 0 ? speed : this->lastSpeed[i]); - if (i < SIZEOF(this->lastSpeed) - 1) + if (i < _countof(this->lastSpeed) - 1) this->lastSpeed[i + 1] = this->lastSpeed[i]; } - this->avgSpeed /= SIZEOF(this->lastSpeed) + 1; + this->avgSpeed /= _countof(this->lastSpeed) + 1; this->lastSpeed[0] = speed; - mir_sntprintf(this->tab->stzSpeed, SIZEOF(this->tab->stzSpeed), _T("%0.1f kB/s"), this->avgSpeed); + mir_sntprintf(this->tab->stzSpeed, _countof(this->tab->stzSpeed), _T("%0.1f kB/s"), this->avgSpeed); double perc = this->uiFileSize ? ((double)this->uiTotalSent / this->uiFileSize) * 100 : 0; - mir_sntprintf(this->tab->stzComplet, SIZEOF(this->tab->stzComplet), _T("%0.1f%% (%d kB/%d kB)"), perc, (int)this->uiTotalSent/1024, (int)this->uiFileSize/1024); + mir_sntprintf(this->tab->stzComplet, _countof(this->tab->stzComplet), _T("%0.1f%% (%d kB/%d kB)"), perc, (int)this->uiTotalSent/1024, (int)this->uiFileSize/1024); long s = (this->uiFileSize - this->uiTotalSent) / (long)(this->avgSpeed * 1024); int d = (s / 60 / 60 / 24); @@ -408,7 +408,7 @@ void UploadJob::updateStats() TCHAR buff[256]; if (d > 0) mir_sntprintf(buff, _T("%dd %02d:%02d:%02d"), d, h, m, s); else mir_sntprintf(buff, _T("%02d:%02d:%02d"), h, m, s); - mir_sntprintf(this->tab->stzRemain, SIZEOF(this->tab->stzRemain), _T("%s (%d kB/%d kB)"), buff, (this->uiFileSize - this->uiTotalSent)/1024, this->uiFileSize/1024); + mir_sntprintf(this->tab->stzRemain, _countof(this->tab->stzRemain), _T("%s (%d kB/%d kB)"), buff, (this->uiFileSize - this->uiTotalSent)/1024, this->uiFileSize/1024); this->refreshTab(false); } @@ -498,12 +498,12 @@ void UploadJob::closeAllTabs() void UploadJob::createToolTip() { TCHAR *server = mir_a2t(this->ftp->szServer); - mir_sntprintf(uDlg->stzToolTipText, SIZEOF(uDlg->stzToolTipText), + mir_sntprintf(uDlg->stzToolTipText, _countof(uDlg->stzToolTipText), TranslateT("Status: %s\r\nFile: %s\r\nServer: %s"), this->getStatusString(), this->stzFileName, server); if (this->tab->stzSpeed[0] && this->tab->stzComplet[0] && this->tab->stzRemain[0]) - mir_sntprintf(uDlg->stzToolTipText, SIZEOF(uDlg->stzToolTipText), + mir_sntprintf(uDlg->stzToolTipText, _countof(uDlg->stzToolTipText), TranslateT("%s\r\nSpeed: %s\r\nCompleted: %s\r\nRemaining: %s"), uDlg->stzToolTipText, this->tab->stzSpeed, this->tab->stzComplet, this->tab->stzRemain); diff --git a/plugins/FTPFileYM/src/options.cpp b/plugins/FTPFileYM/src/options.cpp index e7503416cb..a68bcd1496 100644 --- a/plugins/FTPFileYM/src/options.cpp +++ b/plugins/FTPFileYM/src/options.cpp @@ -153,13 +153,13 @@ INT_PTR CALLBACK Options::DlgProcOptsAccounts(HWND hwndDlg, UINT msg, WPARAM wPa opt.defaultFTP = opt.selected; ServerList::FTP *ftp = ftpList.getSelected(); - GetDlgItemText(hwndDlg, IDC_FTPLIST, ftp->stzName, SIZEOF(ftp->stzName)); - GetDlgItemTextA(hwndDlg, IDC_SERVER, ftp->szServer, SIZEOF(ftp->szServer)); - GetDlgItemTextA(hwndDlg, IDC_USER, ftp->szUser, SIZEOF(ftp->szUser)); - GetDlgItemTextA(hwndDlg, IDC_PASSWORD, ftp->szPass, SIZEOF(ftp->szPass)); - GetDlgItemTextA(hwndDlg, IDC_DIR, ftp->szDir, SIZEOF(ftp->szDir)); - GetDlgItemTextA(hwndDlg, IDC_URL, ftp->szUrl, SIZEOF(ftp->szUrl)); - GetDlgItemTextA(hwndDlg, IDC_CHMOD, ftp->szChmod, SIZEOF(ftp->szChmod)); + GetDlgItemText(hwndDlg, IDC_FTPLIST, ftp->stzName, _countof(ftp->stzName)); + GetDlgItemTextA(hwndDlg, IDC_SERVER, ftp->szServer, _countof(ftp->szServer)); + GetDlgItemTextA(hwndDlg, IDC_USER, ftp->szUser, _countof(ftp->szUser)); + GetDlgItemTextA(hwndDlg, IDC_PASSWORD, ftp->szPass, _countof(ftp->szPass)); + GetDlgItemTextA(hwndDlg, IDC_DIR, ftp->szDir, _countof(ftp->szDir)); + GetDlgItemTextA(hwndDlg, IDC_URL, ftp->szUrl, _countof(ftp->szUrl)); + GetDlgItemTextA(hwndDlg, IDC_CHMOD, ftp->szChmod, _countof(ftp->szChmod)); ftp->ftpProto = (ServerList::FTP::EProtoType)ComboBox_GetCurSel(GetDlgItem(hwndDlg, IDC_PROTOLIST)); ftp->iPort = GetDlgItemInt(hwndDlg, IDC_PORT, 0, 0); diff --git a/plugins/FTPFileYM/src/serverlist.cpp b/plugins/FTPFileYM/src/serverlist.cpp index 95c677b77c..bb20a4bb74 100644 --- a/plugins/FTPFileYM/src/serverlist.cpp +++ b/plugins/FTPFileYM/src/serverlist.cpp @@ -65,7 +65,7 @@ void ServerList::saveToDb() const ServerList::FTP::FTP(int index) { if (DB::getStringF(0, MODULE, "Name%d", index, this->stzName)) - mir_sntprintf(this->stzName, SIZEOF(this->stzName), TranslateT("FTP Server %d"), index + 1); + mir_sntprintf(this->stzName, _countof(this->stzName), TranslateT("FTP Server %d"), index + 1); DB::getAStringF(0, MODULE, "Password%d", index, this->szPass); DB::getAStringF(0, MODULE, "Server%d", index, this->szServer); -- cgit v1.2.3