summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Yuri Kunde Schlesner2015-01-23 03:44:52 -0200
committerGravatar Yuri Kunde Schlesner2015-01-30 11:49:45 -0200
commit09ae6e1fa38bbf75dcb2796e96575fdba32ec69c (patch)
treee760cb36500849a65931a2f0ad0d6174be617601 /src
parentSVC: Change return type of handlers to ResultCode (diff)
downloadyuzu-09ae6e1fa38bbf75dcb2796e96575fdba32ec69c.tar.gz
yuzu-09ae6e1fa38bbf75dcb2796e96575fdba32ec69c.tar.xz
yuzu-09ae6e1fa38bbf75dcb2796e96575fdba32ec69c.zip
Remove result.h InvalidHandle
It was only being used in two places, where it was replaced by a local constant.
Diffstat (limited to 'src')
-rw-r--r--src/core/hle/kernel/kernel.h3
-rw-r--r--src/core/hle/result.h5
-rw-r--r--src/core/hle/service/fs/archive.cpp23
-rw-r--r--src/core/hle/svc.cpp31
4 files changed, 32 insertions, 30 deletions
diff --git a/src/core/hle/kernel/kernel.h b/src/core/hle/kernel/kernel.h
index 08a5db3b7..9860479ac 100644
--- a/src/core/hle/kernel/kernel.h
+++ b/src/core/hle/kernel/kernel.h
@@ -31,7 +31,8 @@ class Thread;
31const ResultCode ERR_OUT_OF_HANDLES(ErrorDescription::OutOfMemory, ErrorModule::Kernel, 31const ResultCode ERR_OUT_OF_HANDLES(ErrorDescription::OutOfMemory, ErrorModule::Kernel,
32 ErrorSummary::OutOfResource, ErrorLevel::Temporary); 32 ErrorSummary::OutOfResource, ErrorLevel::Temporary);
33// TOOD: Verify code 33// TOOD: Verify code
34const ResultCode ERR_INVALID_HANDLE = InvalidHandle(ErrorModule::Kernel); 34const ResultCode ERR_INVALID_HANDLE(ErrorDescription::InvalidHandle, ErrorModule::Kernel,
35 ErrorSummary::InvalidArgument, ErrorLevel::Permanent);
35 36
36enum KernelHandle : Handle { 37enum KernelHandle : Handle {
37 CurrentThread = 0xFFFF8000, 38 CurrentThread = 0xFFFF8000,
diff --git a/src/core/hle/result.h b/src/core/hle/result.h
index ad06d00aa..948b9e38e 100644
--- a/src/core/hle/result.h
+++ b/src/core/hle/result.h
@@ -227,11 +227,6 @@ inline ResultCode UnimplementedFunction(ErrorModule module) {
227 return ResultCode(ErrorDescription::NotImplemented, module, 227 return ResultCode(ErrorDescription::NotImplemented, module,
228 ErrorSummary::NotSupported, ErrorLevel::Permanent); 228 ErrorSummary::NotSupported, ErrorLevel::Permanent);
229} 229}
230/// Returned when a function is passed an invalid handle.
231inline ResultCode InvalidHandle(ErrorModule module) {
232 return ResultCode(ErrorDescription::InvalidHandle, module,
233 ErrorSummary::InvalidArgument, ErrorLevel::Permanent);
234}
235 230
236/** 231/**
237 * This is an optional value type. It holds a `ResultCode` and, if that code is a success code, 232 * 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 1bb4e4b23..6682f6590 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";
43namespace Service { 43namespace Service {
44namespace FS { 44namespace FS {
45 45
46// TODO: Verify code
47/// Returned when a function is passed an invalid handle.
48const ResultCode ERR_INVALID_HANDLE(ErrorDescription::InvalidHandle, ErrorModule::FS,
49 ErrorSummary::InvalidArgument, ErrorLevel::Permanent);
50
46// Command to access archive file 51// Command to access archive file
47enum class FileCommand : u32 { 52enum class FileCommand : u32 {
48 Dummy1 = 0x000100C6, 53 Dummy1 = 0x000100C6,
@@ -280,7 +285,7 @@ ResultVal<ArchiveHandle> OpenArchive(ArchiveIdCode id_code, FileSys::Path& archi
280 285
281ResultCode CloseArchive(ArchiveHandle handle) { 286ResultCode CloseArchive(ArchiveHandle handle) {
282 if (handle_map.erase(handle) == 0) 287 if (handle_map.erase(handle) == 0)
283 return InvalidHandle(ErrorModule::FS); 288 return ERR_INVALID_HANDLE;
284 else 289 else
285 return RESULT_SUCCESS; 290 return RESULT_SUCCESS;
286} 291}
@@ -301,7 +306,7 @@ ResultCode CreateArchive(std::unique_ptr<FileSys::ArchiveBackend>&& backend, Arc
301ResultVal<Handle> OpenFileFromArchive(ArchiveHandle archive_handle, const FileSys::Path& path, const FileSys::Mode mode) { 306ResultVal<Handle> OpenFileFromArchive(ArchiveHandle archive_handle, const FileSys::Path& path, const FileSys::Mode mode) {
302 Archive* archive = GetArchive(archive_handle); 307 Archive* archive = GetArchive(archive_handle);
303 if (archive == nullptr) 308 if (archive == nullptr)
304 return InvalidHandle(ErrorModule::FS); 309 return ERR_INVALID_HANDLE;
305 310
306 std::unique_ptr<FileSys::FileBackend> backend = archive->backend->OpenFile(path, mode); 311 std::unique_ptr<FileSys::FileBackend> backend = archive->backend->OpenFile(path, mode);
307 if (backend == nullptr) { 312 if (backend == nullptr) {
@@ -318,7 +323,7 @@ ResultVal<Handle> OpenFileFromArchive(ArchiveHandle archive_handle, const FileSy
318ResultCode DeleteFileFromArchive(ArchiveHandle archive_handle, const FileSys::Path& path) { 323ResultCode DeleteFileFromArchive(ArchiveHandle archive_handle, const FileSys::Path& path) {
319 Archive* archive = GetArchive(archive_handle); 324 Archive* archive = GetArchive(archive_handle);
320 if (archive == nullptr) 325 if (archive == nullptr)
321 return InvalidHandle(ErrorModule::FS); 326 return ERR_INVALID_HANDLE;
322 327
323 if (archive->backend->DeleteFile(path)) 328 if (archive->backend->DeleteFile(path))
324 return RESULT_SUCCESS; 329 return RESULT_SUCCESS;
@@ -331,7 +336,7 @@ ResultCode RenameFileBetweenArchives(ArchiveHandle src_archive_handle, const Fil
331 Archive* src_archive = GetArchive(src_archive_handle); 336 Archive* src_archive = GetArchive(src_archive_handle);
332 Archive* dest_archive = GetArchive(dest_archive_handle); 337 Archive* dest_archive = GetArchive(dest_archive_handle);
333 if (src_archive == nullptr || dest_archive == nullptr) 338 if (src_archive == nullptr || dest_archive == nullptr)
334 return InvalidHandle(ErrorModule::FS); 339 return ERR_INVALID_HANDLE;
335 340
336 if (src_archive == dest_archive) { 341 if (src_archive == dest_archive) {
337 if (src_archive->backend->RenameFile(src_path, dest_path)) 342 if (src_archive->backend->RenameFile(src_path, dest_path))
@@ -350,7 +355,7 @@ ResultCode RenameFileBetweenArchives(ArchiveHandle src_archive_handle, const Fil
350ResultCode DeleteDirectoryFromArchive(ArchiveHandle archive_handle, const FileSys::Path& path) { 355ResultCode DeleteDirectoryFromArchive(ArchiveHandle archive_handle, const FileSys::Path& path) {
351 Archive* archive = GetArchive(archive_handle); 356 Archive* archive = GetArchive(archive_handle);
352 if (archive == nullptr) 357 if (archive == nullptr)
353 return InvalidHandle(ErrorModule::FS); 358 return ERR_INVALID_HANDLE;
354 359
355 if (archive->backend->DeleteDirectory(path)) 360 if (archive->backend->DeleteDirectory(path))
356 return RESULT_SUCCESS; 361 return RESULT_SUCCESS;
@@ -361,7 +366,7 @@ ResultCode DeleteDirectoryFromArchive(ArchiveHandle archive_handle, const FileSy
361ResultCode CreateFileInArchive(ArchiveHandle archive_handle, const FileSys::Path& path, u32 file_size) { 366ResultCode CreateFileInArchive(ArchiveHandle archive_handle, const FileSys::Path& path, u32 file_size) {
362 Archive* archive = GetArchive(archive_handle); 367 Archive* archive = GetArchive(archive_handle);
363 if (archive == nullptr) 368 if (archive == nullptr)
364 return InvalidHandle(ErrorModule::FS); 369 return ERR_INVALID_HANDLE;
365 370
366 return archive->backend->CreateFile(path, file_size); 371 return archive->backend->CreateFile(path, file_size);
367} 372}
@@ -369,7 +374,7 @@ ResultCode CreateFileInArchive(ArchiveHandle archive_handle, const FileSys::Path
369ResultCode CreateDirectoryFromArchive(ArchiveHandle archive_handle, const FileSys::Path& path) { 374ResultCode CreateDirectoryFromArchive(ArchiveHandle archive_handle, const FileSys::Path& path) {
370 Archive* archive = GetArchive(archive_handle); 375 Archive* archive = GetArchive(archive_handle);
371 if (archive == nullptr) 376 if (archive == nullptr)
372 return InvalidHandle(ErrorModule::FS); 377 return ERR_INVALID_HANDLE;
373 378
374 if (archive->backend->CreateDirectory(path)) 379 if (archive->backend->CreateDirectory(path))
375 return RESULT_SUCCESS; 380 return RESULT_SUCCESS;
@@ -382,7 +387,7 @@ ResultCode RenameDirectoryBetweenArchives(ArchiveHandle src_archive_handle, cons
382 Archive* src_archive = GetArchive(src_archive_handle); 387 Archive* src_archive = GetArchive(src_archive_handle);
383 Archive* dest_archive = GetArchive(dest_archive_handle); 388 Archive* dest_archive = GetArchive(dest_archive_handle);
384 if (src_archive == nullptr || dest_archive == nullptr) 389 if (src_archive == nullptr || dest_archive == nullptr)
385 return InvalidHandle(ErrorModule::FS); 390 return ERR_INVALID_HANDLE;
386 391
387 if (src_archive == dest_archive) { 392 if (src_archive == dest_archive) {
388 if (src_archive->backend->RenameDirectory(src_path, dest_path)) 393 if (src_archive->backend->RenameDirectory(src_path, dest_path))
@@ -407,7 +412,7 @@ ResultCode RenameDirectoryBetweenArchives(ArchiveHandle src_archive_handle, cons
407ResultVal<Handle> OpenDirectoryFromArchive(ArchiveHandle archive_handle, const FileSys::Path& path) { 412ResultVal<Handle> OpenDirectoryFromArchive(ArchiveHandle archive_handle, const FileSys::Path& path) {
408 Archive* archive = GetArchive(archive_handle); 413 Archive* archive = GetArchive(archive_handle);
409 if (archive == nullptr) 414 if (archive == nullptr)
410 return InvalidHandle(ErrorModule::FS); 415 return ERR_INVALID_HANDLE;
411 416
412 std::unique_ptr<FileSys::DirectoryBackend> backend = archive->backend->OpenDirectory(path); 417 std::unique_ptr<FileSys::DirectoryBackend> backend = archive->backend->OpenDirectory(path);
413 if (backend == nullptr) { 418 if (backend == nullptr) {
diff --git a/src/core/hle/svc.cpp b/src/core/hle/svc.cpp
index bec9837a4..46fca51c7 100644
--- a/src/core/hle/svc.cpp
+++ b/src/core/hle/svc.cpp
@@ -26,6 +26,7 @@
26// Namespace SVC 26// Namespace SVC
27 27
28using Kernel::SharedPtr; 28using Kernel::SharedPtr;
29using Kernel::ERR_INVALID_HANDLE;
29 30
30namespace SVC { 31namespace SVC {
31 32
@@ -71,7 +72,7 @@ static ResultCode MapMemoryBlock(Handle handle, u32 addr, u32 permissions, u32 o
71 72
72 SharedPtr<SharedMemory> shared_memory = Kernel::g_handle_table.Get<SharedMemory>(handle); 73 SharedPtr<SharedMemory> shared_memory = Kernel::g_handle_table.Get<SharedMemory>(handle);
73 if (shared_memory == nullptr) 74 if (shared_memory == nullptr)
74 return InvalidHandle(ErrorModule::Kernel); 75 return ERR_INVALID_HANDLE;
75 76
76 MemoryPermission permissions_type = static_cast<MemoryPermission>(permissions); 77 MemoryPermission permissions_type = static_cast<MemoryPermission>(permissions);
77 switch (permissions_type) { 78 switch (permissions_type) {
@@ -108,7 +109,7 @@ static ResultCode ConnectToPort(Handle* out, const char* port_name) {
108static ResultCode SendSyncRequest(Handle handle) { 109static ResultCode SendSyncRequest(Handle handle) {
109 SharedPtr<Kernel::Session> session = Kernel::g_handle_table.Get<Kernel::Session>(handle); 110 SharedPtr<Kernel::Session> session = Kernel::g_handle_table.Get<Kernel::Session>(handle);
110 if (session == nullptr) { 111 if (session == nullptr) {
111 return InvalidHandle(ErrorModule::Kernel); 112 return ERR_INVALID_HANDLE;
112 } 113 }
113 114
114 LOG_TRACE(Kernel_SVC, "called handle=0x%08X(%s)", handle, session->GetName().c_str()); 115 LOG_TRACE(Kernel_SVC, "called handle=0x%08X(%s)", handle, session->GetName().c_str());
@@ -127,7 +128,7 @@ static ResultCode CloseHandle(Handle handle) {
127static ResultCode WaitSynchronization1(Handle handle, s64 nano_seconds) { 128static ResultCode WaitSynchronization1(Handle handle, s64 nano_seconds) {
128 auto object = Kernel::g_handle_table.GetWaitObject(handle); 129 auto object = Kernel::g_handle_table.GetWaitObject(handle);
129 if (object == nullptr) 130 if (object == nullptr)
130 return InvalidHandle(ErrorModule::Kernel); 131 return ERR_INVALID_HANDLE;
131 132
132 LOG_TRACE(Kernel_SVC, "called handle=0x%08X(%s:%s), nanoseconds=%lld", handle, 133 LOG_TRACE(Kernel_SVC, "called handle=0x%08X(%s:%s), nanoseconds=%lld", handle,
133 object->GetTypeName().c_str(), object->GetName().c_str(), nano_seconds); 134 object->GetTypeName().c_str(), object->GetName().c_str(), nano_seconds);
@@ -176,7 +177,7 @@ static ResultCode WaitSynchronizationN(s32* out, Handle* handles, s32 handle_cou
176 for (int i = 0; i < handle_count; ++i) { 177 for (int i = 0; i < handle_count; ++i) {
177 auto object = Kernel::g_handle_table.GetWaitObject(handles[i]); 178 auto object = Kernel::g_handle_table.GetWaitObject(handles[i]);
178 if (object == nullptr) 179 if (object == nullptr)
179 return InvalidHandle(ErrorModule::Kernel); 180 return ERR_INVALID_HANDLE;
180 181
181 // Check if the current thread should wait on this object... 182 // Check if the current thread should wait on this object...
182 if (object->ShouldWait()) { 183 if (object->ShouldWait()) {
@@ -272,7 +273,7 @@ static ResultCode ArbitrateAddress(Handle handle, u32 address, u32 type, u32 val
272 273
273 SharedPtr<AddressArbiter> arbiter = Kernel::g_handle_table.Get<AddressArbiter>(handle); 274 SharedPtr<AddressArbiter> arbiter = Kernel::g_handle_table.Get<AddressArbiter>(handle);
274 if (arbiter == nullptr) 275 if (arbiter == nullptr)
275 return InvalidHandle(ErrorModule::Kernel); 276 return ERR_INVALID_HANDLE;
276 277
277 return arbiter->ArbitrateAddress(static_cast<Kernel::ArbitrationType>(type), 278 return arbiter->ArbitrateAddress(static_cast<Kernel::ArbitrationType>(type),
278 address, value, nanoseconds); 279 address, value, nanoseconds);
@@ -347,7 +348,7 @@ static void ExitThread() {
347static ResultCode GetThreadPriority(s32* priority, Handle handle) { 348static ResultCode GetThreadPriority(s32* priority, Handle handle) {
348 const SharedPtr<Kernel::Thread> thread = Kernel::g_handle_table.Get<Kernel::Thread>(handle); 349 const SharedPtr<Kernel::Thread> thread = Kernel::g_handle_table.Get<Kernel::Thread>(handle);
349 if (thread == nullptr) 350 if (thread == nullptr)
350 return InvalidHandle(ErrorModule::Kernel); 351 return ERR_INVALID_HANDLE;
351 352
352 *priority = thread->GetPriority(); 353 *priority = thread->GetPriority();
353 return RESULT_SUCCESS; 354 return RESULT_SUCCESS;
@@ -357,7 +358,7 @@ static ResultCode GetThreadPriority(s32* priority, Handle handle) {
357static ResultCode SetThreadPriority(Handle handle, s32 priority) { 358static ResultCode SetThreadPriority(Handle handle, s32 priority) {
358 SharedPtr<Kernel::Thread> thread = Kernel::g_handle_table.Get<Kernel::Thread>(handle); 359 SharedPtr<Kernel::Thread> thread = Kernel::g_handle_table.Get<Kernel::Thread>(handle);
359 if (thread == nullptr) 360 if (thread == nullptr)
360 return InvalidHandle(ErrorModule::Kernel); 361 return ERR_INVALID_HANDLE;
361 362
362 thread->SetPriority(priority); 363 thread->SetPriority(priority);
363 return RESULT_SUCCESS; 364 return RESULT_SUCCESS;
@@ -386,7 +387,7 @@ static ResultCode ReleaseMutex(Handle handle) {
386 387
387 SharedPtr<Mutex> mutex = Kernel::g_handle_table.Get<Mutex>(handle); 388 SharedPtr<Mutex> mutex = Kernel::g_handle_table.Get<Mutex>(handle);
388 if (mutex == nullptr) 389 if (mutex == nullptr)
389 return InvalidHandle(ErrorModule::Kernel); 390 return ERR_INVALID_HANDLE;
390 391
391 mutex->Release(); 392 mutex->Release();
392 return RESULT_SUCCESS; 393 return RESULT_SUCCESS;
@@ -398,7 +399,7 @@ static ResultCode GetThreadId(u32* thread_id, Handle handle) {
398 399
399 const SharedPtr<Kernel::Thread> thread = Kernel::g_handle_table.Get<Kernel::Thread>(handle); 400 const SharedPtr<Kernel::Thread> thread = Kernel::g_handle_table.Get<Kernel::Thread>(handle);
400 if (thread == nullptr) 401 if (thread == nullptr)
401 return InvalidHandle(ErrorModule::Kernel); 402 return ERR_INVALID_HANDLE;
402 403
403 *thread_id = thread->GetThreadId(); 404 *thread_id = thread->GetThreadId();
404 return RESULT_SUCCESS; 405 return RESULT_SUCCESS;
@@ -430,7 +431,7 @@ static ResultCode ReleaseSemaphore(s32* count, Handle handle, s32 release_count)
430 431
431 SharedPtr<Semaphore> semaphore = Kernel::g_handle_table.Get<Semaphore>(handle); 432 SharedPtr<Semaphore> semaphore = Kernel::g_handle_table.Get<Semaphore>(handle);
432 if (semaphore == nullptr) 433 if (semaphore == nullptr)
433 return InvalidHandle(ErrorModule::Kernel); 434 return ERR_INVALID_HANDLE;
434 435
435 ResultVal<s32> release_res = semaphore->Release(release_count); 436 ResultVal<s32> release_res = semaphore->Release(release_count);
436 if (release_res.Failed()) 437 if (release_res.Failed())
@@ -476,7 +477,7 @@ static ResultCode SignalEvent(Handle handle) {
476 477
477 auto evt = Kernel::g_handle_table.Get<Kernel::Event>(handle); 478 auto evt = Kernel::g_handle_table.Get<Kernel::Event>(handle);
478 if (evt == nullptr) 479 if (evt == nullptr)
479 return InvalidHandle(ErrorModule::Kernel); 480 return ERR_INVALID_HANDLE;
480 481
481 evt->Signal(); 482 evt->Signal();
482 HLE::Reschedule(__func__); 483 HLE::Reschedule(__func__);
@@ -489,7 +490,7 @@ static ResultCode ClearEvent(Handle handle) {
489 490
490 auto evt = Kernel::g_handle_table.Get<Kernel::Event>(handle); 491 auto evt = Kernel::g_handle_table.Get<Kernel::Event>(handle);
491 if (evt == nullptr) 492 if (evt == nullptr)
492 return InvalidHandle(ErrorModule::Kernel); 493 return ERR_INVALID_HANDLE;
493 494
494 evt->Clear(); 495 evt->Clear();
495 return RESULT_SUCCESS; 496 return RESULT_SUCCESS;
@@ -520,7 +521,7 @@ static ResultCode ClearTimer(Handle handle) {
520 521
521 SharedPtr<Timer> timer = Kernel::g_handle_table.Get<Timer>(handle); 522 SharedPtr<Timer> timer = Kernel::g_handle_table.Get<Timer>(handle);
522 if (timer == nullptr) 523 if (timer == nullptr)
523 return InvalidHandle(ErrorModule::Kernel); 524 return ERR_INVALID_HANDLE;
524 525
525 timer->Clear(); 526 timer->Clear();
526 return RESULT_SUCCESS; 527 return RESULT_SUCCESS;
@@ -534,7 +535,7 @@ static ResultCode SetTimer(Handle handle, s64 initial, s64 interval) {
534 535
535 SharedPtr<Timer> timer = Kernel::g_handle_table.Get<Timer>(handle); 536 SharedPtr<Timer> timer = Kernel::g_handle_table.Get<Timer>(handle);
536 if (timer == nullptr) 537 if (timer == nullptr)
537 return InvalidHandle(ErrorModule::Kernel); 538 return ERR_INVALID_HANDLE;
538 539
539 timer->Set(initial, interval); 540 timer->Set(initial, interval);
540 return RESULT_SUCCESS; 541 return RESULT_SUCCESS;
@@ -548,7 +549,7 @@ static ResultCode CancelTimer(Handle handle) {
548 549
549 SharedPtr<Timer> timer = Kernel::g_handle_table.Get<Timer>(handle); 550 SharedPtr<Timer> timer = Kernel::g_handle_table.Get<Timer>(handle);
550 if (timer == nullptr) 551 if (timer == nullptr)
551 return InvalidHandle(ErrorModule::Kernel); 552 return ERR_INVALID_HANDLE;
552 553
553 timer->Cancel(); 554 timer->Cancel();
554 return RESULT_SUCCESS; 555 return RESULT_SUCCESS;