Minor EFAULT fix in sys_semaphore_get_value/sys_event_flag_get

ESRCH preceeds EFAULT in both syscalls.
This commit is contained in:
Eladash 2020-05-13 07:01:36 +03:00 committed by Ivan
parent 9266507e4c
commit 7680466e0d
2 changed files with 11 additions and 11 deletions

View file

@ -410,11 +410,6 @@ error_code sys_event_flag_get(ppu_thread& ppu, u32 id, vm::ptr<u64> flags)
sys_event_flag.trace("sys_event_flag_get(id=0x%x, flags=*0x%x)", id, flags);
if (!flags)
{
return CELL_EFAULT;
}
const auto flag = idm::check<lv2_obj, lv2_event_flag>(id, [](lv2_event_flag& flag)
{
return +flag.pattern;
@ -422,10 +417,15 @@ error_code sys_event_flag_get(ppu_thread& ppu, u32 id, vm::ptr<u64> flags)
if (!flag)
{
*flags = 0;
if (flags) *flags = 0;
return CELL_ESRCH;
}
if (!flags)
{
return CELL_EFAULT;
}
*flags = flag.ret;
return CELL_OK;
}

View file

@ -265,11 +265,6 @@ error_code sys_semaphore_get_value(ppu_thread& ppu, u32 sem_id, vm::ptr<s32> cou
sys_semaphore.trace("sys_semaphore_get_value(sem_id=0x%x, count=*0x%x)", sem_id, count);
if (!count)
{
return CELL_EFAULT;
}
const auto sema = idm::check<lv2_obj, lv2_sema>(sem_id, [](lv2_sema& sema)
{
return std::max<s32>(0, sema.val);
@ -280,6 +275,11 @@ error_code sys_semaphore_get_value(ppu_thread& ppu, u32 sem_id, vm::ptr<s32> cou
return CELL_ESRCH;
}
if (!count)
{
return CELL_EFAULT;
}
*count = sema.ret;
return CELL_OK;
}