Fix signed-unsigned comparisons and mark warning as error (part 2).

This commit is contained in:
Nekotekina 2020-02-19 20:03:59 +03:00
parent 771eff273b
commit 92e3eaf3ff
68 changed files with 194 additions and 202 deletions

View file

@ -304,7 +304,7 @@ std::shared_ptr<fs::device_base> fs::device_manager::set_device(const std::strin
std::shared_ptr<fs::device_base> fs::get_virtual_device(const std::string& path)
{
// Every virtual device path must have "//" at the beginning
if (path.size() > 2 && reinterpret_cast<const u16&>(path.front()) == "//"_u16)
if (path.starts_with("//"))
{
return get_device_manager().get_device(path);
}
@ -314,7 +314,7 @@ std::shared_ptr<fs::device_base> fs::get_virtual_device(const std::string& path)
std::shared_ptr<fs::device_base> fs::set_virtual_device(const std::string& name, const std::shared_ptr<device_base>& device)
{
verify(HERE), name.size() > 2, name[0] == '/', name[1] == '/', name.find('/', 2) == -1;
verify(HERE), name.starts_with("//"), name[2] != '/';
return get_device_manager().set_device(name, device);
}
@ -338,7 +338,7 @@ std::string fs::get_parent_dir(const std::string& path)
if (std::exchange(last, pos - 1) != pos)
{
// Return empty string if the path doesn't contain at least 2 elements
return path.substr(0, pos != -1 && path.find_last_not_of(delim, pos, sizeof(delim) - 1) != -1 ? pos : 0);
return path.substr(0, pos != umax && path.find_last_not_of(delim, pos, sizeof(delim) - 1) != umax ? pos : 0);
}
}
}

View file

@ -80,7 +80,7 @@ static u8* add_jit_memory(std::size_t size, uint align)
return _pos;
});
if (pos == -1) [[unlikely]]
if (pos == umax) [[unlikely]]
{
jit_log.warning("JIT: Out of memory (size=0x%x, align=0x%x, off=0x%x)", size, align, Off);
return nullptr;

View file

@ -464,7 +464,7 @@ logs::file_writer::file_writer(const std::string& name)
if (!flush(bufv))
{
if (m_out == -1)
if (m_out == umax)
{
break;
}

View file

@ -1389,7 +1389,7 @@ bool handle_access_violation(u32 addr, bool is_writing, x64_context* context) no
error_code sending_error = sys_event_port_send(pf_port_id, data1, data2, data3);
// If we fail due to being busy, wait a bit and try again.
while (sending_error == CELL_EBUSY)
while (static_cast<u32>(sending_error) == CELL_EBUSY)
{
if (cpu->id_type() == 1)
{
@ -1411,7 +1411,7 @@ bool handle_access_violation(u32 addr, bool is_writing, x64_context* context) no
vm_log.fatal("Unknown error %x while trying to pass page fault.", +sending_error);
cpu->state += cpu_flag::dbg_pause;
}
// Wait until the thread is recovered
for (std::shared_lock pf_lock(pf_events->pf_mutex);
pf_events->events.count(static_cast<u32>(data2)) && !sending_error;)