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/AssocMgr | |
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/AssocMgr')
-rw-r--r-- | plugins/AssocMgr/src/assoclist.cpp | 6 | ||||
-rw-r--r-- | plugins/AssocMgr/src/dde.cpp | 4 | ||||
-rw-r--r-- | plugins/AssocMgr/src/main.cpp | 4 | ||||
-rw-r--r-- | plugins/AssocMgr/src/reg.cpp | 18 | ||||
-rw-r--r-- | plugins/AssocMgr/src/test.cpp | 22 | ||||
-rw-r--r-- | plugins/AssocMgr/src/utils.cpp | 2 |
6 files changed, 28 insertions, 28 deletions
diff --git a/plugins/AssocMgr/src/assoclist.cpp b/plugins/AssocMgr/src/assoclist.cpp index a86a3542c1..5075e719ed 100644 --- a/plugins/AssocMgr/src/assoclist.cpp +++ b/plugins/AssocMgr/src/assoclist.cpp @@ -62,7 +62,7 @@ static void SetAssocEnabled(const ASSOCDATA *assoc, BOOL fEnabled) db_set_b(NULL, "AssocMgr", szSetting, (BYTE)fEnabled);
/* dll name for uninstall */
if(assoc->hInstance!= NULL && assoc->hInstance!= hInst && assoc->hInstance!= GetModuleHandle(NULL))
- if( GetModuleFileName(assoc->hInstance, szBuf, SIZEOF(szBuf)))
+ if( GetModuleFileName(assoc->hInstance, szBuf, _countof(szBuf)))
if( PathToRelativeT(szBuf, szDLL)) {
mir_snprintf(szSetting, "module_%s", assoc->pszClassName);
db_set_ts(NULL, "AssocMgr", szSetting, szDLL);
@@ -266,9 +266,9 @@ static TCHAR* GetAssocTypeDesc(const ASSOCDATA *assoc) {
static TCHAR szDesc[32];
if(assoc->pszFileExt == NULL)
- mir_sntprintf(szDesc, SIZEOF(szDesc), _T("%hs:"), assoc->pszClassName);
+ mir_sntprintf(szDesc, _countof(szDesc), _T("%hs:"), assoc->pszClassName);
else
- mir_sntprintf(szDesc, SIZEOF(szDesc), TranslateT("%hs files"), assoc->pszFileExt);
+ mir_sntprintf(szDesc, _countof(szDesc), TranslateT("%hs files"), assoc->pszFileExt);
return szDesc;
}
diff --git a/plugins/AssocMgr/src/dde.cpp b/plugins/AssocMgr/src/dde.cpp index 5fb674b22a..17706ab018 100644 --- a/plugins/AssocMgr/src/dde.cpp +++ b/plugins/AssocMgr/src/dde.cpp @@ -169,7 +169,7 @@ static HANDLE StartupMainProcess(TCHAR *pszDatabasePath) TCHAR *p,szPath[MAX_PATH];
/* we are inside RunDll32 here */
- if (!GetModuleFileName(hInst,szPath,SIZEOF(szPath))) return NULL;
+ if (!GetModuleFileName(hInst,szPath,_countof(szPath))) return NULL;
p=_tcsrchr(szPath,_T('\\'));
if(p!=NULL) { *p=0; p=_tcsrchr(szPath,_T('\\')); }
if(p==NULL) return NULL;
@@ -202,7 +202,7 @@ __declspec(dllexport) void CALLBACK WaitForDDE(HWND,HINSTANCE,TCHAR *pszCmdLine, if(pHandles[1]!=NULL) {
dwTick=GetTickCount();
/* either process terminated or dde window created */
- if(WaitForMultipleObjects(SIZEOF(pHandles),pHandles,FALSE,DDEMESSAGETIMEOUT)==WAIT_OBJECT_0) {
+ if(WaitForMultipleObjects(_countof(pHandles),pHandles,FALSE,DDEMESSAGETIMEOUT)==WAIT_OBJECT_0) {
dwTick=GetTickCount()-dwTick;
if(dwTick<DDEMESSAGETIMEOUT)
WaitForInputIdle(pHandles[1],DDEMESSAGETIMEOUT-dwTick);
diff --git a/plugins/AssocMgr/src/main.cpp b/plugins/AssocMgr/src/main.cpp index ea21bc1c59..51ac863238 100644 --- a/plugins/AssocMgr/src/main.cpp +++ b/plugins/AssocMgr/src/main.cpp @@ -48,7 +48,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD, LPVOID) static void InstallFile(const TCHAR *pszFileName,const TCHAR *pszDestSubDir)
{
TCHAR szFileFrom[MAX_PATH+1],szFileTo[MAX_PATH+1];
- if (!GetModuleFileName(hInst, szFileFrom, SIZEOF(szFileFrom) - (int)mir_tstrlen(pszFileName)))
+ if (!GetModuleFileName(hInst, szFileFrom, _countof(szFileFrom) - (int)mir_tstrlen(pszFileName)))
return;
TCHAR *p = _tcsrchr(szFileFrom,_T('\\'));
@@ -61,7 +61,7 @@ static void InstallFile(const TCHAR *pszFileName,const TCHAR *pszDestSubDir) return;
CloseHandle(hFile);
- if (!GetModuleFileName(NULL, szFileTo, SIZEOF(szFileTo)-(int)mir_tstrlen(pszDestSubDir)-(int)mir_tstrlen(pszFileName)))
+ if (!GetModuleFileName(NULL, szFileTo, _countof(szFileTo)-(int)mir_tstrlen(pszDestSubDir)-(int)mir_tstrlen(pszFileName)))
return;
p = _tcsrchr(szFileTo,_T('\\'));
if (p)
diff --git a/plugins/AssocMgr/src/reg.cpp b/plugins/AssocMgr/src/reg.cpp index 0917af9c93..13812e61d4 100644 --- a/plugins/AssocMgr/src/reg.cpp +++ b/plugins/AssocMgr/src/reg.cpp @@ -33,7 +33,7 @@ static __inline LONG regchk(LONG res, const char *pszFunc, const void *pszInfo, char *pszErr;
pszErr = GetWinErrorDescription(res);
pszInfo2 = s2t(pszInfo, fInfoUnicode, FALSE); /* does NULL check */
- mir_sntprintf(szMsg, SIZEOF(szMsg), TranslateT("Access failed:\n%.64hs(%.128s)\n%.250hs(%u)\n%.256hs (%u)"), pszFunc, pszInfo2, pszFile, nLine, pszErr, res);
+ mir_sntprintf(szMsg, _countof(szMsg), TranslateT("Access failed:\n%.64hs(%.128s)\n%.250hs(%u)\n%.256hs (%u)"), pszFunc, pszInfo2, pszFile, nLine, pszErr, res);
MessageBox(NULL, szMsg, TranslateT("Registry warning"), MB_OK | MB_ICONINFORMATION | MB_SETFOREGROUND | MB_TOPMOST | MB_TASKMODAL);
if (pszErr != NULL) LocalFree(pszErr);
mir_free(pszInfo2); /* does NULL check */
@@ -127,7 +127,7 @@ TCHAR *MakeRunCommand(BOOL fMirExe,BOOL fFixedDbProfile) {
TCHAR szDbFile[MAX_PATH], szExe[MAX_PATH], *pszFmt;
if (fFixedDbProfile) {
- if ( CallService(MS_DB_GETPROFILENAMET, SIZEOF(szDbFile), (LPARAM)szDbFile))
+ if ( CallService(MS_DB_GETPROFILENAMET, _countof(szDbFile), (LPARAM)szDbFile))
return NULL;
TCHAR *p = _tcsrchr(szDbFile, '.');
if (p)
@@ -135,7 +135,7 @@ TCHAR *MakeRunCommand(BOOL fMirExe,BOOL fFixedDbProfile) }
else mir_tstrcpy(szDbFile, _T("%1")); /* buffer safe */
- if ( !GetModuleFileName(fMirExe ? NULL : hInst, szExe, SIZEOF(szExe)))
+ if ( !GetModuleFileName(fMirExe ? NULL : hInst, szExe, _countof(szExe)))
return NULL;
if (fMirExe)
@@ -145,10 +145,10 @@ TCHAR *MakeRunCommand(BOOL fMirExe,BOOL fFixedDbProfile) /* run command for rundll32.exe calling WaitForDDE */
pszFmt = _T("rundll32.exe %s,WaitForDDE \"/profile:%s\"");
/* ensure the command line is not too long */
- GetShortPathName(szExe, szExe, SIZEOF(szExe));
+ GetShortPathName(szExe, szExe, _countof(szExe));
/* surround by quotes if failed */
size_t len = mir_tstrlen(szExe);
- if ( _tcschr(szExe,_T(' ')) != NULL && (len+2) < SIZEOF(szExe)) {
+ if ( _tcschr(szExe,_T(' ')) != NULL && (len+2) < _countof(szExe)) {
memmove(szExe, szExe+1, (len+1)*sizeof(TCHAR));
szExe[len+2] = szExe[0] = _T('\"');
szExe[len+3] = 0;
@@ -156,7 +156,7 @@ TCHAR *MakeRunCommand(BOOL fMirExe,BOOL fFixedDbProfile) }
TCHAR tszBuffer[1024];
- mir_sntprintf(tszBuffer, SIZEOF(tszBuffer), pszFmt, szExe, szDbFile);
+ mir_sntprintf(tszBuffer, _countof(tszBuffer), pszFmt, szExe, szDbFile);
return mir_tstrdup(tszBuffer);
}
@@ -176,7 +176,7 @@ static BOOL IsValidRunCommand(const TCHAR *pszRunCmd) if (pargs!=NULL) *pargs=0;
pexe=buf;
}
- if (SearchPath(NULL,pexe,_T(".exe"),SIZEOF(szFullExe),szFullExe,&pszFilePart)) {
+ if (SearchPath(NULL,pexe,_T(".exe"),_countof(szFullExe),szFullExe,&pszFilePart)) {
if (pszFilePart!=NULL)
if (!mir_tstrcmpi(pszFilePart,_T("rundll32.exe")) || !mir_tstrcmpi(pszFilePart,_T("rundll.exe"))) {
/* split into dll path and arguments */
@@ -200,7 +200,7 @@ TCHAR *MakeIconLocation(HMODULE hModule,WORD nIconResID) {
TCHAR szModule[MAX_PATH],*pszIconLoc=NULL;
int cch;
- if ((cch=GetModuleFileName(hModule,szModule,SIZEOF(szModule))) != 0) {
+ if ((cch=GetModuleFileName(hModule,szModule,_countof(szModule))) != 0) {
pszIconLoc=(TCHAR*)mir_alloc((cch+=8)*sizeof(TCHAR));
if (pszIconLoc!=NULL)
mir_sntprintf(pszIconLoc, cch, _T("%s,%i"), szModule, -(int)nIconResID); /* id may be 0, buffer safe */
@@ -212,7 +212,7 @@ TCHAR *MakeIconLocation(HMODULE hModule,WORD nIconResID) TCHAR *MakeAppFileName(BOOL fMirExe)
{
TCHAR szExe[MAX_PATH],*psz;
- if (GetModuleFileName(fMirExe?NULL:hInst,szExe,SIZEOF(szExe))) {
+ if (GetModuleFileName(fMirExe?NULL:hInst,szExe,_countof(szExe))) {
psz=_tcsrchr(szExe,_T('\\'));
if (psz!=NULL) ++psz;
else psz=szExe;
diff --git a/plugins/AssocMgr/src/test.cpp b/plugins/AssocMgr/src/test.cpp index 11f10513fe..cd4994331a 100644 --- a/plugins/AssocMgr/src/test.cpp +++ b/plugins/AssocMgr/src/test.cpp @@ -173,7 +173,7 @@ static int AimLinksModulesLoaded(WPARAM wParam,LPARAM lParam) char service_name[MAXMODULELABELLENGTH];
UNREFERENCED_PARAMETER(wParam);
UNREFERENCED_PARAMETER(lParam);
- mir_snprintf(service_name,SIZEOF(service_name),"%s%s",AIM_PROTOCOL_NAME,"ParseAimLink");
+ mir_snprintf(service_name,_countof(service_name),"%s%s",AIM_PROTOCOL_NAME,"ParseAimLink");
/* or "AOL Instant Messenger Links" */
AssocMgr_AddNewUrlType("aim:",Translate("AIM link protocol"),conn.hInstance,IDI_AOL,service_name,0);
return 0;
@@ -183,7 +183,7 @@ void aim_links_init() {
char service_name[MAXMODULELABELLENGTH];
//LOG(LOG_DEBUG,"Links: init");
- mir_snprintf(service_name,SIZEOF(service_name),"%s%s",AIM_PROTOCOL_NAME,"ParseAimLink");
+ mir_snprintf(service_name,_countof(service_name),"%s%s",AIM_PROTOCOL_NAME,"ParseAimLink");
hServiceParseLink=CreateServiceFunction(service_name,ServiceParseAimLink);
hHookModulesLoaded=HookEvent(ME_SYSTEM_MODULESLOADED,AimLinksModulesLoaded);
}
@@ -479,7 +479,7 @@ static int YmsgrLinksModulesLoaded(WPARAM wParam,LPARAM lParam) char szService[MAXMODULELABELLENGTH];
UNREFERENCED_PARAMETER(wParam);
UNREFERENCED_PARAMETER(lParam);
- mir_snprintf(szService,SIZEOF(szService),"%s%s",yahooProtocolName,"ParseYmsgrLink");
+ mir_snprintf(szService,_countof(szService),"%s%s",yahooProtocolName,"ParseYmsgrLink");
AssocMgr_AddNewUrlType("ymsgr:",Translate("Yahoo link protocol"),hinstance,IDI_YAHOO,szService,0);
return 0;
}
@@ -487,7 +487,7 @@ static int YmsgrLinksModulesLoaded(WPARAM wParam,LPARAM lParam) void YmsgrLinksInit(void)
{
char szService[MAXMODULELABELLENGTH];
- mir_snprintf(szService,SIZEOF(szService),"%s%s",yahooProtocolName,"ParseYmsgrLink");
+ mir_snprintf(szService,_countof(szService),"%s%s",yahooProtocolName,"ParseYmsgrLink");
hServiceParseYmsgrLink=CreateServiceFunction(szService,ServiceParseYmsgrLink);
hHookModulesLoaded=HookEvent(ME_SYSTEM_MODULESLOADED,YmsgrLinksModulesLoaded);
}
@@ -586,7 +586,7 @@ static int MsnLinksModulesLoaded(WPARAM wParam,LPARAM lParam) char szService[MAXMODULELABELLENGTH];
UNREFERENCED_PARAMETER(wParam);
UNREFERENCED_PARAMETER(lParam);
- mir_snprintf(szService,SIZEOF(szService),"%s%s",msnProtocolName,"ParseMsnimLink");
+ mir_snprintf(szService,_countof(szService),"%s%s",msnProtocolName,"ParseMsnimLink");
AssocMgr_AddNewUrlType("msnim:",Translate("MSN link protocol"),hInst,IDI_MSN,szService,0);
return 0;
}
@@ -594,7 +594,7 @@ static int MsnLinksModulesLoaded(WPARAM wParam,LPARAM lParam) int LoadMsnLinks(void)
{
char szService[MAXMODULELABELLENGTH];
- mir_snprintf(szService,SIZEOF(szService),"%s%s",msnProtocolName,"ParseMsnimLink");
+ mir_snprintf(szService,_countof(szService),"%s%s",msnProtocolName,"ParseMsnimLink");
hServiceParseMsnimLink=CreateServiceFunction(szService,ServiceParseMsnimLink);
hHookModulesLoaded=HookEvent(ME_SYSTEM_MODULESLOADED,MsnLinksModulesLoaded);
return 0;
@@ -651,7 +651,7 @@ static int LinksModulesLoaded(WPARAM wParam,LPARAM lParam) char szService[MAXMODULELABELLENGTH];
UNREFERENCED_PARAMETER(wParam);
UNREFERENCED_PARAMETER(lParam);
- mir_snprintf(szService,SIZEOF(szService),"%s%s",GG_PROTO,"ParseMsnimLink");
+ mir_snprintf(szService,_countof(szService),"%s%s",GG_PROTO,"ParseMsnimLink");
AssocMgr_AddNewUrlType("gg:",Translate("Gadu-Gadu link protocol"),hInstance,IDI_GG,szService,0);
return 0;
}
@@ -659,7 +659,7 @@ static int LinksModulesLoaded(WPARAM wParam,LPARAM lParam) void gg_registerlinks(void)
{
char szService[MAXMODULELABELLENGTH];
- mir_snprintf(szService,SIZEOF(szService),"%s%s",GG_PROTO,"ParseLink");
+ mir_snprintf(szService,_countof(szService),"%s%s",GG_PROTO,"ParseLink");
hServiceParseLink=CreateServiceFunction(szService,ServiceParseLink);
hHookModulesLoaded=HookEvent(ME_SYSTEM_MODULESLOADED,LinksModulesLoaded);
}
@@ -728,7 +728,7 @@ static int ServiceParseXmppURI(WPARAM wParam,LPARAM lParam) if(ServiceExists(MS_MSG_SENDMESSAGE)) {
hContact=JabberDBCreateContact(jid,jid,TRUE,FALSE);
if(subj!=NULL && body!=NULL) {
- mir_snprintf(msg,SIZEOF(msg),"%.128s %s",subj,body);
+ mir_snprintf(msg,_countof(msg),"%.128s %s",subj,body);
body=msg;
} else if(body==NULL) body=subj;
if(hContact!=NULL)
@@ -777,7 +777,7 @@ static int JabberLinksModulesLoaded(WPARAM wParam,LPARAM lParam) char szService[MAXMODULELABELLENGTH];
UNREFERENCED_PARAMETER(wParam);
UNREFERENCED_PARAMETER(lParam);
- mir_snprintf(szService,SIZEOF(szService),"%s%s",jabberProtoName,"ParseXmppURI");
+ mir_snprintf(szService,_countof(szService),"%s%s",jabberProtoName,"ParseXmppURI");
AssocMgr_AddNewUrlType("xmpp:",Translate("Jabber link protocol"),hInst,IDI_JABBER,szService,0);
return 0;
}
@@ -785,7 +785,7 @@ static int JabberLinksModulesLoaded(WPARAM wParam,LPARAM lParam) int JabberLinksInit()
{
char szService[MAXMODULELABELLENGTH];
- mir_snprintf(szService,SIZEOF(szService),"%s%s",jabberProtoName,"ParseXmppURI");
+ mir_snprintf(szService,_countof(szService),"%s%s",jabberProtoName,"ParseXmppURI");
hServiceParseXmppURI=CreateServiceFunction(szService,ServiceParseXmppURI);
hHookModulesLoaded=HookEvent(ME_SYSTEM_MODULESLOADED,JabberLinksModulesLoaded);
return 0;
diff --git a/plugins/AssocMgr/src/utils.cpp b/plugins/AssocMgr/src/utils.cpp index 0c76880e29..7f8ec8fbf2 100644 --- a/plugins/AssocMgr/src/utils.cpp +++ b/plugins/AssocMgr/src/utils.cpp @@ -143,7 +143,7 @@ void ShowInfoMessage(BYTE flags,const char *pszTitle,const char *pszTextFmt,...) va_list va;
va_start(va,pszTextFmt);
- mir_vsnprintf(szText,SIZEOF(szText),pszTextFmt,va);
+ mir_vsnprintf(szText,_countof(szText),pszTextFmt,va);
va_end(va);
if(ServiceExists(MS_CLIST_SYSTRAY_NOTIFY)) {
|