From 09ae6e1fa38bbf75dcb2796e96575fdba32ec69c Mon Sep 17 00:00:00 2001 From: Yuri Kunde Schlesner Date: Fri, 23 Jan 2015 03:44:52 -0200 Subject: Remove result.h InvalidHandle It was only being used in two places, where it was replaced by a local constant. --- src/core/hle/kernel/kernel.h | 3 ++- src/core/hle/result.h | 5 ----- src/core/hle/service/fs/archive.cpp | 23 ++++++++++++++--------- src/core/hle/svc.cpp | 31 ++++++++++++++++--------------- 4 files changed, 32 insertions(+), 30 deletions(-) diff --git a/src/core/hle/kernel/kernel.h b/src/core/hle/kernel/kernel.h index 08a5db3b..9860479a 100644 --- a/src/core/hle/kernel/kernel.h +++ b/src/core/hle/kernel/kernel.h @@ -31,7 +31,8 @@ class Thread; const ResultCode ERR_OUT_OF_HANDLES(ErrorDescription::OutOfMemory, ErrorModule::Kernel, ErrorSummary::OutOfResource, ErrorLevel::Temporary); // TOOD: Verify code -const ResultCode ERR_INVALID_HANDLE = InvalidHandle(ErrorModule::Kernel); +const ResultCode ERR_INVALID_HANDLE(ErrorDescription::InvalidHandle, ErrorModule::Kernel, + ErrorSummary::InvalidArgument, ErrorLevel::Permanent); enum KernelHandle : Handle { CurrentThread = 0xFFFF8000, diff --git a/src/core/hle/result.h b/src/core/hle/result.h index ad06d00a..948b9e38 100644 --- a/src/core/hle/result.h +++ b/src/core/hle/result.h @@ -227,11 +227,6 @@ inline ResultCode UnimplementedFunction(ErrorModule module) { return ResultCode(ErrorDescription::NotImplemented, module, ErrorSummary::NotSupported, ErrorLevel::Permanent); } -/// Returned when a function is passed an invalid handle. -inline ResultCode InvalidHandle(ErrorModule module) { - return ResultCode(ErrorDescription::InvalidHandle, module, - ErrorSummary::InvalidArgument, ErrorLevel::Permanent); -} /** * This is an optional value type. It holds a `ResultCode` and, if that code is a success code, diff --git a/src/core/hle/service/fs/archive.cpp b/src/core/hle/service/fs/archive.cpp index 1bb4e4b2..6682f659 100644 --- a/src/core/hle/service/fs/archive.cpp +++ b/src/core/hle/service/fs/archive.cpp @@ -43,6 +43,11 @@ const std::string SDCARD_ID = "00000000000000000000000000000000"; namespace Service { namespace FS { +// TODO: Verify code +/// Returned when a function is passed an invalid handle. +const ResultCode ERR_INVALID_HANDLE(ErrorDescription::InvalidHandle, ErrorModule::FS, + ErrorSummary::InvalidArgument, ErrorLevel::Permanent); + // Command to access archive file enum class FileCommand : u32 { Dummy1 = 0x000100C6, @@ -280,7 +285,7 @@ ResultVal OpenArchive(ArchiveIdCode id_code, FileSys::Path& archi ResultCode CloseArchive(ArchiveHandle handle) { if (handle_map.erase(handle) == 0) - return InvalidHandle(ErrorModule::FS); + return ERR_INVALID_HANDLE; else return RESULT_SUCCESS; } @@ -301,7 +306,7 @@ ResultCode CreateArchive(std::unique_ptr&& backend, Arc ResultVal OpenFileFromArchive(ArchiveHandle archive_handle, const FileSys::Path& path, const FileSys::Mode mode) { Archive* archive = GetArchive(archive_handle); if (archive == nullptr) - return InvalidHandle(ErrorModule::FS); + return ERR_INVALID_HANDLE; std::unique_ptr backend = archive->backend->OpenFile(path, mode); if (backend == nullptr) { @@ -318,7 +323,7 @@ ResultVal OpenFileFromArchive(ArchiveHandle archive_handle, const FileSy ResultCode DeleteFileFromArchive(ArchiveHandle archive_handle, const FileSys::Path& path) { Archive* archive = GetArchive(archive_handle); if (archive == nullptr) - return InvalidHandle(ErrorModule::FS); + return ERR_INVALID_HANDLE; if (archive->backend->DeleteFile(path)) return RESULT_SUCCESS; @@ -331,7 +336,7 @@ ResultCode RenameFileBetweenArchives(ArchiveHandle src_archive_handle, const Fil Archive* src_archive = GetArchive(src_archive_handle); Archive* dest_archive = GetArchive(dest_archive_handle); if (src_archive == nullptr || dest_archive == nullptr) - return InvalidHandle(ErrorModule::FS); + return ERR_INVALID_HANDLE; if (src_archive == dest_archive) { if (src_archive->backend->RenameFile(src_path, dest_path)) @@ -350,7 +355,7 @@ ResultCode RenameFileBetweenArchives(ArchiveHandle src_archive_handle, const Fil ResultCode DeleteDirectoryFromArchive(ArchiveHandle archive_handle, const FileSys::Path& path) { Archive* archive = GetArchive(archive_handle); if (archive == nullptr) - return InvalidHandle(ErrorModule::FS); + return ERR_INVALID_HANDLE; if (archive->backend->DeleteDirectory(path)) return RESULT_SUCCESS; @@ -361,7 +366,7 @@ ResultCode DeleteDirectoryFromArchive(ArchiveHandle archive_handle, const FileSy ResultCode CreateFileInArchive(ArchiveHandle archive_handle, const FileSys::Path& path, u32 file_size) { Archive* archive = GetArchive(archive_handle); if (archive == nullptr) - return InvalidHandle(ErrorModule::FS); + return ERR_INVALID_HANDLE; return archive->backend->CreateFile(path, file_size); } @@ -369,7 +374,7 @@ ResultCode CreateFileInArchive(ArchiveHandle archive_handle, const FileSys::Path ResultCode CreateDirectoryFromArchive(ArchiveHandle archive_handle, const FileSys::Path& path) { Archive* archive = GetArchive(archive_handle); if (archive == nullptr) - return InvalidHandle(ErrorModule::FS); + return ERR_INVALID_HANDLE; if (archive->backend->CreateDirectory(path)) return RESULT_SUCCESS; @@ -382,7 +387,7 @@ ResultCode RenameDirectoryBetweenArchives(ArchiveHandle src_archive_handle, cons Archive* src_archive = GetArchive(src_archive_handle); Archive* dest_archive = GetArchive(dest_archive_handle); if (src_archive == nullptr || dest_archive == nullptr) - return InvalidHandle(ErrorModule::FS); + return ERR_INVALID_HANDLE; if (src_archive == dest_archive) { if (src_archive->backend->RenameDirectory(src_path, dest_path)) @@ -407,7 +412,7 @@ ResultCode RenameDirectoryBetweenArchives(ArchiveHandle src_archive_handle, cons ResultVal OpenDirectoryFromArchive(ArchiveHandle archive_handle, const FileSys::Path& path) { Archive* archive = GetArchive(archive_handle); if (archive == nullptr) - return InvalidHandle(ErrorModule::FS); + return ERR_INVALID_HANDLE; std::unique_ptr backend = archive->backend->OpenDirectory(path); if (backend == nullptr) { diff --git a/src/core/hle/svc.cpp b/src/core/hle/svc.cpp index bec9837a..46fca51c 100644 --- a/src/core/hle/svc.cpp +++ b/src/core/hle/svc.cpp @@ -26,6 +26,7 @@ // Namespace SVC using Kernel::SharedPtr; +using Kernel::ERR_INVALID_HANDLE; namespace SVC { @@ -71,7 +72,7 @@ static ResultCode MapMemoryBlock(Handle handle, u32 addr, u32 permissions, u32 o SharedPtr shared_memory = Kernel::g_handle_table.Get(handle); if (shared_memory == nullptr) - return InvalidHandle(ErrorModule::Kernel); + return ERR_INVALID_HANDLE; MemoryPermission permissions_type = static_cast(permissions); switch (permissions_type) { @@ -108,7 +109,7 @@ static ResultCode ConnectToPort(Handle* out, const char* port_name) { static ResultCode SendSyncRequest(Handle handle) { SharedPtr session = Kernel::g_handle_table.Get(handle); if (session == nullptr) { - return InvalidHandle(ErrorModule::Kernel); + return ERR_INVALID_HANDLE; } LOG_TRACE(Kernel_SVC, "called handle=0x%08X(%s)", handle, session->GetName().c_str()); @@ -127,7 +128,7 @@ static ResultCode CloseHandle(Handle handle) { static ResultCode WaitSynchronization1(Handle handle, s64 nano_seconds) { auto object = Kernel::g_handle_table.GetWaitObject(handle); if (object == nullptr) - return InvalidHandle(ErrorModule::Kernel); + return ERR_INVALID_HANDLE; LOG_TRACE(Kernel_SVC, "called handle=0x%08X(%s:%s), nanoseconds=%lld", handle, object->GetTypeName().c_str(), object->GetName().c_str(), nano_seconds); @@ -176,7 +177,7 @@ static ResultCode WaitSynchronizationN(s32* out, Handle* handles, s32 handle_cou for (int i = 0; i < handle_count; ++i) { auto object = Kernel::g_handle_table.GetWaitObject(handles[i]); if (object == nullptr) - return InvalidHandle(ErrorModule::Kernel); + return ERR_INVALID_HANDLE; // Check if the current thread should wait on this object... if (object->ShouldWait()) { @@ -272,7 +273,7 @@ static ResultCode ArbitrateAddress(Handle handle, u32 address, u32 type, u32 val SharedPtr arbiter = Kernel::g_handle_table.Get(handle); if (arbiter == nullptr) - return InvalidHandle(ErrorModule::Kernel); + return ERR_INVALID_HANDLE; return arbiter->ArbitrateAddress(static_cast(type), address, value, nanoseconds); @@ -347,7 +348,7 @@ static void ExitThread() { static ResultCode GetThreadPriority(s32* priority, Handle handle) { const SharedPtr thread = Kernel::g_handle_table.Get(handle); if (thread == nullptr) - return InvalidHandle(ErrorModule::Kernel); + return ERR_INVALID_HANDLE; *priority = thread->GetPriority(); return RESULT_SUCCESS; @@ -357,7 +358,7 @@ static ResultCode GetThreadPriority(s32* priority, Handle handle) { static ResultCode SetThreadPriority(Handle handle, s32 priority) { SharedPtr thread = Kernel::g_handle_table.Get(handle); if (thread == nullptr) - return InvalidHandle(ErrorModule::Kernel); + return ERR_INVALID_HANDLE; thread->SetPriority(priority); return RESULT_SUCCESS; @@ -386,7 +387,7 @@ static ResultCode ReleaseMutex(Handle handle) { SharedPtr mutex = Kernel::g_handle_table.Get(handle); if (mutex == nullptr) - return InvalidHandle(ErrorModule::Kernel); + return ERR_INVALID_HANDLE; mutex->Release(); return RESULT_SUCCESS; @@ -398,7 +399,7 @@ static ResultCode GetThreadId(u32* thread_id, Handle handle) { const SharedPtr thread = Kernel::g_handle_table.Get(handle); if (thread == nullptr) - return InvalidHandle(ErrorModule::Kernel); + return ERR_INVALID_HANDLE; *thread_id = thread->GetThreadId(); return RESULT_SUCCESS; @@ -430,7 +431,7 @@ static ResultCode ReleaseSemaphore(s32* count, Handle handle, s32 release_count) SharedPtr semaphore = Kernel::g_handle_table.Get(handle); if (semaphore == nullptr) - return InvalidHandle(ErrorModule::Kernel); + return ERR_INVALID_HANDLE; ResultVal release_res = semaphore->Release(release_count); if (release_res.Failed()) @@ -476,7 +477,7 @@ static ResultCode SignalEvent(Handle handle) { auto evt = Kernel::g_handle_table.Get(handle); if (evt == nullptr) - return InvalidHandle(ErrorModule::Kernel); + return ERR_INVALID_HANDLE; evt->Signal(); HLE::Reschedule(__func__); @@ -489,7 +490,7 @@ static ResultCode ClearEvent(Handle handle) { auto evt = Kernel::g_handle_table.Get(handle); if (evt == nullptr) - return InvalidHandle(ErrorModule::Kernel); + return ERR_INVALID_HANDLE; evt->Clear(); return RESULT_SUCCESS; @@ -520,7 +521,7 @@ static ResultCode ClearTimer(Handle handle) { SharedPtr timer = Kernel::g_handle_table.Get(handle); if (timer == nullptr) - return InvalidHandle(ErrorModule::Kernel); + return ERR_INVALID_HANDLE; timer->Clear(); return RESULT_SUCCESS; @@ -534,7 +535,7 @@ static ResultCode SetTimer(Handle handle, s64 initial, s64 interval) { SharedPtr timer = Kernel::g_handle_table.Get(handle); if (timer == nullptr) - return InvalidHandle(ErrorModule::Kernel); + return ERR_INVALID_HANDLE; timer->Set(initial, interval); return RESULT_SUCCESS; @@ -548,7 +549,7 @@ static ResultCode CancelTimer(Handle handle) { SharedPtr timer = Kernel::g_handle_table.Get(handle); if (timer == nullptr) - return InvalidHandle(ErrorModule::Kernel); + return ERR_INVALID_HANDLE; timer->Cancel(); return RESULT_SUCCESS; -- cgit v1.2.3