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/AutoShutdown/src/frame.cpp | 16 ++++++++-------- plugins/AutoShutdown/src/main.cpp | 2 +- plugins/AutoShutdown/src/settingsdlg.cpp | 6 +++--- plugins/AutoShutdown/src/shutdownsvc.cpp | 2 +- plugins/AutoShutdown/src/utils.cpp | 10 +++++----- 5 files changed, 18 insertions(+), 18 deletions(-) (limited to 'plugins/AutoShutdown/src') diff --git a/plugins/AutoShutdown/src/frame.cpp b/plugins/AutoShutdown/src/frame.cpp index c01bf11b54..e66b12998e 100644 --- a/plugins/AutoShutdown/src/frame.cpp +++ b/plugins/AutoShutdown/src/frame.cpp @@ -358,8 +358,8 @@ static LRESULT CALLBACK FrameWndProc(HWND hwndFrame,UINT msg,WPARAM wParam,LPARA else { TCHAR szOutput[256]; if (dat->fTimeFlags&SDWTF_ST_TIME) - GetFormatedDateTime(szOutput,SIZEOF(szOutput),dat->settingLastTime,TRUE); - else GetFormatedCountdown(szOutput,SIZEOF(szOutput),dat->countdown); + GetFormatedDateTime(szOutput,_countof(szOutput),dat->settingLastTime,TRUE); + else GetFormatedCountdown(szOutput,_countof(szOutput),dat->countdown); SetWindowText(dat->hwndTime,szOutput); PostMessage(hwndFrame,M_CHECK_CLIPPED,0,0); /* update tooltip text (if shown) */ @@ -443,7 +443,7 @@ static LRESULT CALLBACK FrameWndProc(HWND hwndFrame,UINT msg,WPARAM wParam,LPARA HFONT hFontPrev=NULL; TCHAR szOutput[256]; dat->flags&=~FWPDF_TIMEISCLIPPED; - if (GetWindowText(dat->hwndTime,szOutput,SIZEOF(szOutput))) + if (GetWindowText(dat->hwndTime,szOutput,_countof(szOutput))) if (GetClientRect(dat->hwndTime,&rc)) { hdc=GetDC(dat->hwndTime); if (hdc != NULL) { @@ -484,17 +484,17 @@ static LRESULT CALLBACK FrameWndProc(HWND hwndFrame,UINT msg,WPARAM wParam,LPARA case TTN_NEEDTEXT: { NMTTDISPINFO *ttdi=(NMTTDISPINFO*)lParam; if (dat->flags&FWPDF_TIMEISCLIPPED && (HWND)wParam==dat->hwndTime) { - if (GetWindowText(dat->hwndTime,ttdi->szText,SIZEOF(ttdi->szText))) + if (GetWindowText(dat->hwndTime,ttdi->szText,_countof(ttdi->szText))) ttdi->lpszText=ttdi->szText; } else if ((HWND)wParam==dat->hwndIcon) ttdi->lpszText=TranslateT("Automatic Shutdown"); else { - TCHAR szTime[SIZEOF(ttdi->szText)]; + TCHAR szTime[_countof(ttdi->szText)]; if (dat->fTimeFlags&SDWTF_ST_TIME) - GetFormatedDateTime(szTime,SIZEOF(szTime),dat->settingLastTime,FALSE); - else GetFormatedCountdown(szTime,SIZEOF(szTime),dat->countdown); - mir_sntprintf(ttdi->szText,SIZEOF(ttdi->szText),_T("%s %s"),(dat->fTimeFlags&SDWTF_ST_TIME)?TranslateT("Shutdown at:"):TranslateT("Time left:"),szTime); + GetFormatedDateTime(szTime,_countof(szTime),dat->settingLastTime,FALSE); + else GetFormatedCountdown(szTime,_countof(szTime),dat->countdown); + mir_sntprintf(ttdi->szText,_countof(ttdi->szText),_T("%s %s"),(dat->fTimeFlags&SDWTF_ST_TIME)?TranslateT("Shutdown at:"):TranslateT("Time left:"),szTime); ttdi->lpszText=ttdi->szText; } return 0; diff --git a/plugins/AutoShutdown/src/main.cpp b/plugins/AutoShutdown/src/main.cpp index 7962e5fe6b..e7cdf5ac2d 100644 --- a/plugins/AutoShutdown/src/main.cpp +++ b/plugins/AutoShutdown/src/main.cpp @@ -76,7 +76,7 @@ extern "C" __declspec(dllexport) int Load(void) if (InitFrame()) return 1; /* before icons */ /* shared */ - Icon_Register(hInst, "Automatic Shutdown", iconList, SIZEOF(iconList)); + Icon_Register(hInst, "Automatic Shutdown", iconList, _countof(iconList)); InitShutdownSvc(); InitWatcher(); /* before InitSettingsDlg() */ diff --git a/plugins/AutoShutdown/src/settingsdlg.cpp b/plugins/AutoShutdown/src/settingsdlg.cpp index 207cdbaad2..89cdb08aed 100644 --- a/plugins/AutoShutdown/src/settingsdlg.cpp +++ b/plugins/AutoShutdown/src/settingsdlg.cpp @@ -45,7 +45,7 @@ static BOOL CALLBACK DisplayCpuUsageProc(BYTE nCpuUsage,LPARAM lParam) /* dialog closed? */ if (!IsWindow((HWND)lParam)) return FALSE; /* stop poll thread */ TCHAR str[64]; - mir_sntprintf(str,SIZEOF(str),TranslateT("(current: %u%%)"),nCpuUsage); + mir_sntprintf(str,_countof(str),TranslateT("(current: %u%%)"),nCpuUsage); SetWindowText((HWND)lParam,str); return TRUE; } @@ -116,8 +116,8 @@ static INT_PTR CALLBACK SettingsDlgProc(HWND hwndDlg,UINT msg,WPARAM wParam,LPAR HWND hwndCombo=GetDlgItem(hwndDlg,IDC_COMBO_COUNTDOWNUNIT); DWORD lastUnit=db_get_dw(NULL,"AutoShutdown","CountdownUnit",SETTING_COUNTDOWNUNIT_DEFAULT); SendMessage(hwndCombo,CB_SETLOCALE,(WPARAM)locale,0); /* sort order */ - SendMessage(hwndCombo,CB_INITSTORAGE,SIZEOF(unitNames),SIZEOF(unitNames)*16); /* approx. */ - for(int i=0;i