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/AVS/src | |
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/AVS/src')
-rw-r--r-- | plugins/AVS/src/acc.cpp | 2 | ||||
-rw-r--r-- | plugins/AVS/src/cache.cpp | 2 | ||||
-rw-r--r-- | plugins/AVS/src/main.cpp | 8 | ||||
-rw-r--r-- | plugins/AVS/src/options.cpp | 6 | ||||
-rw-r--r-- | plugins/AVS/src/services.cpp | 20 | ||||
-rw-r--r-- | plugins/AVS/src/utils.cpp | 4 |
6 files changed, 21 insertions, 21 deletions
diff --git a/plugins/AVS/src/acc.cpp b/plugins/AVS/src/acc.cpp index b58e9922f0..14ce6c27f4 100644 --- a/plugins/AVS/src/acc.cpp +++ b/plugins/AVS/src/acc.cpp @@ -469,7 +469,7 @@ static LRESULT CALLBACK ACCWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP return TRUE;
case AVATAR_SETNOAVATARTEXT:
- mir_tstrncpy(data->noAvatarText, TranslateTS((TCHAR*)lParam), SIZEOF(data->noAvatarText));
+ mir_tstrncpy(data->noAvatarText, TranslateTS((TCHAR*)lParam), _countof(data->noAvatarText));
Invalidate(hwnd);
return TRUE;
diff --git a/plugins/AVS/src/cache.cpp b/plugins/AVS/src/cache.cpp index d14200ac06..f723c05f81 100644 --- a/plugins/AVS/src/cache.cpp +++ b/plugins/AVS/src/cache.cpp @@ -149,7 +149,7 @@ void NotifyMetaAware(MCONTACT hContact, CacheNode *node, AVATARCACHEENTRY *ace) // Default value
if (cacn.hash[0] == '\0')
- mir_sntprintf(cacn.hash, SIZEOF(cacn.hash), _T("AVS-HASH-%x"), GetFileHash(cacn.filename));
+ mir_sntprintf(cacn.hash, _countof(cacn.hash), _T("AVS-HASH-%x"), GetFileHash(cacn.filename));
NotifyEventHooks(hEventContactAvatarChanged, (WPARAM)cacn.hContact, (LPARAM)&cacn);
}
diff --git a/plugins/AVS/src/main.cpp b/plugins/AVS/src/main.cpp index d551874527..6ed85901fd 100644 --- a/plugins/AVS/src/main.cpp +++ b/plugins/AVS/src/main.cpp @@ -142,10 +142,10 @@ static void LoadProtoInfo(PROTOCOLDESCRIPTOR *proto) return;
char protoName[MAX_PATH];
- mir_snprintf(protoName, SIZEOF(protoName), "Global avatar for %s accounts", proto->szName);
+ mir_snprintf(protoName, _countof(protoName), "Global avatar for %s accounts", proto->szName);
TCHAR protoNameTmp[MAX_PATH];
- mir_sntprintf(protoNameTmp, SIZEOF(protoNameTmp), TranslateT("Global avatar for %s accounts"), _A2T(proto->szName));
+ mir_sntprintf(protoNameTmp, _countof(protoNameTmp), TranslateT("Global avatar for %s accounts"), _A2T(proto->szName));
protoPicCacheEntry *pce = new protoPicCacheEntry;
if (CreateAvatarInCache(0, pce, protoName) != 1)
db_unset(0, PPICT_MODULE, protoName);
@@ -323,7 +323,7 @@ void InternalDrawAvatar(AVATARDRAWREQUEST *r, HBITMAP hbm, LONG bmWidth, LONG bm static int ModulesLoaded(WPARAM, LPARAM)
{
TCHAR szEventName[100];
- mir_sntprintf(szEventName, SIZEOF(szEventName), _T("avs_loaderthread_%d"), GetCurrentThreadId());
+ mir_sntprintf(szEventName, _countof(szEventName), _T("avs_loaderthread_%d"), GetCurrentThreadId());
hLoaderEvent = CreateEvent(NULL, TRUE, FALSE, szEventName);
SetThreadPriority(mir_forkthread(PicLoader, 0), THREAD_PRIORITY_IDLE);
@@ -381,7 +381,7 @@ static int LoadAvatarModule() InitServices();
InitPolls();
- _tcsncpy_s(g_szDataPath, SIZEOF(g_szDataPath), VARST(_T("%miranda_userdata%\\")), _TRUNCATE);
+ _tcsncpy_s(g_szDataPath, _countof(g_szDataPath), VARST(_T("%miranda_userdata%\\")), _TRUNCATE);
_tcslwr(g_szDataPath);
return 0;
}
diff --git a/plugins/AVS/src/options.cpp b/plugins/AVS/src/options.cpp index 0f7793b45f..3294089c99 100644 --- a/plugins/AVS/src/options.cpp +++ b/plugins/AVS/src/options.cpp @@ -100,7 +100,7 @@ static void RemoveProtoPic(const char *szProto) static void SetProtoPic(char *szProto) { TCHAR FileName[MAX_PATH], filter[256]; - Bitmap_GetFilter(filter, SIZEOF(filter)); + Bitmap_GetFilter(filter, _countof(filter)); OPENFILENAME ofn = { 0 }; ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400; @@ -388,7 +388,7 @@ static INT_PTR CALLBACK DlgProcOptionsProtos(HWND hwndDlg, UINT msg, WPARAM wPar if (!db_get_ts(NULL, PPICT_MODULE, g_selectedProto, &dbv)) { if (!PathIsAbsoluteT(VARST(dbv.ptszVal))) { TCHAR szFinalPath[MAX_PATH]; - mir_sntprintf(szFinalPath, SIZEOF(szFinalPath), _T("%%miranda_path%%\\%s"), dbv.ptszVal); + mir_sntprintf(szFinalPath, _countof(szFinalPath), _T("%%miranda_path%%\\%s"), dbv.ptszVal); SetDlgItemText(hwndDlg, IDC_PROTOAVATARNAME, szFinalPath); } else SetDlgItemText(hwndDlg, IDC_PROTOAVATARNAME, dbv.ptszVal); @@ -1081,7 +1081,7 @@ static INT_PTR CALLBACK DlgProcAvatarProtoInfo(HWND hwndDlg, UINT msg, WPARAM wP break; char description[256]; - CallProtoService(proto, PS_GETNAME, SIZEOF(description), (LPARAM)description); + CallProtoService(proto, PS_GETNAME, _countof(description), (LPARAM)description); TCHAR *descr = mir_a2t(description); if (MessageBox(hwndDlg, TranslateT("Are you sure you want to remove your avatar?"), descr, MB_YESNO) == IDYES) avSetMyAvatar(proto, _T("")); diff --git a/plugins/AVS/src/services.cpp b/plugins/AVS/src/services.cpp index 5162f283f6..33084606e9 100644 --- a/plugins/AVS/src/services.cpp +++ b/plugins/AVS/src/services.cpp @@ -128,7 +128,7 @@ static INT_PTR avSetAvatar(MCONTACT hContact, TCHAR *tszPath) if (tszPath == NULL) {
TCHAR filter[256];
- Bitmap_GetFilter(filter, SIZEOF(filter));
+ Bitmap_GetFilter(filter, _countof(filter));
OPENFILENAME ofn = { 0 };
ofn.lStructSize = sizeof(ofn);
@@ -347,7 +347,7 @@ void SaveImage(SaveProtocolData &d, char *protocol, int format) if (!Proto_IsAvatarFormatSupported(protocol, format))
return;
- mir_sntprintf(d.image_file_name, SIZEOF(d.image_file_name), _T("%s%s"), d.temp_file, ProtoGetAvatarExtension(format));
+ mir_sntprintf(d.image_file_name, _countof(d.image_file_name), _T("%s%s"), d.temp_file, ProtoGetAvatarExtension(format));
if (BmpFilterSaveBitmap(d.hBmpProto, d.image_file_name, format == PA_FORMAT_JPEG ? JPEG_QUALITYSUPERB : 0))
return;
@@ -549,14 +549,14 @@ static int InternalSetMyAvatar(char *protocol, TCHAR *szFinalName, SetMyAvatarHo // Copy avatar file to store as global one
TCHAR globalFile[1024];
BOOL saved = TRUE;
- if (FoldersGetCustomPathT(hGlobalAvatarFolder, globalFile, SIZEOF(globalFile), _T(""))) {
- mir_sntprintf(globalFile, SIZEOF(globalFile), _T("%s%s"), g_szDataPath, _T("GlobalAvatar"));
+ if (FoldersGetCustomPathT(hGlobalAvatarFolder, globalFile, _countof(globalFile), _T(""))) {
+ mir_sntprintf(globalFile, _countof(globalFile), _T("%s%s"), g_szDataPath, _T("GlobalAvatar"));
CreateDirectory(globalFile, NULL);
}
TCHAR *ext = _tcsrchr(szFinalName, _T('.')); // Can't be NULL here
if (format == PA_FORMAT_XML || format == PA_FORMAT_SWF) {
- mir_sntprintf(globalFile, SIZEOF(globalFile), _T("%s\\my_global_avatar%s"), globalFile, ext);
+ mir_sntprintf(globalFile, _countof(globalFile), _T("%s\\my_global_avatar%s"), globalFile, ext);
CopyFile(szFinalName, globalFile, FALSE);
}
else {
@@ -574,12 +574,12 @@ static int InternalSetMyAvatar(char *protocol, TCHAR *szFinalName, SetMyAvatarHo // Check if need to resize
if (hBmpTmp == hBmp || hBmpTmp == NULL) {
// Use original image
- mir_sntprintf(globalFile, SIZEOF(globalFile), _T("%s\\my_global_avatar%s"), globalFile, ext);
+ mir_sntprintf(globalFile, _countof(globalFile), _T("%s\\my_global_avatar%s"), globalFile, ext);
CopyFile(szFinalName, globalFile, FALSE);
}
else {
// Save as PNG
- mir_sntprintf(globalFile, SIZEOF(globalFile), _T("%s\\my_global_avatar.png"), globalFile);
+ mir_sntprintf(globalFile, _countof(globalFile), _T("%s\\my_global_avatar.png"), globalFile);
if (BmpFilterSaveBitmap(hBmpTmp, globalFile, 0))
saved = FALSE;
@@ -665,7 +665,7 @@ INT_PTR avSetMyAvatar(char* protocol, TCHAR* tszPath) FilterGetStrings(filter, allAcceptXML, allAcceptSWF);
TCHAR inipath[1024];
- FoldersGetCustomPathT(hMyAvatarsFolder, inipath, SIZEOF(inipath), _T("."));
+ FoldersGetCustomPathT(hMyAvatarsFolder, inipath, _countof(inipath), _T("."));
OPENFILENAME ofn = { 0 };
ofn.lStructSize = sizeof(ofn);
@@ -685,10 +685,10 @@ INT_PTR avSetMyAvatar(char* protocol, TCHAR* tszPath) TCHAR title[256];
if (protocol == NULL)
- mir_sntprintf(title, SIZEOF(title), TranslateT("Set My Avatar"));
+ mir_sntprintf(title, _countof(title), TranslateT("Set My Avatar"));
else {
TCHAR* prototmp = mir_a2t(protocol);
- mir_sntprintf(title, SIZEOF(title), TranslateT("Set My Avatar for %s"), prototmp);
+ mir_sntprintf(title, _countof(title), TranslateT("Set My Avatar for %s"), prototmp);
mir_free(prototmp);
}
ofn.lpstrTitle = title;
diff --git a/plugins/AVS/src/utils.cpp b/plugins/AVS/src/utils.cpp index 030696b7fc..c59c8a9499 100644 --- a/plugins/AVS/src/utils.cpp +++ b/plugins/AVS/src/utils.cpp @@ -103,7 +103,7 @@ int CreateAvatarInCache(MCONTACT hContact, avatarCacheEntry *ace, char *szProto) if (pdescr == NULL)
return -1;
char key[MAX_PATH];
- mir_snprintf(key, SIZEOF(key), "Global avatar for %s accounts", pdescr->szProtoName);
+ mir_snprintf(key, _countof(key), "Global avatar for %s accounts", pdescr->szProtoName);
if (tszValue = db_get_tsa(NULL, PPICT_MODULE, key))
MyPathToAbsolute(tszValue, tszFilename);
}
@@ -128,7 +128,7 @@ int CreateAvatarInCache(MCONTACT hContact, avatarCacheEntry *ace, char *szProto) if (CallProtoService(szProto, PS_GETMYAVATAR, (WPARAM)szFileName, (LPARAM)MAX_PATH))
tszFilename[0] = '\0';
else
- MultiByteToWideChar(CP_ACP, 0, szFileName, -1, tszFilename, SIZEOF(tszFilename));
+ MultiByteToWideChar(CP_ACP, 0, szFileName, -1, tszFilename, _countof(tszFilename));
}
else if (tszValue = db_get_tsa(NULL, szProto, "AvatarFile"))
MyPathToAbsolute(tszValue, tszFilename);
|