summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdeel <adeelbm@outlook.com>2019-02-24 12:14:06 -0800
committerAdeel <adeelbm@outlook.com>2019-02-24 15:53:32 -0800
commitdc19f81f05dd2559af329c528c2f04e869d8ef1e (patch)
treea61fb44fa2b31ec85e2daf9e670f01a6c4f97e59
parent333232d98639df980133205c41791cb9dc7f3d34 (diff)
downloadcoreclr-dc19f81f05dd2559af329c528c2f04e869d8ef1e.tar.gz
coreclr-dc19f81f05dd2559af329c528c2f04e869d8ef1e.tar.bz2
coreclr-dc19f81f05dd2559af329c528c2f04e869d8ef1e.zip
Fix comparison and narrowing errors reported by GCC
-rw-r--r--src/coreclr/hosts/unixcoreruncommon/coreruncommon.cpp2
-rw-r--r--src/debug/createdump/crashinfo.cpp8
-rw-r--r--src/debug/createdump/datatarget.cpp4
-rw-r--r--src/debug/debug-pal/unix/twowaypipe.cpp8
-rw-r--r--src/unwinder/amd64/unwinder_amd64.cpp2
-rw-r--r--src/vm/callingconvention.h2
-rw-r--r--src/vm/codeversion.h22
-rw-r--r--src/vm/crossloaderallocatorhash.inl2
-rw-r--r--src/vm/inlinetracking.h2
-rw-r--r--src/vm/rejit.h2
-rw-r--r--tests/src/Interop/PInvoke/Decimal/PInvoke/DecNative.cpp6
-rw-r--r--tests/src/Interop/PInvoke/Decimal/ReversePInvoke/RevNative.cpp6
-rw-r--r--tests/src/Interop/StructMarshalling/PInvoke/MarshalStructAsParamDLL.h4
-rw-r--r--tests/src/Interop/StructMarshalling/ReversePInvoke/MarshalExpStruct/ExpStructAsParamNative.h4
-rw-r--r--tests/src/Interop/StructMarshalling/ReversePInvoke/MarshalSeqStruct/SeqStructDelRevPInvokeNative.h4
-rw-r--r--tests/src/JIT/jit64/mcc/interop/native_i1c.cpp15
16 files changed, 44 insertions, 49 deletions
diff --git a/src/coreclr/hosts/unixcoreruncommon/coreruncommon.cpp b/src/coreclr/hosts/unixcoreruncommon/coreruncommon.cpp
index eb2333c8c6..7bfe2eaa98 100644
--- a/src/coreclr/hosts/unixcoreruncommon/coreruncommon.cpp
+++ b/src/coreclr/hosts/unixcoreruncommon/coreruncommon.cpp
@@ -190,7 +190,7 @@ void AddFilesFromDirectoryToTpaList(const char* directory, std::string& tpaList)
// Walk the directory for each extension separately so that we first get files with .ni.dll extension,
// then files with .dll extension, etc.
- for (int extIndex = 0; extIndex < sizeof(tpaExtensions) / sizeof(tpaExtensions[0]); extIndex++)
+ for (size_t extIndex = 0; extIndex < sizeof(tpaExtensions) / sizeof(tpaExtensions[0]); extIndex++)
{
const char* ext = tpaExtensions[extIndex];
int extLength = strlen(ext);
diff --git a/src/debug/createdump/crashinfo.cpp b/src/debug/createdump/crashinfo.cpp
index 4db2b00eeb..192ed82b43 100644
--- a/src/debug/createdump/crashinfo.cpp
+++ b/src/debug/createdump/crashinfo.cpp
@@ -317,7 +317,7 @@ CrashInfo::EnumerateModuleMappings()
// Making something like: /proc/123/maps
char mapPath[128];
int chars = snprintf(mapPath, sizeof(mapPath), "/proc/%d/maps", m_pid);
- assert(chars > 0 && chars <= sizeof(mapPath));
+ assert(chars > 0 && (size_t)chars <= sizeof(mapPath));
FILE* mapsFile = fopen(mapPath, "r");
if (mapsFile == nullptr)
@@ -374,7 +374,7 @@ CrashInfo::EnumerateModuleMappings()
std::string coreclrPath;
coreclrPath.append(moduleName);
size_t last = coreclrPath.rfind(MAKEDLLNAME_A("coreclr"));
- if (last != -1) {
+ if (last != std::string::npos) {
m_coreclrPath = coreclrPath.substr(0, last);
}
}
@@ -909,7 +909,7 @@ CrashInfo::InsertMemoryRegion(const MemoryRegion& region)
// time to avoid the overlapping pages.
uint64_t numberPages = region.Size() / PAGE_SIZE;
- for (int p = 0; p < numberPages; p++, start += PAGE_SIZE)
+ for (uint64_t p = 0; p < numberPages; p++, start += PAGE_SIZE)
{
MemoryRegion memoryRegionPage(region.Flags(), start, start + PAGE_SIZE);
@@ -957,7 +957,7 @@ CrashInfo::ValidRegion(const MemoryRegion& region)
uint64_t start = region.StartAddress();
uint64_t numberPages = region.Size() / PAGE_SIZE;
- for (int p = 0; p < numberPages; p++, start += PAGE_SIZE)
+ for (uint64_t p = 0; p < numberPages; p++, start += PAGE_SIZE)
{
BYTE buffer[1];
uint32_t read;
diff --git a/src/debug/createdump/datatarget.cpp b/src/debug/createdump/datatarget.cpp
index b0fb6ebcf4..934545090d 100644
--- a/src/debug/createdump/datatarget.cpp
+++ b/src/debug/createdump/datatarget.cpp
@@ -151,7 +151,7 @@ DumpDataTarget::ReadVirtual(
{
assert(m_fd != -1);
size_t read = pread64(m_fd, buffer, size, (off64_t)(ULONG_PTR)address);
- if (read == -1)
+ if (read == (size_t)-1)
{
*done = 0;
return E_FAIL;
@@ -215,7 +215,7 @@ DumpDataTarget::GetThreadContext(
memset(context, 0, contextSize);
for (const ThreadInfo* thread : m_crashInfo->Threads())
{
- if (thread->Tid() == threadID)
+ if (thread->Tid() == (pid_t)threadID)
{
thread->GetThreadContext(contextFlags, reinterpret_cast<CONTEXT*>(context));
return S_OK;
diff --git a/src/debug/debug-pal/unix/twowaypipe.cpp b/src/debug/debug-pal/unix/twowaypipe.cpp
index b0acb1df7b..91afd820fb 100644
--- a/src/debug/debug-pal/unix/twowaypipe.cpp
+++ b/src/debug/debug-pal/unix/twowaypipe.cpp
@@ -117,8 +117,8 @@ int TwoWayPipe::Read(void *buffer, DWORD bufferSize)
while ((bytesRead = (int)read(m_inboundPipe, buffer, cb)) > 0)
{
totalBytesRead += bytesRead;
- _ASSERTE(totalBytesRead <= bufferSize);
- if (totalBytesRead >= bufferSize)
+ _ASSERTE(totalBytesRead <= (int)bufferSize);
+ if (totalBytesRead >= (int)bufferSize)
{
break;
}
@@ -144,8 +144,8 @@ int TwoWayPipe::Write(const void *data, DWORD dataSize)
while ((bytesWritten = (int)write(m_outboundPipe, data, cb)) > 0)
{
totalBytesWritten += bytesWritten;
- _ASSERTE(totalBytesWritten <= dataSize);
- if (totalBytesWritten >= dataSize)
+ _ASSERTE(totalBytesWritten <= (int)dataSize);
+ if (totalBytesWritten >= (int)dataSize)
{
break;
}
diff --git a/src/unwinder/amd64/unwinder_amd64.cpp b/src/unwinder/amd64/unwinder_amd64.cpp
index 65da7862a5..8d989d4095 100644
--- a/src/unwinder/amd64/unwinder_amd64.cpp
+++ b/src/unwinder/amd64/unwinder_amd64.cpp
@@ -134,7 +134,7 @@ public:
UCHAR operator[](int index)
{
int realIndex = m_offset + index;
- UNWINDER_ASSERT(realIndex < sizeof(m_buffer));
+ UNWINDER_ASSERT(realIndex < (int)sizeof(m_buffer));
return m_buffer[realIndex];
}
};
diff --git a/src/vm/callingconvention.h b/src/vm/callingconvention.h
index eaabaa42b2..7368fecac8 100644
--- a/src/vm/callingconvention.h
+++ b/src/vm/callingconvention.h
@@ -179,7 +179,7 @@ struct TransitionBlock
LIMITED_METHOD_CONTRACT;
#if defined(UNIX_AMD64_ABI)
- return offset >= sizeof(TransitionBlock);
+ return offset >= (int)sizeof(TransitionBlock);
#else
int ofsArgRegs = GetOffsetOfArgumentRegisters();
diff --git a/src/vm/codeversion.h b/src/vm/codeversion.h
index 821c938788..a85a6beb21 100644
--- a/src/vm/codeversion.h
+++ b/src/vm/codeversion.h
@@ -105,14 +105,16 @@ private:
Synthetic
};
+ struct SyntheticStorage
+ {
+ PTR_MethodDesc m_pMethodDesc;
+ };
+
StorageKind m_storageKind;
union
{
PTR_NativeCodeVersionNode m_pVersionNode;
- struct SyntheticStorage
- {
- PTR_MethodDesc m_pMethodDesc;
- } m_synthetic;
+ SyntheticStorage m_synthetic;
};
#endif // FEATURE_CODE_VERSIONING
};
@@ -203,15 +205,17 @@ private:
Synthetic
};
+ struct SyntheticStorage
+ {
+ PTR_Module m_pModule;
+ mdMethodDef m_methodDef;
+ };
+
StorageKind m_storageKind;
union
{
PTR_ILCodeVersionNode m_pVersionNode;
- struct SyntheticStorage
- {
- PTR_Module m_pModule;
- mdMethodDef m_methodDef;
- } m_synthetic;
+ SyntheticStorage m_synthetic;
};
};
diff --git a/src/vm/crossloaderallocatorhash.inl b/src/vm/crossloaderallocatorhash.inl
index 51bce4e1ae..a12470cf6c 100644
--- a/src/vm/crossloaderallocatorhash.inl
+++ b/src/vm/crossloaderallocatorhash.inl
@@ -201,7 +201,7 @@ template <class TKey_, class TValue_>
/*static*/ inline INT32 GCHeapHashDependentHashTrackerHashTraits::Hash(PtrTypeKey *pValue)
{
LIMITED_METHOD_CONTRACT;
- return (INT32)*pValue;
+ return *(INT32*)pValue;
}
/*static*/ inline INT32 GCHeapHashDependentHashTrackerHashTraits::Hash(PTRARRAYREF arr, INT32 index)
diff --git a/src/vm/inlinetracking.h b/src/vm/inlinetracking.h
index 976a0e72db..58336a42b4 100644
--- a/src/vm/inlinetracking.h
+++ b/src/vm/inlinetracking.h
@@ -106,7 +106,7 @@ public:
static count_t Hash(key_t k)
{
LIMITED_METHOD_DAC_CONTRACT;
- return ((count_t)k.m_methodDef ^ (count_t)k.m_module);
+ return k.m_methodDef ^ *(count_t*)k.m_module;
}
static const element_t Null()
{
diff --git a/src/vm/rejit.h b/src/vm/rejit.h
index 8401ecb960..09513e10c7 100644
--- a/src/vm/rejit.h
+++ b/src/vm/rejit.h
@@ -150,7 +150,7 @@ private:
typedef CodeVersionManager * key_t;
static key_t GetKey(const element_t &e) { return e->m_pCodeVersionManager; }
static BOOL Equals(key_t k1, key_t k2) { return (k1 == k2); }
- static count_t Hash(key_t k) { return (count_t)k; }
+ static count_t Hash(key_t k) { return *(count_t*)k; }
static bool IsNull(const element_t &e) { return (e == NULL); }
};
diff --git a/tests/src/Interop/PInvoke/Decimal/PInvoke/DecNative.cpp b/tests/src/Interop/PInvoke/Decimal/PInvoke/DecNative.cpp
index a853f7eed1..875d580546 100644
--- a/tests/src/Interop/PInvoke/Decimal/PInvoke/DecNative.cpp
+++ b/tests/src/Interop/PInvoke/Decimal/PInvoke/DecNative.cpp
@@ -6,11 +6,11 @@
#include <xplatform.h>
#include "platformdefines.h"
-DECIMAL g_DECIMAL_MaxValue = { 0, {{ 0, 0 }}, 0xffffffff, {{0xffffffff, 0xffffffff}} };
-DECIMAL g_DECIMAL_MinValue = { 0, {{ 0, DECIMAL_NEG }}, 0xffffffff, {{0xffffffff, 0xffffffff}} };
+DECIMAL g_DECIMAL_MaxValue = { 0, {{ 0, 0 }}, static_cast<int>(0xffffffff), {{static_cast<int>(0xffffffff), static_cast<int>(0xffffffff)}} };
+DECIMAL g_DECIMAL_MinValue = { 0, {{ 0, DECIMAL_NEG }}, static_cast<int>(0xffffffff), {{static_cast<int>(0xffffffff), static_cast<int>(0xffffffff)}} };
DECIMAL g_DECIMAL_Zero = { 0 };
-CY g_CY_MaxValue = { { 0xffffffff, 0x7fffffff } };
+CY g_CY_MaxValue = { { static_cast<int>(0xffffffff), static_cast<int>(0x7fffffff) } };
CY g_CY_MinValue = { { (LONG)0x00000000, (LONG)0x80000000 } };
CY g_CY_Zero = { { 0 } };
diff --git a/tests/src/Interop/PInvoke/Decimal/ReversePInvoke/RevNative.cpp b/tests/src/Interop/PInvoke/Decimal/ReversePInvoke/RevNative.cpp
index 6f716e8420..d586bfae0a 100644
--- a/tests/src/Interop/PInvoke/Decimal/ReversePInvoke/RevNative.cpp
+++ b/tests/src/Interop/PInvoke/Decimal/ReversePInvoke/RevNative.cpp
@@ -6,11 +6,11 @@
#include <xplatform.h>
#include "platformdefines.h"
-DECIMAL g_DECIMAL_MaxValue = { 0, {{ 0, 0 }}, 0xffffffff, {{0xffffffff, 0xffffffff}} };
-DECIMAL g_DECIMAL_MinValue = { 0, {{ 0, DECIMAL_NEG }}, 0xffffffff, {{0xffffffff, 0xffffffff }}};
+DECIMAL g_DECIMAL_MaxValue = { 0, {{ 0, 0 }}, static_cast<int>(0xffffffff), {{static_cast<int>(0xffffffff), static_cast<int>(0xffffffff)}} };
+DECIMAL g_DECIMAL_MinValue = { 0, {{ 0, DECIMAL_NEG }}, static_cast<int>(0xffffffff), {{static_cast<int>(0xffffffff), static_cast<int>(0xffffffff) }}};
DECIMAL g_DECIMAL_Zero = { 0 };
-CY g_CY_MaxValue = { {0xffffffff, 0x7fffffff} };
+CY g_CY_MaxValue = { {static_cast<int>(0xffffffff), static_cast<int>(0x7fffffff)} };
CY g_CY_MinValue = { {(LONG)0x00000000, (LONG)0x80000000} };
CY g_CY_Zero = { {0} };
diff --git a/tests/src/Interop/StructMarshalling/PInvoke/MarshalStructAsParamDLL.h b/tests/src/Interop/StructMarshalling/PInvoke/MarshalStructAsParamDLL.h
index 3d3bc81c0c..6b38ec93e4 100644
--- a/tests/src/Interop/StructMarshalling/PInvoke/MarshalStructAsParamDLL.h
+++ b/tests/src/Interop/StructMarshalling/PInvoke/MarshalStructAsParamDLL.h
@@ -374,8 +374,8 @@ void ChangeNumberSequential(NumberSequential* p)
bool IsCorrectNumberSequential(NumberSequential* p)
{
- if(p->i32 != (-0x7fffffff - 1) || p->ui32 != 0xffffffff || p->s1 != -0x8000 || p->us1 != 0xffff || p->b != 0 ||
- p->sb != 0x7f ||p->i16 != -0x8000 || p->ui16 != 0xffff || p->i64 != -1234567890 ||
+ if(p->i32 != (-0x7fffffff - 1) || p->ui32 != 0xffffffff || p->s1 != -0x8000 || p->us1 != 0xffff || p->b != 0 ||
+ p->sb != 0x7f ||p->i16 != -0x8000 || p->ui16 != 0xffff || p->i64 != (unsigned)-1234567890 ||
p->ui64 != 1234567890 || (p->sgl) != 32.0 || p->d != 3.2)
{
return false;
diff --git a/tests/src/Interop/StructMarshalling/ReversePInvoke/MarshalExpStruct/ExpStructAsParamNative.h b/tests/src/Interop/StructMarshalling/ReversePInvoke/MarshalExpStruct/ExpStructAsParamNative.h
index 2f6ebc9d90..0c931c6e86 100644
--- a/tests/src/Interop/StructMarshalling/ReversePInvoke/MarshalExpStruct/ExpStructAsParamNative.h
+++ b/tests/src/Interop/StructMarshalling/ReversePInvoke/MarshalExpStruct/ExpStructAsParamNative.h
@@ -404,8 +404,8 @@ void ChangeNumberSequential(NumberSequential* p)
bool IsCorrectNumberSequential(NumberSequential* p)
{
- if(p->i32 != INT_MIN || p->ui32 != 0xffffffff || p->s1 != -0x8000 || p->us1 != 0xffff || p->b != 0 ||
- p->sb != 0x7f ||p->i16 != -0x8000 || p->ui16 != 0xffff || p->i64 != -1234567890 ||
+ if(p->i32 != INT_MIN || p->ui32 != 0xffffffff || p->s1 != -0x8000 || p->us1 != 0xffff || p->b != 0 ||
+ p->sb != 0x7f ||p->i16 != -0x8000 || p->ui16 != 0xffff || p->i64 != (unsigned)-1234567890 ||
p->ui64 != 1234567890 || (p->sgl) != 32.0 || p->d != 3.2)
{
return false;
diff --git a/tests/src/Interop/StructMarshalling/ReversePInvoke/MarshalSeqStruct/SeqStructDelRevPInvokeNative.h b/tests/src/Interop/StructMarshalling/ReversePInvoke/MarshalSeqStruct/SeqStructDelRevPInvokeNative.h
index 43fdb7febb..30205ba9cb 100644
--- a/tests/src/Interop/StructMarshalling/ReversePInvoke/MarshalSeqStruct/SeqStructDelRevPInvokeNative.h
+++ b/tests/src/Interop/StructMarshalling/ReversePInvoke/MarshalSeqStruct/SeqStructDelRevPInvokeNative.h
@@ -392,8 +392,8 @@ void ChangeNumberSequential(NumberSequential* p)
bool IsCorrectNumberSequential(NumberSequential* p)
{
- if(p->i32 != INT_MIN || p->ui32 != 0xffffffff || p->s1 != -0x8000 || p->us1 != 0xffff || p->b != 0 ||
- p->sb != 0x7f ||p->i16 != -0x8000 || p->ui16 != 0xffff || p->i64 != -1234567890 ||
+ if(p->i32 != INT_MIN || p->ui32 != 0xffffffff || p->s1 != -0x8000 || p->us1 != 0xffff || p->b != 0 ||
+ p->sb != 0x7f ||p->i16 != -0x8000 || p->ui16 != 0xffff || p->i64 != (unsigned)-1234567890 ||
p->ui64 != 1234567890 || (p->sgl) != 32.0 || p->d != 3.2)
{
return false;
diff --git a/tests/src/JIT/jit64/mcc/interop/native_i1c.cpp b/tests/src/JIT/jit64/mcc/interop/native_i1c.cpp
index b20408db22..35c70ac3b1 100644
--- a/tests/src/JIT/jit64/mcc/interop/native_i1c.cpp
+++ b/tests/src/JIT/jit64/mcc/interop/native_i1c.cpp
@@ -4,17 +4,12 @@
#include <stdarg.h>
#include "native.h"
-#ifdef __clang__
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wvarargs"
-#endif
-
-MCC_API VType1 sum(float first, ...) {
+MCC_API VType1 sum(double first, ...) {
VType1 result;
int count = 0;
float sum = 0.0;
- float val = first;
+ float val = (float)first;
va_list args;
// initialize variable arguments.
@@ -22,7 +17,7 @@ MCC_API VType1 sum(float first, ...) {
while (val != (float)-1) {
sum += val;
count++;
- val = va_arg(args, float);
+ val = (float)va_arg(args, double);
}
// reset variable arguments.
va_end(args);
@@ -53,7 +48,3 @@ MCC_API VType1 sum(float first, ...) {
return result;
}
-
-#ifdef __clang__
-#pragma clang diagnostic pop
-#endif