From dc19f81f05dd2559af329c528c2f04e869d8ef1e Mon Sep 17 00:00:00 2001 From: Adeel Date: Sun, 24 Feb 2019 12:14:06 -0800 Subject: Fix comparison and narrowing errors reported by GCC --- src/debug/createdump/crashinfo.cpp | 8 ++++---- src/debug/createdump/datatarget.cpp | 4 ++-- src/debug/debug-pal/unix/twowaypipe.cpp | 8 ++++---- 3 files changed, 10 insertions(+), 10 deletions(-) (limited to 'src/debug') 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)); 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; } -- cgit v1.2.3