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()) if (IsOpen())
return ftello(m_file); return ftello(m_file);
else else
return -1; return UINT64_MAX;
} }
bool IOFile::Flush() bool IOFile::Flush()

View File

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

View File

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

View File

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

View File

@ -42,7 +42,7 @@ u32 CDump::GetGPR(int _step, int _gpr)
u32 offset = _step * STRUCTUR_SIZE; u32 offset = _step * STRUCTUR_SIZE;
if (offset >= m_size) if (offset >= m_size)
return -1; return UINT32_MAX;
return Read32(offset + OFFSET_GPR + (_gpr * 4)); return Read32(offset + OFFSET_GPR + (_gpr * 4));
} }
@ -52,7 +52,7 @@ u32 CDump::GetPC(int _step)
u32 offset = _step * STRUCTUR_SIZE; u32 offset = _step * STRUCTUR_SIZE;
if (offset >= m_size) if (offset >= m_size)
return -1; return UINT32_MAX;
return Read32(offset + OFFSET_PC); return Read32(offset + OFFSET_PC);
} }

View File

@ -495,7 +495,7 @@ void Interpreter::divwx(UGeckoInstruction inst)
} }
if (((u32)a & 0x80000000) && b == 0) if (((u32)a & 0x80000000) && b == 0)
rGPR[inst.RD] = -1; rGPR[inst.RD] = UINT32_MAX;
else else
rGPR[inst.RD] = 0; rGPR[inst.RD] = 0;
} }

View File

@ -730,8 +730,8 @@ u32 PPCAnalyzer::Analyze(u32 address, CodeBlock* block, CodeBuffer* buffer, u32
code[i].opinfo = opinfo; code[i].opinfo = opinfo;
code[i].address = address; code[i].address = address;
code[i].inst = inst; code[i].inst = inst;
code[i].branchTo = -1; code[i].branchTo = UINT32_MAX;
code[i].branchToIndex = -1; code[i].branchToIndex = UINT32_MAX;
code[i].skip = false; code[i].skip = false;
block->m_stats->numCycles += opinfo->numCycles; block->m_stats->numCycles += opinfo->numCycles;
block->m_physical_addresses.insert(result.physical_address); block->m_physical_addresses.insert(result.physical_address);

View File

@ -48,7 +48,7 @@ private:
CISOFileReader(File::IOFile file); CISOFileReader(File::IOFile file);
typedef u16 MapType; typedef u16 MapType;
static const MapType UNUSED_BLOCK_ID = -1; static const MapType UNUSED_BLOCK_ID = UINT16_MAX;
File::IOFile m_file; File::IOFile m_file;
u64 m_size; u64 m_size;

View File

@ -35,7 +35,7 @@ const size_t VolumeDirectory::MAX_ID_LENGTH;
VolumeDirectory::VolumeDirectory(const std::string& directory, bool is_wii, VolumeDirectory::VolumeDirectory(const std::string& directory, bool is_wii,
const std::string& apploader, const std::string& dol) const std::string& apploader, const std::string& dol)
: m_data_start_address(-1), m_disk_header(DISKHEADERINFO_ADDRESS), : m_data_start_address(UINT64_MAX), m_disk_header(DISKHEADERINFO_ADDRESS),
m_disk_header_info(std::make_unique<SDiskHeaderInfo>()), m_fst_address(0), m_dol_address(0) m_disk_header_info(std::make_unique<SDiskHeaderInfo>()), m_fst_address(0), m_dol_address(0)
{ {
m_root_directory = ExtractDirectoryName(directory); m_root_directory = ExtractDirectoryName(directory);

View File

@ -32,7 +32,8 @@ namespace DiscIO
constexpr u64 PARTITION_DATA_OFFSET = 0x20000; constexpr u64 PARTITION_DATA_OFFSET = 0x20000;
VolumeWii::VolumeWii(std::unique_ptr<BlobReader> reader) VolumeWii::VolumeWii(std::unique_ptr<BlobReader> reader)
: m_pReader(std::move(reader)), m_game_partition(PARTITION_NONE), m_last_decrypted_block(-1) : m_pReader(std::move(reader)), m_game_partition(PARTITION_NONE),
m_last_decrypted_block(UINT64_MAX)
{ {
_assert_(m_pReader); _assert_(m_pReader);

View File

@ -32,7 +32,7 @@ static DSPDebuggerLLE* m_DebuggerFrame = nullptr;
DSPDebuggerLLE::DSPDebuggerLLE(wxWindow* parent, wxWindowID id) DSPDebuggerLLE::DSPDebuggerLLE(wxWindow* parent, wxWindowID id)
: wxPanel(parent, id, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, _("DSP LLE Debugger")), : wxPanel(parent, id, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, _("DSP LLE Debugger")),
m_CachedStepCounter(-1), m_toolbar_item_size(FromDIP(wxSize(16, 16))) m_CachedStepCounter(UINT64_MAX), m_toolbar_item_size(FromDIP(wxSize(16, 16)))
{ {
Bind(wxEVT_MENU, &DSPDebuggerLLE::OnChangeState, this, ID_RUNTOOL, ID_SHOWPCTOOL); Bind(wxEVT_MENU, &DSPDebuggerLLE::OnChangeState, this, ID_RUNTOOL, ID_SHOWPCTOOL);

View File

@ -370,9 +370,9 @@ TextureCache::TextureCache()
{ {
CompileShaders(); CompileShaders();
s_ActiveTexture = -1; s_ActiveTexture = UINT32_MAX;
for (auto& gtex : s_Textures) for (auto& gtex : s_Textures)
gtex = -1; gtex = UINT32_MAX;
if (g_ActiveConfig.backend_info.bSupportsPaletteConversion) if (g_ActiveConfig.backend_info.bSupportsPaletteConversion)
{ {
@ -519,8 +519,8 @@ bool TextureCache::CompileShaders()
s_ColorMatrixUniform = glGetUniformLocation(s_ColorMatrixProgram.glprogid, "colmat"); s_ColorMatrixUniform = glGetUniformLocation(s_ColorMatrixProgram.glprogid, "colmat");
s_DepthMatrixUniform = glGetUniformLocation(s_DepthMatrixProgram.glprogid, "colmat"); s_DepthMatrixUniform = glGetUniformLocation(s_DepthMatrixProgram.glprogid, "colmat");
s_ColorCbufid = -1; s_ColorCbufid = UINT32_MAX;
s_DepthCbufid = -1; s_DepthCbufid = UINT32_MAX;
s_ColorCopyPositionUniform = glGetUniformLocation(s_ColorCopyProgram.glprogid, "copy_position"); s_ColorCopyPositionUniform = glGetUniformLocation(s_ColorCopyProgram.glprogid, "copy_position");
s_ColorMatrixPositionUniform = s_ColorMatrixPositionUniform =

View File

@ -16,7 +16,7 @@ u16* IndexGenerator::index_buffer_current;
u16* IndexGenerator::BASEIptr; u16* IndexGenerator::BASEIptr;
u32 IndexGenerator::base_index; u32 IndexGenerator::base_index;
static const u16 s_primitive_restart = -1; static const u16 s_primitive_restart = UINT16_MAX;
static u16* (*primitive_table[8])(u16*, u32, u32); static u16* (*primitive_table[8])(u16*, u32, u32);

View File

@ -994,7 +994,7 @@ void TextureCacheBase::CopyRenderTargetToTexture(u32 dstAddr, unsigned int dstFo
float* const ColorMask = colmat + 20; float* const ColorMask = colmat + 20;
ColorMask[0] = ColorMask[1] = ColorMask[2] = ColorMask[3] = 255.0f; ColorMask[0] = ColorMask[1] = ColorMask[2] = ColorMask[3] = 255.0f;
ColorMask[4] = ColorMask[5] = ColorMask[6] = ColorMask[7] = 1.0f / 255.0f; ColorMask[4] = ColorMask[5] = ColorMask[6] = ColorMask[7] = 1.0f / 255.0f;
unsigned int cbufid = -1; unsigned int cbufid = UINT_MAX;
u32 srcFormat = bpmem.zcontrol.pixel_format; u32 srcFormat = bpmem.zcontrol.pixel_format;
bool efbHasAlpha = srcFormat == PEControl::RGBA6_Z24; bool efbHasAlpha = srcFormat == PEControl::RGBA6_Z24;

View File

@ -36,7 +36,7 @@ public:
private: private:
size_t CalculateHash() const size_t CalculateHash() const
{ {
size_t h = -1; size_t h = SIZE_MAX;
for (auto word : vid) for (auto word : vid)
{ {