diff options
author | George Hazan <george.hazan@gmail.com> | 2014-07-16 13:43:06 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2014-07-16 13:43:06 +0000 |
commit | eefe0f0d556fbf3d77602d0a99b9134505050756 (patch) | |
tree | 41eef7b1ea9fca98c8e22be29ba0eb07fffb19e1 | |
parent | 9d8530d69c5896d91e8e9468e769a4eafb9cc53b (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
44 files changed, 168 insertions, 182 deletions
diff --git a/plugins/AVS/src/cache.cpp b/plugins/AVS/src/cache.cpp index 4e7c28bdab..999d9cba53 100644 --- a/plugins/AVS/src/cache.cpp +++ b/plugins/AVS/src/cache.cpp @@ -172,13 +172,13 @@ void NotifyMetaAware(MCONTACT hContact, CacheNode *node = NULL, AVATARCACHEENTRY // Get hash
char *szProto = GetContactProto(hContact);
if (szProto != NULL) {
- DBVARIANT dbv = {0};
- if ( !db_get_s(hContact, szProto, "AvatarHash", &dbv)) {
+ DBVARIANT dbv = { 0 };
+ if (!db_get_s(hContact, szProto, "AvatarHash", &dbv)) {
if (dbv.type == DBVT_TCHAR)
- _tcsncpy_s(cacn.hash, SIZEOF(cacn.hash), dbv.ptszVal, _TRUNCATE);
+ _tcsncpy_s(cacn.hash, dbv.ptszVal, _TRUNCATE);
else if (dbv.type == DBVT_BLOB) {
- ptrA szHash( mir_base64_encode(dbv.pbVal, dbv.cpbVal));
- _tcsncpy_s(cacn.hash, SIZEOF(cacn.hash), _A2T(szHash), _TRUNCATE);
+ ptrA szHash(mir_base64_encode(dbv.pbVal, dbv.cpbVal));
+ _tcsncpy_s(cacn.hash, _A2T(szHash), _TRUNCATE);
}
db_free(&dbv);
}
@@ -206,7 +206,7 @@ void DeleteAvatarFromCache(MCONTACT hContact, BOOL forever) hContact = GetContactThatHaveTheAvatar(hContact);
CacheNode *node = FindAvatarInCache(hContact, FALSE);
if (node == NULL) {
- struct CacheNode temp_node = {0};
+ struct CacheNode temp_node = { 0 };
temp_node.dwFlags |= (db_mc_isSub(hContact) ? MC_ISSUBCONTACT : 0);
NotifyMetaAware(hContact, &temp_node, (AVATARCACHEENTRY *)GetProtoDefaultAvatar(hContact));
return;
@@ -252,10 +252,10 @@ void PicLoader(LPVOID param) else if (dwDelay > 100)
dwDelay = 100;
- while(!g_shutDown) {
+ while (!g_shutDown) {
CacheNode *node = g_Cache;
- while(!g_shutDown && node) {
+ while (!g_shutDown && node) {
if (node->mustLoad > 0 && node->ace.hContact) {
node->mustLoad = 0;
AVATARCACHEENTRY ace_temp;
diff --git a/plugins/AVS/src/utils.cpp b/plugins/AVS/src/utils.cpp index 244282cc25..e4ab45e2ff 100644 --- a/plugins/AVS/src/utils.cpp +++ b/plugins/AVS/src/utils.cpp @@ -244,7 +244,7 @@ int CreateAvatarInCache(MCONTACT hContact, avatarCacheEntry *ace, char *szProto) if ( lstrlen(tszFilename) < 4)
return -1;
- _tcsncpy_s(tszFilename, SIZEOF(tszFilename), VARST(tszFilename), _TRUNCATE);
+ _tcsncpy_s(tszFilename, VARST(tszFilename), _TRUNCATE);
if ((hFile = CreateFile(tszFilename, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE)
return -2;
diff --git a/plugins/BasicHistory/src/EventList.cpp b/plugins/BasicHistory/src/EventList.cpp index 6a822b8312..d114f3eae6 100644 --- a/plugins/BasicHistory/src/EventList.cpp +++ b/plugins/BasicHistory/src/EventList.cpp @@ -492,10 +492,10 @@ std::wstring EventList::GetContactId() static void GetMessageDescription( DBEVENTINFO *dbei, TCHAR* buf, int cbBuf )
{
- TCHAR* msg = DbGetEventTextT( dbei, CP_ACP );
- _tcsncpy_s(buf, cbBuf, msg ? msg : TranslateT("Invalid Message"), cbBuf - 1 );
- buf[ cbBuf-1 ] = 0;
- mir_free( msg );
+ TCHAR *msg = DbGetEventTextT(dbei, CP_ACP);
+ _tcsncpy_s(buf, cbBuf, msg ? msg : TranslateT("Invalid Message"), _TRUNCATE);
+ buf[cbBuf - 1] = 0;
+ mir_free(msg);
}
void EventList::GetObjectDescription( DBEVENTINFO *dbei, TCHAR* str, int cbStr )
diff --git a/plugins/BasicHistory/src/Options.cpp b/plugins/BasicHistory/src/Options.cpp index 0d0e56198c..bed9f30bdb 100644 --- a/plugins/BasicHistory/src/Options.cpp +++ b/plugins/BasicHistory/src/Options.cpp @@ -244,27 +244,27 @@ void Options::Load(void) fid.cbSize = sizeof(FontIDT);
cid.cbSize = sizeof(ColourIDT);
hid.cbSize = sizeof(HOTKEYDESC);
- strncpy_s(fid.dbSettingsGroup, "BasicHistory_Fonts", SIZEOF(fid.dbSettingsGroup));
- _tcsncpy_s(fid.backgroundGroup, _T("History"), SIZEOF(fid.backgroundGroup));
- _tcsncpy_s(fid.group, LPGENT("History"), SIZEOF(fid.group));
+ strncpy_s(fid.dbSettingsGroup, "BasicHistory_Fonts", _TRUNCATE);
+ _tcsncpy_s(fid.backgroundGroup, _T("History"), _TRUNCATE);
+ _tcsncpy_s(fid.group, LPGENT("History"), _TRUNCATE);
for (int i = 0; i < g_fontsSize; ++i) {
fid.order = i;
- _tcsncpy_s(fid.deffontsettings.szFace, g_FontOptionsList[i].szDefFace, LF_FACESIZE);
+ _tcsncpy_s(fid.deffontsettings.szFace, g_FontOptionsList[i].szDefFace, _TRUNCATE);
fid.deffontsettings.size = g_FontOptionsList[i].defSize;
fid.deffontsettings.colour = g_FontOptionsList[i].defColour;
fid.deffontsettings.style = g_FontOptionsList[i].defStyle;
fid.deffontsettings.charset = DEFAULT_CHARSET;
mir_snprintf(fid.prefix, SIZEOF(fid.prefix), "Font%d", i);
- _tcsncpy_s(fid.name, g_FontOptionsList[i].szDescr, SIZEOF(fid.name));
- _tcsncpy_s(fid.backgroundName, g_FontOptionsList[i].szBackgroundName, SIZEOF(fid.name));
+ _tcsncpy_s(fid.name, g_FontOptionsList[i].szDescr, _TRUNCATE);
+ _tcsncpy_s(fid.backgroundName, g_FontOptionsList[i].szBackgroundName, _TRUNCATE);
fid.flags = FIDF_DEFAULTVALID | FIDF_CLASSGENERAL | g_FontOptionsList[i].flags;
FontRegisterT(&fid);
}
- strncpy_s(cid.dbSettingsGroup, "BasicHistory_Fonts", SIZEOF(fid.dbSettingsGroup));
- _tcsncpy_s(cid.group, LPGENT("History"), SIZEOF(fid.group));
+ strncpy_s(cid.dbSettingsGroup, "BasicHistory_Fonts", _TRUNCATE);
+ _tcsncpy_s(cid.group, LPGENT("History"), _TRUNCATE);
for (int i = 0; i < g_colorsSize; ++i) {
- _tcsncpy_s(cid.name, g_ColorOptionsList[i].tszName, SIZEOF(cid.name));
+ _tcsncpy_s(cid.name, g_ColorOptionsList[i].tszName, _TRUNCATE);
mir_snprintf(cid.setting, SIZEOF(cid.setting), "Color%d", i);
cid.order = i;
cid.defcolour = g_ColorOptionsList[i].def;
@@ -417,8 +417,8 @@ COLORREF Options::GetFont(Fonts fontId, PLOGFONT font) {
FontIDT fid = {0};
fid.cbSize = sizeof(FontIDT);
- _tcsncpy_s(fid.group, LPGENT("History"), SIZEOF(fid.group));
- _tcsncpy_s(fid.name, g_FontOptionsList[fontId].szDescr, SIZEOF(fid.name));
+ _tcsncpy_s(fid.group, LPGENT("History"), _TRUNCATE);
+ _tcsncpy_s(fid.name, g_FontOptionsList[fontId].szDescr, _TRUNCATE);
return (COLORREF)CallService(MS_FONT_GETT, (WPARAM)&fid, (LPARAM)font);
}
@@ -426,8 +426,8 @@ COLORREF Options::GetColor(Colors colorId) {
ColourIDT cid = {0};
cid.cbSize = sizeof(ColourIDT);
- _tcsncpy_s(cid.group, LPGENT("History"), SIZEOF(cid.group));
- _tcsncpy_s(cid.name, g_ColorOptionsList[colorId].tszName, SIZEOF(cid.name));
+ _tcsncpy_s(cid.group, LPGENT("History"), _TRUNCATE);
+ _tcsncpy_s(cid.name, g_ColorOptionsList[colorId].tszName, _TRUNCATE);
return (COLORREF)CallService(MS_COLOUR_GETT, (WPARAM)&cid, NULL);
}
diff --git a/plugins/Clist_modern/src/modern_tbbutton.cpp b/plugins/Clist_modern/src/modern_tbbutton.cpp index 2825a8259d..4274347583 100644 --- a/plugins/Clist_modern/src/modern_tbbutton.cpp +++ b/plugins/Clist_modern/src/modern_tbbutton.cpp @@ -240,7 +240,7 @@ static LRESULT CALLBACK ToolbarButtonProc(HWND hwndDlg, UINT msg, WPARAM wParam break;
case WM_SETTEXT:
- _tcsncpy_s(bct->szText, SIZEOF(bct->szText), (TCHAR*)lParam, _TRUNCATE);
+ _tcsncpy_s(bct->szText, (TCHAR*)lParam, _TRUNCATE);
break;
case WM_SETFONT:
diff --git a/plugins/Clist_mw/src/clcfonts.cpp b/plugins/Clist_mw/src/clcfonts.cpp index 7794139d37..de73ee3600 100644 --- a/plugins/Clist_mw/src/clcfonts.cpp +++ b/plugins/Clist_mw/src/clcfonts.cpp @@ -66,7 +66,7 @@ void RegisterCListFonts() pcli->pfnGetFontSetting(i, &lf, &fontid.deffontsettings.colour);
lf.lfHeight = -MulDiv(lf.lfHeight, GetDeviceCaps(hdc, LOGPIXELSY), 72);
- _tcsncpy_s(fontid.deffontsettings.szFace, SIZEOF(fontid.deffontsettings.szFace), lf.lfFaceName, _TRUNCATE);
+ _tcsncpy_s(fontid.deffontsettings.szFace, lf.lfFaceName, _TRUNCATE);
fontid.deffontsettings.charset = lf.lfCharSet;
fontid.deffontsettings.size = (char)lf.lfHeight;
fontid.deffontsettings.style = (lf.lfWeight >= FW_BOLD ? DBFONTF_BOLD : 0) | (lf.lfItalic ? DBFONTF_ITALIC : 0);
diff --git a/plugins/Clist_nicer/src/CLCButton.cpp b/plugins/Clist_nicer/src/CLCButton.cpp index 5cbf3fd6d6..a01c7b45bd 100644 --- a/plugins/Clist_nicer/src/CLCButton.cpp +++ b/plugins/Clist_nicer/src/CLCButton.cpp @@ -390,7 +390,7 @@ static LRESULT CALLBACK TSButtonWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPAR break;
case WM_SETTEXT:
- _tcsncpy_s(bct->szText, SIZEOF(bct->szText), (TCHAR*)lParam, _TRUNCATE);
+ _tcsncpy_s(bct->szText, (TCHAR*)lParam, _TRUNCATE);
break;
case BM_GETIMAGE:
diff --git a/plugins/Clist_nicer/src/clui.cpp b/plugins/Clist_nicer/src/clui.cpp index 9b8263034c..20c8e4a103 100644 --- a/plugins/Clist_nicer/src/clui.cpp +++ b/plugins/Clist_nicer/src/clui.cpp @@ -2061,7 +2061,7 @@ void FS_RegisterFonts() pcli->pfnGetFontSetting(i, &lf, &fid.deffontsettings.colour);
lf.lfHeight = -MulDiv(lf.lfHeight, GetDeviceCaps(hdc, LOGPIXELSY), 72);
- _tcsncpy_s(fid.deffontsettings.szFace, SIZEOF(fid.deffontsettings.szFace), lf.lfFaceName, _TRUNCATE);
+ _tcsncpy_s(fid.deffontsettings.szFace, lf.lfFaceName, _TRUNCATE);
fid.deffontsettings.charset = lf.lfCharSet;
fid.deffontsettings.size = (char)lf.lfHeight;
fid.deffontsettings.style = (lf.lfWeight >= FW_BOLD ? DBFONTF_BOLD : 0) | (lf.lfItalic ? DBFONTF_ITALIC : 0);
diff --git a/plugins/ConnectionNotify/src/ConnectionNotify.cpp b/plugins/ConnectionNotify/src/ConnectionNotify.cpp index 91be0a6a42..7c2ffab9e5 100644 --- a/plugins/ConnectionNotify/src/ConnectionNotify.cpp +++ b/plugins/ConnectionNotify/src/ConnectionNotify.cpp @@ -72,11 +72,11 @@ BOOL strrep(TCHAR *src,TCHAR *needle,TCHAR *newstring) return FALSE;
pos=(int)(found-src);
- _tcsncpy_s(begining,_countof(begining),src,pos);
+ _tcsncpy_s(begining, src, pos);
begining[pos]='\0';
pos=pos+(int)_tcslen(needle);
- _tcsncpy_s(tail,_countof(tail),src+pos,sizeof(tail));
+ _tcsncpy_s(tail, src+pos, _TRUNCATE);
begining[pos]='\0';
pos=mir_sntprintf(src,_tcslen(src),_T("%s%s%s"),begining,newstring,tail);
diff --git a/plugins/Exchange/src/emails.cpp b/plugins/Exchange/src/emails.cpp index 696c595b02..d6dd60bc79 100644 --- a/plugins/Exchange/src/emails.cpp +++ b/plugins/Exchange/src/emails.cpp @@ -61,7 +61,7 @@ int CExchangeServer::Connect(int bForceConnect) GetStringFromDatabase("Username", _T(""), user, _countof(user));
if (ServiceExists(MS_UTILS_REPLACEVARS))
- _tcsncpy_s(user, _countof(user), VARST(user), _TRUNCATE);
+ _tcsncpy_s(user, VARST(user), _TRUNCATE);
GetStringFromDatabase("Password", _T(""), password, _countof(password));
GetStringFromDatabase("Server", _T(""), server, _countof(server));
diff --git a/plugins/HistoryLinkListPlus/src/linklist_fct.cpp b/plugins/HistoryLinkListPlus/src/linklist_fct.cpp index 40d45560fa..81dc82af75 100644 --- a/plugins/HistoryLinkListPlus/src/linklist_fct.cpp +++ b/plugins/HistoryLinkListPlus/src/linklist_fct.cpp @@ -150,7 +150,7 @@ int ExtractURI(DBEVENTINFO *dbei, HANDLE hEvent, LISTELEMENT *listStart) if ( (_tcsstr(wordsearch, _T("www.")) != NULL) && (_tcsstr(wordsearch, _T("http://")) == NULL))
{
- _tcsncpy_s(link, _countof(link), _T("http://"), _mstrlen(_T("http://")));
+ _tcsncpy_s(link, _T("http://"), _mstrlen(_T("http://")));
// Link longer than defined max -> cut link to max
if ( (i-wordStart+1) > (int)(LINK_MAX-_mstrlen(_T("http://"))))
_tcsncpy_s(link + _mstrlen(_T("http://")), _countof(link), word, LINK_MAX - _mstrlen(_T("http://")));
@@ -164,7 +164,7 @@ int ExtractURI(DBEVENTINFO *dbei, HANDLE hEvent, LISTELEMENT *listStart) link_size = LINK_MAX;
else
link_size = i-wordStart+1;
- _tcsncpy_s(link, _countof(link), word, link_size);
+ _tcsncpy_s(link, word, link_size);
}
dbtimestring.szFormat = _T("d-t");
@@ -173,8 +173,8 @@ int ExtractURI(DBEVENTINFO *dbei, HANDLE hEvent, LISTELEMENT *listStart) CallService(MS_DB_TIME_TIMESTAMPTOSTRINGT,(WPARAM)dbei->timestamp, (LPARAM)&dbtimestring);
date_ptr = _tcstok_s(dbdate, _T("-"), &tok_ctx);
time_ptr = _tcstok_s(NULL, _T("-"), &tok_ctx);
- _tcsncpy_s(date, _countof(date), date_ptr, DATE_SIZE);
- _tcsncpy_s(time, _countof(time), time_ptr, TIME_SIZE);
+ _tcsncpy_s(date, date_ptr, _TRUNCATE);
+ _tcsncpy_s(time, time_ptr, _TRUNCATE);
// Prevent overflow
date[DATE_SIZE] = _T('\0');
time[TIME_SIZE] = _T('\0');
@@ -187,9 +187,9 @@ int ExtractURI(DBEVENTINFO *dbei, HANDLE hEvent, LISTELEMENT *listStart) if ( type == LINK_MAIL && _tcsstr(link, _T("mailto:")) == NULL )
{
- _tcsncpy_s(templink, _countof(templink), link, LINK_MAX-1);
- _tcsncpy_s(link, _countof(link), _T("mailto:"), LINK_MAX-1);
- _tcsncpy_s(link + _mstrlen(_T("mailto:")), _countof(link), templink, LINK_MAX-_mstrlen(_T("mailto:"))-1);
+ _tcsncpy_s(templink, link, _TRUNCATE);
+ _tcsncpy_s(link, _T("mailto:"), _TRUNCATE);
+ _tcsncpy_s(link + _mstrlen(_T("mailto:")), _countof(link), templink, _TRUNCATE);
}
// Add new Element to list:
@@ -200,9 +200,9 @@ int ExtractURI(DBEVENTINFO *dbei, HANDLE hEvent, LISTELEMENT *listStart) ZeroMemory(newElement, sizeof(LISTELEMENT));
newElement->direction = direction;
newElement->type = type;
- _tcsncpy_s(newElement->date, _countof(newElement->date), date, DATE_SIZE-1);
- _tcsncpy_s(newElement->time, _countof(newElement->time), time, TIME_SIZE-1);
- _tcsncpy_s(newElement->link, _countof(newElement->link), link, LINK_MAX-1);
+ _tcsncpy_s(newElement->date, date, _TRUNCATE);
+ _tcsncpy_s(newElement->time, time, _TRUNCATE);
+ _tcsncpy_s(newElement->link, link, _TRUNCATE);
newElement->hEvent = hEvent;
actualElement = listStart;
@@ -334,7 +334,7 @@ void WriteLinkList(HWND hDlg, BYTE params, LISTELEMENT *listStart, LPCTSTR searc cf.dwMask = CFM_ITALIC | CFM_BOLD | CFM_FACE | CFM_COLOR;
cf.dwEffects = CFE_BOLD;
cf.crTextColor = colourSet.text;
- _tcscpy_s(cf.szFaceName, _countof(cf.szFaceName), _T("Arial"));
+ _tcscpy_s(cf.szFaceName, _T("Arial"));
SendDlgItemMessage( hDlg, IDC_MAIN, EM_SETCHARFORMAT, SCF_SELECTION | SCF_WORD, (LPARAM) &cf);
ZeroMemory(searchText, _countof(searchText)*sizeof(TCHAR));
@@ -346,7 +346,7 @@ void WriteLinkList(HWND hDlg, BYTE params, LISTELEMENT *listStart, LPCTSTR searc ZeroMemory(&cf, sizeof(cf));
cf.cbSize = sizeof(cf);
cf.dwMask = CFM_FACE | CFM_BOLD;
- _tcscpy_s(cf.szFaceName, _countof(cf.szFaceName), _T("Courier"));
+ _tcscpy_s(cf.szFaceName, _T("Courier"));
SendDlgItemMessage( hDlg, IDC_MAIN, EM_SETCHARFORMAT, SCF_SELECTION | SCF_WORD, (LPARAM)&cf);
}
@@ -357,13 +357,13 @@ void WriteLinkList(HWND hDlg, BYTE params, LISTELEMENT *listStart, LPCTSTR searc linePos = GetLastLinePos(listStart);
if ((realListCount - append) == 1)
- _tcscpy_s(lastDate, _countof(lastDate), actualElement->date);
+ _tcscpy_s(lastDate, actualElement->date);
for(appCount = 1; appCount <= (realListCount - append); appCount++)
{
actualElement = actualElement->nextElement;
if(appCount == (realListCount - append - 1))
- _tcscpy_s(lastDate, _countof(lastDate), actualElement->date);
+ _tcscpy_s(lastDate, actualElement->date);
}
gtl.flags = GTL_PRECISE;
gtl.codepage = CP_ACP;
@@ -447,7 +447,7 @@ void WriteLinkList(HWND hDlg, BYTE params, LISTELEMENT *listStart, LPCTSTR searc cf.cbSize = sizeof(cf);
cf.dwMask = CFM_ITALIC | CFM_BOLD | CFM_FACE;
cf.dwEffects = CFE_BOLD;
- _tcscpy_s(cf.szFaceName, _countof(cf.szFaceName), _T("Arial"));
+ _tcscpy_s(cf.szFaceName, _T("Arial"));
SendDlgItemMessage( hDlg, IDC_MAIN, EM_SETCHARFORMAT, SCF_SELECTION | SCF_WORD, (LPARAM) &cf);
if ( options.showDate != 0 )
{
@@ -455,11 +455,11 @@ void WriteLinkList(HWND hDlg, BYTE params, LISTELEMENT *listStart, LPCTSTR searc SendDlgItemMessage( hDlg, IDC_MAIN, EM_REPLACESEL, FALSE, (LPARAM) _T("\n\n"));
linePos += 3;
}
- _tcscpy_s(lastDate, _countof(lastDate), actualElement->date);
+ _tcscpy_s(lastDate, actualElement->date);
ZeroMemory( &cf, sizeof(cf));
cf.cbSize = sizeof cf;
cf.dwMask = CFM_ITALIC | CFM_BOLD | CFM_UNDERLINE | CFM_FACE;
- _tcscpy_s(cf.szFaceName, _countof(cf.szFaceName), _T("Courier"));
+ _tcscpy_s(cf.szFaceName, _T("Courier"));
SendDlgItemMessage( hDlg, IDC_MAIN, EM_SETCHARFORMAT, SCF_SELECTION | SCF_WORD, (LPARAM) &cf);
}
ZeroMemory( &cf, sizeof(cf));
@@ -517,7 +517,7 @@ void WriteLinkList(HWND hDlg, BYTE params, LISTELEMENT *listStart, LPCTSTR searc cf.cbSize = sizeof(cf);
cf.dwMask = CFM_ITALIC | CFM_BOLD | CFM_FACE;
cf.dwEffects = CFE_BOLD;
- _tcscpy_s(cf.szFaceName, _countof(cf.szFaceName), _T("Arial"));
+ _tcscpy_s(cf.szFaceName, _T("Arial"));
SendDlgItemMessage( hDlg, IDC_MAIN, EM_SETCHARFORMAT, SCF_SELECTION | SCF_WORD, (LPARAM) &cf);
SendDlgItemMessage( hDlg, IDC_MAIN, EM_REPLACESEL, FALSE, (LPARAM)TranslateT("No messages found!\nPlease change current filter options."));
SendDlgItemMessage( hDlg, IDC_MAIN, EM_REPLACESEL, FALSE, (LPARAM)_T("\n"));
@@ -557,7 +557,7 @@ int WriteOptionExample(HWND hDlg, DWORD InColourSel, DWORD OutColourSel, DWORD B ZeroMemory(&cf, sizeof(cf));
cf.cbSize = sizeof(cf);
cf.dwMask = CFM_FACE | CFM_BOLD | CFM_ITALIC | CFM_COLOR;
- _tcscpy_s(cf.szFaceName, _countof(cf.szFaceName), _T("Courier"));
+ _tcscpy_s(cf.szFaceName, _T("Courier"));
cf.crTextColor = TxtColourSel;
SendDlgItemMessage( hDlg, IDC_OPTIONS_RE, EM_SETCHARFORMAT, SCF_SELECTION | SCF_WORD, (LPARAM) &cf);
if ( options->showLine == 1 )
@@ -569,7 +569,7 @@ int WriteOptionExample(HWND hDlg, DWORD InColourSel, DWORD OutColourSel, DWORD B cf.cbSize = sizeof(cf);
cf.dwMask = CFM_BOLD | CFM_FACE | CFM_COLOR;
cf.dwEffects = CFE_BOLD;
- _tcscpy_s(cf.szFaceName, _countof(cf.szFaceName), _T("Arial"));
+ _tcscpy_s(cf.szFaceName, _T("Arial"));
cf.crTextColor = TxtColourSel;
SendDlgItemMessage( hDlg, IDC_OPTIONS_RE, EM_SETCHARFORMAT, SCF_SELECTION | SCF_WORD, (LPARAM) &cf);
@@ -581,7 +581,7 @@ int WriteOptionExample(HWND hDlg, DWORD InColourSel, DWORD OutColourSel, DWORD B ZeroMemory(&cf, sizeof(cf));
cf.cbSize = sizeof(cf);
cf.dwMask = CFM_ITALIC | CFM_BOLD | CFM_UNDERLINE | CFM_FACE;
- _tcscpy_s(cf.szFaceName, _countof(cf.szFaceName), _T("Courier"));
+ _tcscpy_s(cf.szFaceName, _T("Courier"));
SendDlgItemMessage( hDlg, IDC_OPTIONS_RE, EM_SETCHARFORMAT, SCF_SELECTION | SCF_WORD, (LPARAM) &cf);
// incoming
@@ -589,7 +589,7 @@ int WriteOptionExample(HWND hDlg, DWORD InColourSel, DWORD OutColourSel, DWORD B cf.cbSize = sizeof(cf);
cf.dwMask = CFM_COLOR | CFM_FACE;
cf.crTextColor = InColourSel;
- _tcscpy_s(cf.szFaceName, _countof(cf.szFaceName), _T("Courier"));
+ _tcscpy_s(cf.szFaceName, _T("Courier"));
SendDlgItemMessage(hDlg, IDC_OPTIONS_RE, EM_SETCHARFORMAT, SCF_SELECTION | SCF_WORD, (LPARAM)&cf );
if ( options->showDirection == 1 )
@@ -612,7 +612,7 @@ int WriteOptionExample(HWND hDlg, DWORD InColourSel, DWORD OutColourSel, DWORD B cf.cbSize = sizeof(cf);
cf.dwMask = CFM_COLOR | CFM_FACE;
cf.crTextColor = OutColourSel;
- _tcscpy_s(cf.szFaceName, _countof(cf.szFaceName), _T("Courier"));
+ _tcscpy_s(cf.szFaceName, _T("Courier"));
SendDlgItemMessage(hDlg, IDC_OPTIONS_RE, EM_SETCHARFORMAT, SCF_SELECTION | SCF_WORD, (LPARAM)&cf);
@@ -1274,7 +1274,7 @@ BOOL SaveEditAsStream( HWND hDlg ) TCHAR szFilename[MAX_PATH];
// Initialize filename field
- _tcscpy_s(szFilename, _countof(szFilename), _T("*.rtf"));
+ _tcscpy_s(szFilename, _T("*.rtf"));
// Fill in OPENFILENAME struct
ZeroMemory(&ofn, sizeof(OPENFILENAME));
ofn.lStructSize = sizeof(OPENFILENAME);
diff --git a/plugins/LotusNotify/src/LotusNotify.cpp b/plugins/LotusNotify/src/LotusNotify.cpp index 7b7dbd1e23..fd18559cf1 100644 --- a/plugins/LotusNotify/src/LotusNotify.cpp +++ b/plugins/LotusNotify/src/LotusNotify.cpp @@ -286,16 +286,15 @@ BOOL checkFilters(TCHAR* str, int field) {
TCHAR buff[512] = _T("");
TCHAR *strptr = NULL;
- switch(field)
- {
+ switch(field) {
case 0:
- _tcsncpy_s(buff, SIZEOF(buff), settingFilterSender, SIZEOF(buff));
+ _tcsncpy_s(buff, settingFilterSender, _TRUNCATE);
break;
case 1:
- _tcsncpy_s(buff, SIZEOF(buff), settingFilterSubject, SIZEOF(buff));
+ _tcsncpy_s(buff, settingFilterSubject, _TRUNCATE);
break;
case 2:
- _tcsncpy_s(buff, SIZEOF(buff), settingFilterTo, SIZEOF(buff));
+ _tcsncpy_s(buff, settingFilterTo, _TRUNCATE);
break;
}
@@ -303,8 +302,8 @@ BOOL checkFilters(TCHAR* str, int field) while(strptr = _tcschr(buff, ';'))
{
TCHAR tmp[512] = TEXT(""), *ptr;
- _tcsncpy_s(tmp, SIZEOF(tmp), buff, (strptr-buff));
- _tcsncpy_s(buff, SIZEOF(buff), strptr + 1, SIZEOF(buff));
+ _tcsncpy_s(tmp, buff, (strptr-buff));
+ _tcsncpy_s(buff, strptr + 1, _TRUNCATE);
if(_tcsstr(_tcslwr(ptr=_tcsdup(str)),_tcslwr(tmp)))
{
@@ -512,8 +511,8 @@ void ErMsgT(TCHAR* msg) log_p(L"Error: %S", msg);
if(settingShowError && !isPopupWaiting) {
TCHAR buffer[256+14];
- _tcsncpy_s(buffer, _countof(buffer), _T("LotusNotify: "), SIZEOF(buffer));
- _tcscat_s(buffer, _countof(buffer), msg);
+ _tcsncpy_s(buffer, _T("LotusNotify: "), _TRUNCATE);
+ _tcscat_s(buffer, msg);
isPopupWaiting = TRUE;
PUShowMessageT(buffer, SM_WARNING);
isPopupWaiting = FALSE;
@@ -761,15 +760,13 @@ void checkthread(void*) ZeroMemory(msgFrom,512);
ZeroMemory(msgSubject,512);
- if(wcslen(field_from_UNICODE) < 512 && wcslen(field_from_UNICODE) > 3 && wcsstr(field_from_UNICODE, L"CN=") == field_from_UNICODE){
- _tcsncpy_s(msgFrom, SIZEOF(msgFrom), &(field_from_UNICODE[3]), wcscspn(field_from_UNICODE, L"/")-3 );
- } else {
- _tcsncpy_s(msgFrom, SIZEOF(msgFrom), field_from_UNICODE, _TRUNCATE);
- }
+ if(wcslen(field_from_UNICODE) < 512 && wcslen(field_from_UNICODE) > 3 && wcsstr(field_from_UNICODE, L"CN=") == field_from_UNICODE)
+ _tcsncpy_s(msgFrom, &(field_from_UNICODE[3]), wcscspn(field_from_UNICODE, L"/")-3 );
+ else
+ _tcsncpy_s(msgFrom, field_from_UNICODE, _TRUNCATE);
- for (Att = 0; (MailGetMessageAttachmentInfo1)(note_handle, Att,&bhAttachment, NULL, &cSize, NULL, NULL, NULL, NULL); Att++) {
+ for (Att = 0; (MailGetMessageAttachmentInfo1)(note_handle, Att,&bhAttachment, NULL, &cSize, NULL, NULL, NULL, NULL); Att++)
attSize += cSize;
- }
#ifdef _DEBUG
log_p(L"checkthread: MAIL INFO: date=[%S], from=[%s], to=[%s], cc=[%s], sub=[%s], attSize=[%d]"
@@ -998,13 +995,13 @@ void LoadSettings() db_free(&dbv);
if(!db_get_ts(NULL, PLUGINNAME, "LNFilterSender",&dbv))
- _tcsncpy_s(settingFilterSender, SIZEOF(settingFilterSender), dbv.ptszVal, SIZEOF(settingFilterSender));
+ _tcsncpy_s(settingFilterSender, dbv.ptszVal, _TRUNCATE);
db_free(&dbv);
if(!db_get_ts(NULL, PLUGINNAME, "LNFilterSubject",&dbv))
- _tcsncpy_s(settingFilterSubject, SIZEOF(settingFilterSubject), dbv.ptszVal, SIZEOF(settingFilterSubject));
+ _tcsncpy_s(settingFilterSubject, dbv.ptszVal, _TRUNCATE);
db_free(&dbv);
if(!db_get_ts(NULL, PLUGINNAME, "LNFilterTo",&dbv))
- _tcsncpy_s(settingFilterTo ,SIZEOF(settingFilterTo), dbv.ptszVal, SIZEOF(settingFilterTo));
+ _tcsncpy_s(settingFilterTo, dbv.ptszVal, _TRUNCATE);
db_free(&dbv);
settingOnceOnly = db_get_b (NULL, PLUGINNAME, "LNOnceOnly",0);
@@ -1105,28 +1102,28 @@ INT_PTR CALLBACK DlgProcLotusNotifyOpts(HWND hwndDlg, UINT msg, WPARAM wParam, L TCHAR buff[512];
TCHAR* strptr;
- _tcsncpy_s(buff, SIZEOF(buff), settingFilterSender, SIZEOF(buff));
+ _tcsncpy_s(buff, settingFilterSender, _TRUNCATE);
while(strptr = _tcschr(buff, TEXT(';'))) {
TCHAR tmp[512] = TEXT("");
- _tcsncpy_s(tmp, SIZEOF(tmp), buff, (strptr-buff));
+ _tcsncpy_s(tmp, buff, (strptr-buff));
SendDlgItemMessage(hwndDlg, IDC_FILTER_SENDER , CB_ADDSTRING, 0, (LPARAM)tmp);
- _tcsncpy_s(buff, SIZEOF(buff), strptr + 1, SIZEOF(buff));
+ _tcsncpy_s(buff, strptr + 1, _TRUNCATE);
}
- _tcsncpy_s(buff, SIZEOF(buff), settingFilterSubject, SIZEOF(buff) );
+ _tcsncpy_s(buff, settingFilterSubject, _TRUNCATE);
while(strptr = _tcschr(buff, TEXT(';'))) {
TCHAR tmp[512] = TEXT("");
- _tcsncpy_s(tmp, SIZEOF(tmp), buff, (strptr-buff));
+ _tcsncpy_s(tmp, buff, (strptr-buff));
SendDlgItemMessage(hwndDlg, IDC_FILTER_SUBJECT , CB_ADDSTRING, 0, (LPARAM)tmp);
- _tcsncpy_s(buff, SIZEOF(buff), strptr + 1, SIZEOF(buff));
+ _tcsncpy_s(buff, strptr + 1, _TRUNCATE);
}
- _tcsncpy_s(buff, SIZEOF(buff), settingFilterTo, SIZEOF(buff) );
+ _tcsncpy_s(buff, settingFilterTo, _TRUNCATE);
while(strptr = _tcschr(buff, TEXT(';'))) {
TCHAR tmp[512] = TEXT("");
- _tcsncpy_s(tmp, SIZEOF(tmp), buff, (strptr-buff));
+ _tcsncpy_s(tmp, buff, (strptr-buff));
SendDlgItemMessage(hwndDlg, IDC_FILTER_TO , CB_ADDSTRING, 0, (LPARAM)tmp);
- _tcsncpy_s(buff, SIZEOF(buff), strptr + 1, SIZEOF(buff));
+ _tcsncpy_s(buff, strptr + 1, _TRUNCATE);
}
break;
@@ -1292,7 +1289,7 @@ INT_PTR CALLBACK DlgProcLotusNotifyOpts(HWND hwndDlg, UINT msg, WPARAM wParam, L db_set_b(0, PLUGINNAME, buff, settingStatus[i] ? 1 : 0);
}
- _tcsncpy_s(settingFilterSender, SIZEOF(settingFilterSender), TEXT(""), SIZEOF(settingFilterSender));
+ settingFilterSender[0] = 0;
for(i=0; i<SendDlgItemMessage(hwndDlg, IDC_FILTER_SENDER, CB_GETCOUNT, 0, (LONG)0); i++){
TCHAR text[512] = TEXT("");
SendDlgItemMessage(hwndDlg,IDC_FILTER_SENDER ,CB_GETLBTEXT,(WPARAM)i,(LONG) (LPSTR)text);
@@ -1301,7 +1298,7 @@ INT_PTR CALLBACK DlgProcLotusNotifyOpts(HWND hwndDlg, UINT msg, WPARAM wParam, L }
db_set_ts(NULL, PLUGINNAME, "LNFilterSender", settingFilterSender);
- _tcsncpy_s(settingFilterSubject, SIZEOF(settingFilterSubject), TEXT(""),SIZEOF(settingFilterSubject));
+ settingFilterSubject[0] = 0;
for(i=0; i<SendDlgItemMessage(hwndDlg, IDC_FILTER_SUBJECT, CB_GETCOUNT, 0, (LONG)0); i++){
TCHAR text[512] = TEXT("");
SendDlgItemMessage(hwndDlg,IDC_FILTER_SUBJECT ,CB_GETLBTEXT,(WPARAM)i,(LONG) (LPSTR)text);
@@ -1310,7 +1307,7 @@ INT_PTR CALLBACK DlgProcLotusNotifyOpts(HWND hwndDlg, UINT msg, WPARAM wParam, L }
db_set_ts(NULL, PLUGINNAME, "LNFilterSubject", settingFilterSubject);
- _tcsncpy_s(settingFilterTo, SIZEOF(settingFilterTo), TEXT(""),SIZEOF(settingFilterTo));
+ settingFilterTo[0] = 0;
for(i=0; i<SendDlgItemMessage(hwndDlg, IDC_FILTER_TO, CB_GETCOUNT, 0, (LONG)0); i++){
TCHAR text[512] = TEXT("");
SendDlgItemMessage(hwndDlg,IDC_FILTER_TO ,CB_GETLBTEXT,(WPARAM)i,(LONG) (LPSTR)text);
@@ -1483,12 +1480,12 @@ void checkEnvPath(TCHAR *path) }
assert(_tcslen(path) + _tcslen(cur) + 1 < SIZEOF(nowy));
- _tcsncpy_s(nowy, _countof(nowy), _T("PATH="), SIZEOF(nowy));
- _tcscat_s(nowy, _countof(nowy), cur);
+ _tcsncpy_s(nowy, _T("PATH="), _TRUNCATE);
+ _tcscat_s(nowy, cur);
if(cur[_tcslen(cur)-1]!=';')
- _tcscat_s(nowy, _countof(nowy), _T(";"));
- _tcscat_s(nowy, _countof(nowy), path);
- _tcscat_s(nowy, _countof(nowy), _T(";"));
+ _tcscat_s(nowy, _T(";"));
+ _tcscat_s(nowy, path);
+ _tcscat_s(nowy, _T(";"));
_tputenv(nowy);
diff --git a/plugins/MyDetails/src/data.cpp b/plugins/MyDetails/src/data.cpp index 66f91b9e93..bb2dd807ae 100644 --- a/plugins/MyDetails/src/data.cpp +++ b/plugins/MyDetails/src/data.cpp @@ -532,7 +532,7 @@ void ProtocolArray::GetDefaultNick() {
ptrT tszNick(db_get_tsa(0, MODULE_NAME, SETTING_DEFAULT_NICK));
if (tszNick)
- _tcsncpy_s(default_nick, SIZEOF(default_nick), tszNick, _TRUNCATE);
+ _tcsncpy_s(default_nick, tszNick, _TRUNCATE);
else
default_nick[0] = '\0';
}
@@ -541,7 +541,7 @@ void ProtocolArray::GetDefaultAvatar() {
ptrT tszFile(db_get_tsa(0, "ContactPhoto", "File"));
if (tszFile)
- _tcsncpy_s(default_avatar_file, SIZEOF(default_avatar_file), tszFile, _TRUNCATE);
+ _tcsncpy_s(default_avatar_file, tszFile, _TRUNCATE);
else
default_avatar_file[0] = '\0';
}
diff --git a/plugins/PackUpdater/Src/Notifications.cpp b/plugins/PackUpdater/Src/Notifications.cpp index 8b41c0eee3..4944abfeb8 100644 --- a/plugins/PackUpdater/Src/Notifications.cpp +++ b/plugins/PackUpdater/Src/Notifications.cpp @@ -441,7 +441,7 @@ INT_PTR CALLBACK DlgUpdate(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam memset(&pi, 0, sizeof(PROCESS_INFORMATION));
si.cb = sizeof(STARTUPINFO);
{
- _tcsncpy_s(tszCurrentDir, SIZEOF(tszCurrentDir), arFilePath[i].c_str(), _TRUNCATE);
+ _tcsncpy_s(tszCurrentDir, arFilePath[i].c_str(), _TRUNCATE);
TCHAR *p = _tcsrchr(tszCurrentDir, '\\');
if (p) *p = 0;
}
diff --git a/plugins/Popup/src/bitmap_funcs.cpp b/plugins/Popup/src/bitmap_funcs.cpp index 4385def2d1..4c9f42514c 100644 --- a/plugins/Popup/src/bitmap_funcs.cpp +++ b/plugins/Popup/src/bitmap_funcs.cpp @@ -912,26 +912,17 @@ bool MyBitmap::loadFromFile(const TCHAR *fn, const TCHAR *fnAlpha) if (bits) freemem();
if (!_tcsncmp(fn, _T("pixel:"), lstrlen(_T("pixel:"))))
- {
return loadFromFile_pixel(fn, fnAlpha);
- } else
+
if (!_tcsncmp(fn, _T("gradient:"), lstrlen(_T("gradient:"))))
- {
return loadFromFile_gradient(fn, fnAlpha);
- } else
- {
- TCHAR ext[5];
- _tcsncpy_s(ext, SIZEOF(ext), fn + (_tcslen(fn) - 4), _TRUNCATE);
- if (!lstrcmpi(ext, _T(".png")))
- {
- return loadFromFile_png(fn, fnAlpha);
- } else
- {
- return loadFromFile_default(fn, fnAlpha);
- }
- }
- // unreachable place
- return false;
+
+ TCHAR ext[5];
+ _tcsncpy_s(ext, fn + (_tcslen(fn) - 4), _TRUNCATE);
+ if (!lstrcmpi(ext, _T(".png")))
+ return loadFromFile_png(fn, fnAlpha);
+
+ return loadFromFile_default(fn, fnAlpha);
}
void MyBitmap::allocate(int w, int h)
diff --git a/plugins/Scriver/src/chat/window.cpp b/plugins/Scriver/src/chat/window.cpp index 13a8dc3505..9f4b27a16b 100644 --- a/plugins/Scriver/src/chat/window.cpp +++ b/plugins/Scriver/src/chat/window.cpp @@ -803,7 +803,7 @@ static void ProcessNickListHovering(HWND hwnd, int hoveredItem, POINT * pt, SESS if (ProtoServiceExists(parentdat->pszModule, MS_GC_PROTO_GETTOOLTIPTEXT)) {
TCHAR *p = (TCHAR*)ProtoCallService(parentdat->pszModule, MS_GC_PROTO_GETTOOLTIPTEXT, (WPARAM)parentdat->ptszID, (LPARAM)ui->pszUID);
if (p != NULL) {
- _tcsncpy_s(tszBuf, SIZEOF(tszBuf), p, _TRUNCATE);
+ _tcsncpy_s(tszBuf, p, _TRUNCATE);
mir_free(p);
}
}
diff --git a/plugins/TabSRMM/src/chat/options.cpp b/plugins/TabSRMM/src/chat/options.cpp index 0040e69b2f..ce4dbe34da 100644 --- a/plugins/TabSRMM/src/chat/options.cpp +++ b/plugins/TabSRMM/src/chat/options.cpp @@ -690,14 +690,14 @@ void RegisterFontServiceFonts() { ColourRegisterT(&cid);
}
cid.order++;
- _tcsncpy_s(cid.name, SIZEOF(cid.name), LPGENT("Nick list background"), _TRUNCATE);
- strncpy_s(cid.setting, SIZEOF(cid.setting), "ColorNicklistBG", _TRUNCATE);
+ _tcsncpy_s(cid.name, LPGENT("Nick list background"), _TRUNCATE);
+ strncpy_s(cid.setting, "ColorNicklistBG", _TRUNCATE);
cid.defcolour = SRMSGDEFSET_BKGCOLOUR;
ColourRegisterT(&cid);
cid.order++;
- _tcsncpy_s(cid.name, SIZEOF(cid.name), LPGENT("Group chat log background"), _TRUNCATE);
- strncpy_s(cid.setting, SIZEOF(cid.setting), "ColorLogBG", _TRUNCATE);
+ _tcsncpy_s(cid.name, LPGENT("Group chat log background"), _TRUNCATE);
+ strncpy_s(cid.setting, "ColorLogBG", _TRUNCATE);
ColourRegisterT(&cid);
// static colors (info panel, tool bar background etc...)
diff --git a/plugins/TabSRMM/src/chat/window.cpp b/plugins/TabSRMM/src/chat/window.cpp index 5386ad7423..8cb081d5aa 100644 --- a/plugins/TabSRMM/src/chat/window.cpp +++ b/plugins/TabSRMM/src/chat/window.cpp @@ -1397,7 +1397,7 @@ static void ProcessNickListHovering(HWND hwnd, int hoveredItem, POINT * pt, SESS if ( ProtoServiceExists(parentdat->pszModule, MS_GC_PROTO_GETTOOLTIPTEXT)) { TCHAR *p = (TCHAR*)ProtoCallService(parentdat->pszModule, MS_GC_PROTO_GETTOOLTIPTEXT, (WPARAM)parentdat->ptszID, (LPARAM)ui1->pszUID); if (p != NULL) { - _tcsncpy_s(tszBuf, SIZEOF(tszBuf), p, _TRUNCATE); + _tcsncpy_s(tszBuf, p, _TRUNCATE); mir_free(p); } } @@ -1761,7 +1761,7 @@ static LRESULT CALLBACK NicklistSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, if (ProtoServiceExists(parentdat->pszModule, MS_GC_PROTO_GETTOOLTIPTEXT)) { TCHAR *p = (TCHAR*)ProtoCallService(parentdat->pszModule, MS_GC_PROTO_GETTOOLTIPTEXT, (WPARAM)parentdat->ptszID, (LPARAM)ui1->pszUID); if (p) { - _tcsncpy_s(tszBuf, SIZEOF(tszBuf), p, _TRUNCATE); + _tcsncpy_s(tszBuf, p, _TRUNCATE); mir_free(p); } } @@ -2039,7 +2039,7 @@ INT_PTR CALLBACK RoomWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar dat->hTabIcon = dat->hTabStatusIcon; if (dat->cache->getStatus() != dat->cache->getOldStatus()) { - _tcsncpy_s(dat->szStatus, SIZEOF(dat->szStatus), pcli->pfnGetStatusModeDescription(dat->wStatus, 0), _TRUNCATE); + _tcsncpy_s(dat->szStatus, pcli->pfnGetStatusModeDescription(dat->wStatus, 0), _TRUNCATE); TCITEM item = { 0 }; item.mask = TCIF_TEXT; diff --git a/plugins/TabSRMM/src/eventpopups.cpp b/plugins/TabSRMM/src/eventpopups.cpp index cd98a09016..7af5e2671e 100644 --- a/plugins/TabSRMM/src/eventpopups.cpp +++ b/plugins/TabSRMM/src/eventpopups.cpp @@ -684,7 +684,7 @@ static int PopupShowT(NEN_OPTIONS *pluginOptions, MCONTACT hContact, HANDLE hEve if (hContact)
mir_sntprintf(pud.lptzContactName, MAX_CONTACTNAME, _T("%s"), pcli->pfnGetContactDisplayName(hContact, 0));
else
- _tcsncpy_s(pud.lptzContactName, MAX_CONTACTNAME, _A2T(dbe.szModule), _TRUNCATE);
+ _tcsncpy_s(pud.lptzContactName, _A2T(dbe.szModule), _TRUNCATE);
TCHAR *szPreview = GetPreviewT((WORD)eventType, &dbe);
if (szPreview) {
diff --git a/plugins/TabSRMM/src/generic_msghandlers.cpp b/plugins/TabSRMM/src/generic_msghandlers.cpp index a45931b803..3a08715d5d 100644 --- a/plugins/TabSRMM/src/generic_msghandlers.cpp +++ b/plugins/TabSRMM/src/generic_msghandlers.cpp @@ -1760,7 +1760,7 @@ void TSAPI DM_UpdateTitle(TWindowData *dat, WPARAM wParam, LPARAM lParam) dat->dwFlagsEx = dat->idle ? dat->dwFlagsEx | MWF_SHOW_ISIDLE : dat->dwFlagsEx & ~MWF_SHOW_ISIDLE; dat->wStatus = dat->cache->getStatus(); - _tcsncpy_s(dat->szStatus, SIZEOF(dat->szStatus), pcli->pfnGetStatusModeDescription(dat->szProto == NULL ? ID_STATUS_OFFLINE : dat->wStatus, 0), _TRUNCATE); + _tcsncpy_s(dat->szStatus, pcli->pfnGetStatusModeDescription(dat->szProto == NULL ? ID_STATUS_OFFLINE : dat->wStatus, 0), _TRUNCATE); if (lParam != 0) { if (PluginConfig.m_CutContactNameOnTabs) diff --git a/plugins/TabSRMM/src/msgdialog.cpp b/plugins/TabSRMM/src/msgdialog.cpp index d3f1859f50..ee8677a731 100644 --- a/plugins/TabSRMM/src/msgdialog.cpp +++ b/plugins/TabSRMM/src/msgdialog.cpp @@ -1251,7 +1251,7 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP if (dat->hContact && dat->szProto != NULL) {
dat->wStatus = db_get_w(dat->hContact, dat->szProto, "Status", ID_STATUS_OFFLINE);
- _tcsncpy_s(dat->szStatus, SIZEOF(dat->szStatus), pcli->pfnGetStatusModeDescription(dat->szProto == NULL ? ID_STATUS_OFFLINE : dat->wStatus, 0), _TRUNCATE);
+ _tcsncpy_s(dat->szStatus, pcli->pfnGetStatusModeDescription(dat->szProto == NULL ? ID_STATUS_OFFLINE : dat->wStatus, 0), _TRUNCATE);
}
else dat->wStatus = ID_STATUS_OFFLINE;
diff --git a/plugins/Weather/src/weather_opt.cpp b/plugins/Weather/src/weather_opt.cpp index f16c4d888e..1b4573da80 100644 --- a/plugins/Weather/src/weather_opt.cpp +++ b/plugins/Weather/src/weather_opt.cpp @@ -115,7 +115,7 @@ void LoadOptions(void) opt.eUnit = db_get_w(NULL, WEATHERPROTONAME, "eUnit", 2);
ptrT szValue(db_get_tsa(NULL, WEATHERPROTONAME, "DegreeSign"));
- _tcsncpy_s(opt.DegreeSign, SIZEOF(opt.DegreeSign), (szValue == NULL) ? _T("") : szValue, _TRUNCATE);
+ _tcsncpy_s(opt.DegreeSign, (szValue == NULL) ? _T("") : szValue, _TRUNCATE);
opt.DoNotAppendUnit = db_get_b(NULL, WEATHERPROTONAME, "DoNotAppendUnit", 0);
opt.NoFrac = db_get_b(NULL, WEATHERPROTONAME, "NoFractions", 0);
@@ -191,7 +191,7 @@ void LoadOptions(void) // misc
if (szValue = db_get_tsa(NULL, WEATHERPROTONAME, "Default"))
- _tcsncpy_s(opt.Default, SIZEOF(opt.Default), szValue, _TRUNCATE);
+ _tcsncpy_s(opt.Default, szValue, _TRUNCATE);
else
opt.Default[0] = 0;
}
diff --git a/plugins/WebView/src/webview_datawnd.cpp b/plugins/WebView/src/webview_datawnd.cpp index 084215923a..a7dee35823 100644 --- a/plugins/WebView/src/webview_datawnd.cpp +++ b/plugins/WebView/src/webview_datawnd.cpp @@ -162,7 +162,7 @@ INT_PTR CALLBACK DlgProcDisplayData(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA url[0] = '\0';
if (!db_get_ts(hContact2, MODULENAME, URL_KEY, &dbv)) {
- _tcsncpy_s(url, SIZEOF(url), dbv.ptszVal, _TRUNCATE);
+ _tcsncpy_s(url, dbv.ptszVal, _TRUNCATE);
db_free(&dbv);
}
SetDlgItemText(hwndDlg, IDC_OPEN_URL, FixButtonText(url, SIZEOF(url)));
diff --git a/plugins/WebView/src/webview_opts.cpp b/plugins/WebView/src/webview_opts.cpp index 9e7149908e..347ccd2bdb 100644 --- a/plugins/WebView/src/webview_opts.cpp +++ b/plugins/WebView/src/webview_opts.cpp @@ -49,15 +49,15 @@ void strdel(TCHAR *parBuffer, int len ) TCHAR* FixButtonText(TCHAR *url, size_t len)
{
TCHAR buttontext[256], stringbefore[256], newbuttontext[256];
- _tcsncpy_s(buttontext, SIZEOF(buttontext), url, _TRUNCATE);
- _tcsncpy_s(newbuttontext, SIZEOF(newbuttontext), url, _TRUNCATE);
+ _tcsncpy_s(buttontext, url, _TRUNCATE);
+ _tcsncpy_s(newbuttontext, url, _TRUNCATE);
if ( _tcschr(newbuttontext, '&') != 0) {
while (true) {
if ( _tcschr(newbuttontext, '&') == 0)
break;
- _tcsncpy_s(buttontext, SIZEOF(buttontext), newbuttontext, _TRUNCATE);
+ _tcsncpy_s(buttontext, newbuttontext, _TRUNCATE);
TCHAR *stringafter = _tcschr(buttontext, '&');
int pos = (stringafter - buttontext);
int posbefore = (stringafter - buttontext) - 1;
diff --git a/plugins/WebView/src/webview_services.cpp b/plugins/WebView/src/webview_services.cpp index 0289f0a096..b8fdf9aaa2 100644 --- a/plugins/WebView/src/webview_services.cpp +++ b/plugins/WebView/src/webview_services.cpp @@ -53,7 +53,7 @@ int DBSettingChanged(WPARAM wParam, LPARAM lParam) TCHAR nick[100];
ptrT oldnick( db_get_tsa(hContact, "CList", "MyHandle"));
if (oldnick != NULL)
- _tcsncpy_s(nick, SIZEOF(nick), oldnick, _TRUNCATE);
+ _tcsncpy_s(nick, oldnick, _TRUNCATE);
else
nick[0] = 0;
diff --git a/plugins/YARelay/src/main.cpp b/plugins/YARelay/src/main.cpp index 6cacf14429..e41a97859c 100644 --- a/plugins/YARelay/src/main.cpp +++ b/plugins/YARelay/src/main.cpp @@ -158,7 +158,7 @@ static int MessageEventAdded(WPARAM wParam, LPARAM lParam) ci.dwFlag = CNF_UNIQUEID;
if (CallService(MS_CONTACT_GETCONTACTINFO, 0, (long)&ci) == 0){
if (ci.type == CNFT_ASCIIZ)
- _tcsncpy_s(buf, ci.pszVal, SIZEOF(buf));
+ _tcsncpy_s(buf, ci.pszVal, _TRUNCATE);
else if (ci.type == CNFT_BYTE)
mir_sntprintf(buf, SIZEOF(buf), _T("%u"), ci.bVal);
else if (ci.type == CNFT_WORD)
diff --git a/protocols/FacebookRM/src/avatars.cpp b/protocols/FacebookRM/src/avatars.cpp index c0ac06fd22..ea247fac1f 100644 --- a/protocols/FacebookRM/src/avatars.cpp +++ b/protocols/FacebookRM/src/avatars.cpp @@ -40,7 +40,7 @@ bool FacebookProto::GetDbAvatarInfo(PROTO_AVATAR_INFORMATIONT &ai, std::string * std::tstring filename = GetAvatarFolder() + L'\\' + dbv.ptszVal + (TCHAR*)_A2T(ext.c_str());
db_free(&dbv);
- _tcsncpy_s(ai.filename, SIZEOF(ai.filename), filename.c_str(), _TRUNCATE);
+ _tcsncpy_s(ai.filename, filename.c_str(), _TRUNCATE);
ai.format = ProtoGetAvatarFormat(ai.filename);
return true;
}
diff --git a/protocols/Gadu-Gadu/src/core.cpp b/protocols/Gadu-Gadu/src/core.cpp index 3e3e9fb723..0514783678 100644 --- a/protocols/Gadu-Gadu/src/core.cpp +++ b/protocols/Gadu-Gadu/src/core.cpp @@ -635,7 +635,7 @@ retry: TCHAR strFmt1[64];
TCHAR strFmt2[64];
- _tcsncpy_s(strFmt2, SIZEOF(strFmt2), pcli->pfnGetStatusModeDescription( status_gg2m(atoi(__status)), 0), _TRUNCATE);
+ _tcsncpy_s(strFmt2, pcli->pfnGetStatusModeDescription( status_gg2m(atoi(__status)), 0), _TRUNCATE);
if (__city) {
mir_sntprintf(strFmt1, SIZEOF(strFmt1), _T(", %s %s"), TranslateT("City:"), __city);
_tcsncat(strFmt2, strFmt1, SIZEOF(strFmt2) - _tcslen(strFmt2));
diff --git a/protocols/IcqOscarJ/src/icq_server.cpp b/protocols/IcqOscarJ/src/icq_server.cpp index dccf6996cb..3f7e5166e1 100644 --- a/protocols/IcqOscarJ/src/icq_server.cpp +++ b/protocols/IcqOscarJ/src/icq_server.cpp @@ -295,8 +295,6 @@ void CIcqProto::sendServPacket(icq_packet *pPacket) connectionHandleMutex->Enter();
if (hServerConn) {
- int nSendResult;
-
// This critsec makes sure that the sequence order doesn't get screwed up
localSeqMutex->Enter();
@@ -309,7 +307,7 @@ void CIcqProto::sendServPacket(icq_packet *pPacket) pPacket->pData[2] = ((wLocalSequence & 0xff00) >> 8);
pPacket->pData[3] = (wLocalSequence & 0x00ff);
- nSendResult = Netlib_Send(hServerConn, (const char *)pPacket->pData, pPacket->wLen, 0);
+ int nSendResult = Netlib_Send(hServerConn, (const char *)pPacket->pData, pPacket->wLen, 0);
localSeqMutex->Leave();
connectionHandleMutex->Leave();
diff --git a/protocols/JabberG/src/jabber_iqid.cpp b/protocols/JabberG/src/jabber_iqid.cpp index 988ca2246e..a7ca0a42e8 100644 --- a/protocols/JabberG/src/jabber_iqid.cpp +++ b/protocols/JabberG/src/jabber_iqid.cpp @@ -1441,7 +1441,7 @@ LBL_ErrFormat: mir_sha1_finish(&sha, digest);
GetAvatarFileName(hContact, tszFileName, SIZEOF(tszFileName));
- _tcsncpy_s(AI.filename, SIZEOF(AI.filename), tszFileName, _TRUNCATE);
+ _tcsncpy_s(AI.filename, tszFileName, _TRUNCATE);
FILE *out = _tfopen(tszFileName, _T("wb"));
if (out != NULL) {
diff --git a/protocols/JabberG/src/jabber_svc.cpp b/protocols/JabberG/src/jabber_svc.cpp index 8eabdc5e08..8b89ebc57e 100644 --- a/protocols/JabberG/src/jabber_svc.cpp +++ b/protocols/JabberG/src/jabber_svc.cpp @@ -156,7 +156,7 @@ INT_PTR __cdecl CJabberProto::JabberGetAvatarInfo(WPARAM wParam, LPARAM lParam) mir_sntprintf(szJid, SIZEOF(szJid), _T("%s/%s"), tszJid, bestResName);
if (szJid[0] == 0)
- _tcsncpy_s(szJid, SIZEOF(szJid), tszJid, _TRUNCATE);
+ _tcsncpy_s(szJid, tszJid, _TRUNCATE);
debugLog(_T("Rereading %s for %s"), isXVcard ? JABBER_FEAT_VCARD_TEMP : JABBER_FEAT_AVATAR, szJid);
@@ -411,7 +411,7 @@ INT_PTR __cdecl CJabberProto::JabberServiceParseXmppURI(WPARAM, LPARAM lParam) // skip leading prefix
TCHAR szUri[ 1024 ];
- _tcsncpy_s(szUri, SIZEOF(szUri), arg, _TRUNCATE);
+ _tcsncpy_s(szUri, arg, _TRUNCATE);
TCHAR *szJid = _tcschr(szUri, _T(':'));
if (szJid == NULL)
return 1;
diff --git a/protocols/JabberG/src/jabber_thread.cpp b/protocols/JabberG/src/jabber_thread.cpp index d502cfee54..ba9373f5ec 100644 --- a/protocols/JabberG/src/jabber_thread.cpp +++ b/protocols/JabberG/src/jabber_thread.cpp @@ -261,7 +261,7 @@ LBL_Exit: replaceStr(m_szStreamId, NULL);
if ((tszValue = getTStringA("LoginName")) != NULL)
- _tcsncpy_s(info->username, SIZEOF(info->username), tszValue, _TRUNCATE);
+ _tcsncpy_s(info->username, tszValue, _TRUNCATE);
if (*rtrimt(info->username) == '\0') {
DWORD dwSize = SIZEOF(info->username);
@@ -297,7 +297,7 @@ LBL_FatalError: }
else {
if ((tszValue = getTStringA("Resource")) != NULL)
- _tcsncpy_s(info->resource, SIZEOF(info->resource), tszValue, _TRUNCATE);
+ _tcsncpy_s(info->resource, tszValue, _TRUNCATE);
else
_tcscpy(info->resource, _T("Miranda"));
}
diff --git a/src/core/stdclist/src/clcfonts.cpp b/src/core/stdclist/src/clcfonts.cpp index fe4c9c1e9a..3951ca6cc4 100644 --- a/src/core/stdclist/src/clcfonts.cpp +++ b/src/core/stdclist/src/clcfonts.cpp @@ -62,7 +62,7 @@ void RegisterCListFonts() pcli->pfnGetFontSetting(i, &lf, &fontid.deffontsettings.colour);
lf.lfHeight = -MulDiv(lf.lfHeight, GetDeviceCaps(hdc, LOGPIXELSY), 72);
- _tcsncpy_s(fontid.deffontsettings.szFace, SIZEOF(fontid.deffontsettings.szFace), lf.lfFaceName, _TRUNCATE);
+ _tcsncpy_s(fontid.deffontsettings.szFace, lf.lfFaceName, _TRUNCATE);
fontid.deffontsettings.charset = lf.lfCharSet;
fontid.deffontsettings.size = (char)lf.lfHeight;
fontid.deffontsettings.style = (lf.lfWeight >= FW_BOLD ? DBFONTF_BOLD : 0) | (lf.lfItalic ? DBFONTF_ITALIC : 0);
diff --git a/src/core/stdfile/filerecvdlg.cpp b/src/core/stdfile/filerecvdlg.cpp index c8dba320ee..f238a91199 100644 --- a/src/core/stdfile/filerecvdlg.cpp +++ b/src/core/stdfile/filerecvdlg.cpp @@ -134,7 +134,7 @@ void GetContactReceivedFilesDir(MCONTACT hContact, TCHAR *szDir, int cchDir, BOO ptrT tszRecvPath(db_get_tsa(NULL, "SRFile", "RecvFilesDirAdv"));
if (tszRecvPath)
- _tcsncpy_s(tszTemp, SIZEOF(tszTemp), tszRecvPath, _TRUNCATE);
+ _tcsncpy_s(tszTemp, tszRecvPath, _TRUNCATE);
else
mir_sntprintf(tszTemp, SIZEOF(tszTemp), _T("%%mydocuments%%\\%s\\%%userid%%"), TranslateT("My received files"));
@@ -180,7 +180,7 @@ void GetReceivedFilesDir(TCHAR *szDir, int cchDir) ptrT tszRecvPath(db_get_tsa(NULL, "SRFile", "RecvFilesDirAdv"));
if (tszRecvPath)
- _tcsncpy_s(tszTemp, SIZEOF(tszTemp), tszRecvPath, _TRUNCATE);
+ _tcsncpy_s(tszTemp, tszRecvPath, _TRUNCATE);
else
mir_sntprintf(tszTemp, SIZEOF(tszTemp), _T("%%mydocuments%%\\%s\\%%userid%%"), TranslateT("My received files"));
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 : <hreadID);
+ return (HANDLE)::mir_forkthreadowner((pThreadFuncOwner)*(void**)&pFunc, pThis, param, threadID ? threadID : <hreadID);
}
/////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/modules/chat/chat_opts.cpp b/src/modules/chat/chat_opts.cpp index ffcd82d6d9..428d1e72f8 100644 --- a/src/modules/chat/chat_opts.cpp +++ b/src/modules/chat/chat_opts.cpp @@ -124,7 +124,7 @@ void LoadMsgDlgFont(int i, LOGFONT *lf, COLORREF *colour) if (tszFace == NULL)
lstrcpy(lf->lfFaceName, FO.szDefFace);
else
- _tcsncpy_s(lf->lfFaceName, SIZEOF(lf->lfFaceName), tszFace, _TRUNCATE);
+ _tcsncpy_s(lf->lfFaceName, tszFace, _TRUNCATE);
}
}
@@ -136,13 +136,13 @@ void RegisterFonts(void) FontIDT fontid = { sizeof(fontid) };
fontid.flags = FIDF_ALLOWREREGISTER | FIDF_DEFAULTVALID | FIDF_NEEDRESTART;
- _tcsncpy_s(fontid.backgroundGroup, SIZEOF(fontid.backgroundGroup), g_szFontGroup, _TRUNCATE);
- _tcsncpy_s(fontid.group, SIZEOF(fontid.group), g_szFontGroup, _TRUNCATE);
+ _tcsncpy_s(fontid.backgroundGroup, g_szFontGroup, _TRUNCATE);
+ _tcsncpy_s(fontid.group, g_szFontGroup, _TRUNCATE);
for (int i = 0; i < SIZEOF(fontOptionsList); i++, index++) {
FontOptionsList &FO = fontOptionsList[i];
strncpy(fontid.dbSettingsGroup, CHATFONT_MODULE, sizeof(fontid.dbSettingsGroup));
- _tcsncpy_s(fontid.name, SIZEOF(fontid.name), FO.szDescr, _TRUNCATE);
+ _tcsncpy_s(fontid.name, FO.szDescr, _TRUNCATE);
char idstr[10];
mir_snprintf(idstr, SIZEOF(idstr), "Font%d", index);
@@ -152,25 +152,25 @@ void RegisterFonts(void) switch (i) {
case 18:
case 19:
- _tcsncpy_s(fontid.backgroundName, SIZEOF(fontid.backgroundName), LPGENT("Nick list background"), _TRUNCATE);
+ _tcsncpy_s(fontid.backgroundName, LPGENT("Nick list background"), _TRUNCATE);
break;
case 17:
if (g_iFontMode == FONTMODE_SKIP)
continue;
if (g_iFontMode == FONTMODE_USE) {
- _tcsncpy_s(fontid.name, SIZEOF(fontid.name), LPGENT("Message typing area"), _TRUNCATE);
- _tcsncpy_s(fontid.backgroundName, SIZEOF(fontid.backgroundName), LPGENT("Message background"), _TRUNCATE);
+ _tcsncpy_s(fontid.name, LPGENT("Message typing area"), _TRUNCATE);
+ _tcsncpy_s(fontid.backgroundName, LPGENT("Message background"), _TRUNCATE);
FO.defColour = RGB(0, 0, 40);
break;
}
- _tcsncpy_s(fontid.name, SIZEOF(fontid.name), LPGENT("Chat log symbols (Webdings)"), _TRUNCATE);
+ _tcsncpy_s(fontid.name, LPGENT("Chat log symbols (Webdings)"), _TRUNCATE);
FO.szDefFace = _T("Webdings");
FO.defColour = RGB(170, 170, 170);
FO.defCharset = SYMBOL_CHARSET;
// fall through
default:
- _tcsncpy_s(fontid.backgroundName, SIZEOF(fontid.backgroundName), LPGENT("Group chat log background"), _TRUNCATE);
+ _tcsncpy_s(fontid.backgroundName, LPGENT("Group chat log background"), _TRUNCATE);
break;
}
_tcsncpy(fontid.deffontsettings.szFace, FO.szDefFace, SIZEOF(fontid.deffontsettings.szFace));
diff --git a/src/modules/chat/chat_svc.cpp b/src/modules/chat/chat_svc.cpp index 211e913d83..7363c4b36f 100644 --- a/src/modules/chat/chat_svc.cpp +++ b/src/modules/chat/chat_svc.cpp @@ -232,7 +232,7 @@ static INT_PTR Service_NewChat(WPARAM, LPARAM lParam) if (si->iType == GCW_SERVER)
mir_sntprintf(szTemp, SIZEOF(szTemp), _T("Server: %s"), si->ptszName);
else
- _tcsncpy_s(szTemp, SIZEOF(szTemp), si->ptszName, _TRUNCATE);
+ _tcsncpy_s(szTemp, si->ptszName, _TRUNCATE);
si->hContact = ci.AddRoom(gcw->pszModule, gcw->ptszID, szTemp, si->iType);
db_set_s(si->hContact, si->pszModule, "Topic", "");
db_unset(si->hContact, "CList", "StatusMsg");
diff --git a/src/modules/chat/clist.cpp b/src/modules/chat/clist.cpp index a9e55d5fa6..d4de18e515 100644 --- a/src/modules/chat/clist.cpp +++ b/src/modules/chat/clist.cpp @@ -27,7 +27,7 @@ MCONTACT AddRoom(const char *pszModule, const TCHAR *pszRoom, const TCHAR *pszDi TCHAR pszGroup[50]; *pszGroup = '\0';
ptrT groupName(db_get_tsa(NULL, CHAT_MODULE, "AddToGroup"));
if (groupName)
- _tcsncpy_s(pszGroup, SIZEOF(pszGroup), groupName, _TRUNCATE);
+ _tcsncpy_s(pszGroup, groupName, _TRUNCATE);
else
_tcscpy(pszGroup, _T("Chat rooms"));
diff --git a/src/modules/chat/tools.cpp b/src/modules/chat/tools.cpp index dd74d42f1a..284753c0b4 100644 --- a/src/modules/chat/tools.cpp +++ b/src/modules/chat/tools.cpp @@ -744,7 +744,7 @@ TCHAR* GetChatLogsFilename(SESSION_INFO *si, time_t tTime) // we have to reparse the filename
TCHAR *tszNow = ci.MakeTimeStamp(_T("%a%d%m%Y"), tTime); // once a day
if (_tcscmp(tszOldTimeStamp, tszNow)) {
- _tcsncpy_s(tszOldTimeStamp, 30, tszNow, _TRUNCATE);
+ _tcsncpy_s(tszOldTimeStamp, tszNow, _TRUNCATE);
*si->pszLogFileName = 0;
}
diff --git a/src/modules/database/database.cpp b/src/modules/database/database.cpp index 58112c2ac4..9ede9ce6e9 100644 --- a/src/modules/database/database.cpp +++ b/src/modules/database/database.cpp @@ -52,9 +52,9 @@ static void fillProfileName(const TCHAR* ptszFileName) else
p++;
- _tcsncpy_s(g_profileName, SIZEOF(g_profileName), p, _TRUNCATE);
+ _tcsncpy_s(g_profileName, p, _TRUNCATE);
- _tcsncpy_s(g_shortProfileName, SIZEOF(g_shortProfileName), p, _TRUNCATE);
+ _tcsncpy_s(g_shortProfileName, p, _TRUNCATE);
TCHAR *pos = _tcsrchr(g_shortProfileName, '.');
if (lstrcmpi(pos, _T(".dat")) == 0)
*pos = 0;
diff --git a/src/modules/metacontacts/meta_edit.cpp b/src/modules/metacontacts/meta_edit.cpp index 51a8a4f3e9..20bbf3680d 100644 --- a/src/modules/metacontacts/meta_edit.cpp +++ b/src/modules/metacontacts/meta_edit.cpp @@ -97,7 +97,7 @@ static void FillContactList(HWND hList) SendMessage(hList, LVM_SETITEM, 0, (LPARAM)&LvItem); // Enter text to SubItems
LvItem.iSubItem = 2; // protocol
- _tcsncpy_s(buff, SIZEOF(buff), (pa == NULL) ? _A2T(szProto) : pa->tszAccountName, _TRUNCATE);
+ _tcsncpy_s(buff, (pa == NULL) ? _A2T(szProto) : pa->tszAccountName, _TRUNCATE);
ListView_SetItem(hList, &LvItem);
}
else {
diff --git a/src/modules/utils/path.cpp b/src/modules/utils/path.cpp index 2a4bcaa530..0bd1e79383 100644 --- a/src/modules/utils/path.cpp +++ b/src/modules/utils/path.cpp @@ -178,7 +178,7 @@ static __forceinline char *GetPathVarX(char *, int code) switch(code) {
case 1:
if (hAvatarFolder != NULL)
- _tcsncpy_s(szFullPath, SIZEOF(szFullPath), tszAvatarRoot, _TRUNCATE);
+ _tcsncpy_s(szFullPath, tszAvatarRoot, _TRUNCATE);
else
mir_sntprintf(szFullPath, SIZEOF(szFullPath), _T("%s\\%s\\AvatarCache"), g_profileDir, g_shortProfileName);
break;
@@ -262,7 +262,7 @@ static __forceinline TCHAR *GetPathVarX(TCHAR *, int code) switch(code) {
case 1:
if (hAvatarFolder != NULL)
- _tcsncpy_s(szFullPath, SIZEOF(szFullPath), tszAvatarRoot, _TRUNCATE);
+ _tcsncpy_s(szFullPath, tszAvatarRoot, _TRUNCATE);
else
mir_sntprintf(szFullPath, SIZEOF(szFullPath), _T("%s\\%s\\AvatarCache"), g_profileDir, g_shortProfileName);
break;
@@ -434,7 +434,7 @@ static int OnFoldersChanged(WPARAM, LPARAM) TCHAR tmpVar[MAX_PATH];
if (!FoldersGetCustomPathT(hAvatarFolder, tmpVar, SIZEOF(tmpVar), tszAvatarRoot))
- _tcsncpy_s(tszAvatarRoot, SIZEOF(tszAvatarRoot), tmpVar, SIZEOF(tmpVar));
+ _tcsncpy_s(tszAvatarRoot, tmpVar, _TRUNCATE);
return 0;
}
@@ -444,7 +444,7 @@ void InitPathVar() if (hAvatarFolder = FoldersRegisterCustomPathT( LPGEN("Avatars"), LPGEN("Avatars root folder"), tszAvatarRoot)) {
TCHAR tmpVar[MAX_PATH];
if (!FoldersGetCustomPathT(hAvatarFolder, tmpVar, SIZEOF(tmpVar), tszAvatarRoot))
- _tcsncpy_s(tszAvatarRoot, SIZEOF(tszAvatarRoot), tmpVar, SIZEOF(tmpVar));
+ _tcsncpy_s(tszAvatarRoot, tmpVar, _TRUNCATE);
HookEvent(ME_FOLDERS_PATH_CHANGED, OnFoldersChanged);
}
}
|