cellPad: fix potential out of bounds read and u32 warnings

This commit is contained in:
Megamouse 2023-08-25 21:42:29 +02:00
parent 656f971823
commit 9d88102520
3 changed files with 8 additions and 8 deletions

View file

@ -71,9 +71,9 @@ void pad_info::save(utils::serial& ar)
sys_io_serialize(ar); sys_io_serialize(ar);
} }
extern void send_sys_io_connect_event(u32 index, u32 state); extern void send_sys_io_connect_event(usz index, u32 state);
void cellPad_NotifyStateChange(u32 index, u32 state) void cellPad_NotifyStateChange(usz index, u32 state)
{ {
auto info = g_fxo->try_get<pad_info>(); auto info = g_fxo->try_get<pad_info>();
@ -84,7 +84,7 @@ void cellPad_NotifyStateChange(u32 index, u32 state)
std::lock_guard lock(pad::g_pad_mutex); std::lock_guard lock(pad::g_pad_mutex);
if (!info->max_connect) if (index >= info->get_max_connect())
{ {
return; return;
} }
@ -148,7 +148,7 @@ void cellPad_NotifyStateChange(u32 index, u32 state)
} }
} }
extern void pad_state_notify_state_change(u32 index, u32 state) extern void pad_state_notify_state_change(usz index, u32 state)
{ {
cellPad_NotifyStateChange(index, state); cellPad_NotifyStateChange(index, state);
} }
@ -179,7 +179,7 @@ error_code cellPadInit(ppu_thread& ppu, u32 max_connect)
const auto& pads = handler->GetPads(); const auto& pads = handler->GetPads();
for (u32 i = 0; i < statuses.size(); ++i) for (usz i = 0; i < statuses.size(); ++i)
{ {
if (i >= config.get_max_connect()) if (i >= config.get_max_connect())
break; break;

View file

@ -36,7 +36,7 @@ extern void sys_io_serialize(utils::serial& ar)
g_fxo->get<libio_sys_config>().save_or_load(ar); g_fxo->get<libio_sys_config>().save_or_load(ar);
} }
extern void cellPad_NotifyStateChange(u32 index, u32 state); extern void cellPad_NotifyStateChange(usz index, u32 state);
void config_event_entry(ppu_thread& ppu) void config_event_entry(ppu_thread& ppu)
{ {
@ -101,7 +101,7 @@ std::unique_lock<shared_mutex> lock_lv2_mutex_alike(shared_mutex& mtx, ppu_threa
return lock; return lock;
} }
extern void send_sys_io_connect_event(u32 index, u32 state) extern void send_sys_io_connect_event(usz index, u32 state)
{ {
auto& cfg = g_fxo->get<libio_sys_config>(); auto& cfg = g_fxo->get<libio_sys_config>();

View file

@ -7,7 +7,7 @@
cfg_input g_cfg_input; cfg_input g_cfg_input;
extern void pad_state_notify_state_change(u32 index, u32 state); extern void pad_state_notify_state_change(usz index, u32 state);
PadHandlerBase::PadHandlerBase(pad_handler type) : m_type(type) PadHandlerBase::PadHandlerBase(pad_handler type) : m_type(type)
{ {