summaryrefslogtreecommitdiff
path: root/plugins/Variables
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2015-06-19 19:35:42 +0000
committerGeorge Hazan <george.hazan@gmail.com>2015-06-19 19:35:42 +0000
commit4c814798c7bc7f6a0f92c21b027b26290622aa2f (patch)
tree9bbfb38bd639f352300aa16ff7c45f5a9b2dba6d /plugins/Variables
parentf0f0cd088f1ec3a85abee825ddbc214f3f6b92c3 (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/Variables')
-rw-r--r--plugins/Variables/src/contact.cpp2
-rw-r--r--plugins/Variables/src/dbhelpers.h18
-rw-r--r--plugins/Variables/src/parse_inet.cpp2
-rw-r--r--plugins/Variables/src/parse_math.cpp2
-rw-r--r--plugins/Variables/src/parse_metacontacts.cpp6
-rw-r--r--plugins/Variables/src/parse_miranda.cpp10
-rw-r--r--plugins/Variables/src/parse_system.cpp14
7 files changed, 27 insertions, 27 deletions
diff --git a/plugins/Variables/src/contact.cpp b/plugins/Variables/src/contact.cpp
index 0c8a0642e7..1bd05d180d 100644
--- a/plugins/Variables/src/contact.cpp
+++ b/plugins/Variables/src/contact.cpp
@@ -94,7 +94,7 @@ BYTE getContactInfoType(TCHAR* type)
if (type == NULL || mir_tstrlen(type) == 0 )
return 0;
- for (int i=0; i < SIZEOF(builtinCnfs); i++ )
+ for (int i=0; i < _countof(builtinCnfs); i++ )
if (!mir_tstrcmp( builtinCnfs[i].str, type ))
return builtinCnfs[i].cnfCode;
diff --git a/plugins/Variables/src/dbhelpers.h b/plugins/Variables/src/dbhelpers.h
index 9cad9fdce1..b6fe9f7c42 100644
--- a/plugins/Variables/src/dbhelpers.h
+++ b/plugins/Variables/src/dbhelpers.h
@@ -26,7 +26,7 @@ static int __inline DBWriteIthSettingByte(DWORD i, MCONTACT hContact,const char
char dbSetting[128];
- mir_snprintf(dbSetting, SIZEOF(dbSetting), "%s%u_%s", PREFIX_ITH, i, szSetting);
+ mir_snprintf(dbSetting, _countof(dbSetting), "%s%u_%s", PREFIX_ITH, i, szSetting);
return db_set_b(hContact, szModule, dbSetting, val);
}
@@ -34,7 +34,7 @@ static int __inline DBWriteIthSettingWord(DWORD i, MCONTACT hContact,const char
char dbSetting[128];
- mir_snprintf(dbSetting, SIZEOF(dbSetting), "%s%u_%s", PREFIX_ITH, i, szSetting);
+ mir_snprintf(dbSetting, _countof(dbSetting), "%s%u_%s", PREFIX_ITH, i, szSetting);
return db_set_w(hContact, szModule, dbSetting, val);
}
@@ -42,7 +42,7 @@ static int __inline DBWriteIthSettingDword(DWORD i, MCONTACT hContact,const char
char dbSetting[128];
- mir_snprintf(dbSetting, SIZEOF(dbSetting), "%s%u_%s", PREFIX_ITH, i, szSetting);
+ mir_snprintf(dbSetting, _countof(dbSetting), "%s%u_%s", PREFIX_ITH, i, szSetting);
return db_set_dw(hContact, szModule, dbSetting, val);
}
@@ -50,7 +50,7 @@ static int __inline DBWriteIthSettingString(DWORD i, MCONTACT hContact,const cha
char dbSetting[128];
- mir_snprintf(dbSetting, SIZEOF(dbSetting), "%s%u_%s", PREFIX_ITH, i, szSetting);
+ mir_snprintf(dbSetting, _countof(dbSetting), "%s%u_%s", PREFIX_ITH, i, szSetting);
return db_set_s(hContact, szModule, dbSetting, val);
}
@@ -59,7 +59,7 @@ static int __inline DBGetIthSettingByte(DWORD i, MCONTACT hContact, const char *
char dbSetting[128];
- mir_snprintf(dbSetting, SIZEOF(dbSetting), "%s%u_%s", PREFIX_ITH, i, szSetting);
+ mir_snprintf(dbSetting, _countof(dbSetting), "%s%u_%s", PREFIX_ITH, i, szSetting);
return db_get_b(hContact, szModule, dbSetting, errorValue);
}
@@ -68,7 +68,7 @@ static WORD __inline DBGetIthSettingWord(DWORD i, MCONTACT hContact, const char
char dbSetting[128];
- mir_snprintf(dbSetting, SIZEOF(dbSetting), "%s%u_%s", PREFIX_ITH, i, szSetting);
+ mir_snprintf(dbSetting, _countof(dbSetting), "%s%u_%s", PREFIX_ITH, i, szSetting);
return db_get_w(hContact, szModule, dbSetting, errorValue);
}
@@ -77,7 +77,7 @@ static DWORD __inline DBGetIthSettingDword(DWORD i, MCONTACT hContact, const cha
char dbSetting[128];
- mir_snprintf(dbSetting, SIZEOF(dbSetting), "%s%u_%s", PREFIX_ITH, i, szSetting);
+ mir_snprintf(dbSetting, _countof(dbSetting), "%s%u_%s", PREFIX_ITH, i, szSetting);
return db_get_dw(hContact, szModule, dbSetting, errorValue);
}
@@ -86,7 +86,7 @@ static int __inline DBGetIthSetting(DWORD i, MCONTACT hContact, const char *szMo
char dbSetting[128];
- mir_snprintf(dbSetting, SIZEOF(dbSetting), "%s%u_%s", PREFIX_ITH, i, szSetting);
+ mir_snprintf(dbSetting, _countof(dbSetting), "%s%u_%s", PREFIX_ITH, i, szSetting);
return db_get(hContact, szModule, dbSetting, dbv);
}
@@ -94,7 +94,7 @@ static int __inline DBDeleteIthSetting(DWORD i, MCONTACT hContact,const char *sz
char dbSetting[128];
- mir_snprintf(dbSetting, SIZEOF(dbSetting), "%s%u_%s", PREFIX_ITH, i, szSetting);
+ mir_snprintf(dbSetting, _countof(dbSetting), "%s%u_%s", PREFIX_ITH, i, szSetting);
return db_unset(hContact, szModule, dbSetting);
}
diff --git a/plugins/Variables/src/parse_inet.cpp b/plugins/Variables/src/parse_inet.cpp
index c1c6f405ac..8075c5fbc7 100644
--- a/plugins/Variables/src/parse_inet.cpp
+++ b/plugins/Variables/src/parse_inet.cpp
@@ -40,7 +40,7 @@ static TCHAR *parseUrlEnc(ARGUMENTSINFO *ai)
char hex[8];
memmove(res + cur + 3, res + cur + 1, mir_strlen(res + cur + 1) + 1);
- mir_snprintf(hex, SIZEOF(hex), "%%%x", *(res + cur));
+ mir_snprintf(hex, _countof(hex), "%%%x", *(res + cur));
strncpy(res + cur, hex, mir_strlen(hex));
cur += mir_strlen(hex);
}
diff --git a/plugins/Variables/src/parse_math.cpp b/plugins/Variables/src/parse_math.cpp
index 4dc0913824..f86f15d467 100644
--- a/plugins/Variables/src/parse_math.cpp
+++ b/plugins/Variables/src/parse_math.cpp
@@ -54,7 +54,7 @@ static TCHAR *parseHex(ARGUMENTSINFO *ai)
int val = ttoi(ai->targv[1]);
int padding = ttoi(ai->targv[2]);
- mir_sntprintf(szVal, SIZEOF(szVal), _T("%x"), val);
+ mir_sntprintf(szVal, _countof(szVal), _T("%x"), val);
unsigned int zeros = max(padding - (signed int)mir_tstrlen(szVal), 0);
TCHAR *res = (TCHAR*)mir_alloc((zeros + mir_tstrlen(szVal) + 3)*sizeof(TCHAR));
if (res == NULL)
diff --git a/plugins/Variables/src/parse_metacontacts.cpp b/plugins/Variables/src/parse_metacontacts.cpp
index 9992d0af5a..ff2b7a18a6 100644
--- a/plugins/Variables/src/parse_metacontacts.cpp
+++ b/plugins/Variables/src/parse_metacontacts.cpp
@@ -51,7 +51,7 @@ static TCHAR *parseGetParent(ARGUMENTSINFO *ai)
if (szUniqueID == NULL) {
szProto = PROTOID_HANDLE;
TCHAR tszID[40];
- mir_sntprintf(tszID, SIZEOF(tszID), _T("%p"), hContact);
+ mir_sntprintf(tszID, _countof(tszID), _T("%p"), hContact);
szUniqueID = mir_tstrdup(tszID);
}
@@ -91,7 +91,7 @@ static TCHAR *parseGetDefault(ARGUMENTSINFO *ai)
if (szUniqueID == NULL) {
szProto = PROTOID_HANDLE;
TCHAR tszID[40];
- mir_sntprintf(tszID, SIZEOF(tszID), _T("%p"), hContact);
+ mir_sntprintf(tszID, _countof(tszID), _T("%p"), hContact);
szUniqueID = mir_tstrdup(tszID);
}
@@ -131,7 +131,7 @@ static TCHAR *parseGetMostOnline(ARGUMENTSINFO *ai)
if (szUniqueID == NULL) {
szProto = PROTOID_HANDLE;
TCHAR tszID[40];
- mir_sntprintf(tszID, SIZEOF(tszID), _T("%p"), hContact);
+ mir_sntprintf(tszID, _countof(tszID), _T("%p"), hContact);
szUniqueID = mir_tstrdup(tszID);
}
diff --git a/plugins/Variables/src/parse_miranda.cpp b/plugins/Variables/src/parse_miranda.cpp
index bd07c2c23d..d66ed6d3c1 100644
--- a/plugins/Variables/src/parse_miranda.cpp
+++ b/plugins/Variables/src/parse_miranda.cpp
@@ -154,7 +154,7 @@ static TCHAR* parseDBProfileName(ARGUMENTSINFO *ai)
return NULL;
TCHAR name[MAX_PATH];
- if (CallService(MS_DB_GETPROFILENAMET, SIZEOF(name), (LPARAM)name))
+ if (CallService(MS_DB_GETPROFILENAMET, _countof(name), (LPARAM)name))
return NULL;
return mir_tstrdup(name);
@@ -166,7 +166,7 @@ static TCHAR* parseDBProfilePath(ARGUMENTSINFO *ai)
return NULL;
TCHAR path[MAX_PATH];
- if (CallService(MS_DB_GETPROFILEPATHT, SIZEOF(path), (LPARAM)path))
+ if (CallService(MS_DB_GETPROFILEPATHT, _countof(path), (LPARAM)path))
return NULL;
return mir_tstrdup(path);
@@ -390,7 +390,7 @@ static TCHAR* parseMirandaPath(ARGUMENTSINFO *ai)
ai->flags |= AIF_DONTPARSE;
TCHAR path[MAX_PATH];
- if (GetModuleFileName(NULL, path, SIZEOF(path)) == 0)
+ if (GetModuleFileName(NULL, path, _countof(path)) == 0)
return NULL;
return mir_tstrdup(path);
@@ -712,7 +712,7 @@ static TCHAR *parseMirDateString(ARGUMENTSINFO *ai)
ai->flags |= AIF_DONTPARSE;
TCHAR ret[128];
- return mir_tstrdup(TimeZone_ToStringT(time(NULL), _T("d s"), ret, SIZEOF(ret)));
+ return mir_tstrdup(TimeZone_ToStringT(time(NULL), _T("d s"), ret, _countof(ret)));
}
static TCHAR *parseMirandaCoreVar(ARGUMENTSINFO *ai)
@@ -723,7 +723,7 @@ static TCHAR *parseMirandaCoreVar(ARGUMENTSINFO *ai)
ai->flags |= AIF_DONTPARSE;
TCHAR corevar[MAX_PATH];
- mir_sntprintf(corevar, SIZEOF(corevar), _T("%%%s%%"), ai->targv[0]);
+ mir_sntprintf(corevar, _countof(corevar), _T("%%%s%%"), ai->targv[0]);
return Utils_ReplaceVarsT(corevar);
}
diff --git a/plugins/Variables/src/parse_system.cpp b/plugins/Variables/src/parse_system.cpp
index 73c83cf22e..5b63678750 100644
--- a/plugins/Variables/src/parse_system.cpp
+++ b/plugins/Variables/src/parse_system.cpp
@@ -105,7 +105,7 @@ static TCHAR *parseCpuLoad(ARGUMENTSINFO *ai)
pdhStatus = PdhCloseQuery(hQuery);
return NULL;
}
- mir_sntprintf(szVal, SIZEOF(szVal), _T("%.0f"), cValue.doubleValue);
+ mir_sntprintf(szVal, _countof(szVal), _T("%.0f"), cValue.doubleValue);
//PdhRemoveCounter(*hCounter);
PdhCloseQuery(hQuery);
mir_free(szCounter);
@@ -282,7 +282,7 @@ static TCHAR *parseDiffTime(ARGUMENTSINFO *ai)
return NULL;
diff = difftime(mktime(&t1), mktime(&t0));
- mir_sntprintf(szTime, SIZEOF(szTime), _T("%.0f"), diff);
+ mir_sntprintf(szTime, _countof(szTime), _T("%.0f"), diff);
return mir_tstrdup(szTime);
}
@@ -371,7 +371,7 @@ static TCHAR *parseListDir(ARGUMENTSINFO *ai)
tszRes = NULL;
if (ai->argc > 1)
- _tcsncpy(tszFirst, ai->targv[1], SIZEOF(tszFirst) - 1);
+ _tcsncpy(tszFirst, ai->targv[1], _countof(tszFirst) - 1);
if (ai->argc > 2)
tszFilter = ai->targv[2];
@@ -387,10 +387,10 @@ static TCHAR *parseListDir(ARGUMENTSINFO *ai)
bFiles = FALSE;
}
if (tszFirst[mir_tstrlen(tszFirst) - 1] == '\\')
- mir_tstrncat(tszFirst, tszFilter, SIZEOF(tszFirst) - mir_tstrlen(tszFirst) - 1);
+ mir_tstrncat(tszFirst, tszFilter, _countof(tszFirst) - mir_tstrlen(tszFirst) - 1);
else {
- mir_tstrncat(tszFirst, _T("\\"), SIZEOF(tszFirst) - mir_tstrlen(tszFirst) - 1);
- mir_tstrncat(tszFirst, tszFilter, SIZEOF(tszFirst) - mir_tstrlen(tszFirst) - 1);
+ mir_tstrncat(tszFirst, _T("\\"), _countof(tszFirst) - mir_tstrlen(tszFirst) - 1);
+ mir_tstrncat(tszFirst, tszFilter, _countof(tszFirst) - mir_tstrlen(tszFirst) - 1);
}
WIN32_FIND_DATA ffd;
@@ -819,7 +819,7 @@ static TCHAR *parseUpTime(ARGUMENTSINFO *ai)
}
TCHAR szVal[32];
- mir_sntprintf(szVal, SIZEOF(szVal), _T("%u"), cValue.largeValue);
+ mir_sntprintf(szVal, _countof(szVal), _T("%u"), cValue.largeValue);
PdhRemoveCounter(hCounter);
PdhCloseQuery(hQuery);
return mir_tstrdup(szVal);