mirror of
https://github.com/citra-emu/citra.git
synced 2024-11-26 17:10:10 +00:00
Remove result.h InvalidHandle
It was only being used in two places, where it was replaced by a local constant.
This commit is contained in:
parent
44f90340dc
commit
09ae6e1fa3
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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<ArchiveHandle> 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<FileSys::ArchiveBackend>&& backend, Arc
|
||||
ResultVal<Handle> 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<FileSys::FileBackend> backend = archive->backend->OpenFile(path, mode);
|
||||
if (backend == nullptr) {
|
||||
@ -318,7 +323,7 @@ ResultVal<Handle> 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<Handle> 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<FileSys::DirectoryBackend> backend = archive->backend->OpenDirectory(path);
|
||||
if (backend == nullptr) {
|
||||
|
@ -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<SharedMemory> shared_memory = Kernel::g_handle_table.Get<SharedMemory>(handle);
|
||||
if (shared_memory == nullptr)
|
||||
return InvalidHandle(ErrorModule::Kernel);
|
||||
return ERR_INVALID_HANDLE;
|
||||
|
||||
MemoryPermission permissions_type = static_cast<MemoryPermission>(permissions);
|
||||
switch (permissions_type) {
|
||||
@ -108,7 +109,7 @@ static ResultCode ConnectToPort(Handle* out, const char* port_name) {
|
||||
static ResultCode SendSyncRequest(Handle handle) {
|
||||
SharedPtr<Kernel::Session> session = Kernel::g_handle_table.Get<Kernel::Session>(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<AddressArbiter> arbiter = Kernel::g_handle_table.Get<AddressArbiter>(handle);
|
||||
if (arbiter == nullptr)
|
||||
return InvalidHandle(ErrorModule::Kernel);
|
||||
return ERR_INVALID_HANDLE;
|
||||
|
||||
return arbiter->ArbitrateAddress(static_cast<Kernel::ArbitrationType>(type),
|
||||
address, value, nanoseconds);
|
||||
@ -347,7 +348,7 @@ static void ExitThread() {
|
||||
static ResultCode GetThreadPriority(s32* priority, Handle handle) {
|
||||
const SharedPtr<Kernel::Thread> thread = Kernel::g_handle_table.Get<Kernel::Thread>(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<Kernel::Thread> thread = Kernel::g_handle_table.Get<Kernel::Thread>(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> mutex = Kernel::g_handle_table.Get<Mutex>(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<Kernel::Thread> thread = Kernel::g_handle_table.Get<Kernel::Thread>(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> semaphore = Kernel::g_handle_table.Get<Semaphore>(handle);
|
||||
if (semaphore == nullptr)
|
||||
return InvalidHandle(ErrorModule::Kernel);
|
||||
return ERR_INVALID_HANDLE;
|
||||
|
||||
ResultVal<s32> 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<Kernel::Event>(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<Kernel::Event>(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> timer = Kernel::g_handle_table.Get<Timer>(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> timer = Kernel::g_handle_table.Get<Timer>(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> timer = Kernel::g_handle_table.Get<Timer>(handle);
|
||||
if (timer == nullptr)
|
||||
return InvalidHandle(ErrorModule::Kernel);
|
||||
return ERR_INVALID_HANDLE;
|
||||
|
||||
timer->Cancel();
|
||||
return RESULT_SUCCESS;
|
||||
|
Loading…
Reference in New Issue
Block a user