fix various instances of -1 being assigned to unsigned types

This commit is contained in:
Shawn Hoffman
2017-06-07 04:16:02 -07:00
parent be7c6a0819
commit e1a3e41bf3
15 changed files with 25 additions and 27 deletions

View File

@ -986,7 +986,7 @@ u64 IOFile::Tell() const
if (IsOpen())
return ftello(m_file);
else
return -1;
return UINT64_MAX;
}
bool IOFile::Flush()

View File

@ -198,7 +198,7 @@ inline int IntLog2(u64 val)
return 63 - __builtin_clzll(val);
#elif defined(_MSC_VER)
unsigned long result = -1;
unsigned long result = ULONG_MAX;
_BitScanReverse64(&result, val);
return result;

View File

@ -29,8 +29,8 @@ std::string Profiler::s_lazy_result = "";
int Profiler::s_lazy_delay = 0;
Profiler::Profiler(const std::string& name)
: m_name(name), m_usecs(0), m_usecs_min(-1), m_usecs_max(0), m_usecs_quad(0), m_calls(0),
m_depth(0)
: m_name(name), m_usecs(0), m_usecs_min(UINT64_MAX), m_usecs_max(0), m_usecs_quad(0),
m_calls(0), m_depth(0)
{
m_time = Common::Timer::GetTimeUs();
s_max_length = std::max<u32>(s_max_length, u32(m_name.length()));
@ -154,7 +154,7 @@ std::string Profiler::Read()
buffer << std::setw(PROFILER_FIELD_LENGTH) << std::right << m_usecs_max;
m_usecs = 0;
m_usecs_min = -1;
m_usecs_min = UINT64_MAX;
m_usecs_max = 0;
m_usecs_quad = 0;
m_calls = 0;

View File

@ -62,11 +62,8 @@ void SwitchCurrentThread()
}
// Sets the debugger-visible name of the current thread.
// Uses undocumented (actually, it is now documented) trick.
// http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vsdebug/html/vxtsksettingthreadname.asp
// This is implemented much nicer in upcoming msvc++, see:
// http://msdn.microsoft.com/en-us/library/xcb2z8hs(VS.100).aspx
// Uses trick documented in:
// https://docs.microsoft.com/en-us/visualstudio/debugger/how-to-set-a-thread-name-in-native-code
void SetCurrentThreadName(const char* szThreadName)
{
static const DWORD MS_VC_EXCEPTION = 0x406D1388;
@ -83,7 +80,7 @@ void SetCurrentThreadName(const char* szThreadName)
info.dwType = 0x1000;
info.szName = szThreadName;
info.dwThreadID = -1; // dwThreadID;
info.dwThreadID = static_cast<DWORD>(-1);
info.dwFlags = 0;
__try