From edc099f026f3967a87ad8e06727f9afdfb30a346 Mon Sep 17 00:00:00 2001 From: Tony Wasserka Date: Sun, 3 Jun 2018 05:46:27 +0000 Subject: [PATCH] Use "final" and "override" where appropriate (#117) --- .../include/stratosphere/iserviceobject.hpp | 4 +-- .../include/stratosphere/servicesession.hpp | 16 +++++------ .../include/stratosphere/systemevent.hpp | 6 ++-- .../loader/source/ldr_debug_monitor.hpp | 8 +++--- .../loader/source/ldr_process_manager.hpp | 8 +++--- stratosphere/loader/source/ldr_ro_service.hpp | 8 +++--- stratosphere/loader/source/ldr_shell.hpp | 8 +++--- stratosphere/pm/source/pm_boot_mode.hpp | 8 +++--- stratosphere/pm/source/pm_debug_monitor.hpp | 8 +++--- stratosphere/pm/source/pm_info.hpp | 8 +++--- stratosphere/pm/source/pm_process_wait.hpp | 28 +++++++++---------- stratosphere/pm/source/pm_shell.hpp | 8 +++--- stratosphere/sm/source/sm_manager_service.hpp | 8 +++--- stratosphere/sm/source/sm_user_service.hpp | 8 +++--- 14 files changed, 67 insertions(+), 67 deletions(-) diff --git a/stratosphere/libstratosphere/include/stratosphere/iserviceobject.hpp b/stratosphere/libstratosphere/include/stratosphere/iserviceobject.hpp index cf4e7d670..9b569722d 100644 --- a/stratosphere/libstratosphere/include/stratosphere/iserviceobject.hpp +++ b/stratosphere/libstratosphere/include/stratosphere/iserviceobject.hpp @@ -4,8 +4,8 @@ #include "ipc_templating.hpp" class IServiceObject { - public: + protected: virtual ~IServiceObject() { } virtual Result dispatch(IpcParsedCommand &r, IpcCommand &out_c, u64 cmd_id, u8 *pointer_buffer, size_t pointer_buffer_size) = 0; virtual Result handle_deferred() = 0; -}; \ No newline at end of file +}; diff --git a/stratosphere/libstratosphere/include/stratosphere/servicesession.hpp b/stratosphere/libstratosphere/include/stratosphere/servicesession.hpp index 09ed83a99..1b397701e 100644 --- a/stratosphere/libstratosphere/include/stratosphere/servicesession.hpp +++ b/stratosphere/libstratosphere/include/stratosphere/servicesession.hpp @@ -23,7 +23,7 @@ template class IServer; template -class ServiceSession : public IWaitable { +class ServiceSession final : public IWaitable { static_assert(std::is_base_of::value, "Service Objects must derive from IServiceObject"); T *service_object; @@ -39,7 +39,7 @@ class ServiceSession : public IWaitable { this->service_object = new T(); } - virtual ~ServiceSession() { + ~ServiceSession() override { delete this->service_object; if (server_handle) { svcCloseHandle(server_handle); @@ -54,23 +54,23 @@ class ServiceSession : public IWaitable { Handle get_client_handle() { return this->client_handle; } /* IWaitable */ - virtual unsigned int get_num_waitables() { + unsigned int get_num_waitables() override { return 1; } - virtual void get_waitables(IWaitable **dst) { + void get_waitables(IWaitable **dst) override { dst[0] = this; } - virtual void delete_child(IWaitable *child) { + void delete_child(IWaitable *child) override { /* TODO: Panic, because we can never have any children. */ } - virtual Handle get_handle() { + Handle get_handle() override { return this->server_handle; } - virtual void handle_deferred() { + void handle_deferred() override { Result rc = this->service_object->handle_deferred(); int handle_index; @@ -84,7 +84,7 @@ class ServiceSession : public IWaitable { } } - virtual Result handle_signaled(u64 timeout) { + Result handle_signaled(u64 timeout) override { Result rc; int handle_index; diff --git a/stratosphere/libstratosphere/include/stratosphere/systemevent.hpp b/stratosphere/libstratosphere/include/stratosphere/systemevent.hpp index 55b4acdc2..69cce0a6b 100644 --- a/stratosphere/libstratosphere/include/stratosphere/systemevent.hpp +++ b/stratosphere/libstratosphere/include/stratosphere/systemevent.hpp @@ -7,7 +7,7 @@ #define SYSTEMEVENT_INDEX_WAITHANDLE 0 #define SYSTEMEVENT_INDEX_SGNLHANDLE 1 -class SystemEvent : public IEvent { +class SystemEvent final : public IEvent { public: SystemEvent(EventCallback callback) : IEvent(0, callback) { Handle wait_h; @@ -20,7 +20,7 @@ class SystemEvent : public IEvent { this->handles.push_back(sig_h); } - virtual Result signal_event() { + Result signal_event() override { return svcSignalEvent(this->handles[SYSTEMEVENT_INDEX_SGNLHANDLE]); } -}; \ No newline at end of file +}; diff --git a/stratosphere/loader/source/ldr_debug_monitor.hpp b/stratosphere/loader/source/ldr_debug_monitor.hpp index 09c64b0c9..5ca07936e 100644 --- a/stratosphere/loader/source/ldr_debug_monitor.hpp +++ b/stratosphere/loader/source/ldr_debug_monitor.hpp @@ -10,10 +10,10 @@ enum DebugMonitorServiceCmd { Dmnt_Cmd_GetNsoInfo = 2 }; -class DebugMonitorService : IServiceObject { +class DebugMonitorService final : IServiceObject { public: - virtual Result dispatch(IpcParsedCommand &r, IpcCommand &out_c, u64 cmd_id, u8 *pointer_buffer, size_t pointer_buffer_size); - virtual Result handle_deferred() { + Result dispatch(IpcParsedCommand &r, IpcCommand &out_c, u64 cmd_id, u8 *pointer_buffer, size_t pointer_buffer_size) override; + Result handle_deferred() override { /* This service will never defer. */ return 0; } @@ -23,4 +23,4 @@ class DebugMonitorService : IServiceObject { std::tuple add_title_to_launch_queue(u64 tid, InPointer args); std::tuple clear_launch_queue(u64 dat); std::tuple get_nso_info(u64 pid, OutPointerWithClientSize out); -}; \ No newline at end of file +}; diff --git a/stratosphere/loader/source/ldr_process_manager.hpp b/stratosphere/loader/source/ldr_process_manager.hpp index 322eadcb4..62d939870 100644 --- a/stratosphere/loader/source/ldr_process_manager.hpp +++ b/stratosphere/loader/source/ldr_process_manager.hpp @@ -12,7 +12,7 @@ enum ProcessManagerServiceCmd { Pm_Cmd_UnregisterTitle = 3 }; -class ProcessManagerService : IServiceObject { +class ProcessManagerService final : IServiceObject { struct ProgramInfo { u8 main_thread_priority; u8 default_cpu_id; @@ -29,8 +29,8 @@ class ProcessManagerService : IServiceObject { static_assert(sizeof(ProcessManagerService::ProgramInfo) == 0x400, "Incorrect ProgramInfo definition."); public: - virtual Result dispatch(IpcParsedCommand &r, IpcCommand &out_c, u64 cmd_id, u8 *pointer_buffer, size_t pointer_buffer_size); - virtual Result handle_deferred() { + Result dispatch(IpcParsedCommand &r, IpcCommand &out_c, u64 cmd_id, u8 *pointer_buffer, size_t pointer_buffer_size) override; + Result handle_deferred() override { /* This service will never defer. */ return 0; } @@ -44,4 +44,4 @@ class ProcessManagerService : IServiceObject { /* Utilities */ Result populate_program_info_buffer(ProcessManagerService::ProgramInfo *out, Registration::TidSid *tid_sid); -}; \ No newline at end of file +}; diff --git a/stratosphere/loader/source/ldr_ro_service.hpp b/stratosphere/loader/source/ldr_ro_service.hpp index f47d9849b..8b952bfbe 100644 --- a/stratosphere/loader/source/ldr_ro_service.hpp +++ b/stratosphere/loader/source/ldr_ro_service.hpp @@ -12,7 +12,7 @@ enum RoServiceCmd { Ro_Cmd_Initialize = 4, }; -class RelocatableObjectsService : IServiceObject { +class RelocatableObjectsService final : IServiceObject { Handle process_handle; u64 process_id; bool has_initialized; @@ -24,8 +24,8 @@ class RelocatableObjectsService : IServiceObject { svcCloseHandle(this->process_handle); } } - virtual Result dispatch(IpcParsedCommand &r, IpcCommand &out_c, u64 cmd_id, u8 *pointer_buffer, size_t pointer_buffer_size); - virtual Result handle_deferred() { + Result dispatch(IpcParsedCommand &r, IpcCommand &out_c, u64 cmd_id, u8 *pointer_buffer, size_t pointer_buffer_size) override; + Result handle_deferred() override { /* This service will never defer. */ return 0; } @@ -37,4 +37,4 @@ class RelocatableObjectsService : IServiceObject { std::tuple load_nrr(PidDescriptor pid_desc, u64 nrr_address, u64 nrr_size); std::tuple unload_nrr(PidDescriptor pid_desc, u64 nrr_address); std::tuple initialize(PidDescriptor pid_desc, CopiedHandle process_h); -}; \ No newline at end of file +}; diff --git a/stratosphere/loader/source/ldr_shell.hpp b/stratosphere/loader/source/ldr_shell.hpp index a4e8699e6..9eda9ee48 100644 --- a/stratosphere/loader/source/ldr_shell.hpp +++ b/stratosphere/loader/source/ldr_shell.hpp @@ -7,10 +7,10 @@ enum ShellServiceCmd { Shell_Cmd_ClearLaunchQueue = 1 }; -class ShellService : IServiceObject { +class ShellService final : IServiceObject { public: - virtual Result dispatch(IpcParsedCommand &r, IpcCommand &out_c, u64 cmd_id, u8 *pointer_buffer, size_t pointer_buffer_size); - virtual Result handle_deferred() { + Result dispatch(IpcParsedCommand &r, IpcCommand &out_c, u64 cmd_id, u8 *pointer_buffer, size_t pointer_buffer_size) override; + Result handle_deferred() override { /* This service will never defer. */ return 0; } @@ -19,4 +19,4 @@ class ShellService : IServiceObject { /* Actual commands. */ std::tuple add_title_to_launch_queue(u64 tid, InPointer args); std::tuple clear_launch_queue(u64 dat); -}; \ No newline at end of file +}; diff --git a/stratosphere/pm/source/pm_boot_mode.hpp b/stratosphere/pm/source/pm_boot_mode.hpp index fcbe2548c..ade479359 100644 --- a/stratosphere/pm/source/pm_boot_mode.hpp +++ b/stratosphere/pm/source/pm_boot_mode.hpp @@ -7,13 +7,13 @@ enum BootModeCmd { BootMode_Cmd_SetMaintenanceBoot = 1 }; -class BootModeService : IServiceObject { +class BootModeService final : IServiceObject, public IpcCommandWrapper { public: - virtual Result dispatch(IpcParsedCommand &r, IpcCommand &out_c, u64 cmd_id, u8 *pointer_buffer, size_t pointer_buffer_size); - virtual Result handle_deferred(); + Result dispatch(IpcParsedCommand &r, IpcCommand &out_c, u64 cmd_id, u8 *pointer_buffer, size_t pointer_buffer_size) override; + Result handle_deferred() override; private: /* Actual commands. */ std::tuple get_boot_mode(); std::tuple set_maintenance_boot(); -}; \ No newline at end of file +}; diff --git a/stratosphere/pm/source/pm_debug_monitor.hpp b/stratosphere/pm/source/pm_debug_monitor.hpp index 594036689..8b74a1819 100644 --- a/stratosphere/pm/source/pm_debug_monitor.hpp +++ b/stratosphere/pm/source/pm_debug_monitor.hpp @@ -23,10 +23,10 @@ enum DmntCmd_5X { Dmnt_Cmd_5X_EnableDebugForApplication = 5, }; -class DebugMonitorService : IServiceObject { +class DebugMonitorService final : IServiceObject { public: - virtual Result dispatch(IpcParsedCommand &r, IpcCommand &out_c, u64 cmd_id, u8 *pointer_buffer, size_t pointer_buffer_size); - virtual Result handle_deferred(); + Result dispatch(IpcParsedCommand &r, IpcCommand &out_c, u64 cmd_id, u8 *pointer_buffer, size_t pointer_buffer_size) override; + Result handle_deferred() override; private: /* Actual commands. */ @@ -37,4 +37,4 @@ class DebugMonitorService : IServiceObject { std::tuple enable_debug_for_tid(u64 tid); std::tuple get_application_process_id(); std::tuple enable_debug_for_application(); -}; \ No newline at end of file +}; diff --git a/stratosphere/pm/source/pm_info.hpp b/stratosphere/pm/source/pm_info.hpp index ee8618220..d7f791b1d 100644 --- a/stratosphere/pm/source/pm_info.hpp +++ b/stratosphere/pm/source/pm_info.hpp @@ -6,12 +6,12 @@ enum InformationCmd { Information_Cmd_GetTitleId = 0, }; -class InformationService : IServiceObject { +class InformationService final : IServiceObject { public: - virtual Result dispatch(IpcParsedCommand &r, IpcCommand &out_c, u64 cmd_id, u8 *pointer_buffer, size_t pointer_buffer_size); - virtual Result handle_deferred(); + Result dispatch(IpcParsedCommand &r, IpcCommand &out_c, u64 cmd_id, u8 *pointer_buffer, size_t pointer_buffer_size) override; + Result handle_deferred() override; private: /* Actual commands. */ std::tuple get_title_id(u64 pid); -}; \ No newline at end of file +}; diff --git a/stratosphere/pm/source/pm_process_wait.hpp b/stratosphere/pm/source/pm_process_wait.hpp index 484f835c4..d96fdc4f0 100644 --- a/stratosphere/pm/source/pm_process_wait.hpp +++ b/stratosphere/pm/source/pm_process_wait.hpp @@ -2,7 +2,7 @@ #include #include -class ProcessWaiter : public IWaitable { +class ProcessWaiter final : public IWaitable { public: Registration::Process process; @@ -19,33 +19,33 @@ class ProcessWaiter : public IWaitable { } /* IWaitable */ - virtual unsigned int get_num_waitables() { + unsigned int get_num_waitables() override { return 1; } - virtual void get_waitables(IWaitable **dst) { + void get_waitables(IWaitable **dst) override { dst[0] = this; } - virtual void delete_child(IWaitable *child) { + void delete_child(IWaitable *child) override { /* TODO: Panic, because we can never have any children. */ } - virtual Handle get_handle() { + Handle get_handle() override { return this->process.handle; } - virtual void handle_deferred() { + void handle_deferred() override { /* TODO: Panic, because we can never be deferred. */ } - virtual Result handle_signaled(u64 timeout) { + Result handle_signaled(u64 timeout) override { Registration::HandleSignaledProcess(this->get_process()); return 0; } }; -class ProcessList : public IWaitable { +class ProcessList final : public IWaitable { private: HosRecursiveMutex mutex; public: @@ -64,11 +64,11 @@ class ProcessList : public IWaitable { } /* IWaitable */ - virtual unsigned int get_num_waitables() { + unsigned int get_num_waitables() override { return process_waiters.size(); } - virtual void get_waitables(IWaitable **dst) { + void get_waitables(IWaitable **dst) override { Lock(); for (unsigned int i = 0; i < process_waiters.size(); i++) { dst[i] = process_waiters[i]; @@ -76,20 +76,20 @@ class ProcessList : public IWaitable { Unlock(); } - virtual void delete_child(IWaitable *child) { + void delete_child(IWaitable *child) override { /* TODO: Panic, because we should never be asked to delete a child. */ } - virtual Handle get_handle() { + Handle get_handle() override { /* TODO: Panic, because we don't have a handle. */ return 0; } - virtual void handle_deferred() { + void handle_deferred() override { /* TODO: Panic, because we can never be deferred. */ } - virtual Result handle_signaled(u64 timeout) { + Result handle_signaled(u64 timeout) override { /* TODO: Panic, because we can never be signaled. */ return 0; } diff --git a/stratosphere/pm/source/pm_shell.hpp b/stratosphere/pm/source/pm_shell.hpp index b9ec9a199..daf8483e8 100644 --- a/stratosphere/pm/source/pm_shell.hpp +++ b/stratosphere/pm/source/pm_shell.hpp @@ -30,10 +30,10 @@ enum ShellCmd_5X { Shell_Cmd_5X_BoostSystemMemoryResourceLimit = 7 }; -class ShellService : IServiceObject { +class ShellService final : IServiceObject { public: - virtual Result dispatch(IpcParsedCommand &r, IpcCommand &out_c, u64 cmd_id, u8 *pointer_buffer, size_t pointer_buffer_size); - virtual Result handle_deferred(); + Result dispatch(IpcParsedCommand &r, IpcCommand &out_c, u64 cmd_id, u8 *pointer_buffer, size_t pointer_buffer_size) override; + Result handle_deferred() override; private: /* Actual commands. */ @@ -47,4 +47,4 @@ class ShellService : IServiceObject { std::tuple notify_boot_finished(); std::tuple get_application_process_id(); std::tuple boost_system_memory_resource_limit(u64 sysmem_size); -}; \ No newline at end of file +}; diff --git a/stratosphere/sm/source/sm_manager_service.hpp b/stratosphere/sm/source/sm_manager_service.hpp index e84eca60e..7346bc08d 100644 --- a/stratosphere/sm/source/sm_manager_service.hpp +++ b/stratosphere/sm/source/sm_manager_service.hpp @@ -7,13 +7,13 @@ enum ManagerServiceCmd { Manager_Cmd_UnregisterProcess = 1 }; -class ManagerService : IServiceObject { +class ManagerService final : IServiceObject { public: - virtual Result dispatch(IpcParsedCommand &r, IpcCommand &out_c, u64 cmd_id, u8 *pointer_buffer, size_t pointer_buffer_size); - virtual Result handle_deferred(); + Result dispatch(IpcParsedCommand &r, IpcCommand &out_c, u64 cmd_id, u8 *pointer_buffer, size_t pointer_buffer_size) override; + Result handle_deferred() override; private: /* Actual commands. */ std::tuple register_process(u64 pid, InBuffer acid_sac, InBuffer aci0_sac); std::tuple unregister_process(u64 pid); -}; \ No newline at end of file +}; diff --git a/stratosphere/sm/source/sm_user_service.hpp b/stratosphere/sm/source/sm_user_service.hpp index 5911bd768..d8c54a08a 100644 --- a/stratosphere/sm/source/sm_user_service.hpp +++ b/stratosphere/sm/source/sm_user_service.hpp @@ -12,15 +12,15 @@ enum UserServiceCmd { User_Cmd_AtmosphereUninstallMitm = 65001 }; -class UserService : IServiceObject { +class UserService final : IServiceObject { u64 pid; bool has_initialized; u64 deferred_service; public: UserService() : pid(U64_MAX), has_initialized(false), deferred_service(0) { } - virtual Result dispatch(IpcParsedCommand &r, IpcCommand &out_c, u64 cmd_id, u8 *pointer_buffer, size_t pointer_buffer_size); - virtual Result handle_deferred(); + Result dispatch(IpcParsedCommand &r, IpcCommand &out_c, u64 cmd_id, u8 *pointer_buffer, size_t pointer_buffer_size) override; + Result handle_deferred() override; private: /* Actual commands. */ @@ -33,4 +33,4 @@ class UserService : IServiceObject { /* Atmosphere commands. */ std::tuple install_mitm(u64 service); std::tuple uninstall_mitm(u64 service); -}; \ No newline at end of file +};