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 /plugins/DbChecker | |
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 'plugins/DbChecker')
-rw-r--r-- | plugins/DbChecker/src/main.cpp | 2 | ||||
-rw-r--r-- | plugins/DbChecker/src/openerror.cpp | 2 | ||||
-rw-r--r-- | plugins/DbChecker/src/progress.cpp | 2 | ||||
-rw-r--r-- | plugins/DbChecker/src/selectdb.cpp | 26 | ||||
-rw-r--r-- | plugins/DbChecker/src/wizard.cpp | 2 | ||||
-rw-r--r-- | plugins/DbChecker/src/worker.cpp | 4 |
6 files changed, 19 insertions, 19 deletions
diff --git a/plugins/DbChecker/src/main.cpp b/plugins/DbChecker/src/main.cpp index c7f1149dde..54166a4afb 100644 --- a/plugins/DbChecker/src/main.cpp +++ b/plugins/DbChecker/src/main.cpp @@ -73,7 +73,7 @@ static INT_PTR CheckProfile(WPARAM wParam, LPARAM lParam) bLaunchMiranda = lParam != 0;
bAutoExit = lParam == 2;
bServiceMode = false;
- _tcsncpy(opts.filename, (TCHAR*)wParam, SIZEOF(opts.filename));
+ _tcsncpy(opts.filename, (TCHAR*)wParam, _countof(opts.filename));
return DialogBox(hInst, MAKEINTRESOURCE(IDD_WIZARD), NULL, WizardDlgProc);
}
diff --git a/plugins/DbChecker/src/openerror.cpp b/plugins/DbChecker/src/openerror.cpp index 09cdb16243..49d4b88bf7 100644 --- a/plugins/DbChecker/src/openerror.cpp +++ b/plugins/DbChecker/src/openerror.cpp @@ -29,7 +29,7 @@ INT_PTR CALLBACK OpenErrorDlgProc(HWND hdlg, UINT message, WPARAM wParam, LPARAM case WM_INITDIALOG:
{
TCHAR szError[256];
- FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, opts.error, 0, szError, SIZEOF(szError), NULL);
+ FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, opts.error, 0, szError, _countof(szError), NULL);
SetDlgItemText(hdlg, IDC_ERRORTEXT, szError);
}
if (opts.error == ERROR_SHARING_VIOLATION) ShowWindow(GetDlgItem(hdlg, IDC_INUSE), SW_SHOW);
diff --git a/plugins/DbChecker/src/progress.cpp b/plugins/DbChecker/src/progress.cpp index 562f0cabb4..ff6a5d7202 100644 --- a/plugins/DbChecker/src/progress.cpp +++ b/plugins/DbChecker/src/progress.cpp @@ -34,7 +34,7 @@ void AddToStatus(int flags, const TCHAR* fmt, ...) va_start(vararg, fmt);
TCHAR str[256];
- mir_vsntprintf(str, SIZEOF(str), fmt, vararg);
+ mir_vsntprintf(str, _countof(str), fmt, vararg);
va_end(vararg);
int i = SendMessage(hwndStatus, LB_ADDSTRING, 0, (LPARAM)str);
diff --git a/plugins/DbChecker/src/selectdb.cpp b/plugins/DbChecker/src/selectdb.cpp index 65e5f69c67..2a04830ae0 100644 --- a/plugins/DbChecker/src/selectdb.cpp +++ b/plugins/DbChecker/src/selectdb.cpp @@ -36,7 +36,7 @@ int OpenDatabase(HWND hdlg, INT iNextPage) if (opts.dbChecker == NULL) {
DATABASELINK* dblink = FindDatabasePlugin(opts.filename);
if (dblink == NULL) {
- mir_sntprintf(tszMsg, SIZEOF(tszMsg),
+ mir_sntprintf(tszMsg, _countof(tszMsg),
TranslateT("Database Checker cannot find a suitable database plugin to open '%s'."),
opts.filename);
LBL_Error:
@@ -45,7 +45,7 @@ int OpenDatabase(HWND hdlg, INT iNextPage) }
if (dblink->CheckDB == NULL) {
- mir_sntprintf(tszMsg, SIZEOF(tszMsg),
+ mir_sntprintf(tszMsg, _countof(tszMsg),
TranslateT("Database driver '%s' doesn't support checking."),
TranslateTS(dblink->szFullName));
goto LBL_Error;
@@ -79,8 +79,8 @@ void GetProfileDirectory(TCHAR* szMirandaDir, TCHAR* szPath, int cbPath) mir_tstrcpy(szMirandaBootIni, szMirandaDir);
mir_tstrcat(szMirandaBootIni, _T("\\mirandaboot.ini"));
- GetPrivateProfileString(_T("Database"), _T("ProfileDir"), _T("./Profiles"), szProfileDir, SIZEOF(szProfileDir), szMirandaBootIni);
- ExpandEnvironmentStrings(szProfileDir, szExpandedProfileDir, SIZEOF(szExpandedProfileDir));
+ GetPrivateProfileString(_T("Database"), _T("ProfileDir"), _T("./Profiles"), szProfileDir, _countof(szProfileDir), szMirandaBootIni);
+ ExpandEnvironmentStrings(szProfileDir, szExpandedProfileDir, _countof(szExpandedProfileDir));
_tchdir(szMirandaDir);
if (!_tfullpath(szPath, szExpandedProfileDir, cbPath))
mir_tstrncpy(szPath, szMirandaDir, cbPath);
@@ -129,7 +129,7 @@ static int AddDatabaseToList(HWND hwndList, const TCHAR* filename, TCHAR* dir) int iNewItem = ListView_InsertItem(hwndList, &lvi);
TCHAR szSize[20];
- mir_sntprintf(szSize, SIZEOF(szSize), _T("%.2lf MB"), totalSize / 1048576.0);
+ mir_sntprintf(szSize, _countof(szSize), _T("%.2lf MB"), totalSize / 1048576.0);
ListView_SetItemText(hwndList, iNewItem, 1, szSize);
return iNewItem;
}
@@ -149,7 +149,7 @@ void FindAdd(HWND hdlg, TCHAR *szProfileDir, TCHAR *szPrefix) if (!(fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) || !mir_tstrcmp(fd.cFileName, _T(".")) || !mir_tstrcmp(fd.cFileName, _T("..")))
continue;
- mir_sntprintf(szFilename, SIZEOF(szFilename), _T("%s\\%s\\%s.dat"), szProfileDir, fd.cFileName, fd.cFileName);
+ mir_sntprintf(szFilename, _countof(szFilename), _T("%s\\%s\\%s.dat"), szProfileDir, fd.cFileName, fd.cFileName);
if (_taccess(szFilename, 0) == 0)
AddDatabaseToList(GetDlgItem(hdlg, IDC_DBLIST), szFilename, szPrefix);
} while (FindNextFile(hFind, &fd));
@@ -192,7 +192,7 @@ INT_PTR CALLBACK SelectDbDlgProc(HWND hdlg, UINT message, WPARAM wParam, LPARAM ListView_InsertColumn(GetDlgItem(hdlg, IDC_DBLIST), 1, &lvc);
TCHAR szMirandaPath[MAX_PATH];
- GetModuleFileName(NULL, szMirandaPath, SIZEOF(szMirandaPath));
+ GetModuleFileName(NULL, szMirandaPath, _countof(szMirandaPath));
TCHAR *str2 = _tcsrchr(szMirandaPath, '\\');
if (str2 != NULL)
*str2 = 0;
@@ -201,11 +201,11 @@ INT_PTR CALLBACK SelectDbDlgProc(HWND hdlg, UINT message, WPARAM wParam, LPARAM HKEY hKey;
TCHAR szProfileDir[MAX_PATH];
TCHAR szMirandaProfiles[MAX_PATH];
- DWORD cbData = SIZEOF(szMirandaPath);
+ DWORD cbData = _countof(szMirandaPath);
mir_tstrcpy(szMirandaProfiles, szMirandaPath);
mir_tstrcat(szMirandaProfiles, _T("\\Profiles"));
- GetProfileDirectory(szMirandaPath, szProfileDir, SIZEOF(szProfileDir));
+ GetProfileDirectory(szMirandaPath, szProfileDir, _countof(szProfileDir));
// search in profile dir (using ini file)
if (mir_tstrcmpi(szProfileDir, szMirandaProfiles))
@@ -219,7 +219,7 @@ INT_PTR CALLBACK SelectDbDlgProc(HWND hdlg, UINT message, WPARAM wParam, LPARAM if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("Software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\miranda32.exe"), 0, KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS) {
if (RegQueryValueEx(hKey, _T("Path"), NULL, NULL, (PBYTE)szMirandaPath, &cbData) == ERROR_SUCCESS) {
if (mir_tstrcmp(szProfileDir, szMirandaPath)) {
- GetProfileDirectory(szMirandaPath, szProfileDir, SIZEOF(szProfileDir));
+ GetProfileDirectory(szMirandaPath, szProfileDir, _countof(szProfileDir));
FindAdd(hdlg, szProfileDir, _T("[reg]\\"));
}
}
@@ -246,7 +246,7 @@ INT_PTR CALLBACK SelectDbDlgProc(HWND hdlg, UINT message, WPARAM wParam, LPARAM return TRUE;
case WZN_PAGECHANGING:
- GetDlgItemText(hdlg, IDC_FILE, opts.filename, SIZEOF(opts.filename));
+ GetDlgItemText(hdlg, IDC_FILE, opts.filename, _countof(opts.filename));
break;
case WM_COMMAND:
@@ -272,7 +272,7 @@ INT_PTR CALLBACK SelectDbDlgProc(HWND hdlg, UINT message, WPARAM wParam, LPARAM tmp = addstring(tmp, _T("*"));
*tmp = 0;
- GetDlgItemText(hdlg, IDC_FILE, str, SIZEOF(str));
+ GetDlgItemText(hdlg, IDC_FILE, str, _countof(str));
ofn.lStructSize = sizeof(ofn);
ofn.hwndOwner = hdlg;
ofn.hInstance = NULL;
@@ -280,7 +280,7 @@ INT_PTR CALLBACK SelectDbDlgProc(HWND hdlg, UINT message, WPARAM wParam, LPARAM ofn.lpstrDefExt = _T("dat");
ofn.lpstrFile = str;
ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
- ofn.nMaxFile = SIZEOF(str);
+ ofn.nMaxFile = _countof(str);
ofn.nMaxFileTitle = MAX_PATH;
if (GetOpenFileName(&ofn)) {
int i = AddDatabaseToList(GetDlgItem(hdlg, IDC_DBLIST), str, _T(""));
diff --git a/plugins/DbChecker/src/wizard.cpp b/plugins/DbChecker/src/wizard.cpp index 58448a4e0f..62f30e1c42 100644 --- a/plugins/DbChecker/src/wizard.cpp +++ b/plugins/DbChecker/src/wizard.cpp @@ -71,7 +71,7 @@ int DoMyControlProcessing(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam, case WM_CTLCOLORSTATIC:
if ((GetWindowLongPtr((HWND)lParam, GWL_STYLE) & 0xFFFF) == 0) {
char szText[256];
- GetWindowTextA((HWND)lParam, szText, SIZEOF(szText));
+ GetWindowTextA((HWND)lParam, szText, _countof(szText));
if (!mir_strcmp(szText, "whiterect")) {
SetTextColor((HDC)wParam, RGB(255, 255, 255));
SetBkColor((HDC)wParam, RGB(255, 255, 255));
diff --git a/plugins/DbChecker/src/worker.cpp b/plugins/DbChecker/src/worker.cpp index 708df28a97..c89063058b 100644 --- a/plugins/DbChecker/src/worker.cpp +++ b/plugins/DbChecker/src/worker.cpp @@ -54,9 +54,9 @@ static void Finalize(time_t& ts) }
for (int i = 1;; i++) {
if (i == 1)
- mir_sntprintf(opts.backupFilename, SIZEOF(opts.backupFilename), TranslateT("%s\\Backup of %s"), dbPath, dbFile);
+ mir_sntprintf(opts.backupFilename, _countof(opts.backupFilename), TranslateT("%s\\Backup of %s"), dbPath, dbFile);
else
- mir_sntprintf(opts.backupFilename, SIZEOF(opts.backupFilename), TranslateT("%s\\Backup (%d) of %s"), dbPath, i, dbFile);
+ mir_sntprintf(opts.backupFilename, _countof(opts.backupFilename), TranslateT("%s\\Backup (%d) of %s"), dbPath, i, dbFile);
if (_taccess(opts.backupFilename, 0) == -1) break;
}
|