Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix some more warnings #14970

Merged
merged 2 commits into from Dec 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion rpcs3/Emu/Cell/Modules/cellPad.cpp
Expand Up @@ -73,7 +73,7 @@ void pad_info::save(utils::serial& ar)

extern void send_sys_io_connect_event(usz index, u32 state);

void cellPad_NotifyStateChange(usz index, u32 /*state*/)
void cellPad_NotifyStateChange(usz index, u64 /*state*/)
{
auto info = g_fxo->try_get<pad_info>();

Expand Down
2 changes: 1 addition & 1 deletion rpcs3/Emu/Cell/Modules/sys_io_.cpp
Expand Up @@ -36,7 +36,7 @@ extern void sys_io_serialize(utils::serial& ar)
g_fxo->get<libio_sys_config>().save_or_load(ar);
}

extern void cellPad_NotifyStateChange(usz index, u32 state);
extern void cellPad_NotifyStateChange(usz index, u64 state);

void config_event_entry(ppu_thread& ppu)
{
Expand Down
15 changes: 8 additions & 7 deletions rpcs3/Emu/Cell/PPUThread.cpp
Expand Up @@ -1624,7 +1624,7 @@ std::vector<std::pair<u32, u32>> ppu_thread::dump_callstack_list() const

inst_neg.resize(new_size);

if (!vm::try_access(inst_bound, &inst_neg[old_size], (new_size - old_size) * sizeof(be_t<u32>), false))
if (!vm::try_access(inst_bound, &inst_neg[old_size], ::narrow<u32>((new_size - old_size) * sizeof(be_t<u32>)), false))
{
// Failure (this would be detected as failure by zeroes)
}
Expand Down Expand Up @@ -1657,7 +1657,7 @@ std::vector<std::pair<u32, u32>> ppu_thread::dump_callstack_list() const

inst_pos.resize(new_size);

if (!vm::try_access(pos, &inst_pos[old_size], (new_size - old_size) * sizeof(be_t<u32>), false))
if (!vm::try_access(pos, &inst_pos[old_size], ::narrow<u32>((new_size - old_size) * sizeof(be_t<u32>)), false))
{
// Failure (this would be detected as failure by zeroes)
}
Expand Down Expand Up @@ -3830,7 +3830,7 @@ extern void ppu_precompile(std::vector<std::string>& dir_queue, std::vector<ppu_
}
}

g_progr_ftotal += file_queue.size();
g_progr_ftotal += ::size32(file_queue);

u64 total_files_size = 0;

Expand All @@ -3856,8 +3856,9 @@ extern void ppu_precompile(std::vector<std::string>& dir_queue, std::vector<ppu_
#endif
// Set low priority
thread_ctrl::scoped_priority low_prio(-1);
u32 inc_fdone = 1;

for (usz func_i = fnext++, inc_fdone = 1; func_i < file_queue.size(); func_i = fnext++, g_progr_fdone += std::exchange(inc_fdone, 1))
for (usz func_i = fnext++; func_i < file_queue.size(); func_i = fnext++, g_progr_fdone += std::exchange(inc_fdone, 1))
{
if (Emu.IsStopped())
{
Expand Down Expand Up @@ -4838,8 +4839,8 @@ bool ppu_initialize(const ppu_module& info, bool check_only, u64 file_size)
jit->fin();
}

usz index = 0;
usz max_count = 0;
u32 index = 0;
u32 max_count = 0;

for (const auto& func : info.funcs)
{
Expand All @@ -4849,7 +4850,7 @@ bool ppu_initialize(const ppu_module& info, bool check_only, u64 file_size)
}
}

usz pending_progress = umax;
u32 pending_progress = umax;

bool early_exit = false;

Expand Down
24 changes: 12 additions & 12 deletions rpcs3/Emu/Cell/PPUTranslator.cpp
Expand Up @@ -152,9 +152,9 @@ Function* PPUTranslator::Translate(const ppu_function& info)
// Don't emit check in small blocks without terminator
bool need_check = info.size >= 16;

for (u32 addr = m_addr; addr < m_addr + info.size; addr += 4)
for (u64 addr = m_addr; addr < m_addr + info.size; addr += 4)
{
const u32 op = *ensure(m_info.get_ptr<u32>(addr + base));
const u32 op = *ensure(m_info.get_ptr<u32>(::narrow<u32>(addr + base)));

switch (g_ppu_itype.decode(op))
{
Expand Down Expand Up @@ -250,7 +250,7 @@ Function* PPUTranslator::Translate(const ppu_function& info)
// Reset MMIO hint
m_may_be_mmio = true;

const u32 op = *ensure(m_info.get_ptr<u32>(m_addr + base));
const u32 op = *ensure(m_info.get_ptr<u32>(::narrow<u32>(m_addr + base)));

(this->*(s_ppu_decoder.decode(op)))({op});

Expand Down Expand Up @@ -368,11 +368,11 @@ void PPUTranslator::CallFunction(u64 target, Value* indirect)
const u64 base = m_reloc ? m_reloc->addr : 0;
const u32 caddr = m_info.segs[0].addr;
const u32 cend = caddr + m_info.segs[0].size - 1;
const u64 _target = target + base;
const u32 _target = ::narrow<u32>(target + base);

if (_target >= caddr && _target <= cend)
{
std::unordered_set<u64> passed_targets{_target};
std::unordered_set<u32> passed_targets{_target};

u32 target_last = _target;

Expand Down Expand Up @@ -663,7 +663,7 @@ Value* PPUTranslator::ReadMemory(Value* addr, Type* type, bool is_be, u32 align)

m_may_be_mmio = false;

if (auto ptr = m_info.get_ptr<instructions_to_test>(std::max<u32>(m_info.segs[0].addr, (m_reloc ? m_reloc->addr : 0) + utils::sub_saturate<u32>(m_addr, sizeof(instructions_to_test) / 2))))
if (auto ptr = m_info.get_ptr<instructions_to_test>(std::max<u32>(m_info.segs[0].addr, (m_reloc ? m_reloc->addr : 0) + utils::sub_saturate<u32>(::narrow<u32>(m_addr), sizeof(instructions_to_test) / 2))))
{
if (ppu_test_address_may_be_mmio(std::span(ptr->insts)))
{
Expand Down Expand Up @@ -726,7 +726,7 @@ void PPUTranslator::WriteMemory(Value* addr, Value* value, bool is_be, u32 align
be_t<u32> insts[128];
};

if (auto ptr = m_info.get_ptr<instructions_to_test>(std::max<u32>(m_info.segs[0].addr, (m_reloc ? m_reloc->addr : 0) + utils::sub_saturate<u32>(m_addr, sizeof(instructions_to_test) / 2))))
if (auto ptr = m_info.get_ptr<instructions_to_test>(std::max<u32>(m_info.segs[0].addr, (m_reloc ? m_reloc->addr : 0) + utils::sub_saturate<u32>(::narrow<u32>(m_addr), sizeof(instructions_to_test) / 2))))
{
if (ppu_test_address_may_be_mmio(std::span(ptr->insts)))
{
Expand Down Expand Up @@ -1056,7 +1056,7 @@ void PPUTranslator::VMADDFP(ppu_opcode_t op)
auto [a, b, c] = get_vrs<f32[4]>(op.va, op.vb, op.vc);

// Optimization: Emit only a floating multiply if the addend is zero
if (auto [ok, data] = get_const_vector(b.value, m_addr); ok)
if (auto [ok, data] = get_const_vector(b.value, ::narrow<u32>(m_addr)); ok)
{
if (data == v128::from32p(1u << 31))
{
Expand Down Expand Up @@ -1348,7 +1348,7 @@ void PPUTranslator::VNMSUBFP(ppu_opcode_t op)
auto [a, b, c] = get_vrs<f32[4]>(op.va, op.vb, op.vc);

// Optimization: Emit only a floating multiply if the addend is zero
if (const auto [ok, data] = get_const_vector(b.value, m_addr); ok)
if (const auto [ok, data] = get_const_vector(b.value, ::narrow<u32>(m_addr)); ok)
{
if (data == v128{})
{
Expand Down Expand Up @@ -1552,7 +1552,7 @@ void PPUTranslator::VSEL(ppu_opcode_t op)
const auto c = get_vr<u32[4]>(op.vc);

// Check if the constant mask doesn't require bit granularity
if (auto [ok, mask] = get_const_vector(c.value, m_addr); ok)
if (auto [ok, mask] = get_const_vector(c.value, ::narrow<u32>(m_addr)); ok)
{
bool sel_32 = true;
for (u32 i = 0; i < 4; i++)
Expand Down Expand Up @@ -3671,7 +3671,7 @@ void PPUTranslator::LWZ(ppu_opcode_t op)
};

// Quick invalidation: expect exact MMIO address, so if the register is being reused with different offset than it's likely not MMIO
if (auto ptr = m_info.get_ptr<instructions_data>(m_addr + 4 + (m_reloc ? m_reloc->addr : 0)))
if (auto ptr = m_info.get_ptr<instructions_data>(::narrow<u32>(m_addr + 4 + (m_reloc ? m_reloc->addr : 0))))
{
for (u32 inst : ptr->insts)
{
Expand Down Expand Up @@ -3774,7 +3774,7 @@ void PPUTranslator::STW(ppu_opcode_t op)
};

// Quick invalidation: expect exact MMIO address, so if the register is being reused with different offset than it's likely not MMIO
if (auto ptr = m_info.get_ptr<instructions_data>(m_addr + 4 + (m_reloc ? m_reloc->addr : 0)))
if (auto ptr = m_info.get_ptr<instructions_data>(::narrow<u32>(m_addr + 4 + (m_reloc ? m_reloc->addr : 0))))
{
for (u32 inst : ptr->insts)
{
Expand Down
2 changes: 1 addition & 1 deletion rpcs3/Emu/Cell/SPUThread.cpp
Expand Up @@ -6193,7 +6193,7 @@ spu_exec_object spu_thread::capture_memory_as_elf(std::span<spu_memory_segment_d

if (auto [vm_addr, ok] = vm::try_get_addr(seg.src_addr); ok)
{
if (!vm::try_access(vm_addr, data.data(), data.size(), false))
Megamouse marked this conversation as resolved.
Show resolved Hide resolved
if (!vm::try_access(vm_addr, data.data(), seg.segment_size, false))
{
spu_log.error("capture_memory_as_elf(): Failed to read {0x%x..0x%x}, aborting capture.", +vm_addr, vm_addr + seg.segment_size - 1);
spu_exec.set_error(elf_error::stream_data);
Expand Down
4 changes: 2 additions & 2 deletions rpcs3/Emu/Cell/lv2/sys_ss.cpp
Expand Up @@ -308,9 +308,9 @@ error_code sys_ss_secure_rtc(u64 cmd, u64 a2, u64 a3, u64 a4)
return 0x80010500; // bad packet id

// a3 is actual output, not 100% sure, but best guess is its tb val
vm::write64(a3, get_timebased_time());
vm::write64(::narrow<u32>(a3), get_timebased_time());
// a4 is a pointer to status, non 0 on error
vm::write64(a4, 0);
vm::write64(::narrow<u32>(a4), 0);
return CELL_OK;
}
else if (cmd == 0x3003)
Expand Down
10 changes: 6 additions & 4 deletions rpcs3/Emu/Memory/vm.cpp
Expand Up @@ -492,7 +492,7 @@ namespace vm

const auto diff = range_lock - g_range_lock_set;

if (bits != umax && !bits.bit_test_set(diff))
if (bits != umax && !bits.bit_test_set(static_cast<u32>(diff)))
{
break;
}
Expand Down Expand Up @@ -557,7 +557,7 @@ namespace vm
for (u64 hi = addr2 >> 16, max = (addr2 + size2 - 1) >> 16; hi <= max; hi++)
{
u64 addr3 = addr2;
u32 size3 = std::min<u64>(addr2 + size2, utils::align(addr2, 0x10000)) - addr2;
u64 size3 = std::min<u64>(addr2 + size2, utils::align(addr2, 0x10000)) - addr2;

if (u64 is_shared = g_shmem[hi]) [[unlikely]]
{
Expand Down Expand Up @@ -2405,8 +2405,10 @@ void fmt_class_string<vm::_ptr_base<const char, u32>>::format(std::string& out,
return;
}

const u32 addr = ::narrow<u32>(arg);

// Filter certainly invalid addresses
if (!vm::check_addr(arg, vm::page_readable))
if (!vm::check_addr(addr, vm::page_readable))
{
out += reinterpret_cast<const char*>(u8"«INVALID_ADDRESS:");
fmt_class_string<u32>::format(out, arg);
Expand All @@ -2418,7 +2420,7 @@ void fmt_class_string<vm::_ptr_base<const char, u32>>::format(std::string& out,

out += reinterpret_cast<const char*>(u8"“");

if (!vm::read_string(arg, umax, out, true))
if (!vm::read_string(addr, umax, out, true))
{
// Revert changes
out.resize(start);
Expand Down
8 changes: 4 additions & 4 deletions rpcs3/Emu/RSX/Common/BufferUtils.cpp
Expand Up @@ -295,8 +295,8 @@ namespace
r = upload_untouched_naive(src.data(), dst.data(), count);
#endif

min_index = r;
max_index = r >> 32;
min_index = static_cast<T>(r);
max_index = static_cast<T>(r >> 32);

return std::make_tuple(min_index, max_index, count);
}
Expand Down Expand Up @@ -401,8 +401,8 @@ namespace
r = upload_untouched_naive(src.data(), dst.data(), count, restart_index);
#endif

min_index = r;
max_index = r >> 32;
min_index = static_cast<T>(r);
max_index = static_cast<T>(r >> 32);

return std::make_tuple(min_index, max_index, count);
}
Expand Down
2 changes: 1 addition & 1 deletion rpcs3/Emu/RSX/RSXThread.cpp
Expand Up @@ -3182,7 +3182,7 @@ namespace rsx

if (count < 0)
{
const u32 found_cmds_count = std::min<u32>(-count, ::size32(pcs_of_valid_cmds) - 1 - index_of_get);
const u32 found_cmds_count = static_cast<u32>(std::min<s64>(-count, pcs_of_valid_cmds.size() - 1LL - index_of_get));

return {found_cmds_count, pcs_of_valid_cmds[index_of_get + found_cmds_count]};
}
Expand Down
3 changes: 2 additions & 1 deletion rpcs3/util/vm_native.cpp
Expand Up @@ -464,7 +464,8 @@ namespace utils
, m_size(utils::align(size, 0x10000))
{
#ifdef _WIN32
m_handle = ensure(::CreateFileMappingW(INVALID_HANDLE_VALUE, nullptr, PAGE_EXECUTE_READWRITE, 0, m_size, nullptr));
const ULARGE_INTEGER max_size{ .QuadPart = m_size };
m_handle = ensure(::CreateFileMappingW(INVALID_HANDLE_VALUE, nullptr, PAGE_EXECUTE_READWRITE, max_size.HighPart, max_size.LowPart, nullptr));
#elif defined(__linux__) || defined(__FreeBSD__)
m_file = -1;

Expand Down