From e5ae43f4c2cca5320559d9c27ce256b2901aed40 Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Mon, 30 Nov 2020 17:24:11 -0800 Subject: [PATCH] results: use R_VALUE for comparisons --- nx/source/display/native_window.c | 2 +- nx/source/kernel/condvar.c | 2 +- nx/source/kernel/virtmem.c | 4 ++-- nx/source/nvidia/fence.c | 6 +++--- nx/source/runtime/devices/fs_dev.c | 6 +++--- nx/source/runtime/devices/romfs_dev.c | 2 +- nx/source/services/applet.c | 4 ++-- nx/source/services/grc.c | 4 ++-- nx/source/services/sm.c | 2 +- 9 files changed, 16 insertions(+), 16 deletions(-) diff --git a/nx/source/display/native_window.c b/nx/source/display/native_window.c index 4fde09f0..c5d11cab 100644 --- a/nx/source/display/native_window.c +++ b/nx/source/display/native_window.c @@ -224,7 +224,7 @@ Result nwindowDequeueBuffer(NWindow* nw, s32* out_slot, NvMultiFence* out_fence) do { eventWait(&nw->event, UINT64_MAX); rc = bqDequeueBuffer(&nw->bq, true, nw->width, nw->height, nw->format, nw->usage, &slot, &fence); - } while (rc == MAKERESULT(Module_LibnxBinder, LibnxBinderError_WouldBlock)); + } while (R_VALUE(rc) == MAKERESULT(Module_LibnxBinder, LibnxBinderError_WouldBlock)); } else rc = bqDequeueBuffer(&nw->bq, false, nw->width, nw->height, nw->format, nw->usage, &slot, &fence); diff --git a/nx/source/kernel/condvar.c b/nx/source/kernel/condvar.c index 168bd7f9..87f8350c 100644 --- a/nx/source/kernel/condvar.c +++ b/nx/source/kernel/condvar.c @@ -11,7 +11,7 @@ Result condvarWaitTimeout(CondVar* c, Mutex* m, u64 timeout) { rc = svcWaitProcessWideKeyAtomic((u32*)m, c, getThreadVars()->handle, timeout); // On timeout, we need to acquire it manually. - if (rc == 0xEA01) + if (R_VALUE(rc) == 0xEA01) mutexLock(m); return rc; diff --git a/nx/source/kernel/virtmem.c b/nx/source/kernel/virtmem.c index 868ed61d..c07b6f31 100644 --- a/nx/source/kernel/virtmem.c +++ b/nx/source/kernel/virtmem.c @@ -176,13 +176,13 @@ void virtmemSetup(void) { // Forgive me. g_IsLegacyKernel = true; rc = svcUnmapMemory((void*)0xFFFFFFFFFFFFE000UL, (void*)0xFFFFFE000UL, 0x1000); - if (rc == KERNELRESULT(InvalidMemoryState)) { + if (R_VALUE(rc) == KERNELRESULT(InvalidMemoryState)) { // Invalid src-address error means that a valid 36-bit address was rejected. // Thus we are 32-bit. _memregionInitHardcoded(&g_AslrRegion, 0x200000ull, 0x100000000ull); _memregionInitHardcoded(&g_StackRegion, 0x200000ull, 0x40000000ull); } - else if (rc == KERNELRESULT(InvalidMemoryRange)) { + else if (R_VALUE(rc) == KERNELRESULT(InvalidMemoryRange)) { // Invalid dst-address error means our 36-bit src-address was valid. // Thus we are 36-bit. _memregionInitHardcoded(&g_AslrRegion, 0x8000000ull, 0x1000000000ull); diff --git a/nx/source/nvidia/fence.c b/nx/source/nvidia/fence.c index 73733ff1..1f31b245 100644 --- a/nx/source/nvidia/fence.c +++ b/nx/source/nvidia/fence.c @@ -88,7 +88,7 @@ static Result _nvFenceEventWaitCommon(Event* event, u32 event_id, s32 timeout_us if (timeout_us >= 0) timeout_ns = (u64)1000*timeout_us; Result rc = eventWait(event, timeout_ns); - if ((rc & 0x3FFFFF) == 0xEA01) { // timeout + if (R_VALUE(rc) == 0xEA01) { // timeout nvioctlNvhostCtrl_EventSignal(g_ctrl_fd, event_id); rc = MAKERESULT(Module_LibnxNvidia, LibnxNvidiaError_Timeout); } @@ -103,7 +103,7 @@ static Result _nvFenceWait_200(NvFence* f, s32 timeout_us) Event* event = _nvGetEvent(event_id); if (event) { rc = nvioctlNvhostCtrl_EventWaitAsync(g_ctrl_fd, f->id, f->value, timeout_us, event_id); - if (rc == MAKERESULT(Module_LibnxNvidia, LibnxNvidiaError_Timeout)) + if (R_VALUE(rc) == MAKERESULT(Module_LibnxNvidia, LibnxNvidiaError_Timeout)) rc = _nvFenceEventWaitCommon(event, 0x10000000 | event_id, timeout_us); } _nvFreeEventSlot(event_id); @@ -115,7 +115,7 @@ static Result _nvFenceWait_100(NvFence* f, s32 timeout_us) { u32 event_id; Result rc = nvioctlNvhostCtrl_EventWait(g_ctrl_fd, f->id, f->value, timeout_us, 0, &event_id); - if (rc == MAKERESULT(Module_LibnxNvidia, LibnxNvidiaError_Timeout) && timeout_us) { + if (R_VALUE(rc) == MAKERESULT(Module_LibnxNvidia, LibnxNvidiaError_Timeout) && timeout_us) { Event event; rc = nvQueryEvent(g_ctrl_fd, event_id, &event); if (R_SUCCEEDED(rc)) { diff --git a/nx/source/runtime/devices/fs_dev.c b/nx/source/runtime/devices/fs_dev.c index 8029e579..e829a22a 100644 --- a/nx/source/runtime/devices/fs_dev.c +++ b/nx/source/runtime/devices/fs_dev.c @@ -802,7 +802,7 @@ fsdev_write(struct _reent *r, } rc = fsFileWrite(&file->fd, file->offset, ptr, len, FsWriteOption_None); - if(rc == 0xD401) + if(R_VALUE(rc) == 0xD401) return fsdev_write_safe(r, fd, ptr, len); if(R_FAILED(rc)) { @@ -911,7 +911,7 @@ fsdev_read(struct _reent *r, /* read the data */ rc = fsFileRead(&file->fd, file->offset, ptr, len, FsReadOption_None, &bytes); - if(rc == 0xD401) + if(R_VALUE(rc) == 0xD401) return fsdev_read_safe(r, fd, ptr, len); if(R_SUCCEEDED(rc)) { @@ -1707,7 +1707,7 @@ fsdev_getmtime(const char *name, if(fs_path.data == NULL) return -1;*/ - /*if(rc == 0) + /*if(R_SUCCEEDED(rc)) {*/ /* convert from milliseconds to seconds */ //*mtime /= 1000; diff --git a/nx/source/runtime/devices/romfs_dev.c b/nx/source/runtime/devices/romfs_dev.c index 31759e8a..8c19e3b2 100644 --- a/nx/source/runtime/devices/romfs_dev.c +++ b/nx/source/runtime/devices/romfs_dev.c @@ -113,7 +113,7 @@ static ssize_t _romfs_read(romfs_mount *mount, u64 offset, void* buffer, u64 siz rc = fsStorageRead(&mount->fd_storage, pos, buffer, size); read = size; } - if (rc == 0xD401) return _romfs_read_safe(mount, pos, buffer, size); + if (R_VALUE(rc) == 0xD401) return _romfs_read_safe(mount, pos, buffer, size); if (R_FAILED(rc)) return -1; return read; } diff --git a/nx/source/services/applet.c b/nx/source/services/applet.c index aa978db3..d22c5e95 100644 --- a/nx/source/services/applet.c +++ b/nx/source/services/applet.c @@ -175,11 +175,11 @@ Result _appletInitialize(void) { else rc = _appletOpenLibraryAppletProxy(&g_appletProxySession, CUR_PROCESS_HANDLE, attr); - if (rc == AM_BUSY_ERROR) { + if (R_VALUE(rc) == AM_BUSY_ERROR) { svcSleepThread(10000000); } - } while (rc == AM_BUSY_ERROR); + } while (R_VALUE(rc) == AM_BUSY_ERROR); } // [7.0.0+] GetAppletCommonFunctions diff --git a/nx/source/services/grc.c b/nx/source/services/grc.c index 717fab56..f5368939 100644 --- a/nx/source/services/grc.c +++ b/nx/source/services/grc.c @@ -68,7 +68,7 @@ static Result _grcCreateGameMovieTrimmer(GrcGameMovieTrimmer *t, size_t size) { if (R_SUCCEEDED(rc)) { rc = appletCreateGameMovieTrimmer(&t->s, &t->tmem); - while(rc == retryrc) { + while(R_VALUE(rc) == retryrc) { svcSleepThread(100000000); rc = appletCreateGameMovieTrimmer(&t->s, &t->tmem); } @@ -184,7 +184,7 @@ Result grcCreateMovieMaker(GrcMovieMaker *m, size_t size) { if (R_SUCCEEDED(rc)) { rc = appletCreateMovieMaker(&m->a, &m->tmem); - while(rc == retryrc) { + while(R_VALUE(rc) == retryrc) { svcSleepThread(100000000); rc = appletCreateMovieMaker(&m->a, &m->tmem); } diff --git a/nx/source/services/sm.c b/nx/source/services/sm.c index 24d4f979..a271d746 100644 --- a/nx/source/services/sm.c +++ b/nx/source/services/sm.c @@ -48,7 +48,7 @@ Result _smInitialize(void) { } Handle tmp; - if (R_SUCCEEDED(rc) && smGetServiceOriginal(&tmp, (SmServiceName){}) == 0x415) { + if (R_SUCCEEDED(rc) && R_VALUE(smGetServiceOriginal(&tmp, (SmServiceName){})) == 0x415) { u64 pid_placeholder = 0; rc = serviceDispatchIn(&g_smSrv, 0, pid_placeholder, .in_send_pid = true); }