core: Remove CASCADE_CODE

* R_TRY replaces completely
This commit is contained in:
GPUCode
2023-12-12 23:52:28 +02:00
parent e9b149c99b
commit 72463c8c8c
4 changed files with 16 additions and 25 deletions

View File

@ -502,8 +502,8 @@ Result Process::Map(VAddr target, VAddr source, u32 size, VMAPermission perms, b
VMAPermission source_perm = privileged ? VMAPermission::None : VMAPermission::ReadWrite;
// Mark source region as Aliased
CASCADE_CODE(vm_manager.ChangeMemoryState(source, size, MemoryState::Private,
VMAPermission::ReadWrite, source_state, source_perm));
R_TRY(vm_manager.ChangeMemoryState(source, size, MemoryState::Private, VMAPermission::ReadWrite,
source_state, source_perm));
CASCADE_RESULT(auto backing_blocks, vm_manager.GetBackingBlocksForRange(source, size));
VAddr interval_target = target;
@ -549,11 +549,11 @@ Result Process::Unmap(VAddr target, VAddr source, u32 size, VMAPermission perms,
MemoryState source_state = privileged ? MemoryState::Locked : MemoryState::Aliased;
CASCADE_CODE(vm_manager.UnmapRange(target, size));
R_TRY(vm_manager.UnmapRange(target, size));
// Change back source region state. Note that the permission is reprotected according to param
CASCADE_CODE(vm_manager.ChangeMemoryState(source, size, source_state, VMAPermission::None,
MemoryState::Private, perms));
R_TRY(vm_manager.ChangeMemoryState(source, size, source_state, VMAPermission::None,
MemoryState::Private, perms));
return ResultSuccess;
}

View File

@ -67,9 +67,9 @@ ResultVal<std::shared_ptr<SharedMemory>> KernelSystem::CreateSharedMemory(
auto& vm_manager = owner_process->vm_manager;
// The memory is already available and mapped in the owner process.
CASCADE_CODE(vm_manager.ChangeMemoryState(address, size, MemoryState::Private,
VMAPermission::ReadWrite, MemoryState::Locked,
SharedMemory::ConvertPermissions(permissions)));
R_TRY(vm_manager.ChangeMemoryState(address, size, MemoryState::Private,
VMAPermission::ReadWrite, MemoryState::Locked,
SharedMemory::ConvertPermissions(permissions)));
auto backing_blocks = vm_manager.GetBackingBlocksForRange(address, size);
ASSERT(backing_blocks.Succeeded()); // should success after verifying memory state above

View File

@ -400,15 +400,6 @@ private:
return CONCAT2(check_result_L, __LINE__).Code(); \
target = std::move(*CONCAT2(check_result_L, __LINE__))
/**
* Analogous to CASCADE_RESULT, but for a bare Result. The code will be propagated if
* non-success, or discarded otherwise.
*/
#define CASCADE_CODE(source) \
auto CONCAT2(check_result_L, __LINE__) = source; \
if (CONCAT2(check_result_L, __LINE__).IsError()) \
return CONCAT2(check_result_L, __LINE__);
#define R_SUCCEEDED(res) (static_cast<Result>(res).IsSuccess())
#define R_FAILED(res) (static_cast<Result>(res).IsError())

View File

@ -985,7 +985,7 @@ void SOC_U::Accept(Kernel::HLERequestContext& ctx) {
static_cast<s32>(async_data->ret));
IPC::RequestBuilder rb(ctx, 0x04, 2, 2);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push(async_data->ret);
rb.PushStaticBuffer(std::move(ctr_addr_buf), 0);
});
@ -1649,7 +1649,7 @@ void SOC_U::GetHostByAddr(Kernel::HLERequestContext& ctx) {
::gethostbyaddr(reinterpret_cast<char*>(&platform_addr), sizeof(platform_addr), type);
IPC::RequestBuilder rb = rp.MakeBuilder(2, 2);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
s32 ret;
if (!result) {
rb.Push(ret = TranslateError(GET_ERRNO));
@ -1670,7 +1670,7 @@ void SOC_U::GetHostByName(Kernel::HLERequestContext& ctx) {
struct hostent* result = ::gethostbyname(reinterpret_cast<char*>(host_name.data()));
IPC::RequestBuilder rb = rp.MakeBuilder(2, 2);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
s32 ret;
if (!result) {
rb.Push(ret = TranslateError(GET_ERRNO));
@ -1772,7 +1772,7 @@ void SOC_U::Connect(Kernel::HLERequestContext& ctx) {
async_data->socket_handle, static_cast<s32>(async_data->ret));
IPC::RequestBuilder rb(ctx, 0x06, 2, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push(async_data->ret);
});
}
@ -1783,7 +1783,7 @@ void SOC_U::InitializeSockets(Kernel::HLERequestContext& ctx) {
const u32 pid = rp.PopPID();
[[maybe_unused]] auto shared_memory = rp.PopObject<Kernel::SharedMemory>();
ResultCode res = RESULT_SUCCESS;
ResultCode res = ResultSuccess;
if (initialized_processes.find(pid) == initialized_processes.end()) {
initialized_processes.insert(pid);
} else {
@ -2091,7 +2091,7 @@ void SOC_U::SendToMultiple(Kernel::HLERequestContext& ctx) {
static_cast<s32>(ret));
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push(ret);
}
@ -2111,7 +2111,7 @@ void SOC_U::CloseSockets(Kernel::HLERequestContext& ctx) {
LOG_DEBUG(Service_SOC, "called, pid={}", pid);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
}
void SOC_U::AddGlobalSocket(Kernel::HLERequestContext& ctx) {
@ -2133,7 +2133,7 @@ void SOC_U::AddGlobalSocket(Kernel::HLERequestContext& ctx) {
LOG_DEBUG(Service_SOC, "called, pid={}, fd={}", pid, socket_handle);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
}
SOC_U::SOC_U() : ServiceFramework("soc:U", 18) {