summaryrefslogtreecommitdiff
path: root/tests/src
diff options
context:
space:
mode:
authorYi Zhang (CLR) <yzha@microsoft.com>2016-05-02 00:42:57 -0700
committerYi Zhang (CLR) <yzha@microsoft.com>2016-05-02 00:42:57 -0700
commite18a26aabee632497cbf4be6258c3c930d004824 (patch)
treefea6cece9c35a4f4e420031a1f188154fa10b2e1 /tests/src
parent4d1c4398863afdf5d6511d69402eb2123eec2327 (diff)
parentde7fb68db2c83cb31927270d97bf993437cf61c4 (diff)
downloadcoreclr-e18a26aabee632497cbf4be6258c3c930d004824.tar.gz
coreclr-e18a26aabee632497cbf4be6258c3c930d004824.tar.bz2
coreclr-e18a26aabee632497cbf4be6258c3c930d004824.zip
Merge pull request #4710 from yizhang82/array_warn_fix
Fix warnings in ByValArray
Diffstat (limited to 'tests/src')
-rw-r--r--tests/src/Interop/ArrayMarshalling/ByValArray/MarshalArrayByValNative.cpp22
-rw-r--r--tests/src/Interop/common/xplatform.h9
2 files changed, 19 insertions, 12 deletions
diff --git a/tests/src/Interop/ArrayMarshalling/ByValArray/MarshalArrayByValNative.cpp b/tests/src/Interop/ArrayMarshalling/ByValArray/MarshalArrayByValNative.cpp
index 26fbbac449..bf3d66d41c 100644
--- a/tests/src/Interop/ArrayMarshalling/ByValArray/MarshalArrayByValNative.cpp
+++ b/tests/src/Interop/ArrayMarshalling/ByValArray/MarshalArrayByValNative.cpp
@@ -71,7 +71,7 @@ helper function
LPSTR ToString(int i)
{
CHAR *pBuffer = (CHAR *)::CoTaskMemAlloc(10 * sizeof(CHAR)); // 10 is enough for our case, WCHAR for BSTR
- snprintf(pBuffer, 10 * sizeof(CHAR), "%d", i);
+ snprintf(pBuffer, 10, "%d", i);
return pBuffer;
}
@@ -81,7 +81,7 @@ TestStruct* InitTestStruct()
{
TestStruct *expected = (TestStruct *)CoTaskMemAlloc( sizeof(TestStruct) * ARRAY_SIZE );
- for ( size_t i = 0; i < ARRAY_SIZE; i++)
+ for ( int i = 0; i < ARRAY_SIZE; i++)
{
expected[i].x = i;
expected[i].d = i;
@@ -103,7 +103,7 @@ BOOL Equals(T *pActual, int cActual, T *pExpected, int cExpected)
return FALSE;
}
- for ( size_t i = 0; i < ((size_t) cExpected); ++i )
+ for ( int i = 0; i < cExpected; ++i )
{
if ( !IsObjectEquals(pActual[i], pExpected[i]) )
{
@@ -124,8 +124,8 @@ template<typename T> bool IsObjectEquals(T o1, T o2)
template<>
bool IsObjectEquals(LPSTR o1, LPSTR o2)
{
- int cLen1 = strlen(o1);
- int cLen2 = strlen(o2);
+ size_t cLen1 = strlen(o1);
+ size_t cLen2 = strlen(o2);
if (cLen1 != cLen2 )
{
@@ -267,7 +267,7 @@ extern "C" DLL_EXPORT BOOL TakeLPSTRArraySeqStructByVal( S_LPSTRArray s, int siz
CHECK_PARAM_NOT_EMPTY( s.arr );
LPSTR expected[ARRAY_SIZE];
- for ( size_t i = 0; i < ARRAY_SIZE; ++i )
+ for ( int i = 0; i < ARRAY_SIZE; ++i )
expected[i] = ToString(i);
return Equals( s.arr, size, expected, ARRAY_SIZE );
@@ -278,7 +278,7 @@ extern "C" DLL_EXPORT BOOL TakeLPCSTRArraySeqStructByVal( S_LPCSTRArray s, int s
CHECK_PARAM_NOT_EMPTY( s.arr );
LPSTR expected[ARRAY_SIZE];
- for ( size_t i = 0; i < ARRAY_SIZE; ++i )
+ for ( int i = 0; i < ARRAY_SIZE; ++i )
expected[i] = ToString(i);
return Equals( s.arr, size, (LPCSTR *)expected, ARRAY_SIZE );
@@ -578,9 +578,9 @@ extern "C" DLL_EXPORT S_CHARArray* S_CHARArray_Ret()
}
extern "C" DLL_EXPORT S_LPSTRArray* S_LPSTRArray_Ret()
-{
+{
S_LPSTRArray *expected = (S_LPSTRArray *)::CoTaskMemAlloc( sizeof(S_LPSTRArray) );
- for ( size_t i = 0; i < ARRAY_SIZE; ++i )
+ for ( int i = 0; i < ARRAY_SIZE; ++i )
expected->arr[i] = ToString(i);
return expected;
@@ -590,7 +590,7 @@ extern "C" DLL_EXPORT S_LPSTRArray* S_LPSTRArray_Ret()
extern "C" DLL_EXPORT S_StructArray* S_StructArray_Ret()
{
S_StructArray *expected = (S_StructArray *)::CoTaskMemAlloc( sizeof(S_StructArray) );
- for ( size_t i = 0; i < ARRAY_SIZE; ++i )
+ for ( int i = 0; i < ARRAY_SIZE; ++i )
{
expected->arr[i].x = i;
expected->arr[i].d = i;
@@ -599,4 +599,4 @@ extern "C" DLL_EXPORT S_StructArray* S_StructArray_Ret()
}
return expected;
-} \ No newline at end of file
+}
diff --git a/tests/src/Interop/common/xplatform.h b/tests/src/Interop/common/xplatform.h
index 0099cae14e..3e7267fe07 100644
--- a/tests/src/Interop/common/xplatform.h
+++ b/tests/src/Interop/common/xplatform.h
@@ -5,6 +5,11 @@
#ifndef __XPLAT_H__
#define __XPLAT_H__
+#ifdef _MSC_VER
+// Our tests don't care about secure CRT
+#define _CRT_SECURE_NO_WARNINGS 1
+#endif
+
// common headers
#include <stdio.h>
#include <memory.h>
@@ -48,8 +53,10 @@
#endif //_WIN32
+#ifndef WINAPI
+#define WINAPI __stdcall
+#endif
-#define WINAPI _cdecl
#ifndef __stdcall
#if __i386__
#define __stdcall __attribute__((stdcall))