summaryrefslogtreecommitdiff
path: root/src/mir_core
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2014-07-16 13:43:06 +0000
committerGeorge Hazan <george.hazan@gmail.com>2014-07-16 13:43:06 +0000
commiteefe0f0d556fbf3d77602d0a99b9134505050756 (patch)
tree41eef7b1ea9fca98c8e22be29ba0eb07fffb19e1 /src/mir_core
parent9d8530d69c5896d91e8e9468e769a4eafb9cc53b (diff)
in _tcsncpy_s / _tcsncat_s / strncpy_s / strncat_s the second parameter to be omitted if the size of first one is fixed (not to contaminate sources with the excessive code)
git-svn-id: http://svn.miranda-ng.org/main/trunk@9829 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'src/mir_core')
-rw-r--r--src/mir_core/langpack.cpp10
-rw-r--r--src/mir_core/logger.cpp2
-rw-r--r--src/mir_core/protos.cpp24
3 files changed, 18 insertions, 18 deletions
diff --git a/src/mir_core/langpack.cpp b/src/mir_core/langpack.cpp
index 94ca9eff2e..435f7cb825 100644
--- a/src/mir_core/langpack.cpp
+++ b/src/mir_core/langpack.cpp
@@ -381,7 +381,7 @@ MIR_CORE_DLL(int) LoadLangPack(const TCHAR *ptszLangPack)
if (!PathIsAbsoluteT(ptszLangPack))
mir_sntprintf(tszFullPath, SIZEOF(tszFullPath), _T("%s\\%s"), g_tszRoot, ptszLangPack);
else
- _tcsncpy_s(tszFullPath, SIZEOF(tszFullPath), ptszLangPack, _TRUNCATE);
+ _tcsncpy_s(tszFullPath, ptszLangPack, _TRUNCATE);
// this lang is already loaded? nothing to do then
if (!lstrcmp(tszFullPath, langPack.tszFullPath))
@@ -397,9 +397,9 @@ MIR_CORE_DLL(int) LoadLangPack(const TCHAR *ptszLangPack)
return 3;
// copy the full file name and extract a file name from it
- _tcsncpy_s(langPack.tszFullPath, SIZEOF(langPack.tszFullPath), tszFullPath, _TRUNCATE);
+ _tcsncpy_s(langPack.tszFullPath, tszFullPath, _TRUNCATE);
TCHAR *p = _tcsrchr(langPack.tszFullPath, '\\');
- _tcsncpy_s(langPack.tszFileName, SIZEOF(langPack.tszFullPath), (p == NULL) ? tszFullPath : p + 1, _TRUNCATE);
+ _tcsncpy_s(langPack.tszFileName, (p == NULL) ? tszFullPath : p + 1, _TRUNCATE);
CharLower(langPack.tszFileName);
FILE *fp = _tfopen(tszFullPath, _T("rt"));
@@ -429,9 +429,9 @@ MIR_CORE_DLL(int) LoadLangPackDescr(const TCHAR *ptszLangPack, LANGPACK_INFO *lp
if (lpInfo == NULL)
return 1;
- _tcsncpy_s(lpInfo->tszFullPath, SIZEOF(lpInfo->tszFullPath), ptszLangPack, _TRUNCATE);
+ _tcsncpy_s(lpInfo->tszFullPath, ptszLangPack, _TRUNCATE);
TCHAR *p = _tcsrchr(lpInfo->tszFullPath, '\\');
- _tcsncpy_s(lpInfo->tszFileName, SIZEOF(lpInfo->tszFullPath), (p == NULL) ? ptszLangPack : p+1, _TRUNCATE);
+ _tcsncpy_s(lpInfo->tszFileName, (p == NULL) ? ptszLangPack : p+1, _TRUNCATE);
CharLower(lpInfo->tszFileName);
FILE *fp = _tfopen(ptszLangPack, _T("rt"));
diff --git a/src/mir_core/logger.cpp b/src/mir_core/logger.cpp
index 4f4aa1a353..e129f48765 100644
--- a/src/mir_core/logger.cpp
+++ b/src/mir_core/logger.cpp
@@ -115,7 +115,7 @@ MIR_CORE_DLL(HANDLE) mir_createLog(const char* pszName, const TCHAR *ptszDescr,
FILE *fp = _tfopen(ptszFile, _T("ab"));
if (fp == NULL) {
TCHAR tszPath[MAX_PATH];
- _tcsncpy_s(tszPath, SIZEOF(tszPath), ptszFile, _TRUNCATE);
+ _tcsncpy_s(tszPath, ptszFile, _TRUNCATE);
CreatePathToFileT(tszPath);
}
else fclose(fp);
diff --git a/src/mir_core/protos.cpp b/src/mir_core/protos.cpp
index ce752450b5..b8cacdd8fb 100644
--- a/src/mir_core/protos.cpp
+++ b/src/mir_core/protos.cpp
@@ -85,8 +85,8 @@ MIR_CORE_DLL(INT_PTR) ProtoCallService(const char *szModule, const char *szServi
return false;
char str[MAXMODULELABELLENGTH * 2];
- strncpy_s(str,szModule,strlen(szModule));
- strncat_s(str,szService,strlen(szService));
+ strncpy_s(str, szModule, _TRUNCATE);
+ strncat_s(str, szService, _TRUNCATE);
return CallService(str, wParam, lParam);
}
@@ -98,8 +98,8 @@ MIR_CORE_DLL(int) ProtoServiceExists(const char *szModule, const char *szService
return false;
char str[MAXMODULELABELLENGTH * 2];
- strncpy_s(str, szModule, strlen(szModule));
- strncat_s(str, szService, strlen(szService));
+ strncpy_s(str, szModule, _TRUNCATE);
+ strncat_s(str, szService, _TRUNCATE);
return ServiceExists(str);
}
@@ -123,16 +123,16 @@ MIR_CORE_DLL(void) ProtoDestructor(PROTO_INTERFACE *pThis)
MIR_CORE_DLL(void) ProtoCreateService(PROTO_INTERFACE *pThis, const char* szService, ProtoServiceFunc serviceProc)
{
char str[MAXMODULELABELLENGTH * 2];
- strncpy_s(str, pThis->m_szModuleName, strlen(pThis->m_szModuleName));
- strncat_s(str, szService, strlen(szService));
+ strncpy_s(str, pThis->m_szModuleName, _TRUNCATE);
+ strncat_s(str, szService, _TRUNCATE);
::CreateServiceFunctionObj(str, (MIRANDASERVICEOBJ)*(void**)&serviceProc, pThis);
}
MIR_CORE_DLL(void) ProtoCreateServiceParam(PROTO_INTERFACE *pThis, const char* szService, ProtoServiceFuncParam serviceProc, LPARAM lParam)
{
char str[MAXMODULELABELLENGTH * 2];
- strncpy_s(str, pThis->m_szModuleName, strlen(pThis->m_szModuleName));
- strncat_s(str, szService, strlen(szService));
+ strncpy_s(str, pThis->m_szModuleName, _TRUNCATE);
+ strncat_s(str, szService, _TRUNCATE);
::CreateServiceFunctionObjParam(str, (MIRANDASERVICEOBJPARAM)*(void**)&serviceProc, pThis, lParam);
}
@@ -144,21 +144,21 @@ MIR_CORE_DLL(void) ProtoHookEvent(PROTO_INTERFACE *pThis, const char* szEvent, P
MIR_CORE_DLL(HANDLE) ProtoCreateHookableEvent(PROTO_INTERFACE *pThis, const char* szName)
{
char str[MAXMODULELABELLENGTH * 2];
- strncpy_s(str, pThis->m_szModuleName, strlen(pThis->m_szModuleName));
- strncat_s(str, szName, strlen(szName));
+ strncpy_s(str, pThis->m_szModuleName, _TRUNCATE);
+ strncat_s(str, szName, _TRUNCATE);
return CreateHookableEvent(str);
}
MIR_CORE_DLL(void) ProtoForkThread(PROTO_INTERFACE *pThis, ProtoThreadFunc pFunc, void *param)
{
UINT threadID;
- CloseHandle((HANDLE)::mir_forkthreadowner((pThreadFuncOwner) *(void**)&pFunc, pThis, param, &threadID));
+ CloseHandle((HANDLE)::mir_forkthreadowner((pThreadFuncOwner)*(void**)&pFunc, pThis, param, &threadID));
}
MIR_CORE_DLL(HANDLE) ProtoForkThreadEx(PROTO_INTERFACE *pThis, ProtoThreadFunc pFunc, void *param, UINT* threadID)
{
UINT lthreadID;
- return (HANDLE)::mir_forkthreadowner((pThreadFuncOwner) *(void**)&pFunc, pThis, param, threadID ? threadID : &lthreadID);
+ return (HANDLE)::mir_forkthreadowner((pThreadFuncOwner)*(void**)&pFunc, pThis, param, threadID ? threadID : &lthreadID);
}
/////////////////////////////////////////////////////////////////////////////////////////