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/TrafficCounter/src/TrafficCounter.cpp | 8 ++++---- plugins/TrafficCounter/src/misc.cpp | 16 ++++++++-------- plugins/TrafficCounter/src/options.cpp | 6 +++--- plugins/TrafficCounter/src/opttree.cpp | 4 ++-- plugins/TrafficCounter/src/statistics.cpp | 2 +- 5 files changed, 18 insertions(+), 18 deletions(-) (limited to 'plugins/TrafficCounter') diff --git a/plugins/TrafficCounter/src/TrafficCounter.cpp b/plugins/TrafficCounter/src/TrafficCounter.cpp index 7c54e5f271..5fff652c5f 100644 --- a/plugins/TrafficCounter/src/TrafficCounter.cpp +++ b/plugins/TrafficCounter/src/TrafficCounter.cpp @@ -214,7 +214,7 @@ int TrafficCounterModulesLoaded(WPARAM wParam, LPARAM lParam) if (db_get_ts(NULL, TRAFFIC_SETTINGS_GROUP, SETTINGS_COUNTER_FORMAT, &dbv) == 0) { if(mir_tstrlen(dbv.ptszVal) > 0) - mir_tstrncpy(Traffic_CounterFormat, dbv.ptszVal, SIZEOF(Traffic_CounterFormat)); + mir_tstrncpy(Traffic_CounterFormat, dbv.ptszVal, _countof(Traffic_CounterFormat)); // db_free(&dbv); } @@ -232,7 +232,7 @@ int TrafficCounterModulesLoaded(WPARAM wParam, LPARAM lParam) if (db_get_ts(NULL, TRAFFIC_SETTINGS_GROUP, SETTINGS_TOOLTIP_FORMAT, &dbv) == 0) { if(mir_tstrlen(dbv.ptszVal) > 0) - mir_tstrncpy(Traffic_TooltipFormat, dbv.ptszVal, SIZEOF(Traffic_TooltipFormat)); + mir_tstrncpy(Traffic_TooltipFormat, dbv.ptszVal, _countof(Traffic_TooltipFormat)); // db_free(&dbv); } @@ -1138,7 +1138,7 @@ void NotifyOnSend(void) ppd.lchIcon = Skin_LoadIcon(SKINICON_EVENT_MESSAGE); _tcsncpy(ppd.lptzContactName, TranslateT("Traffic counter notification"), MAX_CONTACTNAME); // - mir_sntprintf(ppd.lptzText, SIZEOF(ppd.lptzText), TranslateT("%d kilobytes sent"), + mir_sntprintf(ppd.lptzText, _countof(ppd.lptzText), TranslateT("%d kilobytes sent"), notify_send_size = OverallInfo.CurrentSentTraffic >> 10); // ppd.colorBack = Traffic_PopupBkColor; @@ -1157,7 +1157,7 @@ void NotifyOnRecv(void) ppd.lchIcon = Skin_LoadIcon(SKINICON_EVENT_MESSAGE); _tcsncpy(ppd.lptzContactName, TranslateT("Traffic counter notification"),MAX_CONTACTNAME); // - mir_sntprintf(ppd.lptzText, SIZEOF(ppd.lptzText), TranslateT("%d kilobytes received"), + mir_sntprintf(ppd.lptzText, _countof(ppd.lptzText), TranslateT("%d kilobytes received"), notify_recv_size = OverallInfo.CurrentRecvTraffic >> 10); // ppd.colorBack = Traffic_PopupBkColor; diff --git a/plugins/TrafficCounter/src/misc.cpp b/plugins/TrafficCounter/src/misc.cpp index fa304ad0de..2febe16560 100644 --- a/plugins/TrafficCounter/src/misc.cpp +++ b/plugins/TrafficCounter/src/misc.cpp @@ -153,7 +153,7 @@ size_t GetFormattedTraffic(DWORD Value, BYTE Unit, TCHAR *Buffer, size_t Size) return 0; } - mir_sntprintf(Str1, SIZEOF(Str1), _T("%d.%d"), Value / Divider, Value % Divider); + mir_sntprintf(Str1, _countof(Str1), _T("%d.%d"), Value / Divider, Value % Divider); size_t l = GetNumberFormat(LOCALE_USER_DEFAULT, 0, Str1, &nf, NULL, 0); if (!l) return 0; l += mir_tstrlen(szUnit) + 1; @@ -210,49 +210,49 @@ size_t GetDurationFormatM(DWORD Duration, TCHAR *Format, TCHAR *Buffer, WORD Siz if (!mir_tstrcmp(Token, _T("d"))) { q = Duration / (60 * 60 * 24); - mir_sntprintf(Token, SIZEOF(Token), _T("%d"), q); + mir_sntprintf(Token, _countof(Token), _T("%d"), q); Duration -= q * 60 * 60 * 24; } else if (!mir_tstrcmp(Token, _T("h"))) { q = Duration / (60 * 60); - mir_sntprintf(Token, SIZEOF(Token), _T("%d"), q); + mir_sntprintf(Token, _countof(Token), _T("%d"), q); Duration -= q * 60 * 60; } else if (!mir_tstrcmp(Token, _T("hh"))) { q = Duration / (60 * 60); - mir_sntprintf(Token, SIZEOF(Token), _T("%02d"), q); + mir_sntprintf(Token, _countof(Token), _T("%02d"), q); Duration -= q * 60 * 60; } else if (!mir_tstrcmp(Token, _T("m"))) { q = Duration / 60; - mir_sntprintf(Token, SIZEOF(Token), _T("%d"), q); + mir_sntprintf(Token, _countof(Token), _T("%d"), q); Duration -= q * 60; } else if (!mir_tstrcmp(Token, _T("mm"))) { q = Duration / 60; - mir_sntprintf(Token, SIZEOF(Token), _T("%02d"), q); + mir_sntprintf(Token, _countof(Token), _T("%02d"), q); Duration -= q * 60; } else if (!mir_tstrcmp(Token, _T("s"))) { q = Duration; - mir_sntprintf(Token, SIZEOF(Token), _T("%d"), q); + mir_sntprintf(Token, _countof(Token), _T("%d"), q); Duration -= q; } else if (!mir_tstrcmp(Token, _T("ss"))) { q = Duration; - mir_sntprintf(Token, SIZEOF(Token), _T("%02d"), q); + mir_sntprintf(Token, _countof(Token), _T("%02d"), q); Duration -= q; } diff --git a/plugins/TrafficCounter/src/options.cpp b/plugins/TrafficCounter/src/options.cpp index 127b89e4c1..f3a74a2dcd 100644 --- a/plugins/TrafficCounter/src/options.cpp +++ b/plugins/TrafficCounter/src/options.cpp @@ -182,7 +182,7 @@ static INT_PTR CALLBACK DlgProcTCOptions(HWND hwndDlg, UINT msg, WPARAM wParam, if (!Initialized) { pOptions = options; - optionCount = SIZEOF(options); + optionCount = _countof(options); // Если нет Variables, активируем галочки для старого метода рисования if (!bVariablesExists) for (i = 0; i < 8; i++) @@ -310,9 +310,9 @@ static INT_PTR CALLBACK DlgProcTCOptions(HWND hwndDlg, UINT msg, WPARAM wParam, unOptions.ShowOverall = OptTree_GetOptions(hwndDlg, IDC_APPEARANCEOPTIONS, options, optionCount, "ShowOverall"); // Формат счётчиков - GetDlgItemText(hwndDlg, IDC_EDIT_COUNTER_FORMAT, Traffic_CounterFormat, SIZEOF(Traffic_CounterFormat)); + GetDlgItemText(hwndDlg, IDC_EDIT_COUNTER_FORMAT, Traffic_CounterFormat, _countof(Traffic_CounterFormat)); // Формат всплывающей подсказки - GetDlgItemText(hwndDlg, IDC_EDIT_TOOLTIP_FORMAT, Traffic_TooltipFormat, SIZEOF(Traffic_TooltipFormat)); + GetDlgItemText(hwndDlg, IDC_EDIT_TOOLTIP_FORMAT, Traffic_TooltipFormat, _countof(Traffic_TooltipFormat)); // Ключевой цвет UseKeyColor = db_get_b(NULL, "ModernSettings", "UseKeyColor", 1); diff --git a/plugins/TrafficCounter/src/opttree.cpp b/plugins/TrafficCounter/src/opttree.cpp index 792b0022ef..846e9fef93 100644 --- a/plugins/TrafficCounter/src/opttree.cpp +++ b/plugins/TrafficCounter/src/opttree.cpp @@ -34,7 +34,7 @@ static void OptTree_TranslateItem(HWND hwndTree, HTREEITEM hItem) tvi.mask = TVIF_HANDLE|TVIF_TEXT; tvi.hItem = hItem; tvi.pszText = buf; - tvi.cchTextMax = SIZEOF(buf); + tvi.cchTextMax = _countof(buf); SendMessage(hwndTree, TVM_GETITEM, 0, (LPARAM)&tvi); // Проверим, надо ли переводить. if ((tvi.lParam != -1) && (pOptions[tvi.lParam].dwFlag & OPTTREE_NOTRANSLATE)) return; @@ -87,7 +87,7 @@ HTREEITEM OptTree_FindNamedTreeItemAt(HWND hwndTree, HTREEITEM hItem, const TCHA tvi.mask = TVIF_TEXT; tvi.pszText = str; - tvi.cchTextMax = SIZEOF(str); + tvi.cchTextMax = _countof(str); while (tvi.hItem) { diff --git a/plugins/TrafficCounter/src/statistics.cpp b/plugins/TrafficCounter/src/statistics.cpp index 52c64c4e7f..bd5a5ff6d2 100644 --- a/plugins/TrafficCounter/src/statistics.cpp +++ b/plugins/TrafficCounter/src/statistics.cpp @@ -319,7 +319,7 @@ void Stat_ReadFile(BYTE n) pszPath = Utils_ReplaceVarsT(_T("%miranda_userdata%\\statistics")); CreateDirectoryTreeT(pszPath); - mir_sntprintf(FileName, SIZEOF(FileName), _T("%s\\%S.stat"), pszPath, ProtoList[n].name); + mir_sntprintf(FileName, _countof(FileName), _T("%s\\%S.stat"), pszPath, ProtoList[n].name); mir_free(pszPath); GetLocalTime(&stNow); ProtoList[n].hFile = CreateFile(FileName, GENERIC_READ | GENERIC_WRITE, -- cgit v1.2.3