From bbf22b4c607ac98a598b0b70fd9c2a2ed8baff4b Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Sat, 26 Mar 2022 14:48:33 -0700 Subject: [PATCH] ams: globally prefer R_RETURN to return for ams::Result --- exosphere/mariko_fatal/source/fatal_sdmmc.cpp | 2 +- .../mariko_fatal/source/fs/fatal_fs_api.cpp | 8 +- fusee/program/source/fs/fusee_fs_api.cpp | 8 +- .../source/fs/fusee_fs_file_storage.cpp | 10 +- fusee/program/source/fs/fusee_fs_storage.hpp | 12 +- fusee/program/source/fusee_emummc.cpp | 8 +- fusee/program/source/fusee_mmc.cpp | 12 +- fusee/program/source/fusee_sd_card.cpp | 10 +- .../stratosphere/ddsf/ddsf_i_device.hpp | 4 +- .../stratosphere/ddsf/ddsf_i_driver.hpp | 4 +- .../stratosphere/ddsf/impl/ddsf_for_each.hpp | 4 +- .../fs_dbm_hierarchical_rom_file_table.hpp | 10 +- .../common/fs_dbm_rom_key_value_storage.hpp | 8 +- .../stratosphere/fs/fs_i_event_notifier.hpp | 2 +- .../include/stratosphere/fs/fs_istorage.hpp | 8 +- .../include/stratosphere/fs/fs_path.hpp | 2 +- .../stratosphere/fs/fs_path_utility.hpp | 4 +- .../fs/fs_read_only_filesystem.hpp | 10 +- .../stratosphere/fs/fs_remote_filesystem.hpp | 44 ++-- .../stratosphere/fs/fs_remote_storage.hpp | 10 +- .../include/stratosphere/fs/fs_substorage.hpp | 6 +- .../fssrv_filesystem_interface_adapter.hpp | 44 ++-- .../fssrv_storage_interface_adapter.hpp | 12 +- .../fssystem_file_system_buddy_heap.hpp | 6 +- .../fssystem_alignment_matching_storage.hpp | 34 +-- ...system_alignment_matching_storage_impl.hpp | 4 +- .../fssystem_bucket_tree_template_impl.hpp | 2 +- .../fssystem/fssystem_indirect_storage.hpp | 2 +- .../fssystem/fssystem_utility.hpp | 10 +- .../kvdb/kvdb_file_key_value_cache.hpp | 12 +- .../kvdb/kvdb_file_key_value_store.hpp | 10 +- .../kvdb/kvdb_memory_key_value_store.hpp | 10 +- .../lr_add_on_content_location_resolver.hpp | 12 +- .../stratosphere/lr/lr_location_resolver.hpp | 30 +-- .../lr/lr_registered_location_resolver.hpp | 20 +- .../ncm/ncm_content_meta_database.hpp | 58 ++--- .../ncm/ncm_content_meta_extended_data.hpp | 4 +- .../stratosphere/ncm/ncm_content_storage.hpp | 54 ++--- .../ncm/ncm_install_task_base.hpp | 6 +- .../include/stratosphere/os/os_io_region.hpp | 2 +- .../stratosphere/os/os_transfer_memory.hpp | 2 +- .../stratosphere/pgl/pgl_event_observer.hpp | 8 +- .../include/stratosphere/scs/scs_shell.hpp | 2 +- .../sf/cmif/sf_cmif_service_dispatch.hpp | 8 +- .../sf/hipc/sf_hipc_server_manager.hpp | 10 +- .../hipc/sf_hipc_server_session_manager.hpp | 22 +- .../sf/impl/sf_impl_command_serialization.hpp | 10 +- .../include/stratosphere/spl/spl_types.hpp | 2 +- .../svc/svc_stratosphere_shims.hpp | 212 +++++++++--------- .../impl/tipc_autogen_interface_macros.hpp | 24 +- .../impl/tipc_impl_command_serialization.hpp | 2 +- .../impl/tipc_impl_message_api.os.horizon.hpp | 6 +- .../tipc/tipc_deferral_manager.hpp | 8 +- .../stratosphere/tipc/tipc_object_manager.hpp | 2 +- .../stratosphere/tipc/tipc_server_manager.hpp | 2 +- .../capsrv/capsrv_screen_shot_control_api.cpp | 4 +- .../decodersrv_decoder_control_service.cpp | 2 +- .../source/dd/dd_device_address_space.cpp | 8 +- .../source/erpt/srv/erpt_srv_attachment.cpp | 12 +- .../source/erpt/srv/erpt_srv_attachment.hpp | 4 +- .../erpt/srv/erpt_srv_attachment_impl.cpp | 8 +- .../source/erpt/srv/erpt_srv_cipher.hpp | 22 +- .../source/erpt/srv/erpt_srv_context.cpp | 6 +- .../source/erpt/srv/erpt_srv_context_impl.cpp | 14 +- .../erpt/srv/erpt_srv_context_record.cpp | 4 +- .../source/erpt/srv/erpt_srv_formatter.hpp | 4 +- .../source/erpt/srv/erpt_srv_journal.cpp | 10 +- .../erpt/srv/erpt_srv_journal_for_meta.cpp | 2 +- .../source/erpt/srv/erpt_srv_main.cpp | 4 +- .../source/erpt/srv/erpt_srv_manager_impl.cpp | 8 +- .../source/erpt/srv/erpt_srv_report.cpp | 12 +- .../source/erpt/srv/erpt_srv_report.hpp | 4 +- .../source/erpt/srv/erpt_srv_report_impl.cpp | 8 +- .../source/erpt/srv/erpt_srv_reporter.cpp | 2 +- .../source/erpt/srv/erpt_srv_service.cpp | 6 +- .../source/erpt/srv/erpt_srv_session_impl.cpp | 6 +- .../source/erpt/srv/erpt_srv_stream.cpp | 6 +- .../fs_dbm_hierarchical_rom_file_table.cpp | 24 +- .../source/fs/common/fs_file_storage.cpp | 22 +- .../libstratosphere/source/fs/fs_bis.cpp | 4 +- .../source/fs/fs_content_storage.cpp | 2 +- .../libstratosphere/source/fs/fs_data.cpp | 8 +- .../source/fs/fs_device_save_data.cpp | 2 +- .../source/fs/fs_filesystem_utils.cpp | 8 +- .../source/fs/fs_romfs_filesystem.cpp | 16 +- .../source/fs/fs_save_data_management.cpp | 12 +- .../libstratosphere/source/fs/fs_sd_card.cpp | 4 +- .../source/fs/fs_system_save_data.cpp | 8 +- .../source/fs/fsa/fs_directory_accessor.cpp | 4 +- .../source/fs/fsa/fs_file_accessor.cpp | 10 +- .../source/fs/fsa/fs_file_accessor.hpp | 2 +- .../source/fs/fsa/fs_mount_utils.cpp | 2 +- .../source/fs/fsa/fs_registrar.cpp | 6 +- .../source/fs/fsa/fs_user_filesystem.cpp | 6 +- .../source/fs/fsa/fs_user_mount_table.cpp | 4 +- .../fssrv_rom_file_system_creator.cpp | 6 +- .../fssrv/fssrv_file_system_proxy_api.cpp | 25 +-- .../fssrv/fssrv_program_registry_impl.cpp | 4 +- .../fssrv/fssrv_program_registry_service.cpp | 10 +- ...ystem_aes_ctr_counter_extended_storage.cpp | 2 +- .../fssystem/fssystem_aes_ctr_storage.cpp | 4 +- .../fssystem_block_cache_buffered_storage.cpp | 4 +- .../source/fssystem/fssystem_bucket_tree.cpp | 10 +- .../fssystem/fssystem_buffered_storage.cpp | 6 +- ...fssystem_directory_savedata_filesystem.cpp | 12 +- .../fssystem_hierarchical_sha256_storage.cpp | 4 +- .../fssystem_hierarchical_sha256_storage.hpp | 4 +- .../fssystem/fssystem_indirect_storage.cpp | 2 +- .../fssystem/fssystem_key_slot_cache.hpp | 4 +- ...em_memory_resource_buffer_hold_storage.hpp | 12 +- .../source/fssystem/fssystem_nca_reader.cpp | 4 +- .../fssystem_partition_file_system_meta.cpp | 2 +- ...fssystem_read_only_block_cache_storage.hpp | 6 +- .../gpio/driver/gpio_driver_service_api.cpp | 2 +- .../driver/impl/gpio_pad_session_impl.cpp | 2 +- .../source/gpio/gpio_remote_manager_impl.hpp | 4 +- .../gpio/gpio_remote_pad_session_impl.hpp | 30 +-- .../gpio/server/gpio_server_manager_impl.cpp | 2 +- .../libstratosphere/source/hid/hid_api.cpp | 2 +- .../htc/server/driver/htc_htclow_driver.cpp | 6 +- .../htc/server/htc_htc_service_object.cpp | 6 +- .../source/htcfs/htcfs_client.hpp | 64 +++--- .../source/htcfs/htcfs_client_impl.cpp | 32 +-- .../source/htcfs/htcfs_client_impl.hpp | 4 +- .../htcfs/htcfs_directory_service_object.cpp | 10 +- .../htcfs/htcfs_file_service_object.cpp | 18 +- .../htcfs_file_system_service_object.cpp | 24 +- .../source/htcfs/htcfs_result.hpp | 2 +- .../source/htcfs/htcfs_result_utils.hpp | 2 +- .../source/htcfs/htcfs_working_directory.cpp | 4 +- .../htclow/ctrl/htclow_ctrl_service.cpp | 24 +- .../htclow/driver/htclow_socket_driver.cpp | 2 +- .../htclow/driver/htclow_usb_driver.cpp | 2 +- .../source/htclow/driver/htclow_usb_impl.cpp | 2 +- .../source/htclow/htclow_channel.cpp | 16 +- .../source/htclow/htclow_manager.cpp | 28 +-- .../source/htclow/htclow_manager_impl.cpp | 24 +- .../source/htclow/mux/htclow_mux.cpp | 18 +- .../htclow/mux/htclow_mux_channel_impl.cpp | 6 +- .../htcs/client/htcs_session.os.horizon.cpp | 30 +-- .../source/htcs/impl/htcs_manager.cpp | 12 +- .../source/htcs/impl/htcs_manager_impl.cpp | 48 ++-- .../source/htcs/impl/htcs_service.cpp | 2 +- .../server/htcs_manager_service_object.cpp | 4 +- .../server/htcs_socket_service_object.cpp | 4 +- .../nintendo/nx/impl/i2c_bus_accessor.cpp | 10 +- .../nintendo/nx/impl/i2c_bus_accessor.hpp | 4 +- .../source/i2c/driver/i2c_driver_bus_api.cpp | 20 +- .../i2c/driver/i2c_driver_service_api.cpp | 2 +- .../i2c/driver/impl/i2c_i2c_session_impl.cpp | 6 +- .../source/i2c/i2c_client_api.cpp | 6 +- .../i2c/server/i2c_server_manager_impl.cpp | 2 +- .../i2c/server/i2c_server_session_impl.hpp | 14 +- .../source/kvdb/kvdb_file_key_value_store.cpp | 2 +- .../source/ldr/ldr_pm_api.os.horizon.cpp | 16 +- .../source/ldr/ldr_shell_api.os.horizon.cpp | 6 +- .../source/lm/lm_remote_log_service.hpp | 2 +- .../source/lm/srv/lm_sd_card_logger.cpp | 8 +- .../lr_registered_location_resolver_impl.cpp | 4 +- .../lr/lr_remote_location_resolver_impl.hpp | 28 +-- ...mote_registered_location_resolver_impl.hpp | 2 +- .../libstratosphere/source/ncm/ncm_api.cpp | 24 +- .../ncm/ncm_content_management_utils.cpp | 12 +- .../source/ncm/ncm_content_manager_impl.cpp | 18 +- .../ncm/ncm_content_meta_database_impl.cpp | 8 +- .../ncm_content_meta_database_impl_base.hpp | 2 +- .../source/ncm/ncm_content_meta_utils.cpp | 4 +- .../source/ncm/ncm_content_storage_impl.cpp | 32 +-- .../ncm/ncm_host_content_storage_impl.cpp | 4 +- .../source/ncm/ncm_install_task_base.cpp | 12 +- .../source/ncm/ncm_install_task_data.cpp | 30 +-- .../source/ncm/ncm_package_install_task.cpp | 2 +- .../ncm/ncm_package_system_downgrade_task.cpp | 4 +- .../ncm/ncm_package_system_update_task.cpp | 4 +- .../source/ncm/ncm_placeholder_accessor.cpp | 8 +- .../ncm/ncm_remote_content_manager_impl.hpp | 24 +- .../ncm_remote_content_meta_database_impl.hpp | 42 ++-- .../ncm/ncm_remote_content_storage_impl.hpp | 56 ++--- .../nim/nim_network_install_manager_api.cpp | 2 +- .../source/os/impl/os_multiple_wait_impl.cpp | 48 ++-- .../source/os/impl/os_multiple_wait_impl.hpp | 2 +- ...s_multiple_wait_target_impl.os.horizon.cpp | 4 +- ...s_multiple_wait_target_impl.os.horizon.hpp | 10 +- .../os_multiple_wait_target_impl.os.linux.hpp | 10 +- .../os_multiple_wait_target_impl.os.macos.hpp | 10 +- ...s_multiple_wait_target_impl.os.windows.hpp | 8 +- .../os_process_handle_impl.os.horizon.hpp | 4 +- .../source/os/impl/os_thread_manager.cpp | 2 +- .../source/os/os_process_handle_api.cpp | 4 +- .../source/os/os_sdk_reply_and_receive.cpp | 2 +- .../os/os_sdk_thread_local_storage_api.cpp | 2 +- .../libstratosphere/source/os/os_thread.cpp | 4 +- .../source/pgl/pgl_remote_event_observer.hpp | 16 +- .../source/pgl/pgl_shell_api.cpp | 24 +- .../source/pgl/srv/pgl_srv_shell.cpp | 6 +- .../pgl/srv/pgl_srv_shell_event_observer.cpp | 4 +- .../pgl/srv/pgl_srv_shell_host_utils.cpp | 8 +- .../pgl/srv/pgl_srv_shell_interface.cpp | 58 ++--- .../libstratosphere/source/pm/pm_dmnt_api.cpp | 12 +- .../libstratosphere/source/pm/pm_info_api.cpp | 12 +- .../source/pm/pm_shell_api.cpp | 14 +- .../nintendo/nx/powctl_bq24193_driver.cpp | 32 +-- .../nintendo/nx/powctl_max17050_driver.cpp | 40 ++-- .../source/powctl/powctl_battery_api.cpp | 62 ++--- .../source/powctl/powctl_charger_api.cpp | 42 ++-- .../source/psc/psc_pm_module.os.horizon.cpp | 6 +- .../source/psc/psc_remote_pm_module.hpp | 8 +- .../nintendo/nx/impl/pwm_pwm_driver_impl.cpp | 4 +- .../driver/impl/pwm_channel_session_impl.cpp | 16 +- .../pwm/driver/pwm_driver_channel_api.cpp | 8 +- .../pwm/driver/pwm_driver_service_api.cpp | 2 +- .../pwm/server/pwm_server_manager_impl.cpp | 2 +- .../libstratosphere/source/scs/scs_shell.cpp | 2 +- .../impl/settings_configuration_id_impl.cpp | 2 +- .../impl/settings_error_report_impl.cpp | 2 +- .../impl/settings_firmware_version_impl.cpp | 2 +- .../impl/settings_key_value_store.cpp | 75 +++---- .../impl/settings_platform_region_impl.cpp | 2 +- .../impl/settings_product_model_impl.cpp | 2 +- .../settings/impl/settings_region_impl.cpp | 2 +- .../impl/settings_serial_number_impl.cpp | 4 +- .../settings/impl/settings_system_data.cpp | 12 +- .../impl/settings_system_save_data.cpp | 16 +- .../settings/settings_serial_number.cpp | 12 +- .../sf/cmif/sf_cmif_domain_service_object.cpp | 18 +- .../sf/cmif/sf_cmif_service_dispatch.cpp | 12 +- .../source/sf/hipc/sf_hipc_api.os.horizon.cpp | 8 +- .../sf_hipc_server_domain_session_manager.cpp | 6 +- .../source/sf/hipc/sf_hipc_server_manager.cpp | 12 +- .../hipc/sf_hipc_server_session_manager.cpp | 19 +- .../libstratosphere/source/sm/sm_api.cpp | 10 +- .../source/sm/sm_manager_api.cpp | 8 +- .../libstratosphere/source/sm/sm_mitm_api.cpp | 18 +- .../libstratosphere/source/sm/sm_utils.hpp | 4 +- .../socket/impl/socket_api.os.horizon.cpp | 2 +- .../source/socket/socket_api.cpp | 6 +- .../source/spl/impl/spl_api_impl.cpp | 64 +++--- .../source/spl/spl_api.os.horizon.cpp | 50 ++--- ..._srv_profile_controller_for_debug_impl.cpp | 4 +- .../sprofile_srv_profile_importer_impl.cpp | 6 +- .../srv/sprofile_srv_profile_reader_impl.cpp | 10 +- .../srv/sprofile_srv_service_for_bg_agent.cpp | 2 +- ...profile_srv_service_for_system_process.cpp | 2 +- .../libstratosphere/source/time/time_api.cpp | 10 +- .../time_standard_network_system_clock.cpp | 2 +- .../time/time_standard_steady_clock.cpp | 4 +- .../time/time_standard_user_system_clock.cpp | 2 +- .../source/updater/updater_api.cpp | 20 +- .../source/updater/updater_bis_management.cpp | 8 +- .../source/updater/updater_bis_management.hpp | 13 +- .../source/updater/updater_bis_save.cpp | 4 +- .../source/updater/updater_files.cpp | 2 +- .../libstratosphere/source/usb/usb_device.cpp | 32 +-- .../source/usb/usb_remote_ds_endpoint.cpp | 10 +- .../source/usb/usb_remote_ds_interface.cpp | 14 +- .../source/usb/usb_remote_ds_service.cpp | 10 +- .../vapours/results/results_common.hpp | 10 +- .../sdmmc/impl/sdmmc_base_device_accessor.cpp | 12 +- .../sdmmc/impl/sdmmc_base_device_accessor.hpp | 10 +- .../impl/sdmmc_gc_asic_device_accessor.cpp | 2 +- .../sdmmc/impl/sdmmc_i_host_controller.hpp | 4 +- .../sdmmc/impl/sdmmc_mmc_device_accessor.cpp | 14 +- .../impl/sdmmc_sd_card_device_accessor.cpp | 8 +- .../sdmmc_sd_host_standard_controller.cpp | 18 +- ...mmc_sdmmc_controller.board.nintendo_nx.cpp | 18 +- .../libvapours/source/sdmmc/sdmmc_common.cpp | 18 +- .../libvapours/source/sdmmc/sdmmc_gc_asic.cpp | 12 +- .../libvapours/source/sdmmc/sdmmc_mmc.cpp | 10 +- .../libvapours/source/sdmmc/sdmmc_sd_card.cpp | 12 +- .../ams_mitm/source/amsmitm_fs_utils.cpp | 32 +-- .../source/bpc_mitm/bpcmitm_module.cpp | 2 +- .../source/dns_mitm/dnsmitm_module.cpp | 2 +- .../source/fs_mitm/fs_mitm_service.cpp | 6 +- .../source/fs_mitm/fsmitm_boot0storage.cpp | 10 +- .../source/fs_mitm/fsmitm_boot0storage.hpp | 4 +- .../fsmitm_calibration_binary_storage.cpp | 5 +- .../fs_mitm/fsmitm_layered_romfs_storage.cpp | 12 +- .../ams_mitm/source/fs_mitm/fsmitm_module.cpp | 2 +- .../fsmitm_readonly_layered_filesystem.hpp | 28 +-- .../source/ns_mitm/ns_am_mitm_service.cpp | 6 +- .../source/ns_mitm/ns_web_mitm_service.cpp | 6 +- .../ams_mitm/source/ns_mitm/nsmitm_module.cpp | 4 +- .../source/set_mitm/setmitm_module.cpp | 4 +- .../source/set_mitm/setsys_mitm_service.cpp | 2 +- .../source/set_mitm/settings_sd_kvs.cpp | 2 +- .../sysupdater/sysupdater_async_impl.cpp | 2 +- .../sysupdater/sysupdater_async_impl.hpp | 19 +- .../source/sysupdater/sysupdater_fs_utils.cpp | 6 +- .../source/sysupdater/sysupdater_service.cpp | 12 +- .../boot/source/boot_battery_driver.hpp | 16 +- .../boot/source/boot_charger_driver.hpp | 24 +- stratosphere/boot/source/boot_i2c_utils.cpp | 6 +- stratosphere/boot/source/boot_pmic_driver.cpp | 6 +- stratosphere/boot/source/boot_rtc_driver.cpp | 6 +- .../source/dmnt2_breakpoint_manager.cpp | 2 +- .../source/dmnt2_breakpoint_manager_base.cpp | 2 +- .../dmnt.gen2/source/dmnt2_debug_process.cpp | 24 +- .../source/dmnt2_gdb_server_impl.cpp | 2 +- .../source/dmnt2_hardware_breakpoint.cpp | 6 +- .../source/dmnt2_hardware_watchpoint.cpp | 6 +- .../source/dmnt2_software_breakpoint.cpp | 4 +- .../dmnt/source/cheat/dmnt_cheat_service.cpp | 48 ++-- .../dmnt/source/cheat/impl/dmnt_cheat_api.cpp | 76 +++---- .../impl/dmnt_cheat_debug_events_manager.cpp | 8 +- .../fatal/source/fatal_task_clock.cpp | 2 +- .../fatal/source/fatal_task_screen.cpp | 2 +- .../loader/source/ldr_loader_service.cpp | 14 +- .../loader/source/ldr_loader_service.hpp | 28 +-- stratosphere/loader/source/ldr_meta.cpp | 2 +- stratosphere/ncm/source/ncm_main.cpp | 4 +- .../ro/source/impl/ro_service_impl.cpp | 4 +- .../ro/source/ro_debug_monitor_service.cpp | 2 +- stratosphere/ro/source/ro_main.cpp | 6 +- stratosphere/ro/source/ro_ro_service.cpp | 12 +- .../spl/source/spl_crypto_service.hpp | 16 +- .../spl/source/spl_deprecated_service.hpp | 52 ++--- .../source/spl_device_unique_data_service.hpp | 4 +- stratosphere/spl/source/spl_es_service.hpp | 16 +- stratosphere/spl/source/spl_fs_service.hpp | 12 +- .../spl/source/spl_general_service.hpp | 14 +- stratosphere/spl/source/spl_main.cpp | 16 +- stratosphere/spl/source/spl_manu_service.hpp | 2 +- .../spl/source/spl_random_service.hpp | 2 +- .../spl/source/spl_secure_monitor_manager.cpp | 58 ++--- stratosphere/spl/source/spl_ssl_service.hpp | 4 +- 325 files changed, 1955 insertions(+), 1993 deletions(-) diff --git a/exosphere/mariko_fatal/source/fatal_sdmmc.cpp b/exosphere/mariko_fatal/source/fatal_sdmmc.cpp index 98cee3b70..668abbe45 100644 --- a/exosphere/mariko_fatal/source/fatal_sdmmc.cpp +++ b/exosphere/mariko_fatal/source/fatal_sdmmc.cpp @@ -52,7 +52,7 @@ namespace ams::secmon::fatal { } Result CheckSdCardConnection(sdmmc::SpeedMode *out_sm, sdmmc::BusWidth *out_bw) { - return sdmmc::CheckSdCardConnection(out_sm, out_bw, Port); + R_RETURN(sdmmc::CheckSdCardConnection(out_sm, out_bw, Port)); } Result ReadSdCard(void *dst, size_t size, size_t sector_index, size_t sector_count) { diff --git a/exosphere/mariko_fatal/source/fs/fatal_fs_api.cpp b/exosphere/mariko_fatal/source/fs/fatal_fs_api.cpp index b0b812961..fe3edf6e0 100644 --- a/exosphere/mariko_fatal/source/fs/fatal_fs_api.cpp +++ b/exosphere/mariko_fatal/source/fs/fatal_fs_api.cpp @@ -129,7 +129,7 @@ namespace ams::fs { } Result CreateDirectory(const char *path) { - return TranslateFatFsError(f_mkdir(path)); + R_RETURN(TranslateFatFsError(f_mkdir(path))); } Result OpenFile(FileHandle *out_file, const char *path, int mode) { @@ -168,7 +168,7 @@ namespace ams::fs { } Result ReadFile(FileHandle handle, s64 offset, void *buffer, size_t size) { - return ReadFile(handle, offset, buffer, size, fs::ReadOption::None); + R_RETURN(ReadFile(handle, offset, buffer, size, fs::ReadOption::None)); } Result ReadFile(size_t *out, FileHandle handle, s64 offset, void *buffer, size_t size, const fs::ReadOption &option) { @@ -189,7 +189,7 @@ namespace ams::fs { } Result ReadFile(size_t *out, FileHandle handle, s64 offset, void *buffer, size_t size) { - return ReadFile(out, handle, offset, buffer, size, fs::ReadOption::None); + R_RETURN(ReadFile(out, handle, offset, buffer, size, fs::ReadOption::None)); } Result GetFileSize(s64 *out, FileHandle handle) { @@ -199,7 +199,7 @@ namespace ams::fs { } Result FlushFile(FileHandle handle) { - return TranslateFatFsError(f_sync(GetInternalFile(handle))); + R_RETURN(TranslateFatFsError(f_sync(GetInternalFile(handle)))); } Result WriteFile(FileHandle handle, s64 offset, const void *buffer, size_t size, const fs::WriteOption &option) { diff --git a/fusee/program/source/fs/fusee_fs_api.cpp b/fusee/program/source/fs/fusee_fs_api.cpp index 0af1a68fd..d72189241 100644 --- a/fusee/program/source/fs/fusee_fs_api.cpp +++ b/fusee/program/source/fs/fusee_fs_api.cpp @@ -156,7 +156,7 @@ namespace ams::fs { } Result CreateDirectory(const char *path) { - return TranslateFatFsError(f_mkdir(path)); + R_RETURN(TranslateFatFsError(f_mkdir(path))); } Result OpenFile(FileHandle *out_file, const char *path, int mode) { @@ -236,7 +236,7 @@ namespace ams::fs { } Result ReadFile(FileHandle handle, s64 offset, void *buffer, size_t size) { - return ReadFile(handle, offset, buffer, size, fs::ReadOption::None); + R_RETURN(ReadFile(handle, offset, buffer, size, fs::ReadOption::None)); } Result ReadFile(size_t *out, FileHandle handle, s64 offset, void *buffer, size_t size, const fs::ReadOption &option) { @@ -257,7 +257,7 @@ namespace ams::fs { } Result ReadFile(size_t *out, FileHandle handle, s64 offset, void *buffer, size_t size) { - return ReadFile(out, handle, offset, buffer, size, fs::ReadOption::None); + R_RETURN(ReadFile(out, handle, offset, buffer, size, fs::ReadOption::None)); } Result GetFileSize(s64 *out, FileHandle handle) { @@ -267,7 +267,7 @@ namespace ams::fs { } Result FlushFile(FileHandle handle) { - return TranslateFatFsError(f_sync(GetInternalFile(handle))); + R_RETURN(TranslateFatFsError(f_sync(GetInternalFile(handle)))); } Result WriteFile(FileHandle handle, s64 offset, const void *buffer, size_t size, const fs::WriteOption &option) { diff --git a/fusee/program/source/fs/fusee_fs_file_storage.cpp b/fusee/program/source/fs/fusee_fs_file_storage.cpp index 630b61570..79c22a997 100644 --- a/fusee/program/source/fs/fusee_fs_file_storage.cpp +++ b/fusee/program/source/fs/fusee_fs_file_storage.cpp @@ -20,7 +20,7 @@ namespace ams::fs { Result FileHandleStorage::UpdateSize() { R_SUCCEED_IF(m_size != InvalidSize); - return GetFileSize(std::addressof(m_size), m_handle); + R_RETURN(GetFileSize(std::addressof(m_size), m_handle)); } Result FileHandleStorage::Read(s64 offset, void *buffer, size_t size) { @@ -36,7 +36,7 @@ namespace ams::fs { /* Ensure our access is valid. */ R_TRY(IStorage::CheckAccessRange(offset, size, m_size)); - return ReadFile(m_handle, offset, buffer, size, fs::ReadOption()); + R_RETURN(ReadFile(m_handle, offset, buffer, size, fs::ReadOption())); } Result FileHandleStorage::Write(s64 offset, const void *buffer, size_t size) { @@ -52,11 +52,11 @@ namespace ams::fs { /* Ensure our access is valid. */ R_TRY(IStorage::CheckAccessRange(offset, size, m_size)); - return WriteFile(m_handle, offset, buffer, size, fs::WriteOption()); + R_RETURN(WriteFile(m_handle, offset, buffer, size, fs::WriteOption())); } Result FileHandleStorage::Flush() { - return FlushFile(m_handle); + R_RETURN(FlushFile(m_handle)); } Result FileHandleStorage::GetSize(s64 *out_size) { @@ -67,7 +67,7 @@ namespace ams::fs { Result FileHandleStorage::SetSize(s64 size) { m_size = InvalidSize; - return SetFileSize(m_handle, size); + R_RETURN(SetFileSize(m_handle, size)); } } diff --git a/fusee/program/source/fs/fusee_fs_storage.hpp b/fusee/program/source/fs/fusee_fs_storage.hpp index 4e389749c..286a6bbdd 100644 --- a/fusee/program/source/fs/fusee_fs_storage.hpp +++ b/fusee/program/source/fs/fusee_fs_storage.hpp @@ -73,15 +73,15 @@ namespace ams::fs { ReadOnlyStorageAdapter(IStorage &s) : m_storage(s) { /* ... */ } virtual Result Read(s64 offset, void *buffer, size_t size) override { - return m_storage.Read(offset, buffer, size); + R_RETURN(m_storage.Read(offset, buffer, size)); } virtual Result Flush() override { - return m_storage.Flush(); + R_RETURN(m_storage.Flush()); } virtual Result GetSize(s64 *out) override { - return m_storage.GetSize(out); + R_RETURN(m_storage.GetSize(out)); } virtual Result Write(s64 offset, const void *buffer, size_t size) override { @@ -108,7 +108,7 @@ namespace ams::fs { /* Validate arguments and read. */ R_UNLESS(buffer != nullptr, fs::ResultNullptrArgument()); R_TRY(IStorage::CheckAccessRange(offset, size, m_size)); - return m_storage.Read(m_offset + offset, buffer, size); + R_RETURN(m_storage.Read(m_offset + offset, buffer, size)); } virtual Result Write(s64 offset, const void *buffer, size_t size) override{ @@ -118,11 +118,11 @@ namespace ams::fs { /* Validate arguments and write. */ R_UNLESS(buffer != nullptr, fs::ResultNullptrArgument()); R_TRY(IStorage::CheckAccessRange(offset, size, m_size)); - return m_storage.Write(m_offset + offset, buffer, size); + R_RETURN(m_storage.Write(m_offset + offset, buffer, size)); } virtual Result Flush() override { - return m_storage.Flush(); + R_RETURN(m_storage.Flush()); } virtual Result GetSize(s64 *out) override { diff --git a/fusee/program/source/fusee_emummc.cpp b/fusee/program/source/fusee_emummc.cpp index 7aed8822c..d30cc2454 100644 --- a/fusee/program/source/fusee_emummc.cpp +++ b/fusee/program/source/fusee_emummc.cpp @@ -33,7 +33,7 @@ namespace ams::nxboot { ShowFatalError("SdCard: unaligned access to %" PRIx64 ", size=%" PRIx64"\n", static_cast(offset), static_cast(size)); } - return ReadSdCard(buffer, size, offset / sdmmc::SectorSize, size / sdmmc::SectorSize); + R_RETURN(ReadSdCard(buffer, size, offset / sdmmc::SectorSize, size / sdmmc::SectorSize)); } virtual Result Flush() override { @@ -67,7 +67,7 @@ namespace ams::nxboot { ShowFatalError("SdCard: unaligned access to %" PRIx64 ", size=%" PRIx64"\n", static_cast(offset), static_cast(size)); } - return ReadMmc(buffer, size, Partition, offset / sdmmc::SectorSize, size / sdmmc::SectorSize); + R_RETURN(ReadMmc(buffer, size, Partition, offset / sdmmc::SectorSize, size / sdmmc::SectorSize)); } virtual Result Flush() override { @@ -349,11 +349,11 @@ namespace ams::nxboot { } Result ReadBoot0(s64 offset, void *dst, size_t size) { - return g_boot0_storage->Read(offset, dst, size); + R_RETURN(g_boot0_storage->Read(offset, dst, size)); } Result ReadPackage2(s64 offset, void *dst, size_t size) { - return g_package2_storage->Read(offset, dst, size); + R_RETURN(g_package2_storage->Read(offset, dst, size)); } } diff --git a/fusee/program/source/fusee_mmc.cpp b/fusee/program/source/fusee_mmc.cpp index be35f051e..639c83e6f 100644 --- a/fusee/program/source/fusee_mmc.cpp +++ b/fusee/program/source/fusee_mmc.cpp @@ -47,29 +47,29 @@ namespace ams::nxboot { sdmmc::SetMmcWorkBuffer(MmcPort, g_mmc_work_buffer, sizeof(g_mmc_work_buffer)); /* Activate the mmc. */ - return sdmmc::Activate(MmcPort); + R_RETURN(sdmmc::Activate(MmcPort)); } Result CheckMmcConnection(sdmmc::SpeedMode *out_sm, sdmmc::BusWidth *out_bw) { - return sdmmc::CheckMmcConnection(out_sm, out_bw, MmcPort); + R_RETURN(sdmmc::CheckMmcConnection(out_sm, out_bw, MmcPort)); } Result GetMmcMemoryCapacity(u32 *out_num_sectors, sdmmc::MmcPartition partition) { if (partition == sdmmc::MmcPartition_UserData) { - return sdmmc::GetDeviceMemoryCapacity(out_num_sectors, MmcPort); + R_RETURN(sdmmc::GetDeviceMemoryCapacity(out_num_sectors, MmcPort)); } else { - return sdmmc::GetMmcBootPartitionCapacity(out_num_sectors, MmcPort); + R_RETURN(sdmmc::GetMmcBootPartitionCapacity(out_num_sectors, MmcPort)); } } Result ReadMmc(void *dst, size_t size, sdmmc::MmcPartition partition, size_t sector_index, size_t sector_count) { R_TRY(SelectMmcPartition(partition)); - return sdmmc::Read(dst, size, MmcPort, sector_index, sector_count); + R_RETURN(sdmmc::Read(dst, size, MmcPort, sector_index, sector_count)); } Result WriteMmc(sdmmc::MmcPartition partition, size_t sector_index, size_t sector_count, const void *src, size_t size) { R_TRY(SelectMmcPartition(partition)); - return sdmmc::Write(MmcPort, sector_index, sector_count, src, size); + R_RETURN(sdmmc::Write(MmcPort, sector_index, sector_count, src, size)); } } \ No newline at end of file diff --git a/fusee/program/source/fusee_sd_card.cpp b/fusee/program/source/fusee_sd_card.cpp index 3fa0dc272..0b9ec98ed 100644 --- a/fusee/program/source/fusee_sd_card.cpp +++ b/fusee/program/source/fusee_sd_card.cpp @@ -78,7 +78,7 @@ namespace ams::nxboot { sdmmc::SetSdCardWorkBuffer(SdCardPort, g_sd_work_buffer, sizeof(g_sd_work_buffer)); /* Activate the SD card. */ - return sdmmc::Activate(SdCardPort); + R_RETURN(sdmmc::Activate(SdCardPort)); } void FinalizeSdCard() { @@ -90,19 +90,19 @@ namespace ams::nxboot { } Result CheckSdCardConnection(sdmmc::SpeedMode *out_sm, sdmmc::BusWidth *out_bw) { - return sdmmc::CheckSdCardConnection(out_sm, out_bw, SdCardPort); + R_RETURN(sdmmc::CheckSdCardConnection(out_sm, out_bw, SdCardPort)); } Result GetSdCardMemoryCapacity(u32 *out_num_sectors) { - return sdmmc::GetDeviceMemoryCapacity(out_num_sectors, SdCardPort); + R_RETURN(sdmmc::GetDeviceMemoryCapacity(out_num_sectors, SdCardPort)); } Result ReadSdCard(void *dst, size_t size, size_t sector_index, size_t sector_count) { - return sdmmc::Read(dst, size, SdCardPort, sector_index, sector_count); + R_RETURN(sdmmc::Read(dst, size, SdCardPort, sector_index, sector_count)); } Result WriteSdCard(size_t sector_index, size_t sector_count, const void *src, size_t size) { - return sdmmc::Write(SdCardPort, sector_index, sector_count, src, size); + R_RETURN(sdmmc::Write(SdCardPort, sector_index, sector_count, src, size)); } } \ No newline at end of file diff --git a/libraries/libstratosphere/include/stratosphere/ddsf/ddsf_i_device.hpp b/libraries/libstratosphere/include/stratosphere/ddsf/ddsf_i_device.hpp index c32010fe0..045aeaeae 100644 --- a/libraries/libstratosphere/include/stratosphere/ddsf/ddsf_i_device.hpp +++ b/libraries/libstratosphere/include/stratosphere/ddsf/ddsf_i_device.hpp @@ -113,12 +113,12 @@ namespace ams::ddsf { template Result ForEachSession(F f, bool return_on_fail) { - return impl::ForEach(m_session_list_lock, m_session_list, f, return_on_fail); + R_RETURN(impl::ForEach(m_session_list_lock, m_session_list, f, return_on_fail)); } template Result ForEachSession(F f, bool return_on_fail) const { - return impl::ForEach(m_session_list_lock, m_session_list, f, return_on_fail); + R_RETURN(impl::ForEach(m_session_list_lock, m_session_list, f, return_on_fail)); } template diff --git a/libraries/libstratosphere/include/stratosphere/ddsf/ddsf_i_driver.hpp b/libraries/libstratosphere/include/stratosphere/ddsf/ddsf_i_driver.hpp index 3532504d8..a48085d60 100644 --- a/libraries/libstratosphere/include/stratosphere/ddsf/ddsf_i_driver.hpp +++ b/libraries/libstratosphere/include/stratosphere/ddsf/ddsf_i_driver.hpp @@ -76,12 +76,12 @@ namespace ams::ddsf { template Result ForEachDevice(F f, bool return_on_fail) { - return impl::ForEach(m_device_list_lock, m_device_list, f, return_on_fail); + R_RETURN(impl::ForEach(m_device_list_lock, m_device_list, f, return_on_fail)); } template Result ForEachDevice(F f, bool return_on_fail) const { - return impl::ForEach(m_device_list_lock, m_device_list, f, return_on_fail); + R_RETURN(impl::ForEach(m_device_list_lock, m_device_list, f, return_on_fail)); } template diff --git a/libraries/libstratosphere/include/stratosphere/ddsf/impl/ddsf_for_each.hpp b/libraries/libstratosphere/include/stratosphere/ddsf/impl/ddsf_for_each.hpp index e81623e3d..1978d334e 100644 --- a/libraries/libstratosphere/include/stratosphere/ddsf/impl/ddsf_for_each.hpp +++ b/libraries/libstratosphere/include/stratosphere/ddsf/impl/ddsf_for_each.hpp @@ -26,13 +26,13 @@ namespace ams::ddsf::impl { for (auto && it : list) { if (const auto cur_result = f(std::addressof(it)); R_FAILED(cur_result)) { if (return_on_fail) { - return cur_result; + R_RETURN(cur_result); } else if (R_SUCCEEDED(result)) { result = cur_result; } } } - return result; + R_RETURN(result); } template diff --git a/libraries/libstratosphere/include/stratosphere/fs/common/fs_dbm_hierarchical_rom_file_table.hpp b/libraries/libstratosphere/include/stratosphere/fs/common/fs_dbm_hierarchical_rom_file_table.hpp index 298719b2b..1664ab496 100644 --- a/libraries/libstratosphere/include/stratosphere/fs/common/fs_dbm_hierarchical_rom_file_table.hpp +++ b/libraries/libstratosphere/include/stratosphere/fs/common/fs_dbm_hierarchical_rom_file_table.hpp @@ -81,23 +81,23 @@ namespace ams::fs { using Base = KeyValueRomStorageTemplate; public: Result Add(Position *out, const ClientKeyType &key, const Value &value) { - return Base::AddInternal(out, key.key, key.Hash(), key.name.path, key.name.length * sizeof(RomPathChar), value); + R_RETURN(Base::AddInternal(out, key.key, key.Hash(), key.name.path, key.name.length * sizeof(RomPathChar), value)); } Result Get(Position *out_pos, Value *out_val, const ClientKeyType &key) { - return Base::GetInternal(out_pos, out_val, key.key, key.Hash(), key.name.path, key.name.length * sizeof(RomPathChar)); + R_RETURN(Base::GetInternal(out_pos, out_val, key.key, key.Hash(), key.name.path, key.name.length * sizeof(RomPathChar))); } Result GetByPosition(ImplKey *out_key, Value *out_val, Position pos) { - return Base::GetByPosition(out_key, out_val, pos); + R_RETURN(Base::GetByPosition(out_key, out_val, pos)); } Result GetByPosition(ImplKey *out_key, Value *out_val, void *out_aux, size_t *out_aux_size, Position pos) { - return Base::GetByPosition(out_key, out_val, out_aux, out_aux_size, pos); + R_RETURN(Base::GetByPosition(out_key, out_val, out_aux, out_aux_size, pos)); } Result SetByPosition(Position pos, const Value &value) { - return Base::SetByPosition(pos, value); + R_RETURN(Base::SetByPosition(pos, value)); } }; diff --git a/libraries/libstratosphere/include/stratosphere/fs/common/fs_dbm_rom_key_value_storage.hpp b/libraries/libstratosphere/include/stratosphere/fs/common/fs_dbm_rom_key_value_storage.hpp index 3b827ff50..5435d4400 100644 --- a/libraries/libstratosphere/include/stratosphere/fs/common/fs_dbm_rom_key_value_storage.hpp +++ b/libraries/libstratosphere/include/stratosphere/fs/common/fs_dbm_rom_key_value_storage.hpp @@ -175,7 +175,7 @@ namespace ams::fs { Element elem; R_TRY(this->ReadKeyValue(std::addressof(elem), pos)); elem.value = value; - return this->WriteKeyValue(std::addressof(elem), pos, nullptr, 0); + R_RETURN(this->WriteKeyValue(std::addressof(elem), pos, nullptr, 0)); } private: BucketIndex HashToBucket(u32 hash_key) const { @@ -259,14 +259,14 @@ namespace ams::fs { AMS_ASSERT(ind < m_bucket_count); const s64 offset = ind * sizeof(Position); - return m_bucket_storage.Read(offset, out, sizeof(*out)); + R_RETURN(m_bucket_storage.Read(offset, out, sizeof(*out))); } Result WriteBucket(Position pos, BucketIndex ind) { AMS_ASSERT(ind < m_bucket_count); const s64 offset = ind * sizeof(Position); - return m_bucket_storage.Write(offset, std::addressof(pos), sizeof(pos)); + R_RETURN(m_bucket_storage.Write(offset, std::addressof(pos), sizeof(pos))); } Result ReadKeyValue(Element *out, Position pos) { @@ -276,7 +276,7 @@ namespace ams::fs { R_TRY(m_kv_storage.GetSize(std::addressof(kv_size))); AMS_ASSERT(pos < kv_size); - return m_kv_storage.Read(pos, out, sizeof(*out)); + R_RETURN(m_kv_storage.Read(pos, out, sizeof(*out))); } Result ReadKeyValue(Element *out, void *out_aux, size_t *out_aux_size, Position pos) { diff --git a/libraries/libstratosphere/include/stratosphere/fs/fs_i_event_notifier.hpp b/libraries/libstratosphere/include/stratosphere/fs/fs_i_event_notifier.hpp index 7ff663039..6dbba305f 100644 --- a/libraries/libstratosphere/include/stratosphere/fs/fs_i_event_notifier.hpp +++ b/libraries/libstratosphere/include/stratosphere/fs/fs_i_event_notifier.hpp @@ -25,7 +25,7 @@ namespace ams::fs { Result BindEvent(os::SystemEventType *out, os::EventClearMode clear_mode) { AMS_ASSERT(out != nullptr); - return this->DoBindEvent(out, clear_mode); + R_RETURN(this->DoBindEvent(out, clear_mode)); } private: virtual Result DoBindEvent(os::SystemEventType *out, os::EventClearMode clear_mode) = 0; diff --git a/libraries/libstratosphere/include/stratosphere/fs/fs_istorage.hpp b/libraries/libstratosphere/include/stratosphere/fs/fs_istorage.hpp index a430f736b..f8267497a 100644 --- a/libraries/libstratosphere/include/stratosphere/fs/fs_istorage.hpp +++ b/libraries/libstratosphere/include/stratosphere/fs/fs_istorage.hpp @@ -95,19 +95,19 @@ namespace ams::fs { virtual ~ReadOnlyStorageAdapter() { /* ... */ } public: virtual Result Read(s64 offset, void *buffer, size_t size) override { - return m_storage->Read(offset, buffer, size); + R_RETURN(m_storage->Read(offset, buffer, size)); } virtual Result Flush() override { - return m_storage->Flush(); + R_RETURN(m_storage->Flush()); } virtual Result GetSize(s64 *out) override { - return m_storage->GetSize(out); + R_RETURN(m_storage->GetSize(out)); } virtual Result OperateRange(void *dst, size_t dst_size, OperationId op_id, s64 offset, s64 size, const void *src, size_t src_size) override { - return m_storage->OperateRange(dst, dst_size, op_id, offset, size, src, src_size); + R_RETURN(m_storage->OperateRange(dst, dst_size, op_id, offset, size, src, src_size)); } virtual Result Write(s64 offset, const void *buffer, size_t size) override { diff --git a/libraries/libstratosphere/include/stratosphere/fs/fs_path.hpp b/libraries/libstratosphere/include/stratosphere/fs/fs_path.hpp index 9d3de7b8e..3bb588c94 100644 --- a/libraries/libstratosphere/include/stratosphere/fs/fs_path.hpp +++ b/libraries/libstratosphere/include/stratosphere/fs/fs_path.hpp @@ -205,7 +205,7 @@ namespace ams::fs { /* Check the path is valid. */ R_UNLESS(path != nullptr, fs::ResultNullptrArgument()); - return this->Initialize(path, std::strlen(path)); + R_RETURN(this->Initialize(path, std::strlen(path))); } Result InitializeWithFormat(const char *fmt, ...) __attribute__((format (printf, 2, 3))) { diff --git a/libraries/libstratosphere/include/stratosphere/fs/fs_path_utility.hpp b/libraries/libstratosphere/include/stratosphere/fs/fs_path_utility.hpp index 510c5934e..a3025a5ed 100644 --- a/libraries/libstratosphere/include/stratosphere/fs/fs_path_utility.hpp +++ b/libraries/libstratosphere/include/stratosphere/fs/fs_path_utility.hpp @@ -619,7 +619,7 @@ namespace ams::fs { } static constexpr ALWAYS_INLINE Result SkipMountName(const char **out, size_t *out_len, const char *path) { - return ParseMountName(out, out_len, nullptr, 0, path); + R_RETURN(ParseMountName(out, out_len, nullptr, 0, path)); } static constexpr Result ParseMountName(const char **out, size_t *out_len, char *out_mount_name, size_t out_mount_name_buffer_size, const char *path) { @@ -684,7 +684,7 @@ namespace ams::fs { } static constexpr ALWAYS_INLINE Result SkipRelativeDotPath(const char **out, size_t *out_len, const char *path) { - return ParseRelativeDotPath(out, out_len, nullptr, 0, path); + R_RETURN(ParseRelativeDotPath(out, out_len, nullptr, 0, path)); } static constexpr Result ParseRelativeDotPath(const char **out, size_t *out_len, char *out_relative, size_t out_relative_buffer_size, const char *path) { diff --git a/libraries/libstratosphere/include/stratosphere/fs/fs_read_only_filesystem.hpp b/libraries/libstratosphere/include/stratosphere/fs/fs_read_only_filesystem.hpp index f66ba0979..144ed0097 100644 --- a/libraries/libstratosphere/include/stratosphere/fs/fs_read_only_filesystem.hpp +++ b/libraries/libstratosphere/include/stratosphere/fs/fs_read_only_filesystem.hpp @@ -36,11 +36,11 @@ namespace ams::fs { virtual ~ReadOnlyFile() { /* ... */ } private: virtual Result DoRead(size_t *out, s64 offset, void *buffer, size_t size, const fs::ReadOption &option) override final { - return m_base_file->Read(out, offset, buffer, size, option); + R_RETURN(m_base_file->Read(out, offset, buffer, size, option)); } virtual Result DoGetSize(s64 *out) override final { - return m_base_file->GetSize(out); + R_RETURN(m_base_file->GetSize(out)); } virtual Result DoFlush() override final { @@ -66,7 +66,7 @@ namespace ams::fs { switch (op_id) { case OperationId::Invalidate: case OperationId::QueryRange: - return m_base_file->OperateRange(dst, dst_size, op_id, offset, size, src, src_size); + R_RETURN(m_base_file->OperateRange(dst, dst_size, op_id, offset, size, src, src_size)); default: R_THROW(fs::ResultUnsupportedOperateRangeForReadOnlyFile()); } @@ -104,11 +104,11 @@ namespace ams::fs { } virtual Result DoOpenDirectory(std::unique_ptr *out_dir, const fs::Path &path, OpenDirectoryMode mode) override final { - return m_base_fs->OpenDirectory(out_dir, path, mode); + R_RETURN(m_base_fs->OpenDirectory(out_dir, path, mode)); } virtual Result DoGetEntryType(DirectoryEntryType *out, const fs::Path &path) override final { - return m_base_fs->GetEntryType(out, path); + R_RETURN(m_base_fs->GetEntryType(out, path)); } virtual Result DoCommit() override final { diff --git a/libraries/libstratosphere/include/stratosphere/fs/fs_remote_filesystem.hpp b/libraries/libstratosphere/include/stratosphere/fs/fs_remote_filesystem.hpp index 1033e675e..9e6659929 100644 --- a/libraries/libstratosphere/include/stratosphere/fs/fs_remote_filesystem.hpp +++ b/libraries/libstratosphere/include/stratosphere/fs/fs_remote_filesystem.hpp @@ -35,23 +35,23 @@ namespace ams::fs { virtual ~RemoteFile() { fsFileClose(std::addressof(m_base_file)); } public: virtual Result DoRead(size_t *out, s64 offset, void *buffer, size_t size, const fs::ReadOption &option) override final { - return fsFileRead(std::addressof(m_base_file), offset, buffer, size, option._value, out); + R_RETURN(fsFileRead(std::addressof(m_base_file), offset, buffer, size, option._value, out)); } virtual Result DoGetSize(s64 *out) override final { - return fsFileGetSize(std::addressof(m_base_file), out); + R_RETURN(fsFileGetSize(std::addressof(m_base_file), out)); } virtual Result DoFlush() override final { - return fsFileFlush(std::addressof(m_base_file)); + R_RETURN(fsFileFlush(std::addressof(m_base_file))); } virtual Result DoWrite(s64 offset, const void *buffer, size_t size, const fs::WriteOption &option) override final { - return fsFileWrite(std::addressof(m_base_file), offset, buffer, size, option._value); + R_RETURN(fsFileWrite(std::addressof(m_base_file), offset, buffer, size, option._value)); } virtual Result DoSetSize(s64 size) override final { - return fsFileSetSize(std::addressof(m_base_file), size); + R_RETURN(fsFileSetSize(std::addressof(m_base_file), size)); } virtual Result DoOperateRange(void *dst, size_t dst_size, fs::OperationId op_id, s64 offset, s64 size, const void *src, size_t src_size) override final { @@ -60,7 +60,7 @@ namespace ams::fs { R_UNLESS(op_id == OperationId::QueryRange, fs::ResultUnsupportedOperateRangeForFileServiceObjectAdapter()); R_UNLESS(dst_size == sizeof(FileQueryRangeInfo), fs::ResultInvalidSize()); - return fsFileOperateRange(std::addressof(m_base_file), static_cast<::FsOperationId>(op_id), offset, size, reinterpret_cast<::FsRangeInfo *>(dst)); + R_RETURN(fsFileOperateRange(std::addressof(m_base_file), static_cast<::FsOperationId>(op_id), offset, size, reinterpret_cast<::FsRangeInfo *>(dst))); } public: virtual sf::cmif::DomainObjectId GetDomainObjectId() const override final { @@ -80,11 +80,11 @@ namespace ams::fs { public: virtual Result DoRead(s64 *out_count, DirectoryEntry *out_entries, s64 max_entries) override final { static_assert(sizeof(*out_entries) == sizeof(::FsDirectoryEntry)); - return fsDirRead(std::addressof(m_base_dir), out_count, max_entries, reinterpret_cast<::FsDirectoryEntry *>(out_entries)); + R_RETURN(fsDirRead(std::addressof(m_base_dir), out_count, max_entries, reinterpret_cast<::FsDirectoryEntry *>(out_entries))); } virtual Result DoGetEntryCount(s64 *out) override final { - return fsDirGetEntryCount(std::addressof(m_base_dir), out); + R_RETURN(fsDirGetEntryCount(std::addressof(m_base_dir), out)); } public: virtual sf::cmif::DomainObjectId GetDomainObjectId() const override final { @@ -119,31 +119,31 @@ namespace ams::fs { virtual Result DoCreateFile(const fs::Path &path, s64 size, int flags) override final { fssrv::sf::Path sf_path; R_TRY(GetPathForServiceObject(std::addressof(sf_path), path)); - return fsFsCreateFile(std::addressof(m_base_fs), sf_path.str, size, flags); + R_RETURN(fsFsCreateFile(std::addressof(m_base_fs), sf_path.str, size, flags)); } virtual Result DoDeleteFile(const fs::Path &path) override final { fssrv::sf::Path sf_path; R_TRY(GetPathForServiceObject(std::addressof(sf_path), path)); - return fsFsDeleteFile(std::addressof(m_base_fs), sf_path.str); + R_RETURN(fsFsDeleteFile(std::addressof(m_base_fs), sf_path.str)); } virtual Result DoCreateDirectory(const fs::Path &path) override final { fssrv::sf::Path sf_path; R_TRY(GetPathForServiceObject(std::addressof(sf_path), path)); - return fsFsCreateDirectory(std::addressof(m_base_fs), sf_path.str); + R_RETURN(fsFsCreateDirectory(std::addressof(m_base_fs), sf_path.str)); } virtual Result DoDeleteDirectory(const fs::Path &path) override final { fssrv::sf::Path sf_path; R_TRY(GetPathForServiceObject(std::addressof(sf_path), path)); - return fsFsDeleteDirectory(std::addressof(m_base_fs), sf_path.str); + R_RETURN(fsFsDeleteDirectory(std::addressof(m_base_fs), sf_path.str)); } virtual Result DoDeleteDirectoryRecursively(const fs::Path &path) override final { fssrv::sf::Path sf_path; R_TRY(GetPathForServiceObject(std::addressof(sf_path), path)); - return fsFsDeleteDirectoryRecursively(std::addressof(m_base_fs), sf_path.str); + R_RETURN(fsFsDeleteDirectoryRecursively(std::addressof(m_base_fs), sf_path.str)); } virtual Result DoRenameFile(const fs::Path &old_path, const fs::Path &new_path) override final { @@ -151,7 +151,7 @@ namespace ams::fs { fssrv::sf::Path new_sf_path; R_TRY(GetPathForServiceObject(std::addressof(old_sf_path), old_path)); R_TRY(GetPathForServiceObject(std::addressof(new_sf_path), new_path)); - return fsFsRenameFile(std::addressof(m_base_fs), old_sf_path.str, new_sf_path.str); + R_RETURN(fsFsRenameFile(std::addressof(m_base_fs), old_sf_path.str, new_sf_path.str)); } virtual Result DoRenameDirectory(const fs::Path &old_path, const fs::Path &new_path) override final { @@ -159,7 +159,7 @@ namespace ams::fs { fssrv::sf::Path new_sf_path; R_TRY(GetPathForServiceObject(std::addressof(old_sf_path), old_path)); R_TRY(GetPathForServiceObject(std::addressof(new_sf_path), new_path)); - return fsFsRenameDirectory(std::addressof(m_base_fs), old_sf_path.str, new_sf_path.str); + R_RETURN(fsFsRenameDirectory(std::addressof(m_base_fs), old_sf_path.str, new_sf_path.str)); } virtual Result DoGetEntryType(DirectoryEntryType *out, const fs::Path &path) override final { @@ -167,7 +167,7 @@ namespace ams::fs { R_TRY(GetPathForServiceObject(std::addressof(sf_path), path)); static_assert(sizeof(::FsDirEntryType) == sizeof(DirectoryEntryType)); - return fsFsGetEntryType(std::addressof(m_base_fs), sf_path.str, reinterpret_cast<::FsDirEntryType *>(out)); + R_RETURN(fsFsGetEntryType(std::addressof(m_base_fs), sf_path.str, reinterpret_cast<::FsDirEntryType *>(out))); } virtual Result DoOpenFile(std::unique_ptr *out_file, const fs::Path &path, OpenMode mode) override final { @@ -199,38 +199,38 @@ namespace ams::fs { } virtual Result DoCommit() override final { - return fsFsCommit(std::addressof(m_base_fs)); + R_RETURN(fsFsCommit(std::addressof(m_base_fs))); } virtual Result DoGetFreeSpaceSize(s64 *out, const fs::Path &path) override final { fssrv::sf::Path sf_path; R_TRY(GetPathForServiceObject(std::addressof(sf_path), path)); - return fsFsGetFreeSpace(std::addressof(m_base_fs), sf_path.str, out); + R_RETURN(fsFsGetFreeSpace(std::addressof(m_base_fs), sf_path.str, out)); } virtual Result DoGetTotalSpaceSize(s64 *out, const fs::Path &path) override final { fssrv::sf::Path sf_path; R_TRY(GetPathForServiceObject(std::addressof(sf_path), path)); - return fsFsGetTotalSpace(std::addressof(m_base_fs), sf_path.str, out); + R_RETURN(fsFsGetTotalSpace(std::addressof(m_base_fs), sf_path.str, out)); } virtual Result DoCleanDirectoryRecursively(const fs::Path &path) override final { fssrv::sf::Path sf_path; R_TRY(GetPathForServiceObject(std::addressof(sf_path), path)); - return fsFsCleanDirectoryRecursively(std::addressof(m_base_fs), sf_path.str); + R_RETURN(fsFsCleanDirectoryRecursively(std::addressof(m_base_fs), sf_path.str)); } virtual Result DoGetFileTimeStampRaw(FileTimeStampRaw *out, const fs::Path &path) override final { fssrv::sf::Path sf_path; R_TRY(GetPathForServiceObject(std::addressof(sf_path), path)); static_assert(sizeof(FileTimeStampRaw) == sizeof(::FsTimeStampRaw)); - return fsFsGetFileTimeStampRaw(std::addressof(m_base_fs), sf_path.str, reinterpret_cast<::FsTimeStampRaw *>(out)); + R_RETURN(fsFsGetFileTimeStampRaw(std::addressof(m_base_fs), sf_path.str, reinterpret_cast<::FsTimeStampRaw *>(out))); } virtual Result DoQueryEntry(char *dst, size_t dst_size, const char *src, size_t src_size, fsa::QueryId query, const fs::Path &path) override final { fssrv::sf::Path sf_path; R_TRY(GetPathForServiceObject(std::addressof(sf_path), path)); - return fsFsQueryEntry(std::addressof(m_base_fs), dst, dst_size, src, src_size, sf_path.str, static_cast(query)); + R_RETURN(fsFsQueryEntry(std::addressof(m_base_fs), dst, dst_size, src, src_size, sf_path.str, static_cast(query))); } }; #endif diff --git a/libraries/libstratosphere/include/stratosphere/fs/fs_remote_storage.hpp b/libraries/libstratosphere/include/stratosphere/fs/fs_remote_storage.hpp index a8de4d779..170281161 100644 --- a/libraries/libstratosphere/include/stratosphere/fs/fs_remote_storage.hpp +++ b/libraries/libstratosphere/include/stratosphere/fs/fs_remote_storage.hpp @@ -32,23 +32,23 @@ namespace ams::fs { virtual ~RemoteStorage() { fsStorageClose(std::addressof(m_base_storage)); } public: virtual Result Read(s64 offset, void *buffer, size_t size) override { - return fsStorageRead(std::addressof(m_base_storage), offset, buffer, size); + R_RETURN(fsStorageRead(std::addressof(m_base_storage), offset, buffer, size)); }; virtual Result Write(s64 offset, const void *buffer, size_t size) override { - return fsStorageWrite(std::addressof(m_base_storage), offset, buffer, size); + R_RETURN(fsStorageWrite(std::addressof(m_base_storage), offset, buffer, size)); }; virtual Result Flush() override { - return fsStorageFlush(std::addressof(m_base_storage)); + R_RETURN(fsStorageFlush(std::addressof(m_base_storage))); }; virtual Result GetSize(s64 *out_size) override { - return fsStorageGetSize(std::addressof(m_base_storage), out_size); + R_RETURN(fsStorageGetSize(std::addressof(m_base_storage), out_size)); }; virtual Result SetSize(s64 size) override { - return fsStorageSetSize(std::addressof(m_base_storage), size); + R_RETURN(fsStorageSetSize(std::addressof(m_base_storage), size)); }; virtual Result OperateRange(void *dst, size_t dst_size, OperationId op_id, s64 offset, s64 size, const void *src, size_t src_size) override { diff --git a/libraries/libstratosphere/include/stratosphere/fs/fs_substorage.hpp b/libraries/libstratosphere/include/stratosphere/fs/fs_substorage.hpp index 52959ed8d..7953040a9 100644 --- a/libraries/libstratosphere/include/stratosphere/fs/fs_substorage.hpp +++ b/libraries/libstratosphere/include/stratosphere/fs/fs_substorage.hpp @@ -84,7 +84,7 @@ namespace ams::fs { /* Validate arguments and read. */ R_UNLESS(buffer != nullptr, fs::ResultNullptrArgument()); R_TRY(IStorage::CheckAccessRange(offset, size, m_size)); - return m_base_storage->Read(m_offset + offset, buffer, size); + R_RETURN(m_base_storage->Read(m_offset + offset, buffer, size)); } virtual Result Write(s64 offset, const void *buffer, size_t size) override{ @@ -97,12 +97,12 @@ namespace ams::fs { /* Validate arguments and write. */ R_UNLESS(buffer != nullptr, fs::ResultNullptrArgument()); R_TRY(IStorage::CheckAccessRange(offset, size, m_size)); - return m_base_storage->Write(m_offset + offset, buffer, size); + R_RETURN(m_base_storage->Write(m_offset + offset, buffer, size)); } virtual Result Flush() override { R_UNLESS(this->IsValid(), fs::ResultNotInitialized()); - return m_base_storage->Flush(); + R_RETURN(m_base_storage->Flush()); } virtual Result SetSize(s64 size) override { diff --git a/libraries/libstratosphere/include/stratosphere/fssrv/interface_adapters/fssrv_filesystem_interface_adapter.hpp b/libraries/libstratosphere/include/stratosphere/fssrv/interface_adapters/fssrv_filesystem_interface_adapter.hpp index 9e849ca7f..6e05130bb 100644 --- a/libraries/libstratosphere/include/stratosphere/fssrv/interface_adapters/fssrv_filesystem_interface_adapter.hpp +++ b/libraries/libstratosphere/include/stratosphere/fssrv/interface_adapters/fssrv_filesystem_interface_adapter.hpp @@ -135,28 +135,28 @@ namespace ams::fssrv::impl { virtual ~RemoteFile() { fsFileClose(std::addressof(m_base_file)); } public: Result Read(ams::sf::Out out, s64 offset, const ams::sf::OutNonSecureBuffer &buffer, s64 size, fs::ReadOption option) { - return fsFileRead(std::addressof(m_base_file), offset, buffer.GetPointer(), size, option._value, reinterpret_cast(out.GetPointer())); + R_RETURN(fsFileRead(std::addressof(m_base_file), offset, buffer.GetPointer(), size, option._value, reinterpret_cast(out.GetPointer()))); } Result Write(s64 offset, const ams::sf::InNonSecureBuffer &buffer, s64 size, fs::WriteOption option) { - return fsFileWrite(std::addressof(m_base_file), offset, buffer.GetPointer(), size, option._value); + R_RETURN(fsFileWrite(std::addressof(m_base_file), offset, buffer.GetPointer(), size, option._value)); } Result Flush(){ - return fsFileFlush(std::addressof(m_base_file)); + R_RETURN(fsFileFlush(std::addressof(m_base_file))); } Result SetSize(s64 size) { - return fsFileSetSize(std::addressof(m_base_file), size); + R_RETURN(fsFileSetSize(std::addressof(m_base_file), size)); } Result GetSize(ams::sf::Out out) { - return fsFileGetSize(std::addressof(m_base_file), out.GetPointer()); + R_RETURN(fsFileGetSize(std::addressof(m_base_file), out.GetPointer())); } Result OperateRange(ams::sf::Out out, s32 op_id, s64 offset, s64 size) { static_assert(sizeof(::FsRangeInfo) == sizeof(fs::FileQueryRangeInfo)); - return fsFileOperateRange(std::addressof(m_base_file), static_cast<::FsOperationId>(op_id), offset, size, reinterpret_cast<::FsRangeInfo *>(out.GetPointer())); + R_RETURN(fsFileOperateRange(std::addressof(m_base_file), static_cast<::FsOperationId>(op_id), offset, size, reinterpret_cast<::FsRangeInfo *>(out.GetPointer()))); } Result OperateRangeWithBuffer(const ams::sf::OutNonSecureBuffer &out_buf, const ams::sf::InNonSecureBuffer &in_buf, s32 op_id, s64 offset, s64 size) { @@ -178,11 +178,11 @@ namespace ams::fssrv::impl { public: Result Read(ams::sf::Out out, const ams::sf::OutBuffer &out_entries) { static_assert(sizeof(::FsDirectoryEntry) == sizeof(fs::DirectoryEntry)); - return fsDirRead(std::addressof(m_base_dir), out.GetPointer(), out_entries.GetSize() / sizeof(fs::DirectoryEntry), reinterpret_cast<::FsDirectoryEntry *>(out_entries.GetPointer())); + R_RETURN(fsDirRead(std::addressof(m_base_dir), out.GetPointer(), out_entries.GetSize() / sizeof(fs::DirectoryEntry), reinterpret_cast<::FsDirectoryEntry *>(out_entries.GetPointer()))); } Result GetEntryCount(ams::sf::Out out) { - return fsDirGetEntryCount(std::addressof(m_base_dir), out.GetPointer()); + R_RETURN(fsDirGetEntryCount(std::addressof(m_base_dir), out.GetPointer())); } }; static_assert(fssrv::sf::IsIDirectory); @@ -199,61 +199,61 @@ namespace ams::fssrv::impl { public: /* Command API. */ Result CreateFile(const fssrv::sf::Path &path, s64 size, s32 option) { - return fsFsCreateFile(std::addressof(m_base_fs), path.str, size, option); + R_RETURN(fsFsCreateFile(std::addressof(m_base_fs), path.str, size, option)); } Result DeleteFile(const fssrv::sf::Path &path) { - return fsFsDeleteFile(std::addressof(m_base_fs), path.str); + R_RETURN(fsFsDeleteFile(std::addressof(m_base_fs), path.str)); } Result CreateDirectory(const fssrv::sf::Path &path) { - return fsFsCreateDirectory(std::addressof(m_base_fs), path.str); + R_RETURN(fsFsCreateDirectory(std::addressof(m_base_fs), path.str)); } Result DeleteDirectory(const fssrv::sf::Path &path) { - return fsFsDeleteDirectory(std::addressof(m_base_fs), path.str); + R_RETURN(fsFsDeleteDirectory(std::addressof(m_base_fs), path.str)); } Result DeleteDirectoryRecursively(const fssrv::sf::Path &path) { - return fsFsDeleteDirectoryRecursively(std::addressof(m_base_fs), path.str); + R_RETURN(fsFsDeleteDirectoryRecursively(std::addressof(m_base_fs), path.str)); } Result RenameFile(const fssrv::sf::Path &old_path, const fssrv::sf::Path &new_path) { - return fsFsRenameFile(std::addressof(m_base_fs), old_path.str, new_path.str); + R_RETURN(fsFsRenameFile(std::addressof(m_base_fs), old_path.str, new_path.str)); } Result RenameDirectory(const fssrv::sf::Path &old_path, const fssrv::sf::Path &new_path) { - return fsFsRenameDirectory(std::addressof(m_base_fs), old_path.str, new_path.str); + R_RETURN(fsFsRenameDirectory(std::addressof(m_base_fs), old_path.str, new_path.str)); } Result GetEntryType(ams::sf::Out out, const fssrv::sf::Path &path) { static_assert(sizeof(::FsDirEntryType) == sizeof(u32)); - return fsFsGetEntryType(std::addressof(m_base_fs), path.str, reinterpret_cast<::FsDirEntryType *>(out.GetPointer())); + R_RETURN(fsFsGetEntryType(std::addressof(m_base_fs), path.str, reinterpret_cast<::FsDirEntryType *>(out.GetPointer()))); } Result Commit() { - return fsFsCommit(std::addressof(m_base_fs)); + R_RETURN(fsFsCommit(std::addressof(m_base_fs))); } Result GetFreeSpaceSize(ams::sf::Out out, const fssrv::sf::Path &path) { - return fsFsGetFreeSpace(std::addressof(m_base_fs), path.str, out.GetPointer()); + R_RETURN(fsFsGetFreeSpace(std::addressof(m_base_fs), path.str, out.GetPointer())); } Result GetTotalSpaceSize(ams::sf::Out out, const fssrv::sf::Path &path) { - return fsFsGetTotalSpace(std::addressof(m_base_fs), path.str, out.GetPointer()); + R_RETURN(fsFsGetTotalSpace(std::addressof(m_base_fs), path.str, out.GetPointer())); } Result CleanDirectoryRecursively(const fssrv::sf::Path &path) { - return fsFsCleanDirectoryRecursively(std::addressof(m_base_fs), path.str); + R_RETURN(fsFsCleanDirectoryRecursively(std::addressof(m_base_fs), path.str)); } Result GetFileTimeStampRaw(ams::sf::Out out, const fssrv::sf::Path &path) { static_assert(sizeof(fs::FileTimeStampRaw) == sizeof(::FsTimeStampRaw)); - return fsFsGetFileTimeStampRaw(std::addressof(m_base_fs), path.str, reinterpret_cast<::FsTimeStampRaw *>(out.GetPointer())); + R_RETURN(fsFsGetFileTimeStampRaw(std::addressof(m_base_fs), path.str, reinterpret_cast<::FsTimeStampRaw *>(out.GetPointer()))); } Result QueryEntry(const ams::sf::OutBuffer &out_buf, const ams::sf::InBuffer &in_buf, s32 query_id, const fssrv::sf::Path &path) { - return fsFsQueryEntry(std::addressof(m_base_fs), out_buf.GetPointer(), out_buf.GetSize(), in_buf.GetPointer(), in_buf.GetSize(), path.str, static_cast(query_id)); + R_RETURN(fsFsQueryEntry(std::addressof(m_base_fs), out_buf.GetPointer(), out_buf.GetSize(), in_buf.GetPointer(), in_buf.GetSize(), path.str, static_cast(query_id))); } Result OpenFile(ams::sf::Out> out, const fssrv::sf::Path &path, u32 mode); diff --git a/libraries/libstratosphere/include/stratosphere/fssrv/interface_adapters/fssrv_storage_interface_adapter.hpp b/libraries/libstratosphere/include/stratosphere/fssrv/interface_adapters/fssrv_storage_interface_adapter.hpp index df0c3edf5..1c08fb513 100644 --- a/libraries/libstratosphere/include/stratosphere/fssrv/interface_adapters/fssrv_storage_interface_adapter.hpp +++ b/libraries/libstratosphere/include/stratosphere/fssrv/interface_adapters/fssrv_storage_interface_adapter.hpp @@ -57,28 +57,28 @@ namespace ams::fssrv::impl { virtual ~RemoteStorage() { fsStorageClose(std::addressof(m_base_storage)); } public: Result Read(s64 offset, const ams::sf::OutNonSecureBuffer &buffer, s64 size) { - return fsStorageRead(std::addressof(m_base_storage), offset, buffer.GetPointer(), size); + R_RETURN(fsStorageRead(std::addressof(m_base_storage), offset, buffer.GetPointer(), size)); } Result Write(s64 offset, const ams::sf::InNonSecureBuffer &buffer, s64 size) { - return fsStorageWrite(std::addressof(m_base_storage), offset, buffer.GetPointer(), size); + R_RETURN(fsStorageWrite(std::addressof(m_base_storage), offset, buffer.GetPointer(), size)); } Result Flush(){ - return fsStorageFlush(std::addressof(m_base_storage)); + R_RETURN(fsStorageFlush(std::addressof(m_base_storage))); } Result SetSize(s64 size) { - return fsStorageSetSize(std::addressof(m_base_storage), size); + R_RETURN(fsStorageSetSize(std::addressof(m_base_storage), size)); } Result GetSize(ams::sf::Out out) { - return fsStorageGetSize(std::addressof(m_base_storage), out.GetPointer()); + R_RETURN(fsStorageGetSize(std::addressof(m_base_storage), out.GetPointer())); } Result OperateRange(ams::sf::Out out, s32 op_id, s64 offset, s64 size) { static_assert(sizeof(::FsRangeInfo) == sizeof(fs::StorageQueryRangeInfo)); - return fsStorageOperateRange(std::addressof(m_base_storage), static_cast<::FsOperationId>(op_id), offset, size, reinterpret_cast<::FsRangeInfo *>(out.GetPointer())); + R_RETURN(fsStorageOperateRange(std::addressof(m_base_storage), static_cast<::FsOperationId>(op_id), offset, size, reinterpret_cast<::FsRangeInfo *>(out.GetPointer()))); } }; static_assert(fssrv::sf::IsIStorage); diff --git a/libraries/libstratosphere/include/stratosphere/fssystem/buffers/fssystem_file_system_buddy_heap.hpp b/libraries/libstratosphere/include/stratosphere/fssystem/buffers/fssystem_file_system_buddy_heap.hpp index ab014fef3..f1b6e5f2b 100644 --- a/libraries/libstratosphere/include/stratosphere/fssystem/buffers/fssystem_file_system_buddy_heap.hpp +++ b/libraries/libstratosphere/include/stratosphere/fssystem/buffers/fssystem_file_system_buddy_heap.hpp @@ -94,7 +94,7 @@ namespace ams::fssystem { Result Initialize(uintptr_t address, size_t size, size_t block_size, s32 order_max); Result Initialize(uintptr_t address, size_t size, size_t block_size) { - return this->Initialize(address, size, block_size, QueryOrderMax(size, block_size)); + R_RETURN(this->Initialize(address, size, block_size, QueryOrderMax(size, block_size))); } Result Initialize(uintptr_t address, size_t size, size_t block_size, s32 order_max, void *work, size_t work_size) { @@ -103,11 +103,11 @@ namespace ams::fssystem { const auto aligned_work = util::AlignUp(reinterpret_cast(work), alignof(PageList)); m_external_free_lists = reinterpret_cast(aligned_work); - return this->Initialize(address, size, block_size, order_max); + R_RETURN(this->Initialize(address, size, block_size, order_max)); } Result Initialize(uintptr_t address, size_t size, size_t block_size, void *work, size_t work_size) { - return this->Initialize(address, size, block_size, QueryOrderMax(size, block_size), work, work_size); + R_RETURN(this->Initialize(address, size, block_size, QueryOrderMax(size, block_size), work, work_size)); } void Finalize(); diff --git a/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_alignment_matching_storage.hpp b/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_alignment_matching_storage.hpp index 7f18beed8..236add1fb 100644 --- a/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_alignment_matching_storage.hpp +++ b/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_alignment_matching_storage.hpp @@ -64,7 +64,7 @@ namespace ams::fssystem { R_TRY(this->GetSize(std::addressof(bs_size))); R_TRY(fs::IStorage::CheckAccessRange(offset, size, bs_size)); - return AlignmentMatchingStorageImpl::Read(m_base_storage, work_buf, sizeof(work_buf), DataAlign, BufferAlign, offset, static_cast(buffer), size); + R_RETURN(AlignmentMatchingStorageImpl::Read(m_base_storage, work_buf, sizeof(work_buf), DataAlign, BufferAlign, offset, static_cast(buffer), size)); } virtual Result Write(s64 offset, const void *buffer, size_t size) override { @@ -82,16 +82,16 @@ namespace ams::fssystem { R_TRY(this->GetSize(std::addressof(bs_size))); R_TRY(fs::IStorage::CheckAccessRange(offset, size, bs_size)); - return AlignmentMatchingStorageImpl::Write(m_base_storage, work_buf, sizeof(work_buf), DataAlign, BufferAlign, offset, static_cast(buffer), size); + R_RETURN(AlignmentMatchingStorageImpl::Write(m_base_storage, work_buf, sizeof(work_buf), DataAlign, BufferAlign, offset, static_cast(buffer), size)); } virtual Result Flush() override { - return m_base_storage->Flush(); + R_RETURN(m_base_storage->Flush()); } virtual Result SetSize(s64 size) override { ON_SCOPE_EXIT { m_is_base_storage_size_dirty = true; }; - return m_base_storage->SetSize(util::AlignUp(size, DataAlign)); + R_RETURN(m_base_storage->SetSize(util::AlignUp(size, DataAlign))); } virtual Result GetSize(s64 *out) override { @@ -111,7 +111,7 @@ namespace ams::fssystem { virtual Result OperateRange(void *dst, size_t dst_size, fs::OperationId op_id, s64 offset, s64 size, const void *src, size_t src_size) override { if (op_id == fs::OperationId::Invalidate) { - return m_base_storage->OperateRange(fs::OperationId::Invalidate, offset, size); + R_RETURN(m_base_storage->OperateRange(fs::OperationId::Invalidate, offset, size)); } else { /* Succeed if zero size. */ R_SUCCEED_IF(size == 0); @@ -127,7 +127,7 @@ namespace ams::fssystem { const auto aligned_offset_end = util::AlignUp(offset + valid_size, DataAlign); const auto aligned_size = aligned_offset_end - aligned_offset; - return m_base_storage->OperateRange(dst, dst_size, op_id, aligned_offset, aligned_size, src, src_size); + R_RETURN(m_base_storage->OperateRange(dst, dst_size, op_id, aligned_offset, aligned_size, src, src_size)); } } }; @@ -166,7 +166,7 @@ namespace ams::fssystem { PooledBuffer pooled_buffer; pooled_buffer.AllocateParticularlyLarge(m_data_align, m_data_align); - return AlignmentMatchingStorageImpl::Read(m_base_storage, pooled_buffer.GetBuffer(), pooled_buffer.GetSize(), m_data_align, BufferAlign, offset, static_cast(buffer), size); + R_RETURN(AlignmentMatchingStorageImpl::Read(m_base_storage, pooled_buffer.GetBuffer(), pooled_buffer.GetSize(), m_data_align, BufferAlign, offset, static_cast(buffer), size)); } virtual Result Write(s64 offset, const void *buffer, size_t size) override { @@ -184,16 +184,16 @@ namespace ams::fssystem { PooledBuffer pooled_buffer; pooled_buffer.AllocateParticularlyLarge(m_data_align, m_data_align); - return AlignmentMatchingStorageImpl::Write(m_base_storage, pooled_buffer.GetBuffer(), pooled_buffer.GetSize(), m_data_align, BufferAlign, offset, static_cast(buffer), size); + R_RETURN(AlignmentMatchingStorageImpl::Write(m_base_storage, pooled_buffer.GetBuffer(), pooled_buffer.GetSize(), m_data_align, BufferAlign, offset, static_cast(buffer), size)); } virtual Result Flush() override { - return m_base_storage->Flush(); + R_RETURN(m_base_storage->Flush()); } virtual Result SetSize(s64 size) override { ON_SCOPE_EXIT { m_is_base_storage_size_dirty = true; }; - return m_base_storage->SetSize(util::AlignUp(size, m_data_align)); + R_RETURN(m_base_storage->SetSize(util::AlignUp(size, m_data_align))); } virtual Result GetSize(s64 *out) override { @@ -213,7 +213,7 @@ namespace ams::fssystem { virtual Result OperateRange(void *dst, size_t dst_size, fs::OperationId op_id, s64 offset, s64 size, const void *src, size_t src_size) override { if (op_id == fs::OperationId::Invalidate) { - return m_base_storage->OperateRange(fs::OperationId::Invalidate, offset, size); + R_RETURN(m_base_storage->OperateRange(fs::OperationId::Invalidate, offset, size)); } else { /* Succeed if zero size. */ R_SUCCEED_IF(size == 0); @@ -229,7 +229,7 @@ namespace ams::fssystem { const auto aligned_offset_end = util::AlignUp(offset + valid_size, m_data_align); const auto aligned_size = aligned_offset_end - aligned_offset; - return m_base_storage->OperateRange(dst, dst_size, op_id, aligned_offset, aligned_size, src, src_size); + R_RETURN(m_base_storage->OperateRange(dst, dst_size, op_id, aligned_offset, aligned_size, src, src_size)); } } }; @@ -272,16 +272,16 @@ namespace ams::fssystem { /* Allocate a pooled buffer. */ PooledBuffer pooled_buffer(m_data_align, m_data_align); - return AlignmentMatchingStorageImpl::Write(m_base_storage, pooled_buffer.GetBuffer(), pooled_buffer.GetSize(), m_data_align, BufferAlign, offset, static_cast(buffer), size); + R_RETURN(AlignmentMatchingStorageImpl::Write(m_base_storage, pooled_buffer.GetBuffer(), pooled_buffer.GetSize(), m_data_align, BufferAlign, offset, static_cast(buffer), size)); } virtual Result Flush() override { - return m_base_storage->Flush(); + R_RETURN(m_base_storage->Flush()); } virtual Result SetSize(s64 size) override { ON_SCOPE_EXIT { m_base_storage_size = -1; }; - return m_base_storage->SetSize(util::AlignUp(size, m_data_align)); + R_RETURN(m_base_storage->SetSize(util::AlignUp(size, m_data_align))); } virtual Result GetSize(s64 *out) override { @@ -300,7 +300,7 @@ namespace ams::fssystem { virtual Result OperateRange(void *dst, size_t dst_size, fs::OperationId op_id, s64 offset, s64 size, const void *src, size_t src_size) override { if (op_id == fs::OperationId::Invalidate) { - return m_base_storage->OperateRange(fs::OperationId::Invalidate, offset, size); + R_RETURN(m_base_storage->OperateRange(fs::OperationId::Invalidate, offset, size)); } else { /* Succeed if zero size. */ R_SUCCEED_IF(size == 0); @@ -316,7 +316,7 @@ namespace ams::fssystem { const auto aligned_offset_end = util::AlignUp(offset + valid_size, m_data_align); const auto aligned_size = aligned_offset_end - aligned_offset; - return m_base_storage->OperateRange(dst, dst_size, op_id, aligned_offset, aligned_size, src, src_size); + R_RETURN(m_base_storage->OperateRange(dst, dst_size, op_id, aligned_offset, aligned_size, src, src_size)); } } }; diff --git a/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_alignment_matching_storage_impl.hpp b/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_alignment_matching_storage_impl.hpp index 261b6df66..ace8966aa 100644 --- a/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_alignment_matching_storage_impl.hpp +++ b/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_alignment_matching_storage_impl.hpp @@ -26,11 +26,11 @@ namespace ams::fssystem { static Result Write(fs::IStorage *base_storage, char *work_buf, size_t work_buf_size, size_t data_alignment, size_t buffer_alignment, s64 offset, const char *buffer, size_t size); static Result Read(std::shared_ptr &base_storage, char *work_buf, size_t work_buf_size, size_t data_alignment, size_t buffer_alignment, s64 offset, char *buffer, size_t size) { - return Read(base_storage.get(), work_buf, work_buf_size, data_alignment, buffer_alignment, offset, buffer, size); + R_RETURN(Read(base_storage.get(), work_buf, work_buf_size, data_alignment, buffer_alignment, offset, buffer, size)); } static Result Write(std::shared_ptr &base_storage, char *work_buf, size_t work_buf_size, size_t data_alignment, size_t buffer_alignment, s64 offset, const char *buffer, size_t size) { - return Write(base_storage.get(), work_buf, work_buf_size, data_alignment, buffer_alignment, offset, buffer, size); + R_RETURN(Write(base_storage.get(), work_buf, work_buf_size, data_alignment, buffer_alignment, offset, buffer, size)); } }; diff --git a/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_bucket_tree_template_impl.hpp b/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_bucket_tree_template_impl.hpp index 646af2b49..3ae0bd73c 100644 --- a/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_bucket_tree_template_impl.hpp +++ b/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_bucket_tree_template_impl.hpp @@ -166,7 +166,7 @@ namespace ams::fssystem { std::memcpy(std::addressof(param.entry), m_entry, sizeof(EntryType)); /* Scan. */ - return m_tree->ScanContinuousReading(out_info, param); + R_RETURN(m_tree->ScanContinuousReading(out_info, param)); } } diff --git a/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_indirect_storage.hpp b/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_indirect_storage.hpp index 0934b030a..3c232293f 100644 --- a/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_indirect_storage.hpp +++ b/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_indirect_storage.hpp @@ -113,7 +113,7 @@ namespace ams::fssystem { bool IsInitialized() const { return m_table.IsInitialized(); } Result Initialize(IAllocator *allocator, fs::SubStorage node_storage, fs::SubStorage entry_storage, s32 entry_count) { - return m_table.Initialize(allocator, node_storage, entry_storage, NodeSize, sizeof(Entry), entry_count); + R_RETURN(m_table.Initialize(allocator, node_storage, entry_storage, NodeSize, sizeof(Entry), entry_count)); } void SetStorage(s32 idx, fs::SubStorage storage) { diff --git a/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_utility.hpp b/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_utility.hpp index 4a0b5507f..ac8ffb927 100644 --- a/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_utility.hpp +++ b/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_utility.hpp @@ -89,12 +89,12 @@ namespace ams::fssystem { template Result IterateDirectoryRecursively(fs::fsa::IFileSystem *fs, const fs::Path &root_path, OnEnterDir on_enter_dir, OnExitDir on_exit_dir, OnFile on_file) { fs::DirectoryEntry dir_entry = {}; - return IterateDirectoryRecursively(fs, root_path, std::addressof(dir_entry), on_enter_dir, on_exit_dir, on_file); + R_RETURN(IterateDirectoryRecursively(fs, root_path, std::addressof(dir_entry), on_enter_dir, on_exit_dir, on_file)); } template Result IterateDirectoryRecursively(fs::fsa::IFileSystem *fs, OnEnterDir on_enter_dir, OnExitDir on_exit_dir, OnFile on_file) { - return IterateDirectoryRecursively(fs, fs::MakeConstantPath("/"), on_enter_dir, on_exit_dir, on_file); + R_RETURN(IterateDirectoryRecursively(fs, fs::MakeConstantPath("/"), on_enter_dir, on_exit_dir, on_file)); } /* TODO: Cleanup API */ @@ -103,13 +103,13 @@ namespace ams::fssystem { Result CopyFile(fs::fsa::IFileSystem *dst_fs, fs::fsa::IFileSystem *src_fs, const fs::Path &dst_path, const fs::Path &src_path, void *work_buf, size_t work_buf_size); ALWAYS_INLINE Result CopyFile(fs::fsa::IFileSystem *fs, const fs::Path &dst_path, const fs::Path &src_path, void *work_buf, size_t work_buf_size) { - return CopyFile(fs, fs, dst_path, src_path, work_buf, work_buf_size); + R_RETURN(CopyFile(fs, fs, dst_path, src_path, work_buf, work_buf_size)); } Result CopyDirectoryRecursively(fs::fsa::IFileSystem *dst_fs, fs::fsa::IFileSystem *src_fs, const fs::Path &dst_path, const fs::Path &src_path, fs::DirectoryEntry *entry, void *work_buf, size_t work_buf_size); ALWAYS_INLINE Result CopyDirectoryRecursively(fs::fsa::IFileSystem *fs, const fs::Path &dst_path, const fs::Path &src_path, fs::DirectoryEntry *entry, void *work_buf, size_t work_buf_size) { - return CopyDirectoryRecursively(fs, fs, dst_path, src_path, entry, work_buf, work_buf_size); + R_RETURN(CopyDirectoryRecursively(fs, fs, dst_path, src_path, entry, work_buf, work_buf_size)); } /* Semaphore adapter class. */ @@ -147,7 +147,7 @@ namespace ams::fssystem { } ALWAYS_INLINE Result RetryToAvoidTargetLocked(auto f) { - return RetryFinitelyForTargetLocked<2, 25>(f); + R_RETURN((RetryFinitelyForTargetLocked<2, 25>(f))); } void AddCounter(void *counter, size_t counter_size, u64 value); diff --git a/libraries/libstratosphere/include/stratosphere/kvdb/kvdb_file_key_value_cache.hpp b/libraries/libstratosphere/include/stratosphere/kvdb/kvdb_file_key_value_cache.hpp index 2a95dbece..f0057b1cd 100644 --- a/libraries/libstratosphere/include/stratosphere/kvdb/kvdb_file_key_value_cache.hpp +++ b/libraries/libstratosphere/include/stratosphere/kvdb/kvdb_file_key_value_cache.hpp @@ -227,11 +227,11 @@ namespace ams::kvdb { } static Result DirectoryExists(bool *out, const char *path) { - return Exists(out, path, fs::DirectoryEntryType_Directory); + R_RETURN(Exists(out, path, fs::DirectoryEntryType_Directory)); } static Result FileExists(bool *out, const char *path) { - return Exists(out, path, fs::DirectoryEntryType_File); + R_RETURN(Exists(out, path, fs::DirectoryEntryType_File)); } public: static Result CreateNewCache(const char *dir) { @@ -298,18 +298,18 @@ namespace ams::kvdb { Result Get(size_t *out_size, void *out_value, size_t max_out_size, const Key &key) { /* Note that we accessed the key. */ m_lru_list.Update(key); - return m_kvs.Get(out_size, out_value, max_out_size, key); + R_RETURN(m_kvs.Get(out_size, out_value, max_out_size, key)); } template Result Get(Value *out_value, const Key &key) { /* Note that we accessed the key. */ m_lru_list.Update(key); - return m_kvs.Get(out_value, key); + R_RETURN(m_kvs.Get(out_value, key)); } Result GetSize(size_t *out_size, const Key &key) { - return m_kvs.GetSize(out_size, key); + R_RETURN(m_kvs.GetSize(out_size, key)); } Result Set(const Key &key, const void *value, size_t value_size) { @@ -356,7 +356,7 @@ namespace ams::kvdb { template Result Set(const Key &key, const Value &value) { - return this->Set(key, &value, sizeof(Value)); + R_RETURN(this->Set(key, &value, sizeof(Value))); } Result Remove(const Key &key) { diff --git a/libraries/libstratosphere/include/stratosphere/kvdb/kvdb_file_key_value_store.hpp b/libraries/libstratosphere/include/stratosphere/kvdb/kvdb_file_key_value_store.hpp index b5131a464..944c4b318 100644 --- a/libraries/libstratosphere/include/stratosphere/kvdb/kvdb_file_key_value_store.hpp +++ b/libraries/libstratosphere/include/stratosphere/kvdb/kvdb_file_key_value_store.hpp @@ -84,7 +84,7 @@ namespace ams::kvdb { template Result Get(size_t *out_size, void *out_value, size_t max_out_size, const Key &key) { static_assert(util::is_pod::value && sizeof(Key) <= MaxKeySize, "Invalid FileKeyValueStore Key!"); - return this->Get(out_size, out_value, max_out_size, std::addressof(key), sizeof(Key)); + R_RETURN(this->Get(out_size, out_value, max_out_size, std::addressof(key), sizeof(Key))); } template @@ -98,24 +98,24 @@ namespace ams::kvdb { template Result GetSize(size_t *out_size, const Key &key) { - return this->GetSize(out_size, std::addressof(key), sizeof(Key)); + R_RETURN(this->GetSize(out_size, std::addressof(key), sizeof(Key))); } template Result Set(const Key &key, const void *value, size_t value_size) { static_assert(util::is_pod::value && sizeof(Key) <= MaxKeySize, "Invalid FileKeyValueStore Key!"); - return this->Set(std::addressof(key), sizeof(Key), value, value_size); + R_RETURN(this->Set(std::addressof(key), sizeof(Key), value, value_size)); } template Result Set(const Key &key, const Value &value) { static_assert(util::is_pod::value && !std::is_pointer::value, "Invalid FileKeyValueStore Value!"); - return this->Set(key, std::addressof(value), sizeof(Value)); + R_RETURN(this->Set(key, std::addressof(value), sizeof(Value))); } template Result Remove(const Key &key) { - return this->Remove(std::addressof(key), sizeof(Key)); + R_RETURN(this->Remove(std::addressof(key), sizeof(Key))); } }; diff --git a/libraries/libstratosphere/include/stratosphere/kvdb/kvdb_memory_key_value_store.hpp b/libraries/libstratosphere/include/stratosphere/kvdb/kvdb_memory_key_value_store.hpp index 7d550cd6f..6cf380161 100644 --- a/libraries/libstratosphere/include/stratosphere/kvdb/kvdb_memory_key_value_store.hpp +++ b/libraries/libstratosphere/include/stratosphere/kvdb/kvdb_memory_key_value_store.hpp @@ -355,25 +355,25 @@ namespace ams::kvdb { } /* Save the buffer to disk. */ - return this->Commit(buffer, destructive); + R_RETURN(this->Commit(buffer, destructive)); } Result Set(const Key &key, const void *value, size_t value_size) { - return m_index.Set(key, value, value_size); + R_RETURN(m_index.Set(key, value, value_size)); } template Result Set(const Key &key, const Value &value) { /* Only allow setting pod. */ static_assert(util::is_pod::value, "KeyValueStore Values must be pod"); - return this->Set(key, std::addressof(value), sizeof(Value)); + R_RETURN(this->Set(key, std::addressof(value), sizeof(Value))); } template Result Set(const Key &key, const Value *value) { /* Only allow setting pod. */ static_assert(util::is_pod::value, "KeyValueStore Values must be pod"); - return this->Set(key, value, sizeof(Value)); + R_RETURN(this->Set(key, value, sizeof(Value))); } Result Get(size_t *out_size, void *out_value, size_t max_out_size, const Key &key) { @@ -427,7 +427,7 @@ namespace ams::kvdb { } Result Remove(const Key &key) { - return m_index.Remove(key); + R_RETURN(m_index.Remove(key)); } Entry *begin() { diff --git a/libraries/libstratosphere/include/stratosphere/lr/lr_add_on_content_location_resolver.hpp b/libraries/libstratosphere/include/stratosphere/lr/lr_add_on_content_location_resolver.hpp index 0e309c735..877b23176 100644 --- a/libraries/libstratosphere/include/stratosphere/lr/lr_add_on_content_location_resolver.hpp +++ b/libraries/libstratosphere/include/stratosphere/lr/lr_add_on_content_location_resolver.hpp @@ -44,31 +44,31 @@ namespace ams::lr { /* Actual commands. */ Result ResolveAddOnContentPath(Path *out, ncm::DataId id) { AMS_ASSERT(m_interface != nullptr); - return m_interface->ResolveAddOnContentPath(out, id); + R_RETURN(m_interface->ResolveAddOnContentPath(out, id)); } Result RegisterAddOnContentStorage(ncm::DataId id, ncm::ApplicationId application_id, ncm::StorageId storage_id) { AMS_ASSERT(m_interface != nullptr); if (hos::GetVersion() >= hos::Version_9_0_0) { - return m_interface->RegisterAddOnContentStorage(id, application_id, storage_id); + R_RETURN(m_interface->RegisterAddOnContentStorage(id, application_id, storage_id)); } else { - return m_interface->RegisterAddOnContentStorageDeprecated(id, storage_id); + R_RETURN(m_interface->RegisterAddOnContentStorageDeprecated(id, storage_id)); } } Result UnregisterAllAddOnContentPath() { AMS_ASSERT(m_interface != nullptr); - return m_interface->UnregisterAllAddOnContentPath(); + R_RETURN(m_interface->UnregisterAllAddOnContentPath()); } Result RefreshApplicationAddOnContent(const ncm::ApplicationId *ids, size_t num_ids) { AMS_ASSERT(m_interface != nullptr); - return m_interface->RefreshApplicationAddOnContent(sf::InArray(ids, num_ids)); + R_RETURN(m_interface->RefreshApplicationAddOnContent(sf::InArray(ids, num_ids))); } Result UnregisterApplicationAddOnContent(ncm::ApplicationId id) { AMS_ASSERT(m_interface != nullptr); - return m_interface->UnregisterApplicationAddOnContent(id); + R_RETURN(m_interface->UnregisterApplicationAddOnContent(id)); } }; diff --git a/libraries/libstratosphere/include/stratosphere/lr/lr_location_resolver.hpp b/libraries/libstratosphere/include/stratosphere/lr/lr_location_resolver.hpp index cc1b7f370..274d16ca8 100644 --- a/libraries/libstratosphere/include/stratosphere/lr/lr_location_resolver.hpp +++ b/libraries/libstratosphere/include/stratosphere/lr/lr_location_resolver.hpp @@ -43,7 +43,7 @@ namespace ams::lr { public: Result ResolveProgramPath(Path *out, ncm::ProgramId id) { AMS_ASSERT(m_interface != nullptr); - return m_interface->ResolveProgramPath(out, id); + R_RETURN(m_interface->ResolveProgramPath(out, id)); } void RedirectProgramPath(const Path &path, ncm::ProgramId id) { @@ -53,17 +53,17 @@ namespace ams::lr { Result ResolveApplicationControlPath(Path *out, ncm::ProgramId id) { AMS_ASSERT(m_interface != nullptr); - return m_interface->ResolveApplicationControlPath(out, id); + R_RETURN(m_interface->ResolveApplicationControlPath(out, id)); } Result ResolveApplicationHtmlDocumentPath(Path *out, ncm::ProgramId id) { AMS_ASSERT(m_interface != nullptr); - return m_interface->ResolveApplicationHtmlDocumentPath(out, id); + R_RETURN(m_interface->ResolveApplicationHtmlDocumentPath(out, id)); } Result ResolveDataPath(Path *out, ncm::DataId id) { AMS_ASSERT(m_interface != nullptr); - return m_interface->ResolveDataPath(out, id); + R_RETURN(m_interface->ResolveDataPath(out, id)); } void RedirectApplicationControlPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) { @@ -86,7 +86,7 @@ namespace ams::lr { Result ResolveApplicationLegalInformationPath(Path *out, ncm::ProgramId id) { AMS_ASSERT(m_interface != nullptr); - return m_interface->ResolveApplicationLegalInformationPath(out, id); + R_RETURN(m_interface->ResolveApplicationLegalInformationPath(out, id)); } void RedirectApplicationLegalInformationPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) { @@ -100,7 +100,7 @@ namespace ams::lr { Result Refresh() { AMS_ASSERT(m_interface != nullptr); - return m_interface->Refresh(); + R_RETURN(m_interface->Refresh()); } void RedirectApplicationProgramPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) { @@ -115,41 +115,41 @@ namespace ams::lr { Result ClearApplicationRedirection() { AMS_ASSERT(m_interface != nullptr); AMS_ASSERT(hos::GetVersion() < hos::Version_9_0_0); - return this->ClearApplicationRedirection(nullptr, 0); + R_RETURN(this->ClearApplicationRedirection(nullptr, 0)); } Result ClearApplicationRedirection(const ncm::ProgramId *excluding_ids, size_t num_ids) { AMS_ASSERT(m_interface != nullptr); if (hos::GetVersion() >= hos::Version_9_0_0) { - return m_interface->ClearApplicationRedirection(sf::InArray(excluding_ids, num_ids)); + R_RETURN(m_interface->ClearApplicationRedirection(sf::InArray(excluding_ids, num_ids))); } else { - return m_interface->ClearApplicationRedirectionDeprecated(); + R_RETURN(m_interface->ClearApplicationRedirectionDeprecated()); } } Result EraseProgramRedirection(ncm::ProgramId id) { AMS_ASSERT(m_interface != nullptr); - return m_interface->EraseProgramRedirection(id); + R_RETURN(m_interface->EraseProgramRedirection(id)); } Result EraseApplicationControlRedirection(ncm::ProgramId id) { AMS_ASSERT(m_interface != nullptr); - return m_interface->EraseApplicationControlRedirection(id); + R_RETURN(m_interface->EraseApplicationControlRedirection(id)); } Result EraseApplicationHtmlDocumentRedirection(ncm::ProgramId id) { AMS_ASSERT(m_interface != nullptr); - return m_interface->EraseApplicationHtmlDocumentRedirection(id); + R_RETURN(m_interface->EraseApplicationHtmlDocumentRedirection(id)); } Result EraseApplicationLegalInformationRedirection(ncm::ProgramId id) { AMS_ASSERT(m_interface != nullptr); - return m_interface->EraseApplicationLegalInformationRedirection(id); + R_RETURN(m_interface->EraseApplicationLegalInformationRedirection(id)); } Result ResolveProgramPathForDebug(Path *out, ncm::ProgramId id) { AMS_ASSERT(m_interface != nullptr); - return m_interface->ResolveProgramPathForDebug(out, id); + R_RETURN(m_interface->ResolveProgramPathForDebug(out, id)); } void RedirectProgramPathForDebug(const Path &path, ncm::ProgramId id) { @@ -168,7 +168,7 @@ namespace ams::lr { Result EraseProgramRedirectionForDebug(ncm::ProgramId id) { AMS_ASSERT(m_interface != nullptr); - return m_interface->EraseProgramRedirectionForDebug(id); + R_RETURN(m_interface->EraseProgramRedirectionForDebug(id)); } }; diff --git a/libraries/libstratosphere/include/stratosphere/lr/lr_registered_location_resolver.hpp b/libraries/libstratosphere/include/stratosphere/lr/lr_registered_location_resolver.hpp index 6ef018956..d33f0a489 100644 --- a/libraries/libstratosphere/include/stratosphere/lr/lr_registered_location_resolver.hpp +++ b/libraries/libstratosphere/include/stratosphere/lr/lr_registered_location_resolver.hpp @@ -44,21 +44,21 @@ namespace ams::lr { /* Actual commands. */ Result ResolveProgramPath(Path *out, ncm::ProgramId id) { AMS_ASSERT(m_interface != nullptr); - return m_interface->ResolveProgramPath(out, id); + R_RETURN(m_interface->ResolveProgramPath(out, id)); } Result RegisterProgramPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) { AMS_ASSERT(m_interface != nullptr); if (hos::GetVersion() >= hos::Version_9_0_0) { - return m_interface->RegisterProgramPath(path, id, owner_id); + R_RETURN(m_interface->RegisterProgramPath(path, id, owner_id)); } else { - return m_interface->RegisterProgramPathDeprecated(path, id); + R_RETURN(m_interface->RegisterProgramPathDeprecated(path, id)); } } Result UnregisterProgramPath(ncm::ProgramId id) { AMS_ASSERT(m_interface != nullptr); - return m_interface->UnregisterProgramPath(id); + R_RETURN(m_interface->UnregisterProgramPath(id)); } void RedirectProgramPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) { @@ -72,21 +72,21 @@ namespace ams::lr { Result ResolveHtmlDocumentPath(Path *out, ncm::ProgramId id) { AMS_ASSERT(m_interface != nullptr); - return m_interface->ResolveHtmlDocumentPath(out, id); + R_RETURN(m_interface->ResolveHtmlDocumentPath(out, id)); } Result RegisterHtmlDocumentPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) { AMS_ASSERT(m_interface != nullptr); if (hos::GetVersion() >= hos::Version_9_0_0) { - return m_interface->RegisterHtmlDocumentPath(path, id, owner_id); + R_RETURN(m_interface->RegisterHtmlDocumentPath(path, id, owner_id)); } else { - return m_interface->RegisterHtmlDocumentPathDeprecated(path, id); + R_RETURN(m_interface->RegisterHtmlDocumentPathDeprecated(path, id)); } } Result UnregisterHtmlDocumentPath(ncm::ProgramId id) { AMS_ASSERT(m_interface != nullptr); - return m_interface->UnregisterHtmlDocumentPath(id); + R_RETURN(m_interface->UnregisterHtmlDocumentPath(id)); } void RedirectHtmlDocumentPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) { @@ -100,12 +100,12 @@ namespace ams::lr { Result Refresh() { AMS_ASSERT(m_interface != nullptr); - return m_interface->Refresh(); + R_RETURN(m_interface->Refresh()); } Result RefreshExcluding(const ncm::ProgramId *excluding_ids, size_t num_ids) { AMS_ASSERT(m_interface != nullptr); - return m_interface->RefreshExcluding(sf::InArray(excluding_ids, num_ids)); + R_RETURN(m_interface->RefreshExcluding(sf::InArray(excluding_ids, num_ids))); } }; diff --git a/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_meta_database.hpp b/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_meta_database.hpp index c09e2c404..c4cef77df 100644 --- a/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_meta_database.hpp +++ b/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_meta_database.hpp @@ -46,7 +46,7 @@ namespace ams::ncm { public: Result Set(const ContentMetaKey &key, const void *buf, size_t size) { AMS_ASSERT(m_interface != nullptr); - return m_interface->Set(key, sf::InBuffer(buf, size)); + R_RETURN(m_interface->Set(key, sf::InBuffer(buf, size))); } Result Get(size_t *out_size, void *dst, size_t dst_size, const ContentMetaKey &key) { @@ -58,15 +58,15 @@ namespace ams::ncm { R_SUCCEED(); } - #define AMS_NCM_DEFINE_GETTERS(Kind, IdType) \ - Result Get##Kind(ContentId *out, IdType##Id id, u32 version) { \ - return m_interface->GetContentIdByType(out, ContentMetaKey::MakeUnknownType(id.value, version), ContentType::Kind); \ - } \ - \ - Result GetLatest##Kind(ContentId *out, IdType##Id id) { \ - ContentMetaKey latest_key; \ - R_TRY(m_interface->GetLatestContentMetaKey(std::addressof(latest_key), id.value)); \ - return m_interface->GetContentIdByType(out, latest_key, ContentType::Kind); \ + #define AMS_NCM_DEFINE_GETTERS(Kind, IdType) \ + Result Get##Kind(ContentId *out, IdType##Id id, u32 version) { \ + R_RETURN(m_interface->GetContentIdByType(out, ContentMetaKey::MakeUnknownType(id.value, version), ContentType::Kind)); \ + } \ + \ + Result GetLatest##Kind(ContentId *out, IdType##Id id) { \ + ContentMetaKey latest_key; \ + R_TRY(m_interface->GetLatestContentMetaKey(std::addressof(latest_key), id.value)); \ + R_RETURN(m_interface->GetContentIdByType(out, latest_key, ContentType::Kind)); \ } AMS_NCM_DEFINE_GETTERS(Program, Program) @@ -79,29 +79,29 @@ namespace ams::ncm { Result Remove(const ContentMetaKey &key) { AMS_ASSERT(m_interface != nullptr); - return m_interface->Remove(key); + R_RETURN(m_interface->Remove(key)); } Result Remove(SystemProgramId id, u32 version) { - return this->Remove(ContentMetaKey::Make(id, version)); + R_RETURN(this->Remove(ContentMetaKey::Make(id, version))); } Result Remove(SystemDataId id, u32 version) { - return this->Remove(ContentMetaKey::Make(id, version)); + R_RETURN(this->Remove(ContentMetaKey::Make(id, version))); } Result Remove(ApplicationId id, u32 version) { - return this->Remove(ContentMetaKey::Make(id, version)); + R_RETURN(this->Remove(ContentMetaKey::Make(id, version))); } Result GetContentIdByType(ContentId *out_content_id, const ContentMetaKey &key, ContentType type) { AMS_ASSERT(m_interface != nullptr); - return m_interface->GetContentIdByType(out_content_id, key, type); + R_RETURN(m_interface->GetContentIdByType(out_content_id, key, type)); } Result GetContentIdByTypeAndIdOffset(ContentId *out_content_id, const ContentMetaKey &key, ContentType type, u8 id_offset) { AMS_ASSERT(m_interface != nullptr); - return m_interface->GetContentIdByTypeAndIdOffset(out_content_id, key, type, id_offset); + R_RETURN(m_interface->GetContentIdByTypeAndIdOffset(out_content_id, key, type, id_offset)); } ListCount ListApplication(ApplicationContentMetaKey *dst, size_t dst_size) { @@ -118,32 +118,32 @@ namespace ams::ncm { Result GetLatest(ContentMetaKey *out_key, u64 id) { AMS_ASSERT(m_interface != nullptr); - return m_interface->GetLatestContentMetaKey(out_key, id); + R_RETURN(m_interface->GetLatestContentMetaKey(out_key, id)); } Result ListContentInfo(s32 *out_count, ContentInfo *dst, size_t dst_size, const ContentMetaKey &key, s32 offset) { AMS_ASSERT(m_interface != nullptr); - return m_interface->ListContentInfo(out_count, sf::OutArray(dst, dst_size), key, offset); + R_RETURN(m_interface->ListContentInfo(out_count, sf::OutArray(dst, dst_size), key, offset)); } Result ListContentMetaInfo(s32 *out_count, ContentMetaInfo *dst, size_t dst_size, const ContentMetaKey &key, s32 offset) { AMS_ASSERT(m_interface != nullptr); - return m_interface->ListContentMetaInfo(out_count, sf::OutArray(dst, dst_size), key, offset); + R_RETURN(m_interface->ListContentMetaInfo(out_count, sf::OutArray(dst, dst_size), key, offset)); } Result Has(bool *out, const ContentMetaKey &key) { AMS_ASSERT(m_interface != nullptr); - return m_interface->Has(out, key); + R_RETURN(m_interface->Has(out, key)); } Result HasAll(bool *out, const ContentMetaKey *keys, size_t num_keys) { AMS_ASSERT(m_interface != nullptr); - return m_interface->HasAll(out, sf::InArray(keys, num_keys)); + R_RETURN(m_interface->HasAll(out, sf::InArray(keys, num_keys))); } Result HasContent(bool *out, const ContentMetaKey &key, const ContentId &content_id) { AMS_ASSERT(m_interface != nullptr); - return m_interface->HasContent(out, key, content_id); + R_RETURN(m_interface->HasContent(out, key, content_id)); } Result GetSize(size_t *out_size, const ContentMetaKey &key) { @@ -157,37 +157,37 @@ namespace ams::ncm { Result GetRequiredSystemVersion(u32 *out_version, const ContentMetaKey &key) { AMS_ASSERT(m_interface != nullptr); - return m_interface->GetRequiredSystemVersion(out_version, key); + R_RETURN(m_interface->GetRequiredSystemVersion(out_version, key)); } Result GetPatchId(PatchId *out_patch_id, const ContentMetaKey &key) { AMS_ASSERT(m_interface != nullptr); - return m_interface->GetPatchId(out_patch_id, key); + R_RETURN(m_interface->GetPatchId(out_patch_id, key)); } Result DisableForcibly() { AMS_ASSERT(m_interface != nullptr); - return m_interface->DisableForcibly(); + R_RETURN(m_interface->DisableForcibly()); } Result LookupOrphanContent(bool *out_orphaned, ContentId *content_list, size_t count) { AMS_ASSERT(m_interface != nullptr); - return m_interface->LookupOrphanContent(sf::OutArray(out_orphaned, count), sf::InArray(content_list, count)); + R_RETURN(m_interface->LookupOrphanContent(sf::OutArray(out_orphaned, count), sf::InArray(content_list, count))); } Result Commit() { AMS_ASSERT(m_interface != nullptr); - return m_interface->Commit(); + R_RETURN(m_interface->Commit()); } Result GetAttributes(u8 *out_attributes, const ContentMetaKey &key) { AMS_ASSERT(m_interface != nullptr); - return m_interface->GetAttributes(out_attributes, key); + R_RETURN(m_interface->GetAttributes(out_attributes, key)); } Result GetRequiredApplicationVersion(u32 *out_version, const ContentMetaKey &key) { AMS_ASSERT(m_interface != nullptr); - return m_interface->GetRequiredApplicationVersion(out_version, key); + R_RETURN(m_interface->GetRequiredApplicationVersion(out_version, key)); } }; diff --git a/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_meta_extended_data.hpp b/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_meta_extended_data.hpp index 9c60a600f..f30de09de 100644 --- a/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_meta_extended_data.hpp +++ b/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_meta_extended_data.hpp @@ -520,8 +520,8 @@ namespace ams::ncm { public: using AccessorBase::AccessorBase; public: - Result GetHeader(ReadableStructPin *out) { return this->AcquireReadableStructPin(out, 0); } - Result GetHeader(PatchMetaExtendedDataHeader *out) { return this->template ReadStruct(out, 0); } + Result GetHeader(ReadableStructPin *out) { R_RETURN(this->AcquireReadableStructPin(out, 0)); } + Result GetHeader(PatchMetaExtendedDataHeader *out) { R_RETURN(this->template ReadStruct(out, 0)); } Result GetHistoryHeader(ReadableStructPin *out, s32 index) { /* Ensure we have our header. */ diff --git a/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_storage.hpp b/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_storage.hpp index 9adf42278..e236560d3 100644 --- a/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_storage.hpp +++ b/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_storage.hpp @@ -49,37 +49,37 @@ namespace ams::ncm { Result CreatePlaceHolder(PlaceHolderId placeholder_id, ContentId content_id, s64 size) { AMS_ASSERT(m_interface != nullptr); - return m_interface->CreatePlaceHolder(placeholder_id, content_id, size); + R_RETURN(m_interface->CreatePlaceHolder(placeholder_id, content_id, size)); } Result DeletePlaceHolder(PlaceHolderId placeholder_id) { AMS_ASSERT(m_interface != nullptr); - return m_interface->DeletePlaceHolder(placeholder_id); + R_RETURN(m_interface->DeletePlaceHolder(placeholder_id)); } Result HasPlaceHolder(bool *out, PlaceHolderId placeholder_id) { AMS_ASSERT(m_interface != nullptr); - return m_interface->HasPlaceHolder(out, placeholder_id); + R_RETURN(m_interface->HasPlaceHolder(out, placeholder_id)); } Result WritePlaceHolder(PlaceHolderId placeholder_id, s64 offset, const void *buf, size_t size) { AMS_ASSERT(m_interface != nullptr); - return m_interface->WritePlaceHolder(placeholder_id, offset, sf::InBuffer(buf, size)); + R_RETURN(m_interface->WritePlaceHolder(placeholder_id, offset, sf::InBuffer(buf, size))); } Result Register(PlaceHolderId placeholder_id, ContentId content_id) { AMS_ASSERT(m_interface != nullptr); - return m_interface->Register(placeholder_id, content_id); + R_RETURN(m_interface->Register(placeholder_id, content_id)); } Result Delete(ContentId content_id) { AMS_ASSERT(m_interface != nullptr); - return m_interface->Delete(content_id); + R_RETURN(m_interface->Delete(content_id)); } Result Has(bool *out, ContentId content_id) { AMS_ASSERT(m_interface != nullptr); - return m_interface->Has(out, content_id); + R_RETURN(m_interface->Has(out, content_id)); } void GetPath(Path *out, ContentId content_id) { @@ -94,52 +94,52 @@ namespace ams::ncm { Result CleanupAllPlaceHolder() { AMS_ASSERT(m_interface != nullptr); - return m_interface->CleanupAllPlaceHolder(); + R_RETURN(m_interface->CleanupAllPlaceHolder()); } Result ListPlaceHolder(s32 *out_count, PlaceHolderId *out_list, size_t out_list_size) { AMS_ASSERT(m_interface != nullptr); - return m_interface->ListPlaceHolder(out_count, sf::OutArray(out_list, out_list_size)); + R_RETURN(m_interface->ListPlaceHolder(out_count, sf::OutArray(out_list, out_list_size))); } Result GetContentCount(s32 *out_count) { AMS_ASSERT(m_interface != nullptr); - return m_interface->GetContentCount(out_count); + R_RETURN(m_interface->GetContentCount(out_count)); } Result ListContentId(s32 *out_count, ContentId *out_list, size_t out_list_size, s32 offset) { AMS_ASSERT(m_interface != nullptr); - return m_interface->ListContentId(out_count, sf::OutArray(out_list, out_list_size), offset); + R_RETURN(m_interface->ListContentId(out_count, sf::OutArray(out_list, out_list_size), offset)); } Result GetSize(s64 *out_size, ContentId content_id) { AMS_ASSERT(m_interface != nullptr); - return m_interface->GetSizeFromContentId(out_size, content_id); + R_RETURN(m_interface->GetSizeFromContentId(out_size, content_id)); } Result GetSize(s64 *out_size, PlaceHolderId placeholder_id) { AMS_ASSERT(m_interface != nullptr); - return m_interface->GetSizeFromPlaceHolderId(out_size, placeholder_id); + R_RETURN(m_interface->GetSizeFromPlaceHolderId(out_size, placeholder_id)); } Result DisableForcibly() { AMS_ASSERT(m_interface != nullptr); - return m_interface->DisableForcibly(); + R_RETURN(m_interface->DisableForcibly()); } Result RevertToPlaceHolder(PlaceHolderId placeholder_id, ContentId old_content_id, ContentId new_content_id) { AMS_ASSERT(m_interface != nullptr); - return m_interface->RevertToPlaceHolder(placeholder_id, old_content_id, new_content_id); + R_RETURN(m_interface->RevertToPlaceHolder(placeholder_id, old_content_id, new_content_id)); } Result SetPlaceHolderSize(PlaceHolderId placeholder_id, s64 size) { AMS_ASSERT(m_interface != nullptr); - return m_interface->SetPlaceHolderSize(placeholder_id, size); + R_RETURN(m_interface->SetPlaceHolderSize(placeholder_id, size)); } Result ReadContentIdFile(void *dst, size_t size, ContentId content_id, s64 offset) { AMS_ASSERT(m_interface != nullptr); - return m_interface->ReadContentIdFile(sf::OutBuffer(dst, size), content_id, offset); + R_RETURN(m_interface->ReadContentIdFile(sf::OutBuffer(dst, size), content_id, offset)); } Result GetRightsId(ncm::RightsId *out_rights_id, PlaceHolderId placeholder_id) { @@ -147,11 +147,11 @@ namespace ams::ncm { const auto vers = hos::GetVersion(); if (vers >= hos::Version_3_0_0) { - return m_interface->GetRightsIdFromPlaceHolderId(out_rights_id, placeholder_id); + R_RETURN(m_interface->GetRightsIdFromPlaceHolderId(out_rights_id, placeholder_id)); } else { AMS_ABORT_UNLESS(vers >= hos::Version_2_0_0); *out_rights_id = {}; - return m_interface->GetRightsIdFromPlaceHolderIdDeprecated(std::addressof(out_rights_id->id), placeholder_id); + R_RETURN(m_interface->GetRightsIdFromPlaceHolderIdDeprecated(std::addressof(out_rights_id->id), placeholder_id)); } } @@ -160,42 +160,42 @@ namespace ams::ncm { const auto vers = hos::GetVersion(); if (vers >= hos::Version_3_0_0) { - return m_interface->GetRightsIdFromContentId(out_rights_id, content_id); + R_RETURN(m_interface->GetRightsIdFromContentId(out_rights_id, content_id)); } else { AMS_ABORT_UNLESS(vers >= hos::Version_2_0_0); *out_rights_id = {}; - return m_interface->GetRightsIdFromContentIdDeprecated(std::addressof(out_rights_id->id), content_id); + R_RETURN(m_interface->GetRightsIdFromContentIdDeprecated(std::addressof(out_rights_id->id), content_id)); } } Result WriteContentForDebug(ContentId content_id, s64 offset, const void *buf, size_t size) { AMS_ASSERT(m_interface != nullptr); - return m_interface->WriteContentForDebug(content_id, offset, sf::InBuffer(buf, size)); + R_RETURN(m_interface->WriteContentForDebug(content_id, offset, sf::InBuffer(buf, size))); } Result GetFreeSpaceSize(s64 *out_size) { AMS_ASSERT(m_interface != nullptr); - return m_interface->GetFreeSpaceSize(out_size); + R_RETURN(m_interface->GetFreeSpaceSize(out_size)); } Result GetTotalSpaceSize(s64 *out_size) { AMS_ASSERT(m_interface != nullptr); - return m_interface->GetTotalSpaceSize(out_size); + R_RETURN(m_interface->GetTotalSpaceSize(out_size)); } Result FlushPlaceHolder() { AMS_ASSERT(m_interface != nullptr); - return m_interface->FlushPlaceHolder(); + R_RETURN(m_interface->FlushPlaceHolder()); } Result RepairInvalidFileAttribute() { AMS_ASSERT(m_interface != nullptr); - return m_interface->RepairInvalidFileAttribute(); + R_RETURN(m_interface->RepairInvalidFileAttribute()); } Result GetRightsIdFromPlaceHolderIdWithCache(ncm::RightsId *out_rights_id, PlaceHolderId placeholder_id, ContentId cache_content_id) { AMS_ASSERT(m_interface != nullptr); - return m_interface->GetRightsIdFromPlaceHolderIdWithCache(out_rights_id, placeholder_id, cache_content_id); + R_RETURN(m_interface->GetRightsIdFromPlaceHolderIdWithCache(out_rights_id, placeholder_id, cache_content_id)); } }; diff --git a/libraries/libstratosphere/include/stratosphere/ncm/ncm_install_task_base.hpp b/libraries/libstratosphere/include/stratosphere/ncm/ncm_install_task_base.hpp index df3e5b6ef..e84f9e380 100644 --- a/libraries/libstratosphere/include/stratosphere/ncm/ncm_install_task_base.hpp +++ b/libraries/libstratosphere/include/stratosphere/ncm/ncm_install_task_base.hpp @@ -99,7 +99,7 @@ namespace ams::ncm { if (R_FAILED(result)) { this->SetLastResult(result); } - return result; + R_RETURN(result); } public: InstallTaskBase() : m_data(), m_progress(), m_progress_mutex(), m_cancel_mutex(), m_cancel_requested(), m_throughput_mutex() { /* ... */ } @@ -113,12 +113,12 @@ namespace ams::ncm { Result CalculateRequiredSize(s64 *out_size); Result Cleanup(); Result ListContentMetaKey(s32 *out_keys_written, StorageContentMetaKey *out_keys, s32 out_keys_count, s32 offset, ListContentMetaKeyFilter filter); - Result ListContentMetaKey(s32 *out_keys_written, StorageContentMetaKey *out_keys, s32 out_keys_count, s32 offset) { return this->ListContentMetaKey(out_keys_written, out_keys, out_keys_count, offset, ListContentMetaKeyFilter::All); } + Result ListContentMetaKey(s32 *out_keys_written, StorageContentMetaKey *out_keys, s32 out_keys_count, s32 offset) { R_RETURN(this->ListContentMetaKey(out_keys_written, out_keys, out_keys_count, offset, ListContentMetaKeyFilter::All)); } Result ListApplicationContentMetaKey(s32 *out_keys_written, ApplicationContentMetaKey *out_keys, s32 out_keys_count, s32 offset); Result Execute(); Result PrepareAndExecute(); Result Commit(const StorageContentMetaKey *keys, s32 num_keys); - Result Commit() { return this->Commit(nullptr, 0); } + Result Commit() { R_RETURN(this->Commit(nullptr, 0)); } virtual InstallProgress GetProgress(); void ResetLastResult(); Result IncludesExFatDriver(bool *out); diff --git a/libraries/libstratosphere/include/stratosphere/os/os_io_region.hpp b/libraries/libstratosphere/include/stratosphere/os/os_io_region.hpp index 135e95814..f9ce90ce8 100644 --- a/libraries/libstratosphere/include/stratosphere/os/os_io_region.hpp +++ b/libraries/libstratosphere/include/stratosphere/os/os_io_region.hpp @@ -60,7 +60,7 @@ namespace ams::os { } Result Map(void **out, MemoryPermission perm) { - return MapIoRegion(out, std::addressof(m_io_region), perm); + R_RETURN(MapIoRegion(out, std::addressof(m_io_region), perm)); } void Unmap() { diff --git a/libraries/libstratosphere/include/stratosphere/os/os_transfer_memory.hpp b/libraries/libstratosphere/include/stratosphere/os/os_transfer_memory.hpp index d177a8145..b516e8fee 100644 --- a/libraries/libstratosphere/include/stratosphere/os/os_transfer_memory.hpp +++ b/libraries/libstratosphere/include/stratosphere/os/os_transfer_memory.hpp @@ -55,7 +55,7 @@ namespace ams::os { } Result Map(void **out, MemoryPermission owner_perm) { - return MapTransferMemory(out, std::addressof(m_tmem), owner_perm); + R_RETURN(MapTransferMemory(out, std::addressof(m_tmem), owner_perm)); } void Unmap() { diff --git a/libraries/libstratosphere/include/stratosphere/pgl/pgl_event_observer.hpp b/libraries/libstratosphere/include/stratosphere/pgl/pgl_event_observer.hpp index 9ac7ed2c8..2a9eff313 100644 --- a/libraries/libstratosphere/include/stratosphere/pgl/pgl_event_observer.hpp +++ b/libraries/libstratosphere/include/stratosphere/pgl/pgl_event_observer.hpp @@ -56,7 +56,7 @@ namespace ams::pgl { } virtual Result GetProcessEventInfo(pm::ProcessEventInfo *out) override { - return m_cmif_interface->GetProcessEventInfo(out); + R_RETURN(m_cmif_interface->GetProcessEventInfo(out)); } }; @@ -78,7 +78,7 @@ namespace ams::pgl { } virtual Result GetProcessEventInfo(pm::ProcessEventInfo *out) override { - return m_tipc_interface.GetProcessEventInfo(ams::tipc::Out(out)); + R_RETURN(m_tipc_interface.GetProcessEventInfo(ams::tipc::Out(out))); } }; @@ -113,11 +113,11 @@ namespace ams::pgl { } public: Result GetSystemEvent(os::SystemEventType *out) { - return m_impl->GetSystemEvent(out); + R_RETURN(m_impl->GetSystemEvent(out)); } Result GetProcessEventInfo(pm::ProcessEventInfo *out) { - return m_impl->GetProcessEventInfo(out); + R_RETURN(m_impl->GetProcessEventInfo(out)); } }; diff --git a/libraries/libstratosphere/include/stratosphere/scs/scs_shell.hpp b/libraries/libstratosphere/include/stratosphere/scs/scs_shell.hpp index b58cec7c5..7a6013530 100644 --- a/libraries/libstratosphere/include/stratosphere/scs/scs_shell.hpp +++ b/libraries/libstratosphere/include/stratosphere/scs/scs_shell.hpp @@ -32,7 +32,7 @@ namespace ams::scs { Result LaunchProgram(os::ProcessId *out, const ncm::ProgramLocation &loc, const void *args, size_t args_size, u32 process_flags); inline Result LaunchProgram(os::ProcessId *out, ncm::ProgramId program_id, const void *args, size_t args_size, u32 process_flags) { - return LaunchProgram(out, ncm::ProgramLocation::Make(program_id, ncm::StorageId::BuiltInSystem), args, args_size, process_flags); + R_RETURN(LaunchProgram(out, ncm::ProgramLocation::Make(program_id, ncm::StorageId::BuiltInSystem), args, args_size, process_flags)); } Result SubscribeProcessEvent(s32 socket, bool is_register, u64 id); diff --git a/libraries/libstratosphere/include/stratosphere/sf/cmif/sf_cmif_service_dispatch.hpp b/libraries/libstratosphere/include/stratosphere/sf/cmif/sf_cmif_service_dispatch.hpp index 2268f9470..b08e45dfb 100644 --- a/libraries/libstratosphere/include/stratosphere/sf/cmif/sf_cmif_service_dispatch.hpp +++ b/libraries/libstratosphere/include/stratosphere/sf/cmif/sf_cmif_service_dispatch.hpp @@ -95,13 +95,13 @@ namespace ams::sf::cmif { template Result ProcessMessage(ServiceDispatchContext &ctx, const cmif::PointerAndSize &in_raw_data) const { static_assert(std::is_base_of::value, "ServiceDispatchTableBase::Process"); - return static_cast(this)->ProcessMessage(ctx, in_raw_data); + R_RETURN(static_cast(this)->ProcessMessage(ctx, in_raw_data)); } template Result ProcessMessageForMitm(ServiceDispatchContext &ctx, const cmif::PointerAndSize &in_raw_data) const { static_assert(std::is_base_of::value, "ServiceDispatchTableBase::ProcessForMitm"); - return static_cast(this)->ProcessMessageForMitm(ctx, in_raw_data); + R_RETURN(static_cast(this)->ProcessMessageForMitm(ctx, in_raw_data)); } }; @@ -115,11 +115,11 @@ namespace ams::sf::cmif { explicit constexpr ServiceDispatchTableImpl(const std::array &e) : m_entries{e} { /* ... */ } Result ProcessMessage(ServiceDispatchContext &ctx, const cmif::PointerAndSize &in_raw_data) const { - return this->ProcessMessageImpl(ctx, in_raw_data, m_entries.data(), m_entries.size(), InterfaceIdForDebug); + R_RETURN(this->ProcessMessageImpl(ctx, in_raw_data, m_entries.data(), m_entries.size(), InterfaceIdForDebug)); } Result ProcessMessageForMitm(ServiceDispatchContext &ctx, const cmif::PointerAndSize &in_raw_data) const { - return this->ProcessMessageForMitmImpl(ctx, in_raw_data, m_entries.data(), m_entries.size(), InterfaceIdForDebug); + R_RETURN(this->ProcessMessageForMitmImpl(ctx, in_raw_data, m_entries.data(), m_entries.size(), InterfaceIdForDebug)); } constexpr const std::array &GetEntries() const { diff --git a/libraries/libstratosphere/include/stratosphere/sf/hipc/sf_hipc_server_manager.hpp b/libraries/libstratosphere/include/stratosphere/sf/hipc/sf_hipc_server_manager.hpp index 9c4e5293b..6103eddad 100644 --- a/libraries/libstratosphere/include/stratosphere/sf/hipc/sf_hipc_server_manager.hpp +++ b/libraries/libstratosphere/include/stratosphere/sf/hipc/sf_hipc_server_manager.hpp @@ -190,14 +190,14 @@ namespace ams::sf::hipc { template Result AcceptImpl(Server *server, SharedPointer p) { - return ServerSessionManager::AcceptSession(server->m_port_handle, std::move(p)); + R_RETURN(ServerSessionManager::AcceptSession(server->m_port_handle, std::move(p))); } #if AMS_SF_MITM_SUPPORTED template Result AcceptMitmImpl(Server *server, SharedPointer p, std::shared_ptr<::Service> forward_service) { AMS_ABORT_UNLESS(this->CanManageMitmServers()); - return ServerSessionManager::AcceptMitmSession(server->m_port_handle, std::move(p), std::move(forward_service)); + R_RETURN(ServerSessionManager::AcceptMitmSession(server->m_port_handle, std::move(p), std::move(forward_service))); } template @@ -269,7 +269,7 @@ namespace ams::sf::hipc { template Result RegisterObjectForServer(SharedPointer static_object, sm::ServiceName service_name, size_t max_sessions) { - return this->RegisterServerImpl(0, cmif::ServiceObjectHolder(std::move(static_object)), service_name, max_sessions); + R_RETURN(this->RegisterServerImpl(0, cmif::ServiceObjectHolder(std::move(static_object)), service_name, max_sessions)); } void RegisterServer(int port_index, os::NativeHandle port_handle) { @@ -277,7 +277,7 @@ namespace ams::sf::hipc { } Result RegisterServer(int port_index, sm::ServiceName service_name, size_t max_sessions) { - return this->RegisterServerImpl(port_index, cmif::ServiceObjectHolder(), service_name, max_sessions); + R_RETURN(this->RegisterServerImpl(port_index, cmif::ServiceObjectHolder(), service_name, max_sessions)); } /* Processing. */ @@ -503,7 +503,7 @@ namespace ams::sf::hipc { template::type> Result RegisterMitmServer(int port_index, sm::ServiceName service_name) { AMS_ABORT_UNLESS(this->CanManageMitmServers()); - return this->template RegisterMitmServerImpl(port_index, cmif::ServiceObjectHolder(), service_name); + R_RETURN(this->template RegisterMitmServerImpl(port_index, cmif::ServiceObjectHolder(), service_name)); } #endif }; diff --git a/libraries/libstratosphere/include/stratosphere/sf/hipc/sf_hipc_server_session_manager.hpp b/libraries/libstratosphere/include/stratosphere/sf/hipc/sf_hipc_server_session_manager.hpp index dc8a4c43c..f31c2eaf4 100644 --- a/libraries/libstratosphere/include/stratosphere/sf/hipc/sf_hipc_server_session_manager.hpp +++ b/libraries/libstratosphere/include/stratosphere/sf/hipc/sf_hipc_server_session_manager.hpp @@ -140,36 +140,36 @@ namespace ams::sf::hipc { #endif Result ReceiveRequest(ServerSession *session, const cmif::PointerAndSize &message) { - return this->ReceiveRequestImpl(session, message); + R_RETURN(this->ReceiveRequestImpl(session, message)); } Result RegisterSession(ServerSession **out, os::NativeHandle session_handle, cmif::ServiceObjectHolder &&obj) { auto ctor = [&](ServerSession *session_memory) -> Result { - return this->RegisterSessionImpl(session_memory, session_handle, std::forward(obj)); + R_RETURN(this->RegisterSessionImpl(session_memory, session_handle, std::forward(obj))); }; - return this->CreateSessionImpl(out, ctor); + R_RETURN(this->CreateSessionImpl(out, ctor)); } Result AcceptSession(ServerSession **out, os::NativeHandle port_handle, cmif::ServiceObjectHolder &&obj) { auto ctor = [&](ServerSession *session_memory) -> Result { - return this->AcceptSessionImpl(session_memory, port_handle, std::forward(obj)); + R_RETURN(this->AcceptSessionImpl(session_memory, port_handle, std::forward(obj))); }; - return this->CreateSessionImpl(out, ctor); + R_RETURN(this->CreateSessionImpl(out, ctor)); } #if AMS_SF_MITM_SUPPORTED Result RegisterMitmSession(ServerSession **out, os::NativeHandle mitm_session_handle, cmif::ServiceObjectHolder &&obj, std::shared_ptr<::Service> &&fsrv) { auto ctor = [&](ServerSession *session_memory) -> Result { - return this->RegisterMitmSessionImpl(session_memory, mitm_session_handle, std::forward(obj), std::forward>(fsrv)); + R_RETURN(this->RegisterMitmSessionImpl(session_memory, mitm_session_handle, std::forward(obj), std::forward>(fsrv))); }; - return this->CreateSessionImpl(out, ctor); + R_RETURN(this->CreateSessionImpl(out, ctor)); } Result AcceptMitmSession(ServerSession **out, os::NativeHandle mitm_port_handle, cmif::ServiceObjectHolder &&obj, std::shared_ptr<::Service> &&fsrv) { auto ctor = [&](ServerSession *session_memory) -> Result { - return this->AcceptMitmSessionImpl(session_memory, mitm_port_handle, std::forward(obj), std::forward>(fsrv)); + R_RETURN(this->AcceptMitmSessionImpl(session_memory, mitm_port_handle, std::forward(obj), std::forward>(fsrv))); }; - return this->CreateSessionImpl(out, ctor); + R_RETURN(this->CreateSessionImpl(out, ctor)); } #endif public: @@ -183,13 +183,13 @@ namespace ams::sf::hipc { template Result AcceptSession(os::NativeHandle port_handle, SharedPointer obj) { - return this->AcceptSession(port_handle, cmif::ServiceObjectHolder(std::move(obj))); + R_RETURN(this->AcceptSession(port_handle, cmif::ServiceObjectHolder(std::move(obj)))); } #if AMS_SF_MITM_SUPPORTED template Result AcceptMitmSession(os::NativeHandle mitm_port_handle, SharedPointer obj, std::shared_ptr<::Service> &&fsrv) { - return this->AcceptMitmSession(mitm_port_handle, cmif::ServiceObjectHolder(std::move(obj)), std::forward>(fsrv)); + R_RETURN(this->AcceptMitmSession(mitm_port_handle, cmif::ServiceObjectHolder(std::move(obj)), std::forward>(fsrv))); } #endif diff --git a/libraries/libstratosphere/include/stratosphere/sf/impl/sf_impl_command_serialization.hpp b/libraries/libstratosphere/include/stratosphere/sf/impl/sf_impl_command_serialization.hpp index d5e7c5308..83024df40 100644 --- a/libraries/libstratosphere/include/stratosphere/sf/impl/sf_impl_command_serialization.hpp +++ b/libraries/libstratosphere/include/stratosphere/sf/impl/sf_impl_command_serialization.hpp @@ -1197,7 +1197,7 @@ namespace ams::sf::impl { sf::IServiceObject * const this_ptr = ctx.srv_obj; command_result = [this_ptr, invoke_impl, &args_tuple](std::index_sequence) ALWAYS_INLINE_LAMBDA { - return invoke_impl(this_ptr, std::forward::type>(std::get(args_tuple))...); + R_RETURN(invoke_impl(this_ptr, std::forward::type>(std::get(args_tuple))...)); }(std::make_index_sequence::value>()); } @@ -1205,7 +1205,7 @@ namespace ams::sf::impl { cmif::PointerAndSize out_raw_data; ctx.processor->PrepareForErrorReply(ctx, out_raw_data, runtime_metadata); R_TRY(GetCmifOutHeaderPointer(out_header_ptr, out_raw_data)); - return command_result; + R_RETURN(command_result); } } @@ -1254,14 +1254,14 @@ namespace ams::sf::impl { constexpr bool ReturnsVoid = std::is_same::value; static_assert(ReturnsResult || ReturnsVoid, "Service Commands must return Result or void."); - return InvokeServiceCommandImplCommon(out_header_ptr, ctx, in_raw_data, +[](sf::IServiceObject *srv_obj, Arguments &&... args) -> Result { + R_RETURN((InvokeServiceCommandImplCommon(out_header_ptr, ctx, in_raw_data, +[](sf::IServiceObject *srv_obj, Arguments &&... args) -> Result { if constexpr (ReturnsResult) { - return (static_cast(srv_obj)->*ServiceCommandImpl)(std::forward(args)...); + R_RETURN((static_cast(srv_obj)->*ServiceCommandImpl)(std::forward(args)...)); } else { (static_cast(srv_obj)->*ServiceCommandImpl)(std::forward(args)...); R_SUCCEED(); } - }); + }))); } } diff --git a/libraries/libstratosphere/include/stratosphere/spl/spl_types.hpp b/libraries/libstratosphere/include/stratosphere/spl/spl_types.hpp index f49638625..08444261d 100644 --- a/libraries/libstratosphere/include/stratosphere/spl/spl_types.hpp +++ b/libraries/libstratosphere/include/stratosphere/spl/spl_types.hpp @@ -72,7 +72,7 @@ namespace ams::spl { R_UNLESS(spl::ResultSecureMonitorError::Includes(converted), spl::ResultUnexpectedSecureMonitorResult()); /* Return the error. */ - return converted; + R_RETURN(converted); } enum class CipherMode { diff --git a/libraries/libstratosphere/include/stratosphere/svc/svc_stratosphere_shims.hpp b/libraries/libstratosphere/include/stratosphere/svc/svc_stratosphere_shims.hpp index 1ffb3cda6..4850b0292 100644 --- a/libraries/libstratosphere/include/stratosphere/svc/svc_stratosphere_shims.hpp +++ b/libraries/libstratosphere/include/stratosphere/svc/svc_stratosphere_shims.hpp @@ -23,32 +23,32 @@ namespace aarch64::lp64 { ALWAYS_INLINE Result SetHeapSize(::ams::svc::Address *out_address, ::ams::svc::Size size) { - return ::svcSetHeapSize(reinterpret_cast(out_address), size); + R_RETURN(::svcSetHeapSize(reinterpret_cast(out_address), size)); } ALWAYS_INLINE Result SetHeapSize(uintptr_t *out_address, ::ams::svc::Size size) { static_assert(sizeof(::ams::svc::Address) == sizeof(uintptr_t)); - return ::svcSetHeapSize(reinterpret_cast(out_address), size); + R_RETURN(::svcSetHeapSize(reinterpret_cast(out_address), size)); } ALWAYS_INLINE Result SetMemoryPermission(::ams::svc::Address address, ::ams::svc::Size size, ::ams::svc::MemoryPermission perm) { - return ::svcSetMemoryPermission(reinterpret_cast(static_cast(address)), size, static_cast(perm)); + R_RETURN(::svcSetMemoryPermission(reinterpret_cast(static_cast(address)), size, static_cast(perm))); } ALWAYS_INLINE Result SetMemoryAttribute(::ams::svc::Address address, ::ams::svc::Size size, uint32_t mask, uint32_t attr) { - return ::svcSetMemoryAttribute(reinterpret_cast(static_cast(address)), size, mask, attr); + R_RETURN(::svcSetMemoryAttribute(reinterpret_cast(static_cast(address)), size, mask, attr)); } ALWAYS_INLINE Result MapMemory(::ams::svc::Address dst_address, ::ams::svc::Address src_address, ::ams::svc::Size size) { - return ::svcMapMemory(reinterpret_cast(static_cast(dst_address)), reinterpret_cast(static_cast(src_address)), size); + R_RETURN(::svcMapMemory(reinterpret_cast(static_cast(dst_address)), reinterpret_cast(static_cast(src_address)), size)); } ALWAYS_INLINE Result UnmapMemory(::ams::svc::Address dst_address, ::ams::svc::Address src_address, ::ams::svc::Size size) { - return ::svcUnmapMemory(reinterpret_cast(static_cast(dst_address)), reinterpret_cast(static_cast(src_address)), size); + R_RETURN(::svcUnmapMemory(reinterpret_cast(static_cast(dst_address)), reinterpret_cast(static_cast(src_address)), size)); } ALWAYS_INLINE Result QueryMemory(::ams::svc::UserPointer< ::ams::svc::lp64::MemoryInfo *> out_memory_info, ::ams::svc::PageInfo *out_page_info, ::ams::svc::Address address) { - return ::svcQueryMemory(reinterpret_cast<::MemoryInfo *>(out_memory_info.GetPointerUnsafe()), reinterpret_cast(out_page_info), address); + R_RETURN(::svcQueryMemory(reinterpret_cast<::MemoryInfo *>(out_memory_info.GetPointerUnsafe()), reinterpret_cast(out_page_info), address)); } ALWAYS_INLINE void ExitProcess() { @@ -56,11 +56,11 @@ } ALWAYS_INLINE Result CreateThread(::ams::svc::Handle *out_handle, ::ams::svc::ThreadFunc func, ::ams::svc::Address arg, ::ams::svc::Address stack_bottom, int32_t priority, int32_t core_id) { - return ::svcCreateThread(out_handle, reinterpret_cast(static_cast(func)), reinterpret_cast(static_cast(arg)), reinterpret_cast(static_cast(stack_bottom)), priority, core_id); + R_RETURN(::svcCreateThread(out_handle, reinterpret_cast(static_cast(func)), reinterpret_cast(static_cast(arg)), reinterpret_cast(static_cast(stack_bottom)), priority, core_id)); } ALWAYS_INLINE Result StartThread(::ams::svc::Handle thread_handle) { - return ::svcStartThread(thread_handle); + R_RETURN(::svcStartThread(thread_handle)); } ALWAYS_INLINE void ExitThread() { @@ -72,19 +72,19 @@ } ALWAYS_INLINE Result GetThreadPriority(int32_t *out_priority, ::ams::svc::Handle thread_handle) { - return ::svcGetThreadPriority(out_priority, thread_handle); + R_RETURN(::svcGetThreadPriority(out_priority, thread_handle)); } ALWAYS_INLINE Result SetThreadPriority(::ams::svc::Handle thread_handle, int32_t priority) { - return ::svcSetThreadPriority(thread_handle, priority); + R_RETURN(::svcSetThreadPriority(thread_handle, priority)); } ALWAYS_INLINE Result GetThreadCoreMask(int32_t *out_core_id, uint64_t *out_affinity_mask, ::ams::svc::Handle thread_handle) { - return ::svcGetThreadCoreMask(out_core_id, out_affinity_mask, thread_handle); + R_RETURN(::svcGetThreadCoreMask(out_core_id, out_affinity_mask, thread_handle)); } ALWAYS_INLINE Result SetThreadCoreMask(::ams::svc::Handle thread_handle, int32_t core_id, uint64_t affinity_mask) { - return ::svcSetThreadCoreMask(thread_handle, core_id, affinity_mask); + R_RETURN(::svcSetThreadCoreMask(thread_handle, core_id, affinity_mask)); } ALWAYS_INLINE int32_t GetCurrentProcessorNumber() { @@ -92,51 +92,51 @@ } ALWAYS_INLINE Result SignalEvent(::ams::svc::Handle event_handle) { - return ::svcSignalEvent(event_handle); + R_RETURN(::svcSignalEvent(event_handle)); } ALWAYS_INLINE Result ClearEvent(::ams::svc::Handle event_handle) { - return ::svcClearEvent(event_handle); + R_RETURN(::svcClearEvent(event_handle)); } ALWAYS_INLINE Result MapSharedMemory(::ams::svc::Handle shmem_handle, ::ams::svc::Address address, ::ams::svc::Size size, ::ams::svc::MemoryPermission map_perm) { - return ::svcMapSharedMemory(shmem_handle, reinterpret_cast(static_cast(address)), size, static_cast(map_perm)); + R_RETURN(::svcMapSharedMemory(shmem_handle, reinterpret_cast(static_cast(address)), size, static_cast(map_perm))); } ALWAYS_INLINE Result UnmapSharedMemory(::ams::svc::Handle shmem_handle, ::ams::svc::Address address, ::ams::svc::Size size) { - return ::svcUnmapSharedMemory(shmem_handle, reinterpret_cast(static_cast(address)), size); + R_RETURN(::svcUnmapSharedMemory(shmem_handle, reinterpret_cast(static_cast(address)), size)); } ALWAYS_INLINE Result CreateTransferMemory(::ams::svc::Handle *out_handle, ::ams::svc::Address address, ::ams::svc::Size size, ::ams::svc::MemoryPermission map_perm) { - return ::svcCreateTransferMemory(out_handle, reinterpret_cast(static_cast(address)), size, static_cast(map_perm)); + R_RETURN(::svcCreateTransferMemory(out_handle, reinterpret_cast(static_cast(address)), size, static_cast(map_perm))); } ALWAYS_INLINE Result CloseHandle(::ams::svc::Handle handle) { - return ::svcCloseHandle(handle); + R_RETURN(::svcCloseHandle(handle)); } ALWAYS_INLINE Result ResetSignal(::ams::svc::Handle handle) { - return ::svcResetSignal(handle); + R_RETURN(::svcResetSignal(handle)); } ALWAYS_INLINE Result WaitSynchronization(int32_t *out_index, ::ams::svc::UserPointer handles, int32_t num_handles, int64_t timeout_ns) { - return ::svcWaitSynchronization(out_index, handles.GetPointerUnsafe(), num_handles, timeout_ns); + R_RETURN(::svcWaitSynchronization(out_index, handles.GetPointerUnsafe(), num_handles, timeout_ns)); } ALWAYS_INLINE Result CancelSynchronization(::ams::svc::Handle handle) { - return ::svcCancelSynchronization(handle); + R_RETURN(::svcCancelSynchronization(handle)); } ALWAYS_INLINE Result ArbitrateLock(::ams::svc::Handle thread_handle, ::ams::svc::Address address, uint32_t tag) { - return ::svcArbitrateLock(thread_handle, reinterpret_cast(static_cast(address)), tag); + R_RETURN(::svcArbitrateLock(thread_handle, reinterpret_cast(static_cast(address)), tag)); } ALWAYS_INLINE Result ArbitrateUnlock(::ams::svc::Address address) { - return ::svcArbitrateUnlock(reinterpret_cast(static_cast(address))); + R_RETURN(::svcArbitrateUnlock(reinterpret_cast(static_cast(address)))); } ALWAYS_INLINE Result WaitProcessWideKeyAtomic(::ams::svc::Address address, ::ams::svc::Address cv_key, uint32_t tag, int64_t timeout_ns) { - return ::svcWaitProcessWideKeyAtomic(reinterpret_cast(static_cast(address)), reinterpret_cast(static_cast(cv_key)), tag, timeout_ns); + R_RETURN(::svcWaitProcessWideKeyAtomic(reinterpret_cast(static_cast(address)), reinterpret_cast(static_cast(cv_key)), tag, timeout_ns)); } ALWAYS_INLINE void SignalProcessWideKey(::ams::svc::Address cv_key, int32_t count) { @@ -148,31 +148,31 @@ } ALWAYS_INLINE Result ConnectToNamedPort(::ams::svc::Handle *out_handle, ::ams::svc::UserPointer name) { - return ::svcConnectToNamedPort(out_handle, name.GetPointerUnsafe()); + R_RETURN(::svcConnectToNamedPort(out_handle, name.GetPointerUnsafe())); } ALWAYS_INLINE Result SendSyncRequestLight(::ams::svc::Handle session_handle) { - return ::svcSendSyncRequestLight(session_handle); + R_RETURN(::svcSendSyncRequestLight(session_handle)); } ALWAYS_INLINE Result SendSyncRequest(::ams::svc::Handle session_handle) { - return ::svcSendSyncRequest(session_handle); + R_RETURN(::svcSendSyncRequest(session_handle)); } ALWAYS_INLINE Result SendSyncRequestWithUserBuffer(::ams::svc::Address message_buffer, ::ams::svc::Size message_buffer_size, ::ams::svc::Handle session_handle) { - return ::svcSendSyncRequestWithUserBuffer(reinterpret_cast(static_cast(message_buffer)), message_buffer_size, session_handle); + R_RETURN(::svcSendSyncRequestWithUserBuffer(reinterpret_cast(static_cast(message_buffer)), message_buffer_size, session_handle)); } ALWAYS_INLINE Result SendAsyncRequestWithUserBuffer(::ams::svc::Handle *out_event_handle, ::ams::svc::Address message_buffer, ::ams::svc::Size message_buffer_size, ::ams::svc::Handle session_handle) { - return ::svcSendAsyncRequestWithUserBuffer(out_event_handle, reinterpret_cast(static_cast(message_buffer)), message_buffer_size, session_handle); + R_RETURN(::svcSendAsyncRequestWithUserBuffer(out_event_handle, reinterpret_cast(static_cast(message_buffer)), message_buffer_size, session_handle)); } ALWAYS_INLINE Result GetProcessId(uint64_t *out_process_id, ::ams::svc::Handle process_handle) { - return ::svcGetProcessId(out_process_id, process_handle); + R_RETURN(::svcGetProcessId(out_process_id, process_handle)); } ALWAYS_INLINE Result GetThreadId(uint64_t *out_thread_id, ::ams::svc::Handle thread_handle) { - return ::svcGetThreadId(out_thread_id, thread_handle); + R_RETURN(::svcGetThreadId(out_thread_id, thread_handle)); } ALWAYS_INLINE void Break(::ams::svc::BreakReason break_reason, ::ams::svc::Address arg, ::ams::svc::Size size) { @@ -180,7 +180,7 @@ } ALWAYS_INLINE Result OutputDebugString(::ams::svc::UserPointer debug_str, ::ams::svc::Size len) { - return ::svcOutputDebugString(debug_str.GetPointerUnsafe(), len); + R_RETURN(::svcOutputDebugString(debug_str.GetPointerUnsafe(), len)); } ALWAYS_INLINE void ReturnFromException(::ams::Result result) { @@ -188,7 +188,7 @@ } ALWAYS_INLINE Result GetInfo(uint64_t *out, ::ams::svc::InfoType info_type, ::ams::svc::Handle handle, uint64_t info_subtype) { - return ::svcGetInfo(out, static_cast(info_type), handle, info_subtype); + R_RETURN(::svcGetInfo(out, static_cast(info_type), handle, info_subtype)); } ALWAYS_INLINE void FlushEntireDataCache() { @@ -196,47 +196,47 @@ } ALWAYS_INLINE Result FlushDataCache(::ams::svc::Address address, ::ams::svc::Size size) { - return ::svcFlushDataCache(reinterpret_cast(static_cast(address)), size); + R_RETURN(::svcFlushDataCache(reinterpret_cast(static_cast(address)), size)); } ALWAYS_INLINE Result MapPhysicalMemory(::ams::svc::Address address, ::ams::svc::Size size) { - return ::svcMapPhysicalMemory(reinterpret_cast(static_cast(address)), size); + R_RETURN(::svcMapPhysicalMemory(reinterpret_cast(static_cast(address)), size)); } ALWAYS_INLINE Result UnmapPhysicalMemory(::ams::svc::Address address, ::ams::svc::Size size) { - return ::svcUnmapPhysicalMemory(reinterpret_cast(static_cast(address)), size); + R_RETURN(::svcUnmapPhysicalMemory(reinterpret_cast(static_cast(address)), size)); } ALWAYS_INLINE Result GetDebugFutureThreadInfo(::ams::svc::lp64::LastThreadContext *out_context, uint64_t *thread_id, ::ams::svc::Handle debug_handle, int64_t ns) { - return ::svcGetDebugFutureThreadInfo(reinterpret_cast<::LastThreadContext *>(out_context), thread_id, debug_handle, ns); + R_RETURN(::svcGetDebugFutureThreadInfo(reinterpret_cast<::LastThreadContext *>(out_context), thread_id, debug_handle, ns)); } ALWAYS_INLINE Result GetLastThreadInfo(::ams::svc::lp64::LastThreadContext *out_context, ::ams::svc::Address *out_tls_address, uint32_t *out_flags) { - return ::svcGetLastThreadInfo(reinterpret_cast<::LastThreadContext *>(out_context), reinterpret_cast(out_tls_address), out_flags); + R_RETURN(::svcGetLastThreadInfo(reinterpret_cast<::LastThreadContext *>(out_context), reinterpret_cast(out_tls_address), out_flags)); } ALWAYS_INLINE Result GetResourceLimitLimitValue(int64_t *out_limit_value, ::ams::svc::Handle resource_limit_handle, ::ams::svc::LimitableResource which) { - return ::svcGetResourceLimitLimitValue(out_limit_value, resource_limit_handle, static_cast<::LimitableResource>(which)); + R_RETURN(::svcGetResourceLimitLimitValue(out_limit_value, resource_limit_handle, static_cast<::LimitableResource>(which))); } ALWAYS_INLINE Result GetResourceLimitCurrentValue(int64_t *out_current_value, ::ams::svc::Handle resource_limit_handle, ::ams::svc::LimitableResource which) { - return ::svcGetResourceLimitCurrentValue(out_current_value, resource_limit_handle, static_cast<::LimitableResource>(which)); + R_RETURN(::svcGetResourceLimitCurrentValue(out_current_value, resource_limit_handle, static_cast<::LimitableResource>(which))); } ALWAYS_INLINE Result SetThreadActivity(::ams::svc::Handle thread_handle, ::ams::svc::ThreadActivity thread_activity) { - return ::svcSetThreadActivity(thread_handle, static_cast<::ThreadActivity>(thread_activity)); + R_RETURN(::svcSetThreadActivity(thread_handle, static_cast<::ThreadActivity>(thread_activity))); } ALWAYS_INLINE Result GetThreadContext3(::ams::svc::UserPointer< ::ams::svc::ThreadContext *> out_context, ::ams::svc::Handle thread_handle) { - return ::svcGetThreadContext3(reinterpret_cast<::ThreadContext *>(out_context.GetPointerUnsafe()), thread_handle); + R_RETURN(::svcGetThreadContext3(reinterpret_cast<::ThreadContext *>(out_context.GetPointerUnsafe()), thread_handle)); } ALWAYS_INLINE Result WaitForAddress(::ams::svc::Address address, ::ams::svc::ArbitrationType arb_type, int32_t value, int64_t timeout_ns) { - return ::svcWaitForAddress(reinterpret_cast(static_cast(address)), arb_type, value, timeout_ns); + R_RETURN(::svcWaitForAddress(reinterpret_cast(static_cast(address)), arb_type, value, timeout_ns)); } ALWAYS_INLINE Result SignalToAddress(::ams::svc::Address address, ::ams::svc::SignalType signal_type, int32_t value, int32_t count) { - return ::svcSignalToAddress(reinterpret_cast(static_cast(address)), signal_type, value, count); + R_RETURN(::svcSignalToAddress(reinterpret_cast(static_cast(address)), signal_type, value, count)); } ALWAYS_INLINE void SynchronizePreemptionState() { @@ -244,7 +244,7 @@ } ALWAYS_INLINE Result GetResourceLimitPeakValue(int64_t *out_peak_value, ::ams::svc::Handle resource_limit_handle, ::ams::svc::LimitableResource which) { - return ::svcGetResourceLimitPeakValue(out_peak_value, resource_limit_handle, static_cast<::LimitableResource>(which)); + R_RETURN(::svcGetResourceLimitPeakValue(out_peak_value, resource_limit_handle, static_cast<::LimitableResource>(which))); } ALWAYS_INLINE void KernelDebug(::ams::svc::KernelDebugType kern_debug_type, uint64_t arg0, uint64_t arg1, uint64_t arg2) { @@ -256,47 +256,47 @@ } ALWAYS_INLINE Result CreateSession(::ams::svc::Handle *out_server_session_handle, ::ams::svc::Handle *out_client_session_handle, bool is_light, ::ams::svc::Address name) { - return ::svcCreateSession(out_server_session_handle, out_client_session_handle, is_light, name); + R_RETURN(::svcCreateSession(out_server_session_handle, out_client_session_handle, is_light, name)); } ALWAYS_INLINE Result AcceptSession(::ams::svc::Handle *out_handle, ::ams::svc::Handle port) { - return ::svcAcceptSession(out_handle, port); + R_RETURN(::svcAcceptSession(out_handle, port)); } ALWAYS_INLINE Result ReplyAndReceiveLight(::ams::svc::Handle handle) { - return ::svcReplyAndReceiveLight(handle); + R_RETURN(::svcReplyAndReceiveLight(handle)); } ALWAYS_INLINE Result ReplyAndReceive(int32_t *out_index, ::ams::svc::UserPointer handles, int32_t num_handles, ::ams::svc::Handle reply_target, int64_t timeout_ns) { - return ::svcReplyAndReceive(out_index, handles.GetPointerUnsafe(), num_handles, reply_target, timeout_ns); + R_RETURN(::svcReplyAndReceive(out_index, handles.GetPointerUnsafe(), num_handles, reply_target, timeout_ns)); } ALWAYS_INLINE Result ReplyAndReceiveWithUserBuffer(int32_t *out_index, ::ams::svc::Address message_buffer, ::ams::svc::Size message_buffer_size, ::ams::svc::UserPointer handles, int32_t num_handles, ::ams::svc::Handle reply_target, int64_t timeout_ns) { - return ::svcReplyAndReceiveWithUserBuffer(out_index, reinterpret_cast(static_cast(message_buffer)), message_buffer_size, handles.GetPointerUnsafe(), num_handles, reply_target, timeout_ns); + R_RETURN(::svcReplyAndReceiveWithUserBuffer(out_index, reinterpret_cast(static_cast(message_buffer)), message_buffer_size, handles.GetPointerUnsafe(), num_handles, reply_target, timeout_ns)); } ALWAYS_INLINE Result CreateEvent(::ams::svc::Handle *out_write_handle, ::ams::svc::Handle *out_read_handle) { - return ::svcCreateEvent(out_write_handle, out_read_handle); + R_RETURN(::svcCreateEvent(out_write_handle, out_read_handle)); } ALWAYS_INLINE Result MapPhysicalMemoryUnsafe(::ams::svc::Address address, ::ams::svc::Size size) { - return ::svcMapPhysicalMemoryUnsafe(reinterpret_cast(static_cast(address)), size); + R_RETURN(::svcMapPhysicalMemoryUnsafe(reinterpret_cast(static_cast(address)), size)); } ALWAYS_INLINE Result UnmapPhysicalMemoryUnsafe(::ams::svc::Address address, ::ams::svc::Size size) { - return ::svcUnmapPhysicalMemoryUnsafe(reinterpret_cast(static_cast(address)), size); + R_RETURN(::svcUnmapPhysicalMemoryUnsafe(reinterpret_cast(static_cast(address)), size)); } ALWAYS_INLINE Result SetUnsafeLimit(::ams::svc::Size limit) { - return ::svcSetUnsafeLimit(limit); + R_RETURN(::svcSetUnsafeLimit(limit)); } ALWAYS_INLINE Result CreateCodeMemory(::ams::svc::Handle *out_handle, ::ams::svc::Address address, ::ams::svc::Size size) { - return ::svcCreateCodeMemory(out_handle, reinterpret_cast(static_cast(address)), size); + R_RETURN(::svcCreateCodeMemory(out_handle, reinterpret_cast(static_cast(address)), size)); } ALWAYS_INLINE Result ControlCodeMemory(::ams::svc::Handle code_memory_handle, ::ams::svc::CodeMemoryOperation operation, uint64_t address, uint64_t size, ::ams::svc::MemoryPermission perm) { - return ::svcControlCodeMemory(code_memory_handle, static_cast<::CodeMapOperation>(operation), reinterpret_cast(address), size, static_cast(perm)); + R_RETURN(::svcControlCodeMemory(code_memory_handle, static_cast<::CodeMapOperation>(operation), reinterpret_cast(address), size, static_cast(perm))); } ALWAYS_INLINE void SleepSystem() { @@ -304,199 +304,199 @@ } ALWAYS_INLINE Result ReadWriteRegister(uint32_t *out_value, ::ams::svc::PhysicalAddress address, uint32_t mask, uint32_t value) { - return ::svcReadWriteRegister(out_value, address, mask, value); + R_RETURN(::svcReadWriteRegister(out_value, address, mask, value)); } ALWAYS_INLINE Result SetProcessActivity(::ams::svc::Handle process_handle, ::ams::svc::ProcessActivity process_activity) { - return ::svcSetProcessActivity(process_handle, static_cast<::ProcessActivity>(process_activity)); + R_RETURN(::svcSetProcessActivity(process_handle, static_cast<::ProcessActivity>(process_activity))); } ALWAYS_INLINE Result CreateSharedMemory(::ams::svc::Handle *out_handle, ::ams::svc::Size size, ::ams::svc::MemoryPermission owner_perm, ::ams::svc::MemoryPermission remote_perm) { - return ::svcCreateSharedMemory(out_handle, size, static_cast(owner_perm), static_cast(remote_perm)); + R_RETURN(::svcCreateSharedMemory(out_handle, size, static_cast(owner_perm), static_cast(remote_perm))); } ALWAYS_INLINE Result MapTransferMemory(::ams::svc::Handle trmem_handle, ::ams::svc::Address address, ::ams::svc::Size size, ::ams::svc::MemoryPermission owner_perm) { - return ::svcMapTransferMemory(trmem_handle, reinterpret_cast(static_cast(address)), size, static_cast(owner_perm)); + R_RETURN(::svcMapTransferMemory(trmem_handle, reinterpret_cast(static_cast(address)), size, static_cast(owner_perm))); } ALWAYS_INLINE Result UnmapTransferMemory(::ams::svc::Handle trmem_handle, ::ams::svc::Address address, ::ams::svc::Size size) { - return ::svcUnmapTransferMemory(trmem_handle, reinterpret_cast(static_cast(address)), size); + R_RETURN(::svcUnmapTransferMemory(trmem_handle, reinterpret_cast(static_cast(address)), size)); } ALWAYS_INLINE Result CreateInterruptEvent(::ams::svc::Handle *out_read_handle, int32_t interrupt_id, ::ams::svc::InterruptType interrupt_type) { - return ::svcCreateInterruptEvent(out_read_handle, interrupt_id, static_cast(interrupt_type)); + R_RETURN(::svcCreateInterruptEvent(out_read_handle, interrupt_id, static_cast(interrupt_type))); } ALWAYS_INLINE Result QueryPhysicalAddress(::ams::svc::lp64::PhysicalMemoryInfo *out_info, ::ams::svc::Address address) { - return ::svcQueryPhysicalAddress(reinterpret_cast<::PhysicalMemoryInfo *>(out_info), address); + R_RETURN(::svcQueryPhysicalAddress(reinterpret_cast<::PhysicalMemoryInfo *>(out_info), address)); } ALWAYS_INLINE Result QueryIoMapping(::ams::svc::Address *out_address, ::ams::svc::Size *out_size, ::ams::svc::PhysicalAddress physical_address, ::ams::svc::Size size) { - return ::svcQueryIoMapping(reinterpret_cast(out_address), reinterpret_cast(out_size), physical_address, size); + R_RETURN(::svcQueryIoMapping(reinterpret_cast(out_address), reinterpret_cast(out_size), physical_address, size)); } ALWAYS_INLINE Result LegacyQueryIoMapping(::ams::svc::Address *out_address, ::ams::svc::PhysicalAddress physical_address, ::ams::svc::Size size) { - return ::svcLegacyQueryIoMapping(reinterpret_cast(out_address), physical_address, size); + R_RETURN(::svcLegacyQueryIoMapping(reinterpret_cast(out_address), physical_address, size)); } ALWAYS_INLINE Result CreateDeviceAddressSpace(::ams::svc::Handle *out_handle, uint64_t das_address, uint64_t das_size) { - return ::svcCreateDeviceAddressSpace(out_handle, das_address, das_size); + R_RETURN(::svcCreateDeviceAddressSpace(out_handle, das_address, das_size)); } ALWAYS_INLINE Result AttachDeviceAddressSpace(::ams::svc::DeviceName device_name, ::ams::svc::Handle das_handle) { - return ::svcAttachDeviceAddressSpace(static_cast(device_name), das_handle); + R_RETURN(::svcAttachDeviceAddressSpace(static_cast(device_name), das_handle)); } ALWAYS_INLINE Result DetachDeviceAddressSpace(::ams::svc::DeviceName device_name, ::ams::svc::Handle das_handle) { - return ::svcDetachDeviceAddressSpace(static_cast(device_name), das_handle); + R_RETURN(::svcDetachDeviceAddressSpace(static_cast(device_name), das_handle)); } ALWAYS_INLINE Result MapDeviceAddressSpaceByForce(::ams::svc::Handle das_handle, ::ams::svc::Handle process_handle, uint64_t process_address, ::ams::svc::Size size, uint64_t device_address, ::ams::svc::MemoryPermission device_perm) { - return ::svcMapDeviceAddressSpaceByForce(das_handle, process_handle, process_address, size, device_address, static_cast(device_perm)); + R_RETURN(::svcMapDeviceAddressSpaceByForce(das_handle, process_handle, process_address, size, device_address, static_cast(device_perm))); } ALWAYS_INLINE Result MapDeviceAddressSpaceAligned(::ams::svc::Handle das_handle, ::ams::svc::Handle process_handle, uint64_t process_address, ::ams::svc::Size size, uint64_t device_address, ::ams::svc::MemoryPermission device_perm) { - return ::svcMapDeviceAddressSpaceAligned(das_handle, process_handle, process_address, size, device_address, static_cast(device_perm)); + R_RETURN(::svcMapDeviceAddressSpaceAligned(das_handle, process_handle, process_address, size, device_address, static_cast(device_perm))); } ALWAYS_INLINE Result UnmapDeviceAddressSpace(::ams::svc::Handle das_handle, ::ams::svc::Handle process_handle, uint64_t process_address, ::ams::svc::Size size, uint64_t device_address) { - return ::svcUnmapDeviceAddressSpace(das_handle, process_handle, process_address, size, device_address); + R_RETURN(::svcUnmapDeviceAddressSpace(das_handle, process_handle, process_address, size, device_address)); } ALWAYS_INLINE Result InvalidateProcessDataCache(::ams::svc::Handle process_handle, uint64_t address, uint64_t size) { - return ::svcInvalidateProcessDataCache(process_handle, address, size); + R_RETURN(::svcInvalidateProcessDataCache(process_handle, address, size)); } ALWAYS_INLINE Result StoreProcessDataCache(::ams::svc::Handle process_handle, uint64_t address, uint64_t size) { - return ::svcStoreProcessDataCache(process_handle, address, size); + R_RETURN(::svcStoreProcessDataCache(process_handle, address, size)); } ALWAYS_INLINE Result FlushProcessDataCache(::ams::svc::Handle process_handle, uint64_t address, uint64_t size) { - return ::svcFlushProcessDataCache(process_handle, address, size); + R_RETURN(::svcFlushProcessDataCache(process_handle, address, size)); } ALWAYS_INLINE Result DebugActiveProcess(::ams::svc::Handle *out_handle, uint64_t process_id) { - return ::svcDebugActiveProcess(out_handle, process_id); + R_RETURN(::svcDebugActiveProcess(out_handle, process_id)); } ALWAYS_INLINE Result BreakDebugProcess(::ams::svc::Handle debug_handle) { - return ::svcBreakDebugProcess(debug_handle); + R_RETURN(::svcBreakDebugProcess(debug_handle)); } ALWAYS_INLINE Result TerminateDebugProcess(::ams::svc::Handle debug_handle) { - return ::svcTerminateDebugProcess(debug_handle); + R_RETURN(::svcTerminateDebugProcess(debug_handle)); } ALWAYS_INLINE Result GetDebugEvent(::ams::svc::UserPointer< ::ams::svc::lp64::DebugEventInfo *> out_info, ::ams::svc::Handle debug_handle) { - return ::svcGetDebugEvent(out_info.GetPointerUnsafe(), debug_handle); + R_RETURN(::svcGetDebugEvent(out_info.GetPointerUnsafe(), debug_handle)); } ALWAYS_INLINE Result ContinueDebugEvent(::ams::svc::Handle debug_handle, uint32_t flags, ::ams::svc::UserPointer thread_ids, int32_t num_thread_ids) { - return ::svcContinueDebugEvent(debug_handle, flags, const_cast(thread_ids.GetPointerUnsafe()), num_thread_ids); + R_RETURN(::svcContinueDebugEvent(debug_handle, flags, const_cast(thread_ids.GetPointerUnsafe()), num_thread_ids)); } ALWAYS_INLINE Result LegacyContinueDebugEvent(::ams::svc::Handle debug_handle, uint32_t flags, uint64_t thread_id) { - return ::svcLegacyContinueDebugEvent(debug_handle, flags, thread_id); + R_RETURN(::svcLegacyContinueDebugEvent(debug_handle, flags, thread_id)); } ALWAYS_INLINE Result GetProcessList(int32_t *out_num_processes, ::ams::svc::UserPointer out_process_ids, int32_t max_out_count) { - return ::svcGetProcessList(out_num_processes, out_process_ids.GetPointerUnsafe(), max_out_count); + R_RETURN(::svcGetProcessList(out_num_processes, out_process_ids.GetPointerUnsafe(), max_out_count)); } ALWAYS_INLINE Result GetThreadList(int32_t *out_num_threads, ::ams::svc::UserPointer out_thread_ids, int32_t max_out_count, ::ams::svc::Handle debug_handle) { - return ::svcGetThreadList(out_num_threads, out_thread_ids.GetPointerUnsafe(), max_out_count, debug_handle); + R_RETURN(::svcGetThreadList(out_num_threads, out_thread_ids.GetPointerUnsafe(), max_out_count, debug_handle)); } ALWAYS_INLINE Result GetDebugThreadContext(::ams::svc::UserPointer< ::ams::svc::ThreadContext *> out_context, ::ams::svc::Handle debug_handle, uint64_t thread_id, uint32_t context_flags) { - return ::svcGetDebugThreadContext(reinterpret_cast<::ThreadContext *>(out_context.GetPointerUnsafe()), debug_handle, thread_id, context_flags); + R_RETURN(::svcGetDebugThreadContext(reinterpret_cast<::ThreadContext *>(out_context.GetPointerUnsafe()), debug_handle, thread_id, context_flags)); } ALWAYS_INLINE Result SetDebugThreadContext(::ams::svc::Handle debug_handle, uint64_t thread_id, ::ams::svc::UserPointer context, uint32_t context_flags) { - return ::svcSetDebugThreadContext(debug_handle, thread_id, reinterpret_cast(context.GetPointerUnsafe()), context_flags); + R_RETURN(::svcSetDebugThreadContext(debug_handle, thread_id, reinterpret_cast(context.GetPointerUnsafe()), context_flags)); } ALWAYS_INLINE Result QueryDebugProcessMemory(::ams::svc::UserPointer< ::ams::svc::lp64::MemoryInfo *> out_memory_info, ::ams::svc::PageInfo *out_page_info, ::ams::svc::Handle process_handle, ::ams::svc::Address address) { - return ::svcQueryDebugProcessMemory(reinterpret_cast<::MemoryInfo *>(out_memory_info.GetPointerUnsafe()), reinterpret_cast(out_page_info), process_handle, address); + R_RETURN(::svcQueryDebugProcessMemory(reinterpret_cast<::MemoryInfo *>(out_memory_info.GetPointerUnsafe()), reinterpret_cast(out_page_info), process_handle, address)); } ALWAYS_INLINE Result ReadDebugProcessMemory(::ams::svc::Address buffer, ::ams::svc::Handle debug_handle, ::ams::svc::Address address, ::ams::svc::Size size) { - return ::svcReadDebugProcessMemory(reinterpret_cast(static_cast(buffer)), debug_handle, address, size); + R_RETURN(::svcReadDebugProcessMemory(reinterpret_cast(static_cast(buffer)), debug_handle, address, size)); } ALWAYS_INLINE Result WriteDebugProcessMemory(::ams::svc::Handle debug_handle, ::ams::svc::Address buffer, ::ams::svc::Address address, ::ams::svc::Size size) { - return ::svcWriteDebugProcessMemory(debug_handle, reinterpret_cast(static_cast(buffer)), address, size); + R_RETURN(::svcWriteDebugProcessMemory(debug_handle, reinterpret_cast(static_cast(buffer)), address, size)); } ALWAYS_INLINE Result SetHardwareBreakPoint(::ams::svc::HardwareBreakPointRegisterName name, uint64_t flags, uint64_t value) { - return ::svcSetHardwareBreakPoint(static_cast(name), flags, value); + R_RETURN(::svcSetHardwareBreakPoint(static_cast(name), flags, value)); } ALWAYS_INLINE Result GetDebugThreadParam(uint64_t *out_64, uint32_t *out_32, ::ams::svc::Handle debug_handle, uint64_t thread_id, ::ams::svc::DebugThreadParam param) { - return ::svcGetDebugThreadParam(out_64, out_32, debug_handle, thread_id, static_cast<::DebugThreadParam>(param)); + R_RETURN(::svcGetDebugThreadParam(out_64, out_32, debug_handle, thread_id, static_cast<::DebugThreadParam>(param))); } ALWAYS_INLINE Result GetSystemInfo(uint64_t *out, ::ams::svc::SystemInfoType info_type, ::ams::svc::Handle handle, uint64_t info_subtype) { - return ::svcGetSystemInfo(out, static_cast(info_type), handle, info_subtype); + R_RETURN(::svcGetSystemInfo(out, static_cast(info_type), handle, info_subtype)); } ALWAYS_INLINE Result CreatePort(::ams::svc::Handle *out_server_handle, ::ams::svc::Handle *out_client_handle, int32_t max_sessions, bool is_light, ::ams::svc::Address name) { - return ::svcCreatePort(out_server_handle, out_client_handle, max_sessions, is_light, reinterpret_cast(static_cast(name))); + R_RETURN(::svcCreatePort(out_server_handle, out_client_handle, max_sessions, is_light, reinterpret_cast(static_cast(name)))); } ALWAYS_INLINE Result ManageNamedPort(::ams::svc::Handle *out_server_handle, ::ams::svc::UserPointer name, int32_t max_sessions) { - return ::svcManageNamedPort(out_server_handle, name.GetPointerUnsafe(), max_sessions); + R_RETURN(::svcManageNamedPort(out_server_handle, name.GetPointerUnsafe(), max_sessions)); } ALWAYS_INLINE Result ConnectToPort(::ams::svc::Handle *out_handle, ::ams::svc::Handle port) { - return ::svcConnectToPort(out_handle, port); + R_RETURN(::svcConnectToPort(out_handle, port)); } ALWAYS_INLINE Result SetProcessMemoryPermission(::ams::svc::Handle process_handle, uint64_t address, uint64_t size, ::ams::svc::MemoryPermission perm) { - return ::svcSetProcessMemoryPermission(process_handle, address, size, static_cast(perm)); + R_RETURN(::svcSetProcessMemoryPermission(process_handle, address, size, static_cast(perm))); } ALWAYS_INLINE Result MapProcessMemory(::ams::svc::Address dst_address, ::ams::svc::Handle process_handle, uint64_t src_address, ::ams::svc::Size size) { - return ::svcMapProcessMemory(reinterpret_cast(static_cast(dst_address)), process_handle, src_address, size); + R_RETURN(::svcMapProcessMemory(reinterpret_cast(static_cast(dst_address)), process_handle, src_address, size)); } ALWAYS_INLINE Result UnmapProcessMemory(::ams::svc::Address dst_address, ::ams::svc::Handle process_handle, uint64_t src_address, ::ams::svc::Size size) { - return ::svcUnmapProcessMemory(reinterpret_cast(static_cast(dst_address)), process_handle, src_address, size); + R_RETURN(::svcUnmapProcessMemory(reinterpret_cast(static_cast(dst_address)), process_handle, src_address, size)); } ALWAYS_INLINE Result QueryProcessMemory(::ams::svc::UserPointer< ::ams::svc::lp64::MemoryInfo *> out_memory_info, ::ams::svc::PageInfo *out_page_info, ::ams::svc::Handle process_handle, uint64_t address) { - return ::svcQueryProcessMemory(reinterpret_cast<::MemoryInfo *>(out_memory_info.GetPointerUnsafe()), reinterpret_cast(out_page_info), process_handle, address); + R_RETURN(::svcQueryProcessMemory(reinterpret_cast<::MemoryInfo *>(out_memory_info.GetPointerUnsafe()), reinterpret_cast(out_page_info), process_handle, address)); } ALWAYS_INLINE Result MapProcessCodeMemory(::ams::svc::Handle process_handle, uint64_t dst_address, uint64_t src_address, uint64_t size) { - return ::svcMapProcessCodeMemory(process_handle, dst_address, src_address, size); + R_RETURN(::svcMapProcessCodeMemory(process_handle, dst_address, src_address, size)); } ALWAYS_INLINE Result UnmapProcessCodeMemory(::ams::svc::Handle process_handle, uint64_t dst_address, uint64_t src_address, uint64_t size) { - return ::svcUnmapProcessCodeMemory(process_handle, dst_address, src_address, size); + R_RETURN(::svcUnmapProcessCodeMemory(process_handle, dst_address, src_address, size)); } ALWAYS_INLINE Result CreateProcess(::ams::svc::Handle *out_handle, ::ams::svc::UserPointer parameters, ::ams::svc::UserPointer caps, int32_t num_caps) { - return ::svcCreateProcess(out_handle, parameters.GetPointerUnsafe(), caps.GetPointerUnsafe(), num_caps); + R_RETURN(::svcCreateProcess(out_handle, parameters.GetPointerUnsafe(), caps.GetPointerUnsafe(), num_caps)); } ALWAYS_INLINE Result StartProcess(::ams::svc::Handle process_handle, int32_t priority, int32_t core_id, uint64_t main_thread_stack_size) { - return ::svcStartProcess(process_handle, priority, core_id, main_thread_stack_size); + R_RETURN(::svcStartProcess(process_handle, priority, core_id, main_thread_stack_size)); } ALWAYS_INLINE Result TerminateProcess(::ams::svc::Handle process_handle) { - return ::svcTerminateProcess(process_handle); + R_RETURN(::svcTerminateProcess(process_handle)); } ALWAYS_INLINE Result GetProcessInfo(int64_t *out_info, ::ams::svc::Handle process_handle, ::ams::svc::ProcessInfoType info_type) { - return ::svcGetProcessInfo(out_info, process_handle, static_cast<::ProcessInfoType>(info_type)); + R_RETURN(::svcGetProcessInfo(out_info, process_handle, static_cast<::ProcessInfoType>(info_type))); } ALWAYS_INLINE Result CreateResourceLimit(::ams::svc::Handle *out_handle) { - return ::svcCreateResourceLimit(out_handle); + R_RETURN(::svcCreateResourceLimit(out_handle)); } ALWAYS_INLINE Result SetResourceLimitLimitValue(::ams::svc::Handle resource_limit_handle, ::ams::svc::LimitableResource which, int64_t limit_value) { - return ::svcSetResourceLimitLimitValue(resource_limit_handle, static_cast<::LimitableResource>(which), limit_value); + R_RETURN(::svcSetResourceLimitLimitValue(resource_limit_handle, static_cast<::LimitableResource>(which), limit_value)); } ALWAYS_INLINE void CallSecureMonitor(::ams::svc::lp64::SecureMonitorArguments *args) { diff --git a/libraries/libstratosphere/include/stratosphere/tipc/impl/tipc_autogen_interface_macros.hpp b/libraries/libstratosphere/include/stratosphere/tipc/impl/tipc_autogen_interface_macros.hpp index ebdd45b63..b9a8dceb3 100644 --- a/libraries/libstratosphere/include/stratosphere/tipc/impl/tipc_autogen_interface_macros.hpp +++ b/libraries/libstratosphere/include/stratosphere/tipc/impl/tipc_autogen_interface_macros.hpp @@ -91,16 +91,16 @@ namespace ams::tipc::impl { #define AMS_TIPC_IMPL_PROCESS_METHOD_REQUEST(CLASSNAME, CMD_ID, RETURN, NAME, ARGS, ARGNAMES, VERSION_MIN, VERSION_MAX) \ else if (constexpr u16 TipcCommandId = CMD_ID + 0x10; tag == TipcCommandId) { \ - return this->ProcessMethodById(impl, message_buffer, fw_ver); \ + R_RETURN((this->ProcessMethodById(impl, message_buffer, fw_ver))); \ } - #define AMS_TIPC_IMPL_PROCESS_METHOD_REQUEST_BY_ID(CLASSNAME, CMD_ID, RETURN, NAME, ARGS, ARGNAMES, VERSION_MIN, VERSION_MAX) \ - if constexpr (constexpr u16 TipcCommandId = CMD_ID + 0x10; CommandId == TipcCommandId) { \ - constexpr bool MinValid = VERSION_MIN == hos::Version_Min; \ - constexpr bool MaxValid = VERSION_MAX == hos::Version_Max; \ - if ((MinValid || VERSION_MIN <= fw_ver) && (MaxValid || fw_ver <= VERSION_MAX)) { \ - return ::ams::tipc::impl::InvokeServiceCommandImpl(impl, message_buffer); \ - } \ + #define AMS_TIPC_IMPL_PROCESS_METHOD_REQUEST_BY_ID(CLASSNAME, CMD_ID, RETURN, NAME, ARGS, ARGNAMES, VERSION_MIN, VERSION_MAX) \ + if constexpr (constexpr u16 TipcCommandId = CMD_ID + 0x10; CommandId == TipcCommandId) { \ + constexpr bool MinValid = VERSION_MIN == hos::Version_Min; \ + constexpr bool MaxValid = VERSION_MAX == hos::Version_Max; \ + if ((MinValid || VERSION_MIN <= fw_ver) && (MaxValid || fw_ver <= VERSION_MAX)) { \ + R_RETURN((::ams::tipc::impl::InvokeServiceCommandImpl(impl, message_buffer))); \ + } \ } #define AMS_TIPC_IMPL_IS_FIRMWARE_VERSION_ALWAYS_VALID(CLASSNAME, CMD_ID, RETURN, NAME, ARGS, ARGNAMES, VERSION_MIN, VERSION_MAX) \ @@ -133,9 +133,9 @@ namespace ams::tipc::impl { ALWAYS_INLINE Result ProcessDefaultMethod(ImplType *impl, const MessageBuffer &message_buffer) const { \ /* Handle a default command. */ \ if constexpr (HasDefaultServiceCommandProcessor) { \ - return impl->ProcessDefaultServiceCommand(message_buffer); \ + R_RETURN(impl->ProcessDefaultServiceCommand(message_buffer)); \ } else { \ - R_THROW(tipc::ResultInvalidMethod()); \ + R_THROW(tipc::ResultInvalidMethod()); \ } \ } \ \ @@ -143,7 +143,7 @@ namespace ams::tipc::impl { ALWAYS_INLINE Result ProcessMethodById(ImplType *impl, const MessageBuffer &message_buffer, hos::Version fw_ver) const { \ CMD_MACRO(ImplType, AMS_TIPC_IMPL_PROCESS_METHOD_REQUEST_BY_ID) \ \ - return this->ProcessDefaultMethod(impl, message_buffer); \ + R_RETURN(this->ProcessDefaultMethod(impl, message_buffer)); \ } \ \ static consteval bool IsFirmwareVersionAlwaysValid() { \ @@ -170,7 +170,7 @@ namespace ams::tipc::impl { if (false) { } \ CMD_MACRO(ImplType, AMS_TIPC_IMPL_PROCESS_METHOD_REQUEST) \ else { \ - return this->ProcessDefaultMethod(impl, message_buffer); \ + R_RETURN(this->ProcessDefaultMethod(impl, message_buffer)); \ } \ } \ }; \ diff --git a/libraries/libstratosphere/include/stratosphere/tipc/impl/tipc_impl_command_serialization.hpp b/libraries/libstratosphere/include/stratosphere/tipc/impl/tipc_impl_command_serialization.hpp index 63a4dd0f7..d37277805 100644 --- a/libraries/libstratosphere/include/stratosphere/tipc/impl/tipc_impl_command_serialization.hpp +++ b/libraries/libstratosphere/include/stratosphere/tipc/impl/tipc_impl_command_serialization.hpp @@ -628,7 +628,7 @@ namespace ams::tipc::impl { typename Processor::OutHandleHolderType out_handles_holder; const Result command_result = [&](std::index_sequence) ALWAYS_INLINE_LAMBDA { if constexpr (ReturnsResult) { - return (object->*ServiceCommandImpl)(Processor::template DeserializeArgument(message_buffer, out_raw_holder, out_handles_holder)...); + R_RETURN((object->*ServiceCommandImpl)(Processor::template DeserializeArgument(message_buffer, out_raw_holder, out_handles_holder)...)); } else { (object->*ServiceCommandImpl)(Processor::template DeserializeArgument(message_buffer, out_raw_holder, out_handles_holder)...); R_SUCCEED(); diff --git a/libraries/libstratosphere/include/stratosphere/tipc/impl/tipc_impl_message_api.os.horizon.hpp b/libraries/libstratosphere/include/stratosphere/tipc/impl/tipc_impl_message_api.os.horizon.hpp index 998100f43..2655323ba 100644 --- a/libraries/libstratosphere/include/stratosphere/tipc/impl/tipc_impl_message_api.os.horizon.hpp +++ b/libraries/libstratosphere/include/stratosphere/tipc/impl/tipc_impl_message_api.os.horizon.hpp @@ -34,15 +34,15 @@ namespace ams::tipc::impl { } ALWAYS_INLINE Result CloseHandle(tipc::NativeHandle handle) { - return svc::CloseHandle(handle); + R_RETURN(svc::CloseHandle(handle)); } ALWAYS_INLINE Result CreateSession(tipc::NativeHandle *out_server_session_handle, tipc::NativeHandle *out_client_session_handle, bool is_light, uintptr_t name) { - return svc::CreateSession(out_server_session_handle, out_client_session_handle, is_light, name); + R_RETURN(svc::CreateSession(out_server_session_handle, out_client_session_handle, is_light, name)); } ALWAYS_INLINE Result AcceptSession(tipc::NativeHandle *out_handle, tipc::NativeHandle port) { - return svc::AcceptSession(out_handle, port); + R_RETURN(svc::AcceptSession(out_handle, port)); } } diff --git a/libraries/libstratosphere/include/stratosphere/tipc/tipc_deferral_manager.hpp b/libraries/libstratosphere/include/stratosphere/tipc/tipc_deferral_manager.hpp index 122595fca..ee0db8a95 100644 --- a/libraries/libstratosphere/include/stratosphere/tipc/tipc_deferral_manager.hpp +++ b/libraries/libstratosphere/include/stratosphere/tipc/tipc_deferral_manager.hpp @@ -74,11 +74,9 @@ namespace ams::tipc { template ALWAYS_INLINE Result RegisterRetryIfDeferred(ResumeKey key, F f) { - const Result result = f(); - if (tipc::ResultRequestDeferred::Includes(result)) { - this->RegisterRetry(key); - } - return result; + ON_RESULT_INCLUDED(tipc::ResultRequestDeferred) { this->RegisterRetry(key); }; + + R_RETURN(f()); } template diff --git a/libraries/libstratosphere/include/stratosphere/tipc/tipc_object_manager.hpp b/libraries/libstratosphere/include/stratosphere/tipc/tipc_object_manager.hpp index 6c393ab64..e51141f94 100644 --- a/libraries/libstratosphere/include/stratosphere/tipc/tipc_object_manager.hpp +++ b/libraries/libstratosphere/include/stratosphere/tipc/tipc_object_manager.hpp @@ -120,7 +120,7 @@ namespace ams::tipc { *out_object = GetReference(entry->object); *out_holder = nullptr; - return result; + R_RETURN(result); } else { R_SUCCEED(); } diff --git a/libraries/libstratosphere/include/stratosphere/tipc/tipc_server_manager.hpp b/libraries/libstratosphere/include/stratosphere/tipc/tipc_server_manager.hpp index f5f7b2c99..e5a5a7c6b 100644 --- a/libraries/libstratosphere/include/stratosphere/tipc/tipc_server_manager.hpp +++ b/libraries/libstratosphere/include/stratosphere/tipc/tipc_server_manager.hpp @@ -319,7 +319,7 @@ namespace ams::tipc { const Result method_result = message_buffer.GetRaw(raw_data_offset); /* Check that the result is the special deferral result. */ - R_THROW(tipc::ResultRequestDeferred::Includes(method_result)); + return tipc::ResultRequestDeferred::Includes(method_result); } else { /* If deferral isn't supported, requests are never deferred. */ return false; diff --git a/libraries/libstratosphere/source/capsrv/capsrv_screen_shot_control_api.cpp b/libraries/libstratosphere/source/capsrv/capsrv_screen_shot_control_api.cpp index 5a0f29989..68814aead 100644 --- a/libraries/libstratosphere/source/capsrv/capsrv_screen_shot_control_api.cpp +++ b/libraries/libstratosphere/source/capsrv/capsrv_screen_shot_control_api.cpp @@ -19,7 +19,7 @@ namespace ams::capsrv { Result InitializeScreenShotControl() { #if defined(ATMOSPHERE_OS_HORIZON) - return ::capsscInitialize(); + R_RETURN(::capsscInitialize()); #else AMS_ABORT("TODO"); #endif @@ -35,7 +35,7 @@ namespace ams::capsrv { Result CaptureJpegScreenshot(u64 *out_size, void *dst, size_t dst_size, vi::LayerStack layer_stack, TimeSpan timeout) { #if defined(ATMOSPHERE_OS_HORIZON) - return ::capsscCaptureJpegScreenShot(out_size, dst, dst_size, static_cast<::ViLayerStack>(layer_stack), timeout.GetNanoSeconds()); + R_RETURN(::capsscCaptureJpegScreenShot(out_size, dst, dst_size, static_cast<::ViLayerStack>(layer_stack), timeout.GetNanoSeconds())); #else AMS_UNUSED(out_size, dst, dst_size, layer_stack, timeout); AMS_ABORT("TODO"); diff --git a/libraries/libstratosphere/source/capsrv/server/decodersrv/decodersrv_decoder_control_service.cpp b/libraries/libstratosphere/source/capsrv/server/decodersrv/decodersrv_decoder_control_service.cpp index d4682ece6..8be38606a 100644 --- a/libraries/libstratosphere/source/capsrv/server/decodersrv/decodersrv_decoder_control_service.cpp +++ b/libraries/libstratosphere/source/capsrv/server/decodersrv/decodersrv_decoder_control_service.cpp @@ -75,7 +75,7 @@ namespace ams::capsrv::server { size_t work_size = sizeof(g_work_memory.jpeg_decoder_memory); /* Call the decoder implementation. */ - return DecodeJpegImpl(out.GetPointer(), out.GetSize(), in.GetPointer(), in.GetSize(), width, height, option, work, work_size); + R_RETURN(DecodeJpegImpl(out.GetPointer(), out.GetSize(), in.GetPointer(), in.GetSize(), width, height, option, work, work_size)); } } \ No newline at end of file diff --git a/libraries/libstratosphere/source/dd/dd_device_address_space.cpp b/libraries/libstratosphere/source/dd/dd_device_address_space.cpp index 1e41fce60..7a9fa3d5b 100644 --- a/libraries/libstratosphere/source/dd/dd_device_address_space.cpp +++ b/libraries/libstratosphere/source/dd/dd_device_address_space.cpp @@ -42,7 +42,7 @@ namespace ams::dd { } Result CreateDeviceAddressSpace(DeviceAddressSpaceType *das, u64 size) { - return CreateDeviceAddressSpace(das, 0, size); + R_RETURN(CreateDeviceAddressSpace(das, 0, size)); } void DestroyDeviceAddressSpace(DeviceAddressSpaceType *das) { @@ -86,7 +86,7 @@ namespace ams::dd { AMS_ASSERT(size > 0); AMS_ASSERT((process_address & (4_MB - 1)) == (device_address & (4_MB - 1))); - return impl::DeviceAddressSpaceImpl::MapAligned(das->device_handle, process_handle, process_address, size, device_address, device_perm); + R_RETURN(impl::DeviceAddressSpaceImpl::MapAligned(das->device_handle, process_handle, process_address, size, device_address, device_perm)); } Result MapDeviceAddressSpaceNotAligned(DeviceAddressSpaceType *das, ProcessHandle process_handle, u64 process_address, size_t size, DeviceVirtualAddress device_address, MemoryPermission device_perm) { @@ -99,7 +99,7 @@ namespace ams::dd { AMS_ASSERT(device_address + size > device_address); AMS_ASSERT(size > 0); - return impl::DeviceAddressSpaceImpl::MapNotAligned(das->device_handle, process_handle, process_address, size, device_address, device_perm); + R_RETURN(impl::DeviceAddressSpaceImpl::MapNotAligned(das->device_handle, process_handle, process_address, size, device_address, device_perm)); } void UnmapDeviceAddressSpace(DeviceAddressSpaceType *das, ProcessHandle process_handle, u64 process_address, size_t size, DeviceVirtualAddress device_address) { @@ -119,7 +119,7 @@ namespace ams::dd { /* Check pre-conditions. */ AMS_ASSERT(das->state == DeviceAddressSpaceType::State_Initialized); - return impl::DeviceAddressSpaceImpl::Attach(das, device_name); + R_RETURN(impl::DeviceAddressSpaceImpl::Attach(das, device_name)); } void DetachDeviceAddressSpace(DeviceAddressSpaceType *das, DeviceName device_name) { diff --git a/libraries/libstratosphere/source/erpt/srv/erpt_srv_attachment.cpp b/libraries/libstratosphere/source/erpt/srv/erpt_srv_attachment.cpp index f9087de2f..93685480b 100644 --- a/libraries/libstratosphere/source/erpt/srv/erpt_srv_attachment.cpp +++ b/libraries/libstratosphere/source/erpt/srv/erpt_srv_attachment.cpp @@ -46,18 +46,18 @@ namespace ams::erpt::srv { Result Attachment::Open(AttachmentOpenType type) { switch (type) { - case AttachmentOpenType_Create: return this->OpenStream(this->FileName().name, StreamMode_Write, AttachmentStreamBufferSize); - case AttachmentOpenType_Read: return this->OpenStream(this->FileName().name, StreamMode_Read, AttachmentStreamBufferSize); + case AttachmentOpenType_Create: R_RETURN(this->OpenStream(this->FileName().name, StreamMode_Write, AttachmentStreamBufferSize)); + case AttachmentOpenType_Read: R_RETURN(this->OpenStream(this->FileName().name, StreamMode_Read, AttachmentStreamBufferSize)); default: R_THROW(erpt::ResultInvalidArgument()); } } Result Attachment::Read(u32 *out_read_count, u8 *dst, u32 dst_size) { - return this->ReadStream(out_read_count, dst, dst_size); + R_RETURN(this->ReadStream(out_read_count, dst, dst_size)); } Result Attachment::Delete() { - return this->DeleteStream(this->FileName().name); + R_RETURN(this->DeleteStream(this->FileName().name)); } void Attachment::Close() { @@ -72,13 +72,13 @@ namespace ams::erpt::srv { Result Attachment::SetFlags(AttachmentFlagSet flags) { if (((~m_record->m_info.flags) & flags).IsAnySet()) { m_record->m_info.flags |= flags; - return Journal::Commit(); + R_RETURN(Journal::Commit()); } R_SUCCEED(); } Result Attachment::GetSize(s64 *out) const { - return this->GetStreamSize(out); + R_RETURN(this->GetStreamSize(out)); } } diff --git a/libraries/libstratosphere/source/erpt/srv/erpt_srv_attachment.hpp b/libraries/libstratosphere/source/erpt/srv/erpt_srv_attachment.hpp index 0d259cb87..a80b74cc7 100644 --- a/libraries/libstratosphere/source/erpt/srv/erpt_srv_attachment.hpp +++ b/libraries/libstratosphere/source/erpt/srv/erpt_srv_attachment.hpp @@ -50,12 +50,12 @@ namespace ams::erpt::srv { template Result Write(T val) { - return this->WriteStream(reinterpret_cast(std::addressof(val)), sizeof(val)); + R_RETURN(this->WriteStream(reinterpret_cast(std::addressof(val)), sizeof(val))); } template Result Write(const T *buf, u32 buffer_size) { - return this->WriteStream(reinterpret_cast(buf), buffer_size); + R_RETURN(this->WriteStream(reinterpret_cast(buf), buffer_size)); } }; diff --git a/libraries/libstratosphere/source/erpt/srv/erpt_srv_attachment_impl.cpp b/libraries/libstratosphere/source/erpt/srv/erpt_srv_attachment_impl.cpp index 3f161bed1..1d9083e88 100644 --- a/libraries/libstratosphere/source/erpt/srv/erpt_srv_attachment_impl.cpp +++ b/libraries/libstratosphere/source/erpt/srv/erpt_srv_attachment_impl.cpp @@ -46,19 +46,19 @@ namespace ams::erpt::srv { Result AttachmentImpl::Read(ams::sf::Out out_count, const ams::sf::OutBuffer &out_buffer) { R_UNLESS(m_attachment != nullptr, erpt::ResultNotInitialized()); - return m_attachment->Read(out_count.GetPointer(), static_cast(out_buffer.GetPointer()), static_cast(out_buffer.GetSize())); + R_RETURN(m_attachment->Read(out_count.GetPointer(), static_cast(out_buffer.GetPointer()), static_cast(out_buffer.GetSize()))); } Result AttachmentImpl::SetFlags(AttachmentFlagSet flags) { R_UNLESS(m_attachment != nullptr, erpt::ResultNotInitialized()); - return m_attachment->SetFlags(flags); + R_RETURN(m_attachment->SetFlags(flags)); } Result AttachmentImpl::GetFlags(ams::sf::Out out) { R_UNLESS(m_attachment != nullptr, erpt::ResultNotInitialized()); - return m_attachment->GetFlags(out.GetPointer()); + R_RETURN(m_attachment->GetFlags(out.GetPointer())); } Result AttachmentImpl::Close() { @@ -73,7 +73,7 @@ namespace ams::erpt::srv { Result AttachmentImpl::GetSize(ams::sf::Out out) { R_UNLESS(m_attachment != nullptr, erpt::ResultNotInitialized()); - return m_attachment->GetSize(out.GetPointer()); + R_RETURN(m_attachment->GetSize(out.GetPointer())); } } diff --git a/libraries/libstratosphere/source/erpt/srv/erpt_srv_cipher.hpp b/libraries/libstratosphere/source/erpt/srv/erpt_srv_cipher.hpp index 56f0a7fc9..45cae0b4a 100644 --- a/libraries/libstratosphere/source/erpt/srv/erpt_srv_cipher.hpp +++ b/libraries/libstratosphere/source/erpt/srv/erpt_srv_cipher.hpp @@ -59,14 +59,14 @@ namespace ams::erpt::srv { ON_SCOPE_EXIT { std::memset(hdr, 0, sizeof(hdr) + data_size); s_need_to_store_cipher = true; }; - return Formatter::AddField(report, field_id, reinterpret_cast(hdr), sizeof(hdr) + data_size); + R_RETURN(Formatter::AddField(report, field_id, reinterpret_cast(hdr), sizeof(hdr) + data_size)); } public: static Result Begin(Report *report, u32 record_count) { s_need_to_store_cipher = false; crypto::GenerateCryptographicallyRandomBytes(s_key, sizeof(s_key)); - return Formatter::Begin(report, record_count + 1); + R_RETURN(Formatter::Begin(report, record_count + 1)); } static Result End(Report *report) { @@ -84,40 +84,40 @@ namespace ams::erpt::srv { Formatter::AddField(report, FieldId_CipherKey, cipher, sizeof(cipher)); std::memset(s_key, 0, sizeof(s_key)); - return Formatter::End(report); + R_RETURN(Formatter::End(report)); } static Result AddField(Report *report, FieldId field_id, bool value) { - return Formatter::AddField(report, field_id, value); + R_RETURN(Formatter::AddField(report, field_id, value)); } template static Result AddField(Report *report, FieldId field_id, T value) { - return Formatter::AddField(report, field_id, value); + R_RETURN(Formatter::AddField(report, field_id, value)); } static Result AddField(Report *report, FieldId field_id, char *str, u32 len) { if (FieldToFlagMap[field_id] == FieldFlag_Encrypt) { - return EncryptArray(report, field_id, str, len); + R_RETURN(EncryptArray(report, field_id, str, len)); } else { - return Formatter::AddField(report, field_id, str, len); + R_RETURN(Formatter::AddField(report, field_id, str, len)); } } static Result AddField(Report *report, FieldId field_id, u8 *bin, u32 len) { if (FieldToFlagMap[field_id] == FieldFlag_Encrypt) { - return EncryptArray(report, field_id, bin, len); + R_RETURN(EncryptArray(report, field_id, bin, len)); } else { - return Formatter::AddField(report, field_id, bin, len); + R_RETURN(Formatter::AddField(report, field_id, bin, len)); } } template static Result AddField(Report *report, FieldId field_id, T *arr, u32 len) { if (FieldToFlagMap[field_id] == FieldFlag_Encrypt) { - return EncryptArray(report, field_id, arr, len); + R_RETURN(EncryptArray(report, field_id, arr, len)); } else { - return Formatter::AddField(report, field_id, arr, len); + R_RETURN(Formatter::AddField(report, field_id, arr, len)); } } }; diff --git a/libraries/libstratosphere/source/erpt/srv/erpt_srv_context.cpp b/libraries/libstratosphere/source/erpt/srv/erpt_srv_context.cpp index 25a41a4e5..b39be9949 100644 --- a/libraries/libstratosphere/source/erpt/srv/erpt_srv_context.cpp +++ b/libraries/libstratosphere/source/erpt/srv/erpt_srv_context.cpp @@ -100,7 +100,7 @@ namespace ams::erpt::srv { }); R_UNLESS(it != g_category_list.end(), erpt::ResultCategoryNotFound()); - return it->AddContextToCategory(entry, data, data_size); + R_RETURN(it->AddContextToCategory(entry, data, data_size)); } Result Context::SubmitContextRecord(std::unique_ptr record) { @@ -109,7 +109,7 @@ namespace ams::erpt::srv { }); R_UNLESS(it != g_category_list.end(), erpt::ResultCategoryNotFound()); - return it->AddContextRecordToCategory(std::move(record)); + R_RETURN(it->AddContextRecordToCategory(std::move(record))); } Result Context::WriteContextsToReport(Report *report) { @@ -132,7 +132,7 @@ namespace ams::erpt::srv { R_UNLESS(record != nullptr, erpt::ResultOutOfMemory()); /* Submit the context record. */ - return SubmitContextRecord(std::move(record)); + R_RETURN(SubmitContextRecord(std::move(record))); } } diff --git a/libraries/libstratosphere/source/erpt/srv/erpt_srv_context_impl.cpp b/libraries/libstratosphere/source/erpt/srv/erpt_srv_context_impl.cpp index a661f7a22..4bc533d22 100644 --- a/libraries/libstratosphere/source/erpt/srv/erpt_srv_context_impl.cpp +++ b/libraries/libstratosphere/source/erpt/srv/erpt_srv_context_impl.cpp @@ -35,7 +35,7 @@ namespace ams::erpt::srv { SubmitContextForForcedShutdownDetection(ctx, data, data_size); - return Context::SubmitContext(ctx, data, data_size); + R_RETURN(Context::SubmitContext(ctx, data, data_size)); } Result ContextImpl::CreateReport(ReportType report_type, const ams::sf::InBuffer &ctx_buffer, const ams::sf::InBuffer &data_buffer, const ams::sf::InBuffer &meta_buffer, Result result) { @@ -58,7 +58,7 @@ namespace ams::erpt::srv { } Result ContextImpl::CreateReportV0(ReportType report_type, const ams::sf::InBuffer &ctx_buffer, const ams::sf::InBuffer &data_buffer, const ams::sf::InBuffer &meta_buffer) { - return this->CreateReport(report_type, ctx_buffer, data_buffer, meta_buffer, ResultSuccess()); + R_RETURN(this->CreateReport(report_type, ctx_buffer, data_buffer, meta_buffer, ResultSuccess())); } Result ContextImpl::SetInitialLaunchSettingsCompletionTime(const time::SteadyClockTimePoint &time_point) { @@ -135,7 +135,7 @@ namespace ams::erpt::srv { char name_safe[AttachmentNameSizeMax]; util::Strlcpy(name_safe, name, sizeof(name_safe)); - return JournalForAttachments::SubmitAttachment(out.GetPointer(), name_safe, data, data_size); + R_RETURN(JournalForAttachments::SubmitAttachment(out.GetPointer(), name_safe, data, data_size)); } Result ContextImpl::CreateReportWithAttachments(ReportType report_type, const ams::sf::InBuffer &ctx_buffer, const ams::sf::InBuffer &data_buffer, const ams::sf::InBuffer &attachment_ids_buffer, Result result) { @@ -158,19 +158,19 @@ namespace ams::erpt::srv { } Result ContextImpl::CreateReportWithAttachmentsDeprecated(ReportType report_type, const ams::sf::InBuffer &ctx_buffer, const ams::sf::InBuffer &data_buffer, const ams::sf::InBuffer &attachment_ids_buffer) { - return this->CreateReportWithAttachments(report_type, ctx_buffer, data_buffer, attachment_ids_buffer, ResultSuccess()); + R_RETURN(this->CreateReportWithAttachments(report_type, ctx_buffer, data_buffer, attachment_ids_buffer, ResultSuccess())); } Result ContextImpl::RegisterRunningApplet(ncm::ProgramId program_id) { - return Reporter::RegisterRunningApplet(program_id); + R_RETURN(Reporter::RegisterRunningApplet(program_id)); } Result ContextImpl::UnregisterRunningApplet(ncm::ProgramId program_id) { - return Reporter::UnregisterRunningApplet(program_id); + R_RETURN(Reporter::UnregisterRunningApplet(program_id)); } Result ContextImpl::UpdateAppletSuspendedDuration(ncm::ProgramId program_id, TimeSpanType duration) { - return Reporter::UpdateAppletSuspendedDuration(program_id, duration); + R_RETURN(Reporter::UpdateAppletSuspendedDuration(program_id, duration)); } Result ContextImpl::InvalidateForcedShutdownDetection() { diff --git a/libraries/libstratosphere/source/erpt/srv/erpt_srv_context_record.cpp b/libraries/libstratosphere/source/erpt/srv/erpt_srv_context_record.cpp index f1a4148f2..0acc1cabf 100644 --- a/libraries/libstratosphere/source/erpt/srv/erpt_srv_context_record.cpp +++ b/libraries/libstratosphere/source/erpt/srv/erpt_srv_context_record.cpp @@ -202,11 +202,11 @@ namespace ams::erpt::srv { } Result ContextRecord::Add(FieldId field_id, const char *str, u32 str_size) { - return this->Add(field_id, str, str_size, FieldType_String); + R_RETURN(this->Add(field_id, str, str_size, FieldType_String)); } Result ContextRecord::Add(FieldId field_id, const u8 *data, u32 size) { - return this->Add(field_id, data, size, FieldType_U8Array); + R_RETURN(this->Add(field_id, data, size, FieldType_U8Array)); } } diff --git a/libraries/libstratosphere/source/erpt/srv/erpt_srv_formatter.hpp b/libraries/libstratosphere/source/erpt/srv/erpt_srv_formatter.hpp index 639ea4fd9..b50712be3 100644 --- a/libraries/libstratosphere/source/erpt/srv/erpt_srv_formatter.hpp +++ b/libraries/libstratosphere/source/erpt/srv/erpt_srv_formatter.hpp @@ -138,12 +138,12 @@ namespace ams::erpt::srv { template static Result AddField(Report *report, FieldId field_id, T value) { - return AddIdValuePair(report, field_id, value); + R_RETURN(AddIdValuePair(report, field_id, value)); } template static Result AddField(Report *report, FieldId field_id, T *arr, u32 arr_size) { - return AddIdValueArray(report, field_id, arr, arr_size); + R_RETURN(AddIdValueArray(report, field_id, arr, arr_size)); } static Result AddField(Report *report, FieldId field_id, bool value) { diff --git a/libraries/libstratosphere/source/erpt/srv/erpt_srv_journal.cpp b/libraries/libstratosphere/source/erpt/srv/erpt_srv_journal.cpp index 51dc62db1..446ccafca 100644 --- a/libraries/libstratosphere/source/erpt/srv/erpt_srv_journal.cpp +++ b/libraries/libstratosphere/source/erpt/srv/erpt_srv_journal.cpp @@ -48,11 +48,11 @@ namespace ams::erpt::srv { } Result Journal::Delete(ReportId report_id) { - return JournalForReports::DeleteReport(report_id); + R_RETURN(JournalForReports::DeleteReport(report_id)); } Result Journal::GetAttachmentList(AttachmentList *out, ReportId report_id) { - return JournalForAttachments::GetAttachmentList(out, report_id); + R_RETURN(JournalForAttachments::GetAttachmentList(out, report_id)); } util::Uuid Journal::GetJournalId() { @@ -64,7 +64,7 @@ namespace ams::erpt::srv { } Result Journal::GetReportList(ReportList *out, ReportType type_filter) { - return JournalForReports::GetReportList(out, type_filter); + R_RETURN(JournalForReports::GetReportList(out, type_filter)); } u32 Journal::GetStoredReportCount(ReportType type) { @@ -109,11 +109,11 @@ namespace ams::erpt::srv { } Result Journal::Store(JournalRecord *record) { - return JournalForReports::StoreRecord(record); + R_RETURN(JournalForReports::StoreRecord(record)); } Result Journal::Store(JournalRecord *record) { - return JournalForAttachments::StoreRecord(record); + R_RETURN(JournalForAttachments::StoreRecord(record)); } } diff --git a/libraries/libstratosphere/source/erpt/srv/erpt_srv_journal_for_meta.cpp b/libraries/libstratosphere/source/erpt/srv/erpt_srv_journal_for_meta.cpp index 368d97953..152b574f5 100644 --- a/libraries/libstratosphere/source/erpt/srv/erpt_srv_journal_for_meta.cpp +++ b/libraries/libstratosphere/source/erpt/srv/erpt_srv_journal_for_meta.cpp @@ -27,7 +27,7 @@ namespace ams::erpt::srv { } Result JournalForMeta::CommitJournal(Stream *stream) { - return stream->WriteStream(reinterpret_cast(std::addressof(s_journal_meta)), sizeof(s_journal_meta)); + R_RETURN(stream->WriteStream(reinterpret_cast(std::addressof(s_journal_meta)), sizeof(s_journal_meta))); } Result JournalForMeta::RestoreJournal(Stream *stream) { diff --git a/libraries/libstratosphere/source/erpt/srv/erpt_srv_main.cpp b/libraries/libstratosphere/source/erpt/srv/erpt_srv_main.cpp index 6bdf937e2..affc0b453 100644 --- a/libraries/libstratosphere/source/erpt/srv/erpt_srv_main.cpp +++ b/libraries/libstratosphere/source/erpt/srv/erpt_srv_main.cpp @@ -123,11 +123,11 @@ namespace ams::erpt::srv { /* NOTE: Nintendo does not check error code here. */ InitializeForcedShutdownDetection(); - return InitializeService(); + R_RETURN(InitializeService()); } Result SetSerialNumberAndOsVersion(const char *sn, u32 sn_len, const char *os, u32 os_len, const char *os_priv, u32 os_priv_len) { - return Reporter::SetSerialNumberAndOsVersion(sn, sn_len, os, os_len, os_priv, os_priv_len); + R_RETURN(Reporter::SetSerialNumberAndOsVersion(sn, sn_len, os, os_len, os_priv, os_priv_len)); } Result SetProductModel(const char *model, u32 model_len) { diff --git a/libraries/libstratosphere/source/erpt/srv/erpt_srv_manager_impl.cpp b/libraries/libstratosphere/source/erpt/srv/erpt_srv_manager_impl.cpp index d726e8f7b..144507e42 100644 --- a/libraries/libstratosphere/source/erpt/srv/erpt_srv_manager_impl.cpp +++ b/libraries/libstratosphere/source/erpt/srv/erpt_srv_manager_impl.cpp @@ -49,7 +49,7 @@ namespace ams::erpt::srv { Result ManagerImpl::GetReportList(const ams::sf::OutBuffer &out_list, ReportType type_filter) { R_UNLESS(out_list.GetSize() == sizeof(ReportList), erpt::ResultInvalidArgument()); - return Journal::GetReportList(reinterpret_cast(out_list.GetPointer()), type_filter); + R_RETURN(Journal::GetReportList(reinterpret_cast(out_list.GetPointer()), type_filter)); } Result ManagerImpl::GetEvent(ams::sf::OutCopyHandle out) { @@ -60,12 +60,12 @@ namespace ams::erpt::srv { Result ManagerImpl::CleanupReports() { Journal::CleanupReports(); Journal::CleanupAttachments(); - return Journal::Commit(); + R_RETURN(Journal::Commit()); } Result ManagerImpl::DeleteReport(const ReportId &report_id) { R_TRY(Journal::Delete(report_id)); - return Journal::Commit(); + R_RETURN(Journal::Commit()); } Result ManagerImpl::GetStorageUsageStatistics(ams::sf::Out out) { @@ -89,7 +89,7 @@ namespace ams::erpt::srv { Result ManagerImpl::GetAttachmentList(const ams::sf::OutBuffer &out_list, const ReportId &report_id) { R_UNLESS(out_list.GetSize() == sizeof(AttachmentList), erpt::ResultInvalidArgument()); - return Journal::GetAttachmentList(reinterpret_cast(out_list.GetPointer()), report_id); + R_RETURN(Journal::GetAttachmentList(reinterpret_cast(out_list.GetPointer()), report_id)); } } diff --git a/libraries/libstratosphere/source/erpt/srv/erpt_srv_report.cpp b/libraries/libstratosphere/source/erpt/srv/erpt_srv_report.cpp index c52952a8e..67f927819 100644 --- a/libraries/libstratosphere/source/erpt/srv/erpt_srv_report.cpp +++ b/libraries/libstratosphere/source/erpt/srv/erpt_srv_report.cpp @@ -52,18 +52,18 @@ namespace ams::erpt::srv { Result Report::Open(ReportOpenType type) { switch (type) { - case ReportOpenType_Create: return this->OpenStream(this->FileName().name, StreamMode_Write, ReportStreamBufferSize); - case ReportOpenType_Read: return this->OpenStream(this->FileName().name, StreamMode_Read, ReportStreamBufferSize); + case ReportOpenType_Create: R_RETURN(this->OpenStream(this->FileName().name, StreamMode_Write, ReportStreamBufferSize)); + case ReportOpenType_Read: R_RETURN(this->OpenStream(this->FileName().name, StreamMode_Read, ReportStreamBufferSize)); default: R_THROW(erpt::ResultInvalidArgument()); } } Result Report::Read(u32 *out_read_count, u8 *dst, u32 dst_size) { - return this->ReadStream(out_read_count, dst, dst_size); + R_RETURN(this->ReadStream(out_read_count, dst, dst_size)); } Result Report::Delete() { - return this->DeleteStream(this->FileName().name); + R_RETURN(this->DeleteStream(this->FileName().name)); } void Report::Close() { @@ -78,13 +78,13 @@ namespace ams::erpt::srv { Result Report::SetFlags(ReportFlagSet flags) { if (((~m_record->m_info.flags) & flags).IsAnySet()) { m_record->m_info.flags |= flags; - return Journal::Commit(); + R_RETURN(Journal::Commit()); } R_SUCCEED(); } Result Report::GetSize(s64 *out) const { - return this->GetStreamSize(out); + R_RETURN(this->GetStreamSize(out)); } } diff --git a/libraries/libstratosphere/source/erpt/srv/erpt_srv_report.hpp b/libraries/libstratosphere/source/erpt/srv/erpt_srv_report.hpp index 115644e15..c231439c3 100644 --- a/libraries/libstratosphere/source/erpt/srv/erpt_srv_report.hpp +++ b/libraries/libstratosphere/source/erpt/srv/erpt_srv_report.hpp @@ -51,12 +51,12 @@ namespace ams::erpt::srv { template Result Write(T val) { - return this->WriteStream(reinterpret_cast(std::addressof(val)), sizeof(val)); + R_RETURN(this->WriteStream(reinterpret_cast(std::addressof(val)), sizeof(val))); } template Result Write(const T *buf, u32 buffer_size) { - return this->WriteStream(reinterpret_cast(buf), buffer_size); + R_RETURN(this->WriteStream(reinterpret_cast(buf), buffer_size)); } }; diff --git a/libraries/libstratosphere/source/erpt/srv/erpt_srv_report_impl.cpp b/libraries/libstratosphere/source/erpt/srv/erpt_srv_report_impl.cpp index 0a670ffa8..f3c530674 100644 --- a/libraries/libstratosphere/source/erpt/srv/erpt_srv_report_impl.cpp +++ b/libraries/libstratosphere/source/erpt/srv/erpt_srv_report_impl.cpp @@ -46,19 +46,19 @@ namespace ams::erpt::srv { Result ReportImpl::Read(ams::sf::Out out_count, const ams::sf::OutBuffer &out_buffer) { R_UNLESS(m_report != nullptr, erpt::ResultNotInitialized()); - return m_report->Read(out_count.GetPointer(), static_cast(out_buffer.GetPointer()), static_cast(out_buffer.GetSize())); + R_RETURN(m_report->Read(out_count.GetPointer(), static_cast(out_buffer.GetPointer()), static_cast(out_buffer.GetSize()))); } Result ReportImpl::SetFlags(ReportFlagSet flags) { R_UNLESS(m_report != nullptr, erpt::ResultNotInitialized()); - return m_report->SetFlags(flags); + R_RETURN(m_report->SetFlags(flags)); } Result ReportImpl::GetFlags(ams::sf::Out out) { R_UNLESS(m_report != nullptr, erpt::ResultNotInitialized()); - return m_report->GetFlags(out.GetPointer()); + R_RETURN(m_report->GetFlags(out.GetPointer())); } Result ReportImpl::Close() { @@ -73,7 +73,7 @@ namespace ams::erpt::srv { Result ReportImpl::GetSize(ams::sf::Out out) { R_UNLESS(m_report != nullptr, erpt::ResultNotInitialized()); - return m_report->GetSize(out.GetPointer()); + R_RETURN(m_report->GetSize(out.GetPointer())); } } diff --git a/libraries/libstratosphere/source/erpt/srv/erpt_srv_reporter.cpp b/libraries/libstratosphere/source/erpt/srv/erpt_srv_reporter.cpp index 42a2a1150..2efa84820 100644 --- a/libraries/libstratosphere/source/erpt/srv/erpt_srv_reporter.cpp +++ b/libraries/libstratosphere/source/erpt/srv/erpt_srv_reporter.cpp @@ -422,7 +422,7 @@ namespace ams::erpt::srv { R_TRY(record->Initialize(ctx, data, data_size)); /* Create the report. */ - return CreateReport(type, ctx_result, std::move(record), meta, attachments, num_attachments); + R_RETURN(CreateReport(type, ctx_result, std::move(record), meta, attachments, num_attachments)); } Result Reporter::CreateReport(ReportType type, Result ctx_result, std::unique_ptr record, const ReportMetaData *meta, const AttachmentId *attachments, u32 num_attachments) { diff --git a/libraries/libstratosphere/source/erpt/srv/erpt_srv_service.cpp b/libraries/libstratosphere/source/erpt/srv/erpt_srv_service.cpp index e87334702..3df8b45eb 100644 --- a/libraries/libstratosphere/source/erpt/srv/erpt_srv_service.cpp +++ b/libraries/libstratosphere/source/erpt/srv/erpt_srv_service.cpp @@ -66,10 +66,10 @@ namespace ams::erpt::srv { { auto intf = ams::sf::ObjectFactory::CreateSharedEmplaced(std::addressof(g_sf_allocator)); AMS_ABORT_UNLESS(intf != nullptr); - return this->AcceptImpl(server, intf); + R_RETURN(this->AcceptImpl(server, intf)); } case PortIndex_Context: - return AcceptImpl(server, m_context_session_object.GetShared()); + R_RETURN(AcceptImpl(server, m_context_session_object.GetShared())); default: R_THROW(erpt::ResultNotSupported()); } @@ -144,7 +144,7 @@ namespace ams::erpt::srv { Result InitializeService() { util::ConstructAt(g_erpt_server_manager); - return util::GetReference(g_erpt_server_manager).Initialize(); + R_RETURN(util::GetReference(g_erpt_server_manager).Initialize()); } void WaitService() { diff --git a/libraries/libstratosphere/source/erpt/srv/erpt_srv_session_impl.cpp b/libraries/libstratosphere/source/erpt/srv/erpt_srv_session_impl.cpp index 06c655a95..0959aaf57 100644 --- a/libraries/libstratosphere/source/erpt/srv/erpt_srv_session_impl.cpp +++ b/libraries/libstratosphere/source/erpt/srv/erpt_srv_session_impl.cpp @@ -39,15 +39,15 @@ namespace ams::erpt::srv { } Result SessionImpl::OpenReport(ams::sf::Out> out) { - return OpenInterface(out); + R_RETURN((OpenInterface(out))); } Result SessionImpl::OpenManager(ams::sf::Out> out) { - return OpenInterface(out); + R_RETURN((OpenInterface(out))); } Result SessionImpl::OpenAttachment(ams::sf::Out> out) { - return OpenInterface(out); + R_RETURN((OpenInterface(out))); } } diff --git a/libraries/libstratosphere/source/erpt/srv/erpt_srv_stream.cpp b/libraries/libstratosphere/source/erpt/srv/erpt_srv_stream.cpp index d329b4557..35c0db843 100644 --- a/libraries/libstratosphere/source/erpt/srv/erpt_srv_stream.cpp +++ b/libraries/libstratosphere/source/erpt/srv/erpt_srv_stream.cpp @@ -28,7 +28,7 @@ namespace ams::erpt::srv { Result Stream::DeleteStream(const char *path) { R_UNLESS(s_can_access_fs, erpt::ResultInvalidPowerState()); - return fs::DeleteFile(path); + R_RETURN(fs::DeleteFile(path)); } Result Stream::CommitStream() { @@ -47,7 +47,7 @@ namespace ams::erpt::srv { R_TRY(fs::OpenFile(std::addressof(file), path, fs::OpenMode_Read)); ON_SCOPE_EXIT { fs::CloseFile(file); }; - return fs::GetFileSize(out, file); + R_RETURN(fs::GetFileSize(out, file)); } Stream::Stream() : m_buffer_size(0), m_file_position(0), m_buffer_count(0), m_buffer(nullptr), m_stream_mode(StreamMode_Invalid), m_initialized(false) { @@ -206,7 +206,7 @@ namespace ams::erpt::srv { } Result Stream::GetStreamSize(s64 *out) const { - return GetStreamSize(out, m_file_name); + R_RETURN(GetStreamSize(out, m_file_name)); } Result Stream::Flush() { diff --git a/libraries/libstratosphere/source/fs/common/fs_dbm_hierarchical_rom_file_table.cpp b/libraries/libstratosphere/source/fs/common/fs_dbm_hierarchical_rom_file_table.cpp index 3e3767563..cc72487bf 100644 --- a/libraries/libstratosphere/source/fs/common/fs_dbm_hierarchical_rom_file_table.cpp +++ b/libraries/libstratosphere/source/fs/common/fs_dbm_hierarchical_rom_file_table.cpp @@ -74,7 +74,7 @@ namespace ams::fs { .dir = InvalidPosition, .file = InvalidPosition, }; - return m_dir_table.Add(std::addressof(root_pos), root_key, root_entry); + R_RETURN(m_dir_table.Add(std::addressof(root_pos), root_key, root_entry)); } Result HierarchicalRomFileTable::CreateDirectory(RomDirectoryId *out, const RomPathChar *path, const DirectoryInfo &info) { @@ -213,7 +213,7 @@ namespace ams::fs { EntryKey key = {}; R_TRY(this->FindDirectoryRecursive(std::addressof(key), std::addressof(parent_entry), path)); - return this->GetDirectoryInformation(out, key); + R_RETURN(this->GetDirectoryInformation(out, key)); } Result HierarchicalRomFileTable::GetDirectoryInformation(DirectoryInfo *out, RomDirectoryId id) { @@ -235,7 +235,7 @@ namespace ams::fs { EntryKey key = {}; R_TRY(this->FindFileRecursive(std::addressof(key), std::addressof(parent_entry), path)); - return this->OpenFile(out, key); + R_RETURN(this->OpenFile(out, key)); } Result HierarchicalRomFileTable::OpenFile(FileInfo *out, RomFileId id) { @@ -256,7 +256,7 @@ namespace ams::fs { EntryKey key = {}; R_TRY(this->FindDirectoryRecursive(std::addressof(key), std::addressof(parent_entry), path)); - return this->FindOpen(out, key); + R_RETURN(this->FindOpen(out, key)); } Result HierarchicalRomFileTable::FindOpen(FindPosition *out, RomDirectoryId id) { @@ -442,7 +442,7 @@ namespace ams::fs { AMS_ASSERT(out_dir_entry != nullptr); AMS_ASSERT(path != nullptr); - return this->FindPathRecursive(out_key, out_dir_entry, true, path); + R_RETURN(this->FindPathRecursive(out_key, out_dir_entry, true, path)); } Result HierarchicalRomFileTable::FindFileRecursive(EntryKey *out_key, RomDirectoryEntry *out_dir_entry, const RomPathChar *path) { @@ -450,7 +450,7 @@ namespace ams::fs { AMS_ASSERT(out_dir_entry != nullptr); AMS_ASSERT(path != nullptr); - return this->FindPathRecursive(out_key, out_dir_entry, false, path); + R_RETURN(this->FindPathRecursive(out_key, out_dir_entry, false, path)); } Result HierarchicalRomFileTable::CheckSameEntryExists(const EntryKey &key, Result if_exists) { @@ -461,7 +461,7 @@ namespace ams::fs { const Result get_res = m_dir_table.Get(std::addressof(pos), std::addressof(entry), key); if (!fs::ResultDbmKeyNotFound::Includes(get_res)) { R_TRY(get_res); - return if_exists; + R_RETURN(if_exists); } } @@ -472,7 +472,7 @@ namespace ams::fs { const Result get_res = m_file_table.Get(std::addressof(pos), std::addressof(entry), key); if (!fs::ResultDbmKeyNotFound::Includes(get_res)) { R_TRY(get_res); - return if_exists; + R_RETURN(if_exists); } } R_SUCCEED(); @@ -491,7 +491,7 @@ namespace ams::fs { const Result file_res = m_file_table.Get(std::addressof(pos), std::addressof(entry), key); R_UNLESS(R_FAILED(file_res), fs::ResultDbmInvalidOperation()); R_UNLESS(!fs::ResultDbmKeyNotFound::Includes(file_res), fs::ResultDbmDirectoryNotFound()); - return file_res; + R_RETURN(file_res); } Result HierarchicalRomFileTable::GetDirectoryEntry(RomDirectoryEntry *out_entry, RomDirectoryId id) { @@ -507,7 +507,7 @@ namespace ams::fs { const Result file_res = m_file_table.GetByPosition(std::addressof(key), std::addressof(entry), pos); R_UNLESS(R_FAILED(file_res), fs::ResultDbmInvalidOperation()); R_UNLESS(!fs::ResultDbmKeyNotFound::Includes(file_res), fs::ResultDbmDirectoryNotFound()); - return file_res; + R_RETURN(file_res); } Result HierarchicalRomFileTable::GetFileEntry(Position *out_pos, RomFileEntry *out_entry, const EntryKey &key) { @@ -523,7 +523,7 @@ namespace ams::fs { const Result dir_res = m_dir_table.Get(std::addressof(pos), std::addressof(entry), key); R_UNLESS(R_FAILED(dir_res), fs::ResultDbmInvalidOperation()); R_UNLESS(!fs::ResultDbmKeyNotFound::Includes(dir_res), fs::ResultDbmFileNotFound()); - return dir_res; + R_RETURN(dir_res); } Result HierarchicalRomFileTable::GetFileEntry(RomFileEntry *out_entry, RomFileId id) { @@ -539,7 +539,7 @@ namespace ams::fs { const Result dir_res = m_dir_table.GetByPosition(std::addressof(key), std::addressof(entry), pos); R_UNLESS(R_FAILED(dir_res), fs::ResultDbmInvalidOperation()); R_UNLESS(!fs::ResultDbmKeyNotFound::Includes(dir_res), fs::ResultDbmFileNotFound()); - return dir_res; + R_RETURN(dir_res); } Result HierarchicalRomFileTable::GetDirectoryInformation(DirectoryInfo *out, const EntryKey &key) { diff --git a/libraries/libstratosphere/source/fs/common/fs_file_storage.cpp b/libraries/libstratosphere/source/fs/common/fs_file_storage.cpp index c96531416..816bd0a1a 100644 --- a/libraries/libstratosphere/source/fs/common/fs_file_storage.cpp +++ b/libraries/libstratosphere/source/fs/common/fs_file_storage.cpp @@ -19,7 +19,7 @@ namespace ams::fs { Result FileStorage::UpdateSize() { R_SUCCEED_IF(m_size != InvalidSize); - return m_base_file->GetSize(std::addressof(m_size)); + R_RETURN(m_base_file->GetSize(std::addressof(m_size))); } Result FileStorage::Read(s64 offset, void *buffer, size_t size) { @@ -36,7 +36,7 @@ namespace ams::fs { R_TRY(IStorage::CheckAccessRange(offset, size, m_size)); size_t read_size; - return m_base_file->Read(std::addressof(read_size), offset, buffer, size); + R_RETURN(m_base_file->Read(std::addressof(read_size), offset, buffer, size)); } Result FileStorage::Write(s64 offset, const void *buffer, size_t size) { @@ -52,11 +52,11 @@ namespace ams::fs { /* Ensure our access is valid. */ R_TRY(IStorage::CheckAccessRange(offset, size, m_size)); - return m_base_file->Write(offset, buffer, size, fs::WriteOption()); + R_RETURN(m_base_file->Write(offset, buffer, size, fs::WriteOption())); } Result FileStorage::Flush() { - return m_base_file->Flush(); + R_RETURN(m_base_file->Flush()); } Result FileStorage::GetSize(s64 *out_size) { @@ -67,7 +67,7 @@ namespace ams::fs { Result FileStorage::SetSize(s64 size) { m_size = InvalidSize; - return m_base_file->SetSize(size); + R_RETURN(m_base_file->SetSize(size)); } Result FileStorage::OperateRange(void *dst, size_t dst_size, OperationId op_id, s64 offset, s64 size, const void *src, size_t src_size) { @@ -105,7 +105,7 @@ namespace ams::fs { Result FileHandleStorage::UpdateSize() { R_SUCCEED_IF(m_size != InvalidSize); - return GetFileSize(std::addressof(m_size), m_handle); + R_RETURN(GetFileSize(std::addressof(m_size), m_handle)); } Result FileHandleStorage::Read(s64 offset, void *buffer, size_t size) { @@ -124,7 +124,7 @@ namespace ams::fs { /* Ensure our access is valid. */ R_TRY(IStorage::CheckAccessRange(offset, size, m_size)); - return ReadFile(m_handle, offset, buffer, size, fs::ReadOption()); + R_RETURN(ReadFile(m_handle, offset, buffer, size, fs::ReadOption())); } Result FileHandleStorage::Write(s64 offset, const void *buffer, size_t size) { @@ -143,11 +143,11 @@ namespace ams::fs { /* Ensure our access is valid. */ R_TRY(IStorage::CheckAccessRange(offset, size, m_size)); - return WriteFile(m_handle, offset, buffer, size, fs::WriteOption()); + R_RETURN(WriteFile(m_handle, offset, buffer, size, fs::WriteOption())); } Result FileHandleStorage::Flush() { - return FlushFile(m_handle); + R_RETURN(FlushFile(m_handle)); } Result FileHandleStorage::GetSize(s64 *out_size) { @@ -158,7 +158,7 @@ namespace ams::fs { Result FileHandleStorage::SetSize(s64 size) { m_size = InvalidSize; - return SetFileSize(m_handle, size); + R_RETURN(SetFileSize(m_handle, size)); } Result FileHandleStorage::OperateRange(void *dst, size_t dst_size, OperationId op_id, s64 offset, s64 size, const void *src, size_t src_size) { @@ -170,7 +170,7 @@ namespace ams::fs { R_UNLESS(dst != nullptr, fs::ResultNullptrArgument()); R_UNLESS(dst_size == sizeof(QueryRangeInfo), fs::ResultInvalidSize()); - return QueryRange(static_cast(dst), m_handle, offset, size); + R_RETURN(QueryRange(static_cast(dst), m_handle, offset, size)); default: R_THROW(fs::ResultUnsupportedOperateRangeForFileHandleStorage()); } diff --git a/libraries/libstratosphere/source/fs/fs_bis.cpp b/libraries/libstratosphere/source/fs/fs_bis.cpp index bea6b875a..969df0527 100644 --- a/libraries/libstratosphere/source/fs/fs_bis.cpp +++ b/libraries/libstratosphere/source/fs/fs_bis.cpp @@ -103,11 +103,11 @@ namespace ams::fs { } Result MountBis(BisPartitionId id, const char *root_path) { - return impl::MountBisImpl(GetBisMountName(id), id, root_path); + R_RETURN(impl::MountBisImpl(GetBisMountName(id), id, root_path)); } Result MountBis(const char *name, BisPartitionId id) { - return impl::MountBisImpl(name, id, nullptr); + R_RETURN(impl::MountBisImpl(name, id, nullptr)); } void SetBisRootForHost(BisPartitionId id, const char *root_path) { diff --git a/libraries/libstratosphere/source/fs/fs_content_storage.cpp b/libraries/libstratosphere/source/fs/fs_content_storage.cpp index d9722fab6..de6f2e60a 100644 --- a/libraries/libstratosphere/source/fs/fs_content_storage.cpp +++ b/libraries/libstratosphere/source/fs/fs_content_storage.cpp @@ -54,7 +54,7 @@ namespace ams::fs { } Result MountContentStorage(ContentStorageId id) { - return MountContentStorage(GetContentStorageMountName(id), id); + R_RETURN(MountContentStorage(GetContentStorageMountName(id), id)); } Result MountContentStorage(const char *name, ContentStorageId id) { diff --git a/libraries/libstratosphere/source/fs/fs_data.cpp b/libraries/libstratosphere/source/fs/fs_data.cpp index 44382e3dc..c6df940dc 100644 --- a/libraries/libstratosphere/source/fs/fs_data.cpp +++ b/libraries/libstratosphere/source/fs/fs_data.cpp @@ -50,7 +50,7 @@ namespace ams::fs::impl { R_UNLESS(fs != nullptr, fs::ResultAllocationMemoryFailedInDataB()); R_TRY(fs->Initialize(std::move(storage), cache_buffer, cache_size, use_cache)); - return fsa::Register(name, std::move(fs), nullptr, use_data_cache, use_path_cache, false); + R_RETURN(fsa::Register(name, std::move(fs), nullptr, use_data_cache, use_path_cache, false)); } } @@ -73,7 +73,7 @@ namespace ams::fs::impl { /* Validate the mount name. */ AMS_FS_R_TRY(impl::CheckMountName(name)); - return MountDataImpl(name, data_id, storage_id, nullptr, 0, false, false, false); + R_RETURN(MountDataImpl(name, data_id, storage_id, nullptr, 0, false, false, false)); } Result MountData(const char *name, ncm::DataId data_id, ncm::StorageId storage_id, void *cache_buffer, size_t cache_size) { @@ -82,7 +82,7 @@ namespace ams::fs::impl { AMS_FS_R_UNLESS(cache_buffer != nullptr, fs::ResultNullptrArgument()); - return MountDataImpl(name, data_id, storage_id, cache_buffer, cache_size, true, false, false); + R_RETURN(MountDataImpl(name, data_id, storage_id, cache_buffer, cache_size, true, false, false)); } Result MountData(const char *name, ncm::DataId data_id, ncm::StorageId storage_id, void *cache_buffer, size_t cache_size, bool use_data_cache, bool use_path_cache) { @@ -91,7 +91,7 @@ namespace ams::fs::impl { AMS_FS_R_UNLESS(cache_buffer != nullptr, fs::ResultNullptrArgument()); - return MountDataImpl(name, data_id, storage_id, cache_buffer, cache_size, true, use_data_cache, use_path_cache); + R_RETURN(MountDataImpl(name, data_id, storage_id, cache_buffer, cache_size, true, use_data_cache, use_path_cache)); } } diff --git a/libraries/libstratosphere/source/fs/fs_device_save_data.cpp b/libraries/libstratosphere/source/fs/fs_device_save_data.cpp index b5e23b838..cf0a0611c 100644 --- a/libraries/libstratosphere/source/fs/fs_device_save_data.cpp +++ b/libraries/libstratosphere/source/fs/fs_device_save_data.cpp @@ -38,7 +38,7 @@ namespace ams::fs { R_UNLESS(fsa != nullptr, fs::ResultAllocationMemoryFailedInDeviceSaveDataA()); /* Register. */ - return fsa::Register(name, std::move(fsa)); + R_RETURN(fsa::Register(name, std::move(fsa))); } } diff --git a/libraries/libstratosphere/source/fs/fs_filesystem_utils.cpp b/libraries/libstratosphere/source/fs/fs_filesystem_utils.cpp index 8dc6180a2..dd073fc02 100644 --- a/libraries/libstratosphere/source/fs/fs_filesystem_utils.cpp +++ b/libraries/libstratosphere/source/fs/fs_filesystem_utils.cpp @@ -30,7 +30,7 @@ namespace ams::fs { R_TRY(accessor->SetUpPath(std::addressof(sub_fs_path), sub_path)); /* Use the system implementation. */ - return fssystem::EnsureDirectory(accessor->GetRawFileSystemUnsafe(), sub_fs_path); + R_RETURN(fssystem::EnsureDirectory(accessor->GetRawFileSystemUnsafe(), sub_fs_path)); } Result EnsureParentDirectory(const char *path) { @@ -47,7 +47,7 @@ namespace ams::fs { R_TRY(sub_fs_path.RemoveChild()); /* Use the system implementation. */ - return fssystem::EnsureDirectory(accessor->GetRawFileSystemUnsafe(), sub_fs_path); + R_RETURN(fssystem::EnsureDirectory(accessor->GetRawFileSystemUnsafe(), sub_fs_path)); } Result HasFile(bool *out, const char *path) { @@ -60,7 +60,7 @@ namespace ams::fs { fs::Path sub_fs_path; R_TRY(accessor->SetUpPath(std::addressof(sub_fs_path), sub_path)); - return fssystem::HasFile(out, accessor->GetRawFileSystemUnsafe(), sub_fs_path); + R_RETURN(fssystem::HasFile(out, accessor->GetRawFileSystemUnsafe(), sub_fs_path)); } Result HasDirectory(bool *out, const char *path) { @@ -73,7 +73,7 @@ namespace ams::fs { fs::Path sub_fs_path; R_TRY(accessor->SetUpPath(std::addressof(sub_fs_path), sub_path)); - return fssystem::HasDirectory(out, accessor->GetRawFileSystemUnsafe(), sub_fs_path); + R_RETURN(fssystem::HasDirectory(out, accessor->GetRawFileSystemUnsafe(), sub_fs_path)); } } diff --git a/libraries/libstratosphere/source/fs/fs_romfs_filesystem.cpp b/libraries/libstratosphere/source/fs/fs_romfs_filesystem.cpp index 85e7c6bba..a52b57144 100644 --- a/libraries/libstratosphere/source/fs/fs_romfs_filesystem.cpp +++ b/libraries/libstratosphere/source/fs/fs_romfs_filesystem.cpp @@ -95,7 +95,7 @@ namespace ams::fs { Result ConvertFatFileSystemCorruptedResult(Result res) { AMS_ASSERT(fs::ResultFatFileSystemCorrupted::Includes(res)); - return res; + R_RETURN(res); } Result ConvertHostFileSystemCorruptedResult(Result res) { @@ -149,14 +149,14 @@ namespace ams::fs { AMS_ASSERT(offset >= 0); AMS_ASSERT(buffer != nullptr || size == 0); - return ConvertRomFsResult(storage->Read(offset, buffer, size)); + R_RETURN(ConvertRomFsResult(storage->Read(offset, buffer, size))); } Result ReadFileHeader(IStorage *storage, RomFileSystemInformation *out) { AMS_ASSERT(storage != nullptr); AMS_ASSERT(out != nullptr); - return ReadFile(storage, 0, out, sizeof(*out)); + R_RETURN(ReadFile(storage, 0, out, sizeof(*out))); } constexpr size_t CalculateRequiredWorkingMemorySize(const RomFileSystemInformation &header) { @@ -185,7 +185,7 @@ namespace ams::fs { } Result ConvertResult(Result res) const { - return ConvertRomFsResult(res); + R_RETURN(ConvertRomFsResult(res)); } s64 GetOffset() const { @@ -242,7 +242,7 @@ namespace ams::fs { operate_size = this->GetSize() - offset; } - return this->GetStorage()->OperateRange(dst, dst_size, op_id, m_start + offset, operate_size, src, src_size); + R_RETURN(this->GetStorage()->OperateRange(dst, dst_size, op_id, m_start + offset, operate_size, src, src_size)); } default: R_THROW(fs::ResultUnsupportedOperateRangeForRomFsFile()); @@ -267,12 +267,12 @@ namespace ams::fs { virtual ~RomFsDirectory() override { /* ... */ } public: virtual Result DoRead(s64 *out_count, DirectoryEntry *out_entries, s64 max_entries) override { - return this->ReadInternal(out_count, std::addressof(m_current_find), out_entries, max_entries); + R_RETURN(this->ReadInternal(out_count, std::addressof(m_current_find), out_entries, max_entries)); } virtual Result DoGetEntryCount(s64 *out) override { FindPosition find = m_first_find; - return this->ReadInternal(out, std::addressof(find), nullptr, 0); + R_RETURN(this->ReadInternal(out, std::addressof(find), nullptr, 0)); } private: Result ReadInternal(s64 *out_count, FindPosition *find, DirectoryEntry *out_entries, s64 max_entries) { @@ -416,7 +416,7 @@ namespace ams::fs { Result RomFsFileSystem::Initialize(std::unique_ptr&& base, void *work, size_t work_size, bool use_cache) { m_unique_storage = std::move(base); - return this->Initialize(m_unique_storage.get(), work, work_size, use_cache); + R_RETURN(this->Initialize(m_unique_storage.get(), work, work_size, use_cache)); } Result RomFsFileSystem::GetFileInfo(RomFileTable::FileInfo *out, const char *path) { diff --git a/libraries/libstratosphere/source/fs/fs_save_data_management.cpp b/libraries/libstratosphere/source/fs/fs_save_data_management.cpp index ce8f7f79f..0e9bdeb1a 100644 --- a/libraries/libstratosphere/source/fs/fs_save_data_management.cpp +++ b/libraries/libstratosphere/source/fs/fs_save_data_management.cpp @@ -68,23 +68,23 @@ namespace ams::fs { } Result CreateSystemSaveData(SystemSaveDataId save_id, s64 size, s64 journal_size, u32 flags) { - return CreateSystemSaveData(SaveDataSpaceId::System, save_id, InvalidUserId, 0, size, journal_size, flags); + R_RETURN(CreateSystemSaveData(SaveDataSpaceId::System, save_id, InvalidUserId, 0, size, journal_size, flags)); } Result CreateSystemSaveData(SystemSaveDataId save_id, u64 owner_id, s64 size, s64 journal_size, u32 flags) { - return CreateSystemSaveData(SaveDataSpaceId::System, save_id, InvalidUserId, owner_id, size, journal_size, flags); + R_RETURN(CreateSystemSaveData(SaveDataSpaceId::System, save_id, InvalidUserId, owner_id, size, journal_size, flags)); } Result CreateSystemSaveData(SaveDataSpaceId space_id, SystemSaveDataId save_id, u64 owner_id, s64 size, s64 journal_size, u32 flags) { - return CreateSystemSaveData(space_id, save_id, InvalidUserId, owner_id, size, journal_size, flags); + R_RETURN(CreateSystemSaveData(space_id, save_id, InvalidUserId, owner_id, size, journal_size, flags)); } Result CreateSystemSaveData(SystemSaveDataId save_id, UserId user_id, s64 size, s64 journal_size, u32 flags) { - return CreateSystemSaveData(SaveDataSpaceId::System, save_id, user_id, 0, size, journal_size, flags); + R_RETURN(CreateSystemSaveData(SaveDataSpaceId::System, save_id, user_id, 0, size, journal_size, flags)); } Result CreateSystemSaveData(SystemSaveDataId save_id, UserId user_id, u64 owner_id, s64 size, s64 journal_size, u32 flags) { - return CreateSystemSaveData(SaveDataSpaceId::System, save_id, user_id, owner_id, size, journal_size, flags); + R_RETURN(CreateSystemSaveData(SaveDataSpaceId::System, save_id, user_id, owner_id, size, journal_size, flags)); } Result DeleteSaveData(SaveDataId id) { @@ -139,7 +139,7 @@ namespace ams::fs { SaveDataExtraData extra_data; R_TRY(impl::ReadSaveDataFileSystemExtraData(std::addressof(extra_data), space_id, id)); extra_data.flags = flags; - return impl::WriteSaveDataFileSystemExtraData(space_id, id, extra_data); + R_RETURN(impl::WriteSaveDataFileSystemExtraData(space_id, id, extra_data)); } Result GetSaveDataAvailableSize(s64 *out, SaveDataId id) { diff --git a/libraries/libstratosphere/source/fs/fs_sd_card.cpp b/libraries/libstratosphere/source/fs/fs_sd_card.cpp index a4dd456cb..a1e5964ef 100644 --- a/libraries/libstratosphere/source/fs/fs_sd_card.cpp +++ b/libraries/libstratosphere/source/fs/fs_sd_card.cpp @@ -66,7 +66,7 @@ namespace ams::fs { R_UNLESS(generator != nullptr, fs::ResultAllocationMemoryFailedInSdCardA()); /* Register. */ - return fsa::Register(name, std::move(fsa), std::move(generator)); + R_RETURN(fsa::Register(name, std::move(fsa), std::move(generator))); } Result MountSdCardErrorReportDirectoryForAtmosphere(const char *name) { @@ -92,7 +92,7 @@ namespace ams::fs { R_TRY(subdir_fs->Initialize(fs_path)); /* Register. */ - return fsa::Register(name, std::move(subdir_fs)); + R_RETURN(fsa::Register(name, std::move(subdir_fs))); } Result OpenSdCardDetectionEventNotifier(std::unique_ptr *out) { diff --git a/libraries/libstratosphere/source/fs/fs_system_save_data.cpp b/libraries/libstratosphere/source/fs/fs_system_save_data.cpp index 6f89b5cf9..1cae025d4 100644 --- a/libraries/libstratosphere/source/fs/fs_system_save_data.cpp +++ b/libraries/libstratosphere/source/fs/fs_system_save_data.cpp @@ -21,15 +21,15 @@ namespace ams::fs { Result MountSystemSaveData(const char *name, SystemSaveDataId id) { - return MountSystemSaveData(name, id, InvalidUserId); + R_RETURN(MountSystemSaveData(name, id, InvalidUserId)); } Result MountSystemSaveData(const char *name, SaveDataSpaceId space_id, SystemSaveDataId id) { - return MountSystemSaveData(name, space_id, id, InvalidUserId); + R_RETURN(MountSystemSaveData(name, space_id, id, InvalidUserId)); } Result MountSystemSaveData(const char *name, SystemSaveDataId id, UserId user_id) { - return MountSystemSaveData(name, SaveDataSpaceId::System, id, user_id); + R_RETURN(MountSystemSaveData(name, SaveDataSpaceId::System, id, user_id)); } Result MountSystemSaveData(const char *name, SaveDataSpaceId space_id, SystemSaveDataId id, UserId user_id) { @@ -50,7 +50,7 @@ namespace ams::fs { R_UNLESS(fsa != nullptr, fs::ResultAllocationMemoryFailedInSystemSaveDataA()); /* Register. */ - return fsa::Register(name, std::move(fsa)); + R_RETURN(fsa::Register(name, std::move(fsa))); }; AMS_FS_R_TRY(AMS_FS_IMPL_ACCESS_LOG_SYSTEM_MOUNT(mount_impl(), name, AMS_FS_IMPL_ACCESS_LOG_FORMAT_MOUNT_SYSTEM_SAVE_DATA(name, space_id, id, user_id))); diff --git a/libraries/libstratosphere/source/fs/fsa/fs_directory_accessor.cpp b/libraries/libstratosphere/source/fs/fsa/fs_directory_accessor.cpp index 632d53920..fd86a5320 100644 --- a/libraries/libstratosphere/source/fs/fsa/fs_directory_accessor.cpp +++ b/libraries/libstratosphere/source/fs/fsa/fs_directory_accessor.cpp @@ -29,11 +29,11 @@ namespace ams::fs::impl { } Result DirectoryAccessor::Read(s64 *out_count, DirectoryEntry *out_entries, s64 max_entries) { - return m_impl->Read(out_count, out_entries, max_entries); + R_RETURN(m_impl->Read(out_count, out_entries, max_entries)); } Result DirectoryAccessor::GetEntryCount(s64 *out) { - return m_impl->GetEntryCount(out); + R_RETURN(m_impl->GetEntryCount(out)); } } diff --git a/libraries/libstratosphere/source/fs/fsa/fs_file_accessor.cpp b/libraries/libstratosphere/source/fs/fsa/fs_file_accessor.cpp index a5148796d..fc8ab265d 100644 --- a/libraries/libstratosphere/source/fs/fsa/fs_file_accessor.cpp +++ b/libraries/libstratosphere/source/fs/fsa/fs_file_accessor.cpp @@ -46,7 +46,7 @@ namespace ams::fs::impl { } Result FileAccessor::ReadWithoutCacheAccessLog(size_t *out, s64 offset, void *buf, size_t size, const ReadOption &option) { - return m_impl->Read(out, offset, buf, size, option); + R_RETURN(m_impl->Read(out, offset, buf, size, option)); } Result FileAccessor::Read(size_t *out, s64 offset, void *buf, size_t size, const ReadOption &option) { @@ -62,9 +62,9 @@ namespace ams::fs::impl { if (use_path_cache && use_data_cache && false) { /* TODO */ - return this->ReadWithCacheAccessLog(out, offset, buf, size, option, use_path_cache, use_data_cache); + R_RETURN(this->ReadWithCacheAccessLog(out, offset, buf, size, option, use_path_cache, use_data_cache)); } else { - return AMS_FS_IMPL_ACCESS_LOG_WITH_NAME(this->ReadWithoutCacheAccessLog(out, offset, buf, size, option), handle, "ReadFile", AMS_FS_IMPL_ACCESS_LOG_FORMAT_READ_FILE(out, offset, size)); + R_RETURN(AMS_FS_IMPL_ACCESS_LOG_WITH_NAME(this->ReadWithoutCacheAccessLog(out, offset, buf, size, option), handle, "ReadFile", AMS_FS_IMPL_ACCESS_LOG_FORMAT_READ_FILE(out, offset, size))); } } @@ -117,11 +117,11 @@ namespace ams::fs::impl { /* Fail after a write fails. */ R_TRY(m_write_result); - return m_impl->GetSize(out); + R_RETURN(m_impl->GetSize(out)); } Result FileAccessor::OperateRange(void *dst, size_t dst_size, OperationId operation, s64 offset, s64 size, const void *src, size_t src_size) { - return m_impl->OperateRange(dst, dst_size, operation, offset, size, src, src_size); + R_RETURN(m_impl->OperateRange(dst, dst_size, operation, offset, size, src, src_size)); } } \ No newline at end of file diff --git a/libraries/libstratosphere/source/fs/fsa/fs_file_accessor.hpp b/libraries/libstratosphere/source/fs/fsa/fs_file_accessor.hpp index a40bad582..3b293feb8 100644 --- a/libraries/libstratosphere/source/fs/fsa/fs_file_accessor.hpp +++ b/libraries/libstratosphere/source/fs/fsa/fs_file_accessor.hpp @@ -61,7 +61,7 @@ namespace ams::fs::impl { if (!fs::ResultNotEnoughFreeSpace::Includes(r)) { m_write_result = r; } - return r; + R_RETURN(r); } }; diff --git a/libraries/libstratosphere/source/fs/fsa/fs_mount_utils.cpp b/libraries/libstratosphere/source/fs/fsa/fs_mount_utils.cpp index 747f2d49a..74be6c492 100644 --- a/libraries/libstratosphere/source/fs/fsa/fs_mount_utils.cpp +++ b/libraries/libstratosphere/source/fs/fsa/fs_mount_utils.cpp @@ -125,7 +125,7 @@ namespace ams::fs::impl { MountName mount_name; R_TRY(GetMountNameAndSubPath(std::addressof(mount_name), out_sub_path, path)); - return impl::Find(out_accessor, mount_name.str); + R_RETURN(impl::Find(out_accessor, mount_name.str)); } Result Unmount(const char *name) { diff --git a/libraries/libstratosphere/source/fs/fsa/fs_registrar.cpp b/libraries/libstratosphere/source/fs/fsa/fs_registrar.cpp index 551e9ef1b..876cb4063 100644 --- a/libraries/libstratosphere/source/fs/fsa/fs_registrar.cpp +++ b/libraries/libstratosphere/source/fs/fsa/fs_registrar.cpp @@ -23,14 +23,14 @@ namespace ams::fs::fsa { auto accessor = std::make_unique(name, std::move(fs)); R_UNLESS(accessor != nullptr, fs::ResultAllocationMemoryFailedInRegisterA()); - return impl::Register(std::move(accessor)); + R_RETURN(impl::Register(std::move(accessor))); } Result Register(const char *name, std::unique_ptr &&fs, std::unique_ptr &&generator) { auto accessor = std::make_unique(name, std::move(fs), std::move(generator)); R_UNLESS(accessor != nullptr, fs::ResultAllocationMemoryFailedInRegisterB()); - return impl::Register(std::move(accessor)); + R_RETURN(impl::Register(std::move(accessor))); } Result Register(const char *name, std::unique_ptr &&fs, std::unique_ptr &&generator, bool use_data_cache, bool use_path_cache, bool support_multi_commit) { @@ -41,7 +41,7 @@ namespace ams::fs::fsa { accessor->SetPathBasedFileDataCacheAttachable(use_path_cache); accessor->SetMultiCommitSupported(support_multi_commit); - return impl::Register(std::move(accessor)); + R_RETURN(impl::Register(std::move(accessor))); } void Unregister(const char *name) { diff --git a/libraries/libstratosphere/source/fs/fsa/fs_user_filesystem.cpp b/libraries/libstratosphere/source/fs/fsa/fs_user_filesystem.cpp index 34b72ac46..ec3732cee 100644 --- a/libraries/libstratosphere/source/fs/fsa/fs_user_filesystem.cpp +++ b/libraries/libstratosphere/source/fs/fsa/fs_user_filesystem.cpp @@ -23,7 +23,7 @@ namespace ams::fs { Result CreateFile(const char *path, s64 size) { - return CreateFile(path, size, 0); + R_RETURN(CreateFile(path, size, 0)); } Result CreateFile(const char* path, s64 size, int option) { @@ -220,11 +220,11 @@ namespace ams::fs { } Result Commit(const char *mount_name) { - return CommitImpl(mount_name, AMS_CURRENT_FUNCTION_NAME); + R_RETURN(CommitImpl(mount_name, AMS_CURRENT_FUNCTION_NAME)); } Result CommitSaveData(const char *mount_name) { - return CommitImpl(mount_name, AMS_CURRENT_FUNCTION_NAME); + R_RETURN(CommitImpl(mount_name, AMS_CURRENT_FUNCTION_NAME)); } } diff --git a/libraries/libstratosphere/source/fs/fsa/fs_user_mount_table.cpp b/libraries/libstratosphere/source/fs/fsa/fs_user_mount_table.cpp index 1b8f88b92..d81ed9772 100644 --- a/libraries/libstratosphere/source/fs/fsa/fs_user_mount_table.cpp +++ b/libraries/libstratosphere/source/fs/fsa/fs_user_mount_table.cpp @@ -27,11 +27,11 @@ namespace ams::fs::impl { } Result Register(std::unique_ptr &&fs) { - return g_mount_table.Mount(std::move(fs)); + R_RETURN(g_mount_table.Mount(std::move(fs))); } Result Find(FileSystemAccessor **out, const char *name) { - return g_mount_table.Find(out, name); + R_RETURN(g_mount_table.Find(out, name)); } void Unregister(const char *name) { diff --git a/libraries/libstratosphere/source/fssrv/fscreator/fssrv_rom_file_system_creator.cpp b/libraries/libstratosphere/source/fssrv/fscreator/fssrv_rom_file_system_creator.cpp index 1abe1dff4..61720a1e6 100644 --- a/libraries/libstratosphere/source/fssrv/fscreator/fssrv_rom_file_system_creator.cpp +++ b/libraries/libstratosphere/source/fssrv/fscreator/fssrv_rom_file_system_creator.cpp @@ -37,18 +37,18 @@ namespace ams::fssrv::fscreator { /* Check if the buffer is eligible for cache. */ size_t buffer_size = 0; if (R_FAILED(RomFsFileSystem::GetRequiredWorkingMemorySize(std::addressof(buffer_size), storage.get())) || buffer_size == 0 || buffer_size >= 128_KB) { - return RomFsFileSystem::Initialize(std::move(storage), nullptr, 0, false); + R_RETURN(RomFsFileSystem::Initialize(std::move(storage), nullptr, 0, false)); } /* Allocate a buffer. */ m_meta_cache_buffer = m_allocator->Allocate(buffer_size); if (m_meta_cache_buffer == nullptr) { - return RomFsFileSystem::Initialize(std::move(storage), nullptr, 0, false); + R_RETURN(RomFsFileSystem::Initialize(std::move(storage), nullptr, 0, false)); } /* Initialize with cache buffer. */ m_meta_cache_buffer_size = buffer_size; - return RomFsFileSystem::Initialize(std::move(storage), m_meta_cache_buffer, m_meta_cache_buffer_size, true); + R_RETURN(RomFsFileSystem::Initialize(std::move(storage), m_meta_cache_buffer, m_meta_cache_buffer_size, true)); } }; diff --git a/libraries/libstratosphere/source/fssrv/fssrv_file_system_proxy_api.cpp b/libraries/libstratosphere/source/fssrv/fssrv_file_system_proxy_api.cpp index 030d5760d..06b526664 100644 --- a/libraries/libstratosphere/source/fssrv/fssrv_file_system_proxy_api.cpp +++ b/libraries/libstratosphere/source/fssrv/fssrv_file_system_proxy_api.cpp @@ -51,39 +51,28 @@ namespace ams::fssrv { switch (port_index) { case PortIndex_FileSystemProxy: { - return this->AcceptImpl(server, impl::GetFileSystemProxyServiceObject()); + R_RETURN(this->AcceptImpl(server, impl::GetFileSystemProxyServiceObject())); } - break; case PortIndex_ProgramRegistry: { if (os::TryAcquireSemaphore(std::addressof(g_semaphore_for_program_registry))) { - auto sema_guard = SCOPE_GUARD { os::ReleaseSemaphore(std::addressof(g_semaphore_for_program_registry)); }; + ON_RESULT_FAILURE { os::ReleaseSemaphore(std::addressof(g_semaphore_for_program_registry)); }; - R_TRY(this->AcceptImpl(server, impl::GetProgramRegistryServiceObject())); - - sema_guard.Cancel(); + R_RETURN(this->AcceptImpl(server, impl::GetProgramRegistryServiceObject())); } else { - R_TRY(this->AcceptImpl(server, impl::GetInvalidProgramRegistryServiceObject())); + R_RETURN(this->AcceptImpl(server, impl::GetInvalidProgramRegistryServiceObject())); } - - R_SUCCEED(); } - break; case PortIndex_FileSystemProxyForLoader: { if (os::TryAcquireSemaphore(std::addressof(g_semaphore_for_file_system_proxy_for_loader))) { - auto sema_guard = SCOPE_GUARD { os::ReleaseSemaphore(std::addressof(g_semaphore_for_file_system_proxy_for_loader)); }; + ON_RESULT_FAILURE { os::ReleaseSemaphore(std::addressof(g_semaphore_for_file_system_proxy_for_loader)); }; - R_TRY(this->AcceptImpl(server, impl::GetFileSystemProxyForLoaderServiceObject())); - - sema_guard.Cancel(); + R_RETURN(this->AcceptImpl(server, impl::GetFileSystemProxyForLoaderServiceObject())); } else { - R_TRY(this->AcceptImpl(server, impl::GetInvalidFileSystemProxyForLoaderServiceObject())); + R_RETURN(this->AcceptImpl(server, impl::GetInvalidFileSystemProxyForLoaderServiceObject())); } - - R_SUCCEED(); } - break; AMS_UNREACHABLE_DEFAULT_CASE(); } } diff --git a/libraries/libstratosphere/source/fssrv/fssrv_program_registry_impl.cpp b/libraries/libstratosphere/source/fssrv/fssrv_program_registry_impl.cpp index 32dea0cf2..2029ce740 100644 --- a/libraries/libstratosphere/source/fssrv/fssrv_program_registry_impl.cpp +++ b/libraries/libstratosphere/source/fssrv/fssrv_program_registry_impl.cpp @@ -53,7 +53,7 @@ namespace ams::fssrv { R_UNLESS(desc.GetSize() >= static_cast(desc_size), fs::ResultInvalidSize()); /* Register the program. */ - return g_impl->RegisterProgramInfo(process_id, program_id, storage_id, data.GetPointer(), data_size, desc.GetPointer(), desc_size); + R_RETURN(g_impl->RegisterProgramInfo(process_id, program_id, storage_id, data.GetPointer(), data_size, desc.GetPointer(), desc_size)); } Result ProgramRegistryImpl::UnregisterProgram(u64 process_id) { @@ -64,7 +64,7 @@ namespace ams::fssrv { R_UNLESS(fssrv::impl::IsInitialProgram(m_process_id), fs::ResultPermissionDenied()); /* Unregister the program. */ - return g_impl->UnregisterProgramInfo(process_id); + R_RETURN(g_impl->UnregisterProgramInfo(process_id)); } Result ProgramRegistryImpl::SetCurrentProcess(const ams::sf::ClientProcessId &client_pid) { diff --git a/libraries/libstratosphere/source/fssrv/fssrv_program_registry_service.cpp b/libraries/libstratosphere/source/fssrv/fssrv_program_registry_service.cpp index 6963822db..d721a7595 100644 --- a/libraries/libstratosphere/source/fssrv/fssrv_program_registry_service.cpp +++ b/libraries/libstratosphere/source/fssrv/fssrv_program_registry_service.cpp @@ -20,23 +20,23 @@ namespace ams::fssrv { Result ProgramRegistryServiceImpl::RegisterProgramInfo(u64 process_id, u64 program_id, u8 storage_id, const void *data, s64 data_size, const void *desc, s64 desc_size) { - return m_registry_manager->RegisterProgram(process_id, program_id, storage_id, data, data_size, desc, desc_size); + R_RETURN(m_registry_manager->RegisterProgram(process_id, program_id, storage_id, data, data_size, desc, desc_size)); } Result ProgramRegistryServiceImpl::UnregisterProgramInfo(u64 process_id) { - return m_registry_manager->UnregisterProgram(process_id); + R_RETURN(m_registry_manager->UnregisterProgram(process_id)); } Result ProgramRegistryServiceImpl::ResetProgramIndexMapInfo(const fs::ProgramIndexMapInfo *infos, int count) { - return m_index_map_info_manager->Reset(infos, count); + R_RETURN(m_index_map_info_manager->Reset(infos, count)); } Result ProgramRegistryServiceImpl::GetProgramInfo(std::shared_ptr *out, u64 process_id) { - return m_registry_manager->GetProgramInfo(out, process_id); + R_RETURN(m_registry_manager->GetProgramInfo(out, process_id)); } Result ProgramRegistryServiceImpl::GetProgramInfoByProgramId(std::shared_ptr *out, u64 program_id) { - return m_registry_manager->GetProgramInfoByProgramId(out, program_id); + R_RETURN(m_registry_manager->GetProgramInfoByProgramId(out, program_id)); } size_t ProgramRegistryServiceImpl::GetProgramIndexMapInfoCount() { diff --git a/libraries/libstratosphere/source/fssystem/fssystem_aes_ctr_counter_extended_storage.cpp b/libraries/libstratosphere/source/fssystem/fssystem_aes_ctr_counter_extended_storage.cpp index a31f0c5be..d11455167 100644 --- a/libraries/libstratosphere/source/fssystem/fssystem_aes_ctr_counter_extended_storage.cpp +++ b/libraries/libstratosphere/source/fssystem/fssystem_aes_ctr_counter_extended_storage.cpp @@ -76,7 +76,7 @@ namespace ams::fssystem { R_TRY(CreateSoftwareDecryptor(std::addressof(sw_decryptor))); /* Initialize. */ - return this->Initialize(allocator, key, key_size, secure_value, 0, data_storage, fs::SubStorage(std::addressof(table_storage), node_storage_offset, node_storage_size), fs::SubStorage(std::addressof(table_storage), entry_storage_offset, entry_storage_size), header.entry_count, std::move(sw_decryptor)); + R_RETURN(this->Initialize(allocator, key, key_size, secure_value, 0, data_storage, fs::SubStorage(std::addressof(table_storage), node_storage_offset, node_storage_size), fs::SubStorage(std::addressof(table_storage), entry_storage_offset, entry_storage_size), header.entry_count, std::move(sw_decryptor))); } Result AesCtrCounterExtendedStorage::Initialize(IAllocator *allocator, const void *key, size_t key_size, u32 secure_value, s64 counter_offset, fs::SubStorage data_storage, fs::SubStorage node_storage, fs::SubStorage entry_storage, s32 entry_count, std::unique_ptr &&decryptor) { diff --git a/libraries/libstratosphere/source/fssystem/fssystem_aes_ctr_storage.cpp b/libraries/libstratosphere/source/fssystem/fssystem_aes_ctr_storage.cpp index 1d03def5f..06e7275ba 100644 --- a/libraries/libstratosphere/source/fssystem/fssystem_aes_ctr_storage.cpp +++ b/libraries/libstratosphere/source/fssystem/fssystem_aes_ctr_storage.cpp @@ -129,7 +129,7 @@ namespace ams::fssystem { template Result AesCtrStorage::Flush() { - return m_base_storage->Flush(); + R_RETURN(m_base_storage->Flush()); } template @@ -140,7 +140,7 @@ namespace ams::fssystem { template Result AesCtrStorage::GetSize(s64 *out) { - return m_base_storage->GetSize(out); + R_RETURN(m_base_storage->GetSize(out)); } template diff --git a/libraries/libstratosphere/source/fssystem/fssystem_block_cache_buffered_storage.cpp b/libraries/libstratosphere/source/fssystem/fssystem_block_cache_buffered_storage.cpp index 8a4418d6f..90654ad09 100644 --- a/libraries/libstratosphere/source/fssystem/fssystem_block_cache_buffered_storage.cpp +++ b/libraries/libstratosphere/source/fssystem/fssystem_block_cache_buffered_storage.cpp @@ -191,7 +191,7 @@ namespace ams::fssystem { if (!entry.is_cached) { if (const Result result = m_data_storage->Read(entry.range.offset, src, entry.range.size); R_FAILED(result)) { m_block_cache_manager.ReleaseCacheEntry(std::addressof(entry), range); - return this->UpdateLastResult(result); + R_RETURN(this->UpdateLastResult(result)); } entry.is_cached = true; } @@ -293,7 +293,7 @@ namespace ams::fssystem { if (!entry.is_cached && ((offset != entry.range.offset) || (offset + size < static_cast(entry.range.GetEndOffset())))) { if (Result result = m_data_storage->Read(entry.range.offset, dst, entry.range.size); R_FAILED(result)) { m_block_cache_manager.ReleaseCacheEntry(std::addressof(entry), range); - return this->UpdateLastResult(result); + R_RETURN(this->UpdateLastResult(result)); } } entry.is_cached = true; diff --git a/libraries/libstratosphere/source/fssystem/fssystem_bucket_tree.cpp b/libraries/libstratosphere/source/fssystem/fssystem_bucket_tree.cpp index 4280f0563..59c8bae97 100644 --- a/libraries/libstratosphere/source/fssystem/fssystem_bucket_tree.cpp +++ b/libraries/libstratosphere/source/fssystem/fssystem_bucket_tree.cpp @@ -237,7 +237,7 @@ namespace ams::fssystem { R_TRY(visitor->Initialize(this, offsets)); - return visitor->Find(virtual_address); + R_RETURN(visitor->Find(virtual_address)); } Result BucketTree::InvalidateCache() { @@ -429,10 +429,10 @@ namespace ams::fssystem { PooledBuffer pool(node_size, 1); if (node_size <= pool.GetSize()) { - return this->FindEntrySetWithBuffer(out_index, virtual_address, node_index, pool.GetBuffer()); + R_RETURN(this->FindEntrySetWithBuffer(out_index, virtual_address, node_index, pool.GetBuffer())); } else { pool.Deallocate(); - return this->FindEntrySetWithoutBuffer(out_index, virtual_address, node_index); + R_RETURN(this->FindEntrySetWithoutBuffer(out_index, virtual_address, node_index)); } } @@ -486,10 +486,10 @@ namespace ams::fssystem { PooledBuffer pool(entry_set_size, 1); if (entry_set_size <= pool.GetSize()) { - return this->FindEntryWithBuffer(virtual_address, entry_set_index, pool.GetBuffer()); + R_RETURN(this->FindEntryWithBuffer(virtual_address, entry_set_index, pool.GetBuffer())); } else { pool.Deallocate(); - return this->FindEntryWithoutBuffer(virtual_address, entry_set_index); + R_RETURN(this->FindEntryWithoutBuffer(virtual_address, entry_set_index)); } } diff --git a/libraries/libstratosphere/source/fssystem/fssystem_buffered_storage.cpp b/libraries/libstratosphere/source/fssystem/fssystem_buffered_storage.cpp index b392a6bc9..ba36fd7bd 100644 --- a/libraries/libstratosphere/source/fssystem/fssystem_buffered_storage.cpp +++ b/libraries/libstratosphere/source/fssystem/fssystem_buffered_storage.cpp @@ -517,7 +517,7 @@ namespace ams::fssystem { Result Flush() { AMS_ASSERT(m_cache != nullptr); - return m_cache->Flush(); + R_RETURN(m_cache->Flush()); } void Invalidate() { @@ -573,7 +573,7 @@ namespace ams::fssystem { Result Fetch(s64 offset) { AMS_ASSERT(m_cache != nullptr); - return m_cache->Fetch(offset); + R_RETURN(m_cache->Fetch(offset)); } Result FetchFromBuffer(s64 offset, const void *buffer, size_t buffer_size) { @@ -728,7 +728,7 @@ namespace ams::fssystem { } } - return m_base_storage.OperateRange(dst, dst_size, op_id, offset, size, src, src_size); + R_RETURN(m_base_storage.OperateRange(dst, dst_size, op_id, offset, size, src, src_size)); } void BufferedStorage::InvalidateCaches() { diff --git a/libraries/libstratosphere/source/fssystem/fssystem_directory_savedata_filesystem.cpp b/libraries/libstratosphere/source/fssystem/fssystem_directory_savedata_filesystem.cpp index 14fc94f44..ac470f243 100644 --- a/libraries/libstratosphere/source/fssystem/fssystem_directory_savedata_filesystem.cpp +++ b/libraries/libstratosphere/source/fssystem/fssystem_directory_savedata_filesystem.cpp @@ -45,27 +45,27 @@ namespace ams::fssystem { } public: virtual Result DoRead(size_t *out, s64 offset, void *buffer, size_t size, const fs::ReadOption &option) override { - return m_base_file->Read(out, offset, buffer, size, option); + R_RETURN(m_base_file->Read(out, offset, buffer, size, option)); } virtual Result DoGetSize(s64 *out) override { - return m_base_file->GetSize(out); + R_RETURN(m_base_file->GetSize(out)); } virtual Result DoFlush() override { - return m_base_file->Flush(); + R_RETURN(m_base_file->Flush()); } virtual Result DoWrite(s64 offset, const void *buffer, size_t size, const fs::WriteOption &option) override { - return m_base_file->Write(offset, buffer, size, option); + R_RETURN(m_base_file->Write(offset, buffer, size, option)); } virtual Result DoSetSize(s64 size) override { - return m_base_file->SetSize(size); + R_RETURN(m_base_file->SetSize(size)); } virtual Result DoOperateRange(void *dst, size_t dst_size, fs::OperationId op_id, s64 offset, s64 size, const void *src, size_t src_size) override { - return m_base_file->OperateRange(dst, dst_size, op_id, offset, size, src, src_size); + R_RETURN(m_base_file->OperateRange(dst, dst_size, op_id, offset, size, src, src_size)); } public: virtual sf::cmif::DomainObjectId GetDomainObjectId() const override { diff --git a/libraries/libstratosphere/source/fssystem/fssystem_hierarchical_sha256_storage.cpp b/libraries/libstratosphere/source/fssystem/fssystem_hierarchical_sha256_storage.cpp index ae1541e19..448aa3403 100644 --- a/libraries/libstratosphere/source/fssystem/fssystem_hierarchical_sha256_storage.cpp +++ b/libraries/libstratosphere/source/fssystem/fssystem_hierarchical_sha256_storage.cpp @@ -175,7 +175,7 @@ namespace ams::fssystem { template Result HierarchicalSha256Storage::OperateRange(void *dst, size_t dst_size, fs::OperationId op_id, s64 offset, s64 size, const void *src, size_t src_size) { if (op_id == fs::OperationId::Invalidate) { - return m_base_storage->OperateRange(fs::OperationId::Invalidate, offset, size); + R_RETURN(m_base_storage->OperateRange(fs::OperationId::Invalidate, offset, size)); } else { /* Succeed if zero-size. */ R_SUCCEED_IF(size == 0); @@ -188,7 +188,7 @@ namespace ams::fssystem { const auto reduced_size = std::min(m_base_storage_size, util::AlignUp(offset + size, m_hash_target_block_size)) - offset; /* Operate on the base storage. */ - return m_base_storage->OperateRange(dst, dst_size, op_id, offset, reduced_size, src, src_size); + R_RETURN(m_base_storage->OperateRange(dst, dst_size, op_id, offset, reduced_size, src, src_size)); } } diff --git a/libraries/libstratosphere/source/fssystem/fssystem_hierarchical_sha256_storage.hpp b/libraries/libstratosphere/source/fssystem/fssystem_hierarchical_sha256_storage.hpp index 0ef09a1c6..6c872a91e 100644 --- a/libraries/libstratosphere/source/fssystem/fssystem_hierarchical_sha256_storage.hpp +++ b/libraries/libstratosphere/source/fssystem/fssystem_hierarchical_sha256_storage.hpp @@ -44,11 +44,11 @@ namespace ams::fssystem { virtual Result OperateRange(void *dst, size_t dst_size, fs::OperationId op_id, s64 offset, s64 size, const void *src, size_t src_size) override; virtual Result GetSize(s64 *out) override { - return m_base_storage->GetSize(out); + R_RETURN(m_base_storage->GetSize(out)); } virtual Result Flush() override { - return m_base_storage->Flush(); + R_RETURN(m_base_storage->Flush()); } virtual Result SetSize(s64 size) override { diff --git a/libraries/libstratosphere/source/fssystem/fssystem_indirect_storage.cpp b/libraries/libstratosphere/source/fssystem/fssystem_indirect_storage.cpp index 94fbc6609..47754b311 100644 --- a/libraries/libstratosphere/source/fssystem/fssystem_indirect_storage.cpp +++ b/libraries/libstratosphere/source/fssystem/fssystem_indirect_storage.cpp @@ -30,7 +30,7 @@ namespace ams::fssystem { const auto entry_storage_offset = node_storage_offset + node_storage_size; /* Initialize. */ - return this->Initialize(allocator, fs::SubStorage(std::addressof(table_storage), node_storage_offset, node_storage_size), fs::SubStorage(std::addressof(table_storage), entry_storage_offset, entry_storage_size), header.entry_count); + R_RETURN(this->Initialize(allocator, fs::SubStorage(std::addressof(table_storage), node_storage_offset, node_storage_size), fs::SubStorage(std::addressof(table_storage), entry_storage_offset, entry_storage_size), header.entry_count)); } void IndirectStorage::Finalize() { diff --git a/libraries/libstratosphere/source/fssystem/fssystem_key_slot_cache.hpp b/libraries/libstratosphere/source/fssystem/fssystem_key_slot_cache.hpp index eec8d3d0f..a0d2cc10f 100644 --- a/libraries/libstratosphere/source/fssystem/fssystem_key_slot_cache.hpp +++ b/libraries/libstratosphere/source/fssystem/fssystem_key_slot_cache.hpp @@ -73,11 +73,11 @@ namespace ams::fssystem { constexpr KeySlotCache() : m_mutex(), m_high_priority_mru_list(), m_low_priority_mru_list() { /* ... */ } Result AllocateHighPriority(std::unique_ptr *out, const void *key, size_t key_size, s32 key2) { - return this->AllocateFromLru(out, m_high_priority_mru_list, key, key_size, key2); + R_RETURN(this->AllocateFromLru(out, m_high_priority_mru_list, key, key_size, key2)); } Result AllocateLowPriority(std::unique_ptr *out, const void *key, size_t key_size, s32 key2) { - return this->AllocateFromLru(out, m_high_priority_mru_list, key, key_size, key2); + R_RETURN(this->AllocateFromLru(out, m_high_priority_mru_list, key, key_size, key2)); } Result Find(std::unique_ptr *out, const void *key, size_t key_size, s32 key2) { diff --git a/libraries/libstratosphere/source/fssystem/fssystem_memory_resource_buffer_hold_storage.hpp b/libraries/libstratosphere/source/fssystem/fssystem_memory_resource_buffer_hold_storage.hpp index e90e41c79..8043cd46d 100644 --- a/libraries/libstratosphere/source/fssystem/fssystem_memory_resource_buffer_hold_storage.hpp +++ b/libraries/libstratosphere/source/fssystem/fssystem_memory_resource_buffer_hold_storage.hpp @@ -45,42 +45,42 @@ namespace ams::fssystem { /* Check pre-conditions. */ AMS_ASSERT(m_storage != nullptr); - return m_storage->Read(offset, buffer, size); + R_RETURN(m_storage->Read(offset, buffer, size)); } virtual Result OperateRange(void *dst, size_t dst_size, fs::OperationId op_id, s64 offset, s64 size, const void *src, size_t src_size) override { /* Check pre-conditions. */ AMS_ASSERT(m_storage != nullptr); - return m_storage->OperateRange(dst, dst_size, op_id, offset, size, src, src_size); + R_RETURN(m_storage->OperateRange(dst, dst_size, op_id, offset, size, src, src_size)); } virtual Result GetSize(s64 *out) override { /* Check pre-conditions. */ AMS_ASSERT(m_storage != nullptr); - return m_storage->GetSize(out); + R_RETURN(m_storage->GetSize(out)); } virtual Result Flush() override { /* Check pre-conditions. */ AMS_ASSERT(m_storage != nullptr); - return m_storage->Flush(); + R_RETURN(m_storage->Flush()); } virtual Result Write(s64 offset, const void *buffer, size_t size) override { /* Check pre-conditions. */ AMS_ASSERT(m_storage != nullptr); - return m_storage->Write(offset, buffer, size); + R_RETURN(m_storage->Write(offset, buffer, size)); } virtual Result SetSize(s64 size) override { /* Check pre-conditions. */ AMS_ASSERT(m_storage != nullptr); - return m_storage->SetSize(size); + R_RETURN(m_storage->SetSize(size)); } }; diff --git a/libraries/libstratosphere/source/fssystem/fssystem_nca_reader.cpp b/libraries/libstratosphere/source/fssystem/fssystem_nca_reader.cpp index 91e875911..3bc816f50 100644 --- a/libraries/libstratosphere/source/fssystem/fssystem_nca_reader.cpp +++ b/libraries/libstratosphere/source/fssystem/fssystem_nca_reader.cpp @@ -392,7 +392,7 @@ namespace ams::fssystem { AMS_ASSERT(0 <= index && index < NcaHeader::FsCountMax); const s64 offset = sizeof(NcaHeader) + sizeof(NcaFsHeader) * index; - return m_header_storage->Read(offset, dst, sizeof(NcaFsHeader)); + R_RETURN(m_header_storage->Read(offset, dst, sizeof(NcaFsHeader))); } bool NcaReader::GetHeaderSign1Valid() const { @@ -506,7 +506,7 @@ namespace ams::fssystem { AMS_ASSERT(out != nullptr); AMS_ASSERT(this->IsInitialized()); - return m_data.GetHashTargetOffset(out); + R_RETURN(m_data.GetHashTargetOffset(out)); } bool NcaFsHeaderReader::ExistsSparseLayer() const { diff --git a/libraries/libstratosphere/source/fssystem/fssystem_partition_file_system_meta.cpp b/libraries/libstratosphere/source/fssystem/fssystem_partition_file_system_meta.cpp index 6d1d41052..6ff68df8c 100644 --- a/libraries/libstratosphere/source/fssystem/fssystem_partition_file_system_meta.cpp +++ b/libraries/libstratosphere/source/fssystem/fssystem_partition_file_system_meta.cpp @@ -47,7 +47,7 @@ namespace ams::fssystem { R_UNLESS(m_buffer != nullptr, fs::ResultAllocationMemoryFailedInPartitionFileSystemMetaA()); /* Perform regular initialization. */ - return this->Initialize(storage, m_buffer, m_meta_data_size); + R_RETURN(this->Initialize(storage, m_buffer, m_meta_data_size)); } template diff --git a/libraries/libstratosphere/source/fssystem/fssystem_read_only_block_cache_storage.hpp b/libraries/libstratosphere/source/fssystem/fssystem_read_only_block_cache_storage.hpp index 926b7c4d5..a04de8199 100644 --- a/libraries/libstratosphere/source/fssystem/fssystem_read_only_block_cache_storage.hpp +++ b/libraries/libstratosphere/source/fssystem/fssystem_read_only_block_cache_storage.hpp @@ -84,7 +84,7 @@ namespace ams::fssystem { R_SUCCEED(); } else { - return m_base_storage->Read(offset, buffer, size); + R_RETURN(m_base_storage->Read(offset, buffer, size)); } } virtual Result OperateRange(void *dst, size_t dst_size, fs::OperationId op_id, s64 offset, s64 size, const void *src, size_t src_size) override { @@ -106,11 +106,11 @@ namespace ams::fssystem { } /* Operate on the base storage. */ - return m_base_storage->OperateRange(dst, dst_size, op_id, offset, size, src, src_size); + R_RETURN(m_base_storage->OperateRange(dst, dst_size, op_id, offset, size, src, src_size)); } virtual Result GetSize(s64 *out) override { - return m_base_storage->GetSize(out); + R_RETURN(m_base_storage->GetSize(out)); } virtual Result Flush() override { diff --git a/libraries/libstratosphere/source/gpio/driver/gpio_driver_service_api.cpp b/libraries/libstratosphere/source/gpio/driver/gpio_driver_service_api.cpp index 355b9a94f..7e87df1fa 100644 --- a/libraries/libstratosphere/source/gpio/driver/gpio_driver_service_api.cpp +++ b/libraries/libstratosphere/source/gpio/driver/gpio_driver_service_api.cpp @@ -28,7 +28,7 @@ namespace ams::gpio::driver { } Result RegisterDeviceCode(DeviceCode device_code, Pad *pad) { - return impl::RegisterDeviceCode(device_code, pad); + R_RETURN(impl::RegisterDeviceCode(device_code, pad)); } bool UnregisterDeviceCode(DeviceCode device_code) { diff --git a/libraries/libstratosphere/source/gpio/driver/impl/gpio_pad_session_impl.cpp b/libraries/libstratosphere/source/gpio/driver/impl/gpio_pad_session_impl.cpp index 0d1571e40..029013f19 100644 --- a/libraries/libstratosphere/source/gpio/driver/impl/gpio_pad_session_impl.cpp +++ b/libraries/libstratosphere/source/gpio/driver/impl/gpio_pad_session_impl.cpp @@ -110,7 +110,7 @@ namespace ams::gpio::driver::impl { AMS_ASSERT(driver.GetInterruptControlMutex(pad).IsLockedByCurrentThread()); /* Set interrupt enabled. */ - return driver.SetInterruptEnabled(std::addressof(pad), pad.IsInterruptRequiredForDriver()); + R_RETURN(driver.SetInterruptEnabled(std::addressof(pad), pad.IsInterruptRequiredForDriver())); } Result PadSessionImpl::GetInterruptEnabled(bool *out) const { diff --git a/libraries/libstratosphere/source/gpio/gpio_remote_manager_impl.hpp b/libraries/libstratosphere/source/gpio/gpio_remote_manager_impl.hpp index c29777e93..bd6e47fcd 100644 --- a/libraries/libstratosphere/source/gpio/gpio_remote_manager_impl.hpp +++ b/libraries/libstratosphere/source/gpio/gpio_remote_manager_impl.hpp @@ -42,7 +42,7 @@ namespace ams::gpio { } Result IsWakeEventActive(ams::sf::Out out, gpio::GpioPadName pad_name) { - return ::gpioIsWakeEventActive2(out.GetPointer(), static_cast<::GpioPadName>(static_cast(pad_name))); + R_RETURN(::gpioIsWakeEventActive2(out.GetPointer(), static_cast<::GpioPadName>(static_cast(pad_name)))); } Result GetWakeEventActiveFlagSet(ams::sf::Out out) { @@ -66,7 +66,7 @@ namespace ams::gpio { Result OpenSession2(ams::sf::Out> out, DeviceCode device_code, ddsf::AccessMode access_mode); Result IsWakeEventActive2(ams::sf::Out out, DeviceCode device_code) { - return ::gpioIsWakeEventActive2(out.GetPointer(), device_code.GetInternalValue()); + R_RETURN(::gpioIsWakeEventActive2(out.GetPointer(), device_code.GetInternalValue())); } Result SetWakeEventActiveFlagSetForDebug2(DeviceCode device_code, bool is_enabled) { diff --git a/libraries/libstratosphere/source/gpio/gpio_remote_pad_session_impl.hpp b/libraries/libstratosphere/source/gpio/gpio_remote_pad_session_impl.hpp index e72c4e4f9..ee5874504 100644 --- a/libraries/libstratosphere/source/gpio/gpio_remote_pad_session_impl.hpp +++ b/libraries/libstratosphere/source/gpio/gpio_remote_pad_session_impl.hpp @@ -29,47 +29,47 @@ namespace ams::gpio { public: /* Actual commands. */ Result SetDirection(gpio::Direction direction) { - return ::gpioPadSetDirection(std::addressof(m_srv), static_cast<::GpioDirection>(static_cast(direction))); + R_RETURN(::gpioPadSetDirection(std::addressof(m_srv), static_cast<::GpioDirection>(static_cast(direction)))); } Result GetDirection(ams::sf::Out out) { static_assert(sizeof(gpio::Direction) == sizeof(::GpioDirection)); - return ::gpioPadGetDirection(std::addressof(m_srv), reinterpret_cast<::GpioDirection *>(out.GetPointer())); + R_RETURN(::gpioPadGetDirection(std::addressof(m_srv), reinterpret_cast<::GpioDirection *>(out.GetPointer()))); } Result SetInterruptMode(gpio::InterruptMode mode) { - return ::gpioPadSetInterruptMode(std::addressof(m_srv), static_cast<::GpioInterruptMode>(static_cast(mode))); + R_RETURN(::gpioPadSetInterruptMode(std::addressof(m_srv), static_cast<::GpioInterruptMode>(static_cast(mode)))); } Result GetInterruptMode(ams::sf::Out out) { static_assert(sizeof(gpio::InterruptMode) == sizeof(::GpioInterruptMode)); - return ::gpioPadGetInterruptMode(std::addressof(m_srv), reinterpret_cast<::GpioInterruptMode *>(out.GetPointer())); + R_RETURN(::gpioPadGetInterruptMode(std::addressof(m_srv), reinterpret_cast<::GpioInterruptMode *>(out.GetPointer()))); } Result SetInterruptEnable(bool enable) { - return ::gpioPadSetInterruptEnable(std::addressof(m_srv), enable); + R_RETURN(::gpioPadSetInterruptEnable(std::addressof(m_srv), enable)); } Result GetInterruptEnable(ams::sf::Out out) { - return ::gpioPadGetInterruptEnable(std::addressof(m_srv), out.GetPointer()); + R_RETURN(::gpioPadGetInterruptEnable(std::addressof(m_srv), out.GetPointer())); } Result GetInterruptStatus(ams::sf::Out out) { static_assert(sizeof(gpio::InterruptStatus) == sizeof(::GpioInterruptStatus)); - return ::gpioPadGetInterruptStatus(std::addressof(m_srv), reinterpret_cast<::GpioInterruptStatus *>(out.GetPointer())); + R_RETURN(::gpioPadGetInterruptStatus(std::addressof(m_srv), reinterpret_cast<::GpioInterruptStatus *>(out.GetPointer()))); } Result ClearInterruptStatus() { - return ::gpioPadClearInterruptStatus(std::addressof(m_srv)); + R_RETURN(::gpioPadClearInterruptStatus(std::addressof(m_srv))); } Result SetValue(gpio::GpioValue value) { - return ::gpioPadSetValue(std::addressof(m_srv), static_cast<::GpioValue>(static_cast(value))); + R_RETURN(::gpioPadSetValue(std::addressof(m_srv), static_cast<::GpioValue>(static_cast(value)))); } Result GetValue(ams::sf::Out out) { static_assert(sizeof(gpio::GpioValue) == sizeof(::GpioValue)); - return ::gpioPadGetValue(std::addressof(m_srv), reinterpret_cast<::GpioValue *>(out.GetPointer())); + R_RETURN(::gpioPadGetValue(std::addressof(m_srv), reinterpret_cast<::GpioValue *>(out.GetPointer()))); } Result BindInterrupt(ams::sf::OutCopyHandle out) { @@ -80,23 +80,23 @@ namespace ams::gpio { } Result UnbindInterrupt() { - return ::gpioPadUnbindInterrupt(std::addressof(m_srv)); + R_RETURN(::gpioPadUnbindInterrupt(std::addressof(m_srv))); } Result SetDebounceEnabled(bool enable) { - return ::gpioPadSetDebounceEnabled(std::addressof(m_srv), enable); + R_RETURN(::gpioPadSetDebounceEnabled(std::addressof(m_srv), enable)); } Result GetDebounceEnabled(ams::sf::Out out) { - return ::gpioPadGetDebounceEnabled(std::addressof(m_srv), out.GetPointer()); + R_RETURN(::gpioPadGetDebounceEnabled(std::addressof(m_srv), out.GetPointer())); } Result SetDebounceTime(s32 ms) { - return ::gpioPadSetDebounceTime(std::addressof(m_srv), ms); + R_RETURN(::gpioPadSetDebounceTime(std::addressof(m_srv), ms)); } Result GetDebounceTime(ams::sf::Out out) { - return ::gpioPadGetDebounceTime(std::addressof(m_srv), out.GetPointer()); + R_RETURN(::gpioPadGetDebounceTime(std::addressof(m_srv), out.GetPointer())); } Result SetValueForSleepState(gpio::GpioValue value) { diff --git a/libraries/libstratosphere/source/gpio/server/gpio_server_manager_impl.cpp b/libraries/libstratosphere/source/gpio/server/gpio_server_manager_impl.cpp index b828f3e55..226813219 100644 --- a/libraries/libstratosphere/source/gpio/server/gpio_server_manager_impl.cpp +++ b/libraries/libstratosphere/source/gpio/server/gpio_server_manager_impl.cpp @@ -34,7 +34,7 @@ namespace ams::gpio::server { } Result ManagerImpl::OpenSession(ams::sf::Out> out, gpio::GpioPadName pad_name) { - return this->OpenSession2(out, ConvertToDeviceCode(pad_name), ddsf::AccessMode_ReadWrite); + R_RETURN(this->OpenSession2(out, ConvertToDeviceCode(pad_name), ddsf::AccessMode_ReadWrite)); } Result ManagerImpl::OpenSessionForTest(ams::sf::Out> out, gpio::GpioPadName pad_name) { diff --git a/libraries/libstratosphere/source/hid/hid_api.cpp b/libraries/libstratosphere/source/hid/hid_api.cpp index d12f10e54..26291eaee 100644 --- a/libraries/libstratosphere/source/hid/hid_api.cpp +++ b/libraries/libstratosphere/source/hid/hid_api.cpp @@ -52,7 +52,7 @@ namespace ams::hid { if (!g_initialized_hid) { if (!serviceIsActive(hidGetServiceSession())) { if (!pm::info::HasLaunchedBootProgram(ncm::SystemProgramId::Hid)) { - return MAKERESULT(Module_Libnx, LibnxError_InitFail_HID); + R_THROW(MAKERESULT(Module_Libnx, LibnxError_InitFail_HID)); } InitializeHid(); } diff --git a/libraries/libstratosphere/source/htc/server/driver/htc_htclow_driver.cpp b/libraries/libstratosphere/source/htc/server/driver/htc_htclow_driver.cpp index 98ced63e2..6ede55b28 100644 --- a/libraries/libstratosphere/source/htc/server/driver/htc_htclow_driver.cpp +++ b/libraries/libstratosphere/source/htc/server/driver/htc_htclow_driver.cpp @@ -50,7 +50,7 @@ namespace ams::htc::server::driver { AMS_ABORT("Unsupported channel"); } - return this->Open(channel, m_default_receive_buffer, sizeof(m_default_receive_buffer), m_default_send_buffer, sizeof(m_default_send_buffer)); + R_RETURN(this->Open(channel, m_default_receive_buffer, sizeof(m_default_receive_buffer), m_default_send_buffer, sizeof(m_default_send_buffer))); } Result HtclowDriver::Open(htclow::ChannelId channel, void *receive_buffer, size_t receive_buffer_size, void *send_buffer, size_t send_buffer_size) { @@ -132,7 +132,7 @@ namespace ams::htc::server::driver { this->WaitTask(task_id); /* Finish receiving. */ - return m_manager->ReceiveEnd(out, dst, dst_size, GetHtclowChannel(channel, m_module_id), task_id); + R_RETURN(m_manager->ReceiveEnd(out, dst, dst_size, GetHtclowChannel(channel, m_module_id), task_id)); } Result HtclowDriver::Receive(s64 *out, void *dst, s64 dst_size, htclow::ChannelId channel, htclow::ReceiveOption option) { @@ -164,7 +164,7 @@ namespace ams::htc::server::driver { if (htclow::ResultChannelNotExist::Includes(result)) { *out = received; } - return result; + R_RETURN(result); } received += cur_received; diff --git a/libraries/libstratosphere/source/htc/server/htc_htc_service_object.cpp b/libraries/libstratosphere/source/htc/server/htc_htc_service_object.cpp index 19d4cc583..03e31443f 100644 --- a/libraries/libstratosphere/source/htc/server/htc_htc_service_object.cpp +++ b/libraries/libstratosphere/source/htc/server/htc_htc_service_object.cpp @@ -80,11 +80,11 @@ namespace ams::htc::server { } Result HtcServiceObject::GetWorkingDirectoryPath(const sf::OutBuffer &out, s32 max_len) { - return htcfs::GetWorkingDirectory(reinterpret_cast(out.GetPointer()), max_len); + R_RETURN(htcfs::GetWorkingDirectory(reinterpret_cast(out.GetPointer()), max_len)); } Result HtcServiceObject::GetWorkingDirectoryPathSize(sf::Out out_size) { - return htcfs::GetWorkingDirectorySize(out_size.GetPointer()); + R_RETURN(htcfs::GetWorkingDirectorySize(out_size.GetPointer())); } Result HtcServiceObject::RunOnHostStart(sf::Out out_id, sf::OutCopyHandle out, const sf::InBuffer &args) { @@ -111,7 +111,7 @@ namespace ams::htc::server { } /* Finish the run on host task. */ - return m_misc_impl.RunOnHostEnd(out_result.GetPointer(), id); + R_RETURN(m_misc_impl.RunOnHostEnd(out_result.GetPointer(), id)); } Result HtcServiceObject::GetBridgeIpAddress(const sf::OutBuffer &out) { diff --git a/libraries/libstratosphere/source/htcfs/htcfs_client.hpp b/libraries/libstratosphere/source/htcfs/htcfs_client.hpp index f18aa6250..3e3953d71 100644 --- a/libraries/libstratosphere/source/htcfs/htcfs_client.hpp +++ b/libraries/libstratosphere/source/htcfs/htcfs_client.hpp @@ -26,43 +26,43 @@ namespace ams::htcfs { public: Client(htclow::HtclowManager *manager) : m_impl(manager) { /* ... */ } public: - Result OpenFile(s32 *out_handle, const char *path, fs::OpenMode mode, bool case_sensitive) { return ConvertToFsResult(m_impl.OpenFile(out_handle, path, mode, case_sensitive)); } - Result FileExists(bool *out, const char *path, bool case_sensitive) { return ConvertToFsResult(m_impl.FileExists(out, path, case_sensitive)); } - Result DeleteFile(const char *path, bool case_sensitive) { return ConvertToFsResult(m_impl.DeleteFile(path, case_sensitive)); } - Result RenameFile(const char *old_path, const char *new_path, bool case_sensitive) { return ConvertToFsResult(m_impl.RenameFile(old_path, new_path, case_sensitive)); } - Result GetEntryType(fs::DirectoryEntryType *out, const char *path, bool case_sensitive) { return ConvertToFsResult(m_impl.GetEntryType(out, path, case_sensitive)); } - Result OpenDirectory(s32 *out_handle, const char *path, fs::OpenDirectoryMode mode, bool case_sensitive) { return ConvertToFsResult(m_impl.OpenDirectory(out_handle, path, mode, case_sensitive)); } - Result DirectoryExists(bool *out, const char *path, bool case_sensitive) { return ConvertToFsResult(m_impl.DirectoryExists(out, path, case_sensitive)); } - Result CreateDirectory(const char *path, bool case_sensitive) { return ConvertToFsResult(m_impl.CreateDirectory(path, case_sensitive)); } - Result DeleteDirectory(const char *path, bool recursively, bool case_sensitive) { return ConvertToFsResult(m_impl.DeleteDirectory(path, recursively, case_sensitive)); } - Result RenameDirectory(const char *old_path, const char *new_path, bool case_sensitive) { return ConvertToFsResult(m_impl.RenameDirectory(old_path, new_path, case_sensitive)); } - Result CreateFile(const char *path, s64 size, bool case_sensitive) { return ConvertToFsResult(m_impl.CreateFile(path, size, case_sensitive)); } - Result GetFileTimeStamp(u64 *out_create, u64 *out_access, u64 *out_modify, const char *path, bool case_sensitive) { return ConvertToFsResult(m_impl.GetFileTimeStamp(out_create, out_access, out_modify, path, case_sensitive)); } - Result GetCaseSensitivePath(char *dst, size_t dst_size, const char *path) { return ConvertToFsResult(m_impl.GetCaseSensitivePath(dst, dst_size, path)); } - Result GetDiskFreeSpace(s64 *out_free, s64 *out_total, s64 *out_total_free, const char *path) { return ConvertToFsResult(m_impl.GetDiskFreeSpace(out_free, out_total, out_total_free, path)); } + Result OpenFile(s32 *out_handle, const char *path, fs::OpenMode mode, bool case_sensitive) { R_RETURN(ConvertToFsResult(m_impl.OpenFile(out_handle, path, mode, case_sensitive))); } + Result FileExists(bool *out, const char *path, bool case_sensitive) { R_RETURN(ConvertToFsResult(m_impl.FileExists(out, path, case_sensitive))); } + Result DeleteFile(const char *path, bool case_sensitive) { R_RETURN(ConvertToFsResult(m_impl.DeleteFile(path, case_sensitive))); } + Result RenameFile(const char *old_path, const char *new_path, bool case_sensitive) { R_RETURN(ConvertToFsResult(m_impl.RenameFile(old_path, new_path, case_sensitive))); } + Result GetEntryType(fs::DirectoryEntryType *out, const char *path, bool case_sensitive) { R_RETURN(ConvertToFsResult(m_impl.GetEntryType(out, path, case_sensitive))); } + Result OpenDirectory(s32 *out_handle, const char *path, fs::OpenDirectoryMode mode, bool case_sensitive) { R_RETURN(ConvertToFsResult(m_impl.OpenDirectory(out_handle, path, mode, case_sensitive))); } + Result DirectoryExists(bool *out, const char *path, bool case_sensitive) { R_RETURN(ConvertToFsResult(m_impl.DirectoryExists(out, path, case_sensitive))); } + Result CreateDirectory(const char *path, bool case_sensitive) { R_RETURN(ConvertToFsResult(m_impl.CreateDirectory(path, case_sensitive))); } + Result DeleteDirectory(const char *path, bool recursively, bool case_sensitive) { R_RETURN(ConvertToFsResult(m_impl.DeleteDirectory(path, recursively, case_sensitive))); } + Result RenameDirectory(const char *old_path, const char *new_path, bool case_sensitive) { R_RETURN(ConvertToFsResult(m_impl.RenameDirectory(old_path, new_path, case_sensitive))); } + Result CreateFile(const char *path, s64 size, bool case_sensitive) { R_RETURN(ConvertToFsResult(m_impl.CreateFile(path, size, case_sensitive))); } + Result GetFileTimeStamp(u64 *out_create, u64 *out_access, u64 *out_modify, const char *path, bool case_sensitive) { R_RETURN(ConvertToFsResult(m_impl.GetFileTimeStamp(out_create, out_access, out_modify, path, case_sensitive))); } + Result GetCaseSensitivePath(char *dst, size_t dst_size, const char *path) { R_RETURN(ConvertToFsResult(m_impl.GetCaseSensitivePath(dst, dst_size, path))); } + Result GetDiskFreeSpace(s64 *out_free, s64 *out_total, s64 *out_total_free, const char *path) { R_RETURN(ConvertToFsResult(m_impl.GetDiskFreeSpace(out_free, out_total, out_total_free, path))); } - Result CloseDirectory(s32 handle) { return ConvertToFsResult(m_impl.CloseDirectory(handle)); } + Result CloseDirectory(s32 handle) { R_RETURN(ConvertToFsResult(m_impl.CloseDirectory(handle))); } - Result GetEntryCount(s64 *out, s32 handle) { return ConvertToFsResult(m_impl.GetEntryCount(out, handle)); } - Result ReadDirectory(s64 *out, fs::DirectoryEntry *out_entries, size_t max_out_entries, s32 handle) { return ConvertToFsResult(m_impl.ReadDirectory(out, out_entries, max_out_entries, handle)); } - Result ReadDirectoryLarge(s64 *out, fs::DirectoryEntry *out_entries, size_t max_out_entries, s32 handle) { return ConvertToFsResult(m_impl.ReadDirectoryLarge(out, out_entries, max_out_entries, handle)); } - Result GetPriorityForDirectory(s32 *out, s32 handle) { return ConvertToFsResult(m_impl.GetPriorityForDirectory(out, handle)); } - Result SetPriorityForDirectory(s32 priority, s32 handle) { return ConvertToFsResult(m_impl.SetPriorityForDirectory(priority, handle)); } + Result GetEntryCount(s64 *out, s32 handle) { R_RETURN(ConvertToFsResult(m_impl.GetEntryCount(out, handle))); } + Result ReadDirectory(s64 *out, fs::DirectoryEntry *out_entries, size_t max_out_entries, s32 handle) { R_RETURN(ConvertToFsResult(m_impl.ReadDirectory(out, out_entries, max_out_entries, handle))); } + Result ReadDirectoryLarge(s64 *out, fs::DirectoryEntry *out_entries, size_t max_out_entries, s32 handle) { R_RETURN(ConvertToFsResult(m_impl.ReadDirectoryLarge(out, out_entries, max_out_entries, handle))); } + Result GetPriorityForDirectory(s32 *out, s32 handle) { R_RETURN(ConvertToFsResult(m_impl.GetPriorityForDirectory(out, handle))); } + Result SetPriorityForDirectory(s32 priority, s32 handle) { R_RETURN(ConvertToFsResult(m_impl.SetPriorityForDirectory(priority, handle))); } - Result CloseFile(s32 handle) { return ConvertToFsResult(m_impl.CloseFile(handle)); } + Result CloseFile(s32 handle) { R_RETURN(ConvertToFsResult(m_impl.CloseFile(handle))); } - Result ReadFile(s64 *out, void *buffer, s32 handle, s64 offset, s64 buffer_size, fs::ReadOption option) { return ConvertToFsResult(m_impl.ReadFile(out, buffer, handle, offset, buffer_size, option)); } - Result ReadFileLarge(s64 *out, void *buffer, s32 handle, s64 offset, s64 buffer_size, fs::ReadOption option) { return ConvertToFsResult(m_impl.ReadFileLarge(out, buffer, handle, offset, buffer_size, option)); } - Result WriteFile(const void *buffer, s32 handle, s64 offset, s64 buffer_size, fs::WriteOption option) { return ConvertToFsResult(m_impl.WriteFile(buffer, handle, offset, buffer_size, option)); } - Result WriteFileLarge(const void *buffer, s32 handle, s64 offset, s64 buffer_size, fs::WriteOption option) { return ConvertToFsResult(m_impl.WriteFileLarge(buffer, handle, offset, buffer_size, option)); } - Result GetFileSize(s64 *out, s32 handle) { return ConvertToFsResult(m_impl.GetFileSize(out, handle)); } - Result SetFileSize(s64 size, s32 handle) { return ConvertToFsResult(m_impl.SetFileSize(size, handle)); } - Result FlushFile(s32 handle) { return ConvertToFsResult(m_impl.FlushFile(handle)); } - Result GetPriorityForFile(s32 *out, s32 handle) { return ConvertToFsResult(m_impl.GetPriorityForFile(out, handle)); } - Result SetPriorityForFile(s32 priority, s32 handle) { return ConvertToFsResult(m_impl.SetPriorityForFile(priority, handle)); } + Result ReadFile(s64 *out, void *buffer, s32 handle, s64 offset, s64 buffer_size, fs::ReadOption option) { R_RETURN(ConvertToFsResult(m_impl.ReadFile(out, buffer, handle, offset, buffer_size, option))); } + Result ReadFileLarge(s64 *out, void *buffer, s32 handle, s64 offset, s64 buffer_size, fs::ReadOption option) { R_RETURN(ConvertToFsResult(m_impl.ReadFileLarge(out, buffer, handle, offset, buffer_size, option))); } + Result WriteFile(const void *buffer, s32 handle, s64 offset, s64 buffer_size, fs::WriteOption option) { R_RETURN(ConvertToFsResult(m_impl.WriteFile(buffer, handle, offset, buffer_size, option))); } + Result WriteFileLarge(const void *buffer, s32 handle, s64 offset, s64 buffer_size, fs::WriteOption option) { R_RETURN(ConvertToFsResult(m_impl.WriteFileLarge(buffer, handle, offset, buffer_size, option))); } + Result GetFileSize(s64 *out, s32 handle) { R_RETURN(ConvertToFsResult(m_impl.GetFileSize(out, handle))); } + Result SetFileSize(s64 size, s32 handle) { R_RETURN(ConvertToFsResult(m_impl.SetFileSize(size, handle))); } + Result FlushFile(s32 handle) { R_RETURN(ConvertToFsResult(m_impl.FlushFile(handle))); } + Result GetPriorityForFile(s32 *out, s32 handle) { R_RETURN(ConvertToFsResult(m_impl.GetPriorityForFile(out, handle))); } + Result SetPriorityForFile(s32 priority, s32 handle) { R_RETURN(ConvertToFsResult(m_impl.SetPriorityForFile(priority, handle))); } - Result GetWorkingDirectory(char *dst, size_t dst_size) { return ConvertToFsResult(m_impl.GetWorkingDirectory(dst, dst_size)); } - Result GetWorkingDirectorySize(s32 *out) { return ConvertToFsResult(m_impl.GetWorkingDirectorySize(out)); } + Result GetWorkingDirectory(char *dst, size_t dst_size) { R_RETURN(ConvertToFsResult(m_impl.GetWorkingDirectory(dst, dst_size))); } + Result GetWorkingDirectorySize(s32 *out) { R_RETURN(ConvertToFsResult(m_impl.GetWorkingDirectorySize(out))); } }; void InitializeClient(htclow::HtclowManager *manager); diff --git a/libraries/libstratosphere/source/htcfs/htcfs_client_impl.cpp b/libraries/libstratosphere/source/htcfs/htcfs_client_impl.cpp index e36050831..2dc9c2709 100644 --- a/libraries/libstratosphere/source/htcfs/htcfs_client_impl.cpp +++ b/libraries/libstratosphere/source/htcfs/htcfs_client_impl.cpp @@ -261,19 +261,19 @@ namespace ams::htcfs { } Result ClientImpl::SendToRpcChannel(const void *src, s64 size) { - return this->SendToHtclow(src, size, std::addressof(m_rpc_channel)); + R_RETURN(this->SendToHtclow(src, size, std::addressof(m_rpc_channel))); } Result ClientImpl::ReceiveFromRpcChannel(void *dst, s64 size) { - return this->ReceiveFromHtclow(dst, size, std::addressof(m_rpc_channel)); + R_RETURN(this->ReceiveFromHtclow(dst, size, std::addressof(m_rpc_channel))); } Result ClientImpl::ReceiveFromDataChannel(s64 size) { - return m_data_channel.WaitReceive(size); + R_RETURN(m_data_channel.WaitReceive(size)); } Result ClientImpl::SendToDataChannel() { - return m_data_channel.Flush(); + R_RETURN(m_data_channel.Flush()); } Result ClientImpl::SendToHtclow(const void *src, s64 size, htclow::Channel *channel) { @@ -856,14 +856,14 @@ namespace ams::htcfs { const auto htcfs_result = ConvertHtcfsResult(response.params[0]); if (R_FAILED(htcfs_result)) { R_UNLESS(response.body_size == 0, htcfs::ResultUnexpectedResponseBodySize()); - return htcfs_result; + R_RETURN(htcfs_result); } /* Check our operation's result. */ const auto native_result = ConvertNativeResult(response.params[1]); if (R_FAILED(native_result)) { R_UNLESS(response.body_size == 0, htcfs::ResultUnexpectedResponseBodySize()); - return native_result; + R_RETURN(native_result); } /* Check the body size. */ @@ -1016,7 +1016,7 @@ namespace ams::htcfs { /* Receive the entries. */ *out = response.params[2]; - return this->ReceiveFromRpcChannel(out_entries, response.body_size); + R_RETURN(this->ReceiveFromRpcChannel(out_entries, response.body_size)); } Result ClientImpl::ReadDirectoryLarge(s64 *out, fs::DirectoryEntry *out_entries, size_t max_out_entries, s32 handle) { @@ -1052,14 +1052,14 @@ namespace ams::htcfs { const auto htcfs_result = ConvertHtcfsResult(response.params[0]); if (R_FAILED(htcfs_result)) { R_UNLESS(response.body_size == 0, htcfs::ResultUnexpectedResponseBodySize()); - return htcfs_result; + R_RETURN(htcfs_result); } /* Check our operation's result. */ const auto native_result = ConvertNativeResult(response.params[1]); if (R_FAILED(native_result)) { R_UNLESS(response.body_size == 0, htcfs::ResultUnexpectedResponseBodySize()); - return native_result; + R_RETURN(native_result); } /* Check that the number of entries read is allowable. */ @@ -1208,14 +1208,14 @@ namespace ams::htcfs { const auto htcfs_result = ConvertHtcfsResult(response.params[0]); if (R_FAILED(htcfs_result)) { R_UNLESS(response.body_size == 0, htcfs::ResultUnexpectedResponseBodySize()); - return htcfs_result; + R_RETURN(htcfs_result); } /* Check our operation's result. */ const auto native_result = ConvertNativeResult(response.params[1]); if (R_FAILED(native_result)) { R_UNLESS(response.body_size == 0, htcfs::ResultUnexpectedResponseBodySize()); - return native_result; + R_RETURN(native_result); } /* Check the body size. */ @@ -1265,14 +1265,14 @@ namespace ams::htcfs { const auto htcfs_result = ConvertHtcfsResult(response.params[0]); if (R_FAILED(htcfs_result)) { R_UNLESS(response.body_size == 0, htcfs::ResultUnexpectedResponseBodySize()); - return htcfs_result; + R_RETURN(htcfs_result); } /* Check our operation's result. */ const auto native_result = ConvertNativeResult(response.params[1]); if (R_FAILED(native_result)) { R_UNLESS(response.body_size == 0, htcfs::ResultUnexpectedResponseBodySize()); - return native_result; + R_RETURN(native_result); } /* Check that the size read is allowable. */ @@ -1348,7 +1348,7 @@ namespace ams::htcfs { /* Verify that the host reports ready to receive our data. */ if (static_cast(response.params[0]) != HtcfsResult::Ready) { - return ConvertHtcfsResult(response.params[0]); + R_RETURN(ConvertHtcfsResult(response.params[0])); } /* Verify that our send will be valid. */ @@ -1569,7 +1569,7 @@ namespace ams::htcfs { const auto htcfs_result = ConvertHtcfsResult(response.params[0]); if (R_FAILED(htcfs_result)) { R_UNLESS(response.body_size == 0, htcfs::ResultUnexpectedResponseBodySize()); - return htcfs_result; + R_RETURN(htcfs_result); } /* Check that the body size is valid. */ @@ -1610,7 +1610,7 @@ namespace ams::htcfs { const auto htcfs_result = ConvertHtcfsResult(response.params[0]); if (R_FAILED(htcfs_result)) { R_UNLESS(response.body_size == 0, htcfs::ResultUnexpectedResponseBodySize()); - return htcfs_result; + R_RETURN(htcfs_result); } /* Check that the size is representable. */ diff --git a/libraries/libstratosphere/source/htcfs/htcfs_client_impl.hpp b/libraries/libstratosphere/source/htcfs/htcfs_client_impl.hpp index a1bb8429e..a65876907 100644 --- a/libraries/libstratosphere/source/htcfs/htcfs_client_impl.hpp +++ b/libraries/libstratosphere/source/htcfs/htcfs_client_impl.hpp @@ -117,8 +117,8 @@ namespace ams::htcfs { Result SendToHtclow(const void *src, s64 size, htclow::Channel *channel); Result ReceiveFromHtclow(void *dst, s64 size, htclow::Channel *channel); - Result SendRequest(const Header &request) { return this->SendRequest(request, nullptr, 0, nullptr, 0); } - Result SendRequest(const Header &request, const void *arg1, size_t arg1_size) { return this->SendRequest(request, arg1, arg1_size, nullptr, 0); } + Result SendRequest(const Header &request) { R_RETURN(this->SendRequest(request, nullptr, 0, nullptr, 0)); } + Result SendRequest(const Header &request, const void *arg1, size_t arg1_size) { R_RETURN(this->SendRequest(request, arg1, arg1_size, nullptr, 0)); } Result SendRequest(const Header &request, const void *arg1, size_t arg1_size, const void *arg2, size_t arg2_size); void InitializeDataChannelForReceive(void *dst, size_t size); diff --git a/libraries/libstratosphere/source/htcfs/htcfs_directory_service_object.cpp b/libraries/libstratosphere/source/htcfs/htcfs_directory_service_object.cpp index 623e259a7..a24c066a1 100644 --- a/libraries/libstratosphere/source/htcfs/htcfs_directory_service_object.cpp +++ b/libraries/libstratosphere/source/htcfs/htcfs_directory_service_object.cpp @@ -26,23 +26,23 @@ namespace ams::htcfs { } Result DirectoryServiceObject::GetEntryCount(ams::sf::Out out) { - return htcfs::GetClient().GetEntryCount(out.GetPointer(), m_handle); + R_RETURN(htcfs::GetClient().GetEntryCount(out.GetPointer(), m_handle)); } Result DirectoryServiceObject::Read(ams::sf::Out out, const ams::sf::OutMapAliasArray &out_entries) { if (out_entries.GetSize() * sizeof(fs::DirectoryEntry) >= ClientImpl::MaxPacketBodySize) { - return htcfs::GetClient().ReadDirectoryLarge(out.GetPointer(), out_entries.GetPointer(), out_entries.GetSize(), m_handle); + R_RETURN(htcfs::GetClient().ReadDirectoryLarge(out.GetPointer(), out_entries.GetPointer(), out_entries.GetSize(), m_handle)); } else { - return htcfs::GetClient().ReadDirectory(out.GetPointer(), out_entries.GetPointer(), out_entries.GetSize(), m_handle); + R_RETURN(htcfs::GetClient().ReadDirectory(out.GetPointer(), out_entries.GetPointer(), out_entries.GetSize(), m_handle)); } } Result DirectoryServiceObject::SetPriorityForDirectory(s32 priority) { - return htcfs::GetClient().SetPriorityForDirectory(priority, m_handle); + R_RETURN(htcfs::GetClient().SetPriorityForDirectory(priority, m_handle)); } Result DirectoryServiceObject::GetPriorityForDirectory(ams::sf::Out out) { - return htcfs::GetClient().GetPriorityForDirectory(out.GetPointer(), m_handle); + R_RETURN(htcfs::GetClient().GetPriorityForDirectory(out.GetPointer(), m_handle)); } diff --git a/libraries/libstratosphere/source/htcfs/htcfs_file_service_object.cpp b/libraries/libstratosphere/source/htcfs/htcfs_file_service_object.cpp index 0162ff9e8..974542dd1 100644 --- a/libraries/libstratosphere/source/htcfs/htcfs_file_service_object.cpp +++ b/libraries/libstratosphere/source/htcfs/htcfs_file_service_object.cpp @@ -30,9 +30,9 @@ namespace ams::htcfs { R_UNLESS(offset >= 0, htcfs::ResultInvalidArgument()); if (buffer.GetSize() >= ClientImpl::MaxPacketBodySize) { - return htcfs::GetClient().ReadFileLarge(out.GetPointer(), buffer.GetPointer(), m_handle, offset, buffer.GetSize(), option); + R_RETURN(htcfs::GetClient().ReadFileLarge(out.GetPointer(), buffer.GetPointer(), m_handle, offset, buffer.GetSize(), option)); } else { - return htcfs::GetClient().ReadFile(out.GetPointer(), buffer.GetPointer(), m_handle, offset, buffer.GetSize(), option); + R_RETURN(htcfs::GetClient().ReadFile(out.GetPointer(), buffer.GetPointer(), m_handle, offset, buffer.GetSize(), option)); } } @@ -41,33 +41,33 @@ namespace ams::htcfs { R_UNLESS(offset >= 0, htcfs::ResultInvalidArgument()); if (buffer.GetSize() >= ClientImpl::MaxPacketBodySize) { - return htcfs::GetClient().WriteFileLarge(buffer.GetPointer(), m_handle, offset, buffer.GetSize(), option); + R_RETURN(htcfs::GetClient().WriteFileLarge(buffer.GetPointer(), m_handle, offset, buffer.GetSize(), option)); } else { - return htcfs::GetClient().WriteFile(buffer.GetPointer(), m_handle, offset, buffer.GetSize(), option); + R_RETURN(htcfs::GetClient().WriteFile(buffer.GetPointer(), m_handle, offset, buffer.GetSize(), option)); } } Result FileServiceObject::GetFileSize(ams::sf::Out out) { - return htcfs::GetClient().GetFileSize(out.GetPointer(), m_handle); + R_RETURN(htcfs::GetClient().GetFileSize(out.GetPointer(), m_handle)); } Result FileServiceObject::SetFileSize(s64 size) { /* Validate size. */ R_UNLESS(size >= 0, htcfs::ResultInvalidArgument()); - return htcfs::GetClient().SetFileSize(size, m_handle); + R_RETURN(htcfs::GetClient().SetFileSize(size, m_handle)); } Result FileServiceObject::FlushFile() { - return htcfs::GetClient().FlushFile(m_handle); + R_RETURN(htcfs::GetClient().FlushFile(m_handle)); } Result FileServiceObject::SetPriorityForFile(s32 priority) { - return htcfs::GetClient().SetPriorityForFile(priority, m_handle); + R_RETURN(htcfs::GetClient().SetPriorityForFile(priority, m_handle)); } Result FileServiceObject::GetPriorityForFile(ams::sf::Out out) { - return htcfs::GetClient().GetPriorityForFile(out.GetPointer(), m_handle); + R_RETURN(htcfs::GetClient().GetPriorityForFile(out.GetPointer(), m_handle)); } } diff --git a/libraries/libstratosphere/source/htcfs/htcfs_file_system_service_object.cpp b/libraries/libstratosphere/source/htcfs/htcfs_file_system_service_object.cpp index bf04ce941..b079f8016 100644 --- a/libraries/libstratosphere/source/htcfs/htcfs_file_system_service_object.cpp +++ b/libraries/libstratosphere/source/htcfs/htcfs_file_system_service_object.cpp @@ -86,7 +86,7 @@ namespace ams::htcfs { R_UNLESS(IsValidPath(path), htcfs::ResultInvalidArgument()); /* Get whether the file exists. */ - return htcfs::GetClient().FileExists(out.GetPointer(), path.str, case_sensitive); + R_RETURN(htcfs::GetClient().FileExists(out.GetPointer(), path.str, case_sensitive)); } Result FileSystemServiceObject::DeleteFile(const tma::Path &path, bool case_sensitive) { @@ -94,7 +94,7 @@ namespace ams::htcfs { R_UNLESS(IsValidPath(path), htcfs::ResultInvalidArgument()); /* Delete the file. */ - return htcfs::GetClient().DeleteFile(path.str, case_sensitive); + R_RETURN(htcfs::GetClient().DeleteFile(path.str, case_sensitive)); } Result FileSystemServiceObject::RenameFile(const tma::Path &old_path, const tma::Path &new_path, bool case_sensitive) { @@ -103,7 +103,7 @@ namespace ams::htcfs { R_UNLESS(IsValidPath(new_path), htcfs::ResultInvalidArgument()); /* Rename the file. */ - return htcfs::GetClient().RenameFile(old_path.str, new_path.str, case_sensitive); + R_RETURN(htcfs::GetClient().RenameFile(old_path.str, new_path.str, case_sensitive)); } Result FileSystemServiceObject::GetIOType(sf::Out out, const tma::Path &path, bool case_sensitive) { @@ -112,7 +112,7 @@ namespace ams::htcfs { /* Get the entry type. */ static_assert(sizeof(s32) == sizeof(fs::DirectoryEntryType)); - return htcfs::GetClient().GetEntryType(reinterpret_cast(out.GetPointer()), path.str, case_sensitive); + R_RETURN(htcfs::GetClient().GetEntryType(reinterpret_cast(out.GetPointer()), path.str, case_sensitive)); } Result FileSystemServiceObject::OpenDirectory(sf::Out> out, const tma::Path &path, s32 open_mode, bool case_sensitive) { @@ -133,7 +133,7 @@ namespace ams::htcfs { R_UNLESS(IsValidPath(path), htcfs::ResultInvalidArgument()); /* Get whether the file exists. */ - return htcfs::GetClient().DirectoryExists(out.GetPointer(), path.str, case_sensitive); + R_RETURN(htcfs::GetClient().DirectoryExists(out.GetPointer(), path.str, case_sensitive)); } Result FileSystemServiceObject::CreateDirectory(const tma::Path &path, bool case_sensitive) { @@ -141,7 +141,7 @@ namespace ams::htcfs { R_UNLESS(IsValidPath(path), htcfs::ResultInvalidArgument()); /* Create the directory. */ - return htcfs::GetClient().CreateDirectory(path.str, case_sensitive); + R_RETURN(htcfs::GetClient().CreateDirectory(path.str, case_sensitive)); } Result FileSystemServiceObject::DeleteDirectory(const tma::Path &path, bool recursively, bool case_sensitive) { @@ -149,7 +149,7 @@ namespace ams::htcfs { R_UNLESS(IsValidPath(path), htcfs::ResultInvalidArgument()); /* Delete the directory. */ - return htcfs::GetClient().DeleteDirectory(path.str, recursively, case_sensitive); + R_RETURN(htcfs::GetClient().DeleteDirectory(path.str, recursively, case_sensitive)); } Result FileSystemServiceObject::RenameDirectory(const tma::Path &old_path, const tma::Path &new_path, bool case_sensitive) { @@ -158,7 +158,7 @@ namespace ams::htcfs { R_UNLESS(IsValidPath(new_path), htcfs::ResultInvalidArgument()); /* Rename the file. */ - return htcfs::GetClient().RenameDirectory(old_path.str, new_path.str, case_sensitive); + R_RETURN(htcfs::GetClient().RenameDirectory(old_path.str, new_path.str, case_sensitive)); } Result FileSystemServiceObject::CreateFile(const tma::Path &path, s64 size, bool case_sensitive) { @@ -166,7 +166,7 @@ namespace ams::htcfs { R_UNLESS(IsValidPath(path), htcfs::ResultInvalidArgument()); /* Create the file. */ - return htcfs::GetClient().CreateFile(path.str, size, case_sensitive); + R_RETURN(htcfs::GetClient().CreateFile(path.str, size, case_sensitive)); } Result FileSystemServiceObject::GetFileTimeStamp(sf::Out out_create, sf::Out out_access, sf::Out out_modify, const tma::Path &path, bool case_sensitive) { @@ -174,7 +174,7 @@ namespace ams::htcfs { R_UNLESS(IsValidPath(path), htcfs::ResultInvalidArgument()); /* Get the timestamp. */ - return htcfs::GetClient().GetFileTimeStamp(out_create.GetPointer(), out_access.GetPointer(), out_modify.GetPointer(), path.str, case_sensitive); + R_RETURN(htcfs::GetClient().GetFileTimeStamp(out_create.GetPointer(), out_access.GetPointer(), out_modify.GetPointer(), path.str, case_sensitive)); } Result FileSystemServiceObject::GetCaseSensitivePath(const tma::Path &path, const sf::OutBuffer &out) { @@ -182,7 +182,7 @@ namespace ams::htcfs { R_UNLESS(IsValidPath(path), htcfs::ResultInvalidArgument()); /* Get the case sensitive path. */ - return htcfs::GetClient().GetCaseSensitivePath(reinterpret_cast(out.GetPointer()), out.GetSize(), path.str); + R_RETURN(htcfs::GetClient().GetCaseSensitivePath(reinterpret_cast(out.GetPointer()), out.GetSize(), path.str)); } Result FileSystemServiceObject::GetDiskFreeSpaceExW(sf::Out out_free, sf::Out out_total, sf::Out out_total_free, const tma::Path &path) { @@ -190,7 +190,7 @@ namespace ams::htcfs { R_UNLESS(IsValidPath(path), htcfs::ResultInvalidArgument()); /* Get the timestamp. */ - return htcfs::GetClient().GetDiskFreeSpace(out_free.GetPointer(), out_total.GetPointer(), out_total_free.GetPointer(), path.str); + R_RETURN(htcfs::GetClient().GetDiskFreeSpace(out_free.GetPointer(), out_total.GetPointer(), out_total_free.GetPointer(), path.str)); } } diff --git a/libraries/libstratosphere/source/htcfs/htcfs_result.hpp b/libraries/libstratosphere/source/htcfs/htcfs_result.hpp index 1104f3588..ebe23300e 100644 --- a/libraries/libstratosphere/source/htcfs/htcfs_result.hpp +++ b/libraries/libstratosphere/source/htcfs/htcfs_result.hpp @@ -49,7 +49,7 @@ namespace ams::htcfs { } inline Result ConvertHtcfsResult(s64 param) { - return ConvertHtcfsResult(static_cast(param)); + R_RETURN(ConvertHtcfsResult(static_cast(param))); } } diff --git a/libraries/libstratosphere/source/htcfs/htcfs_result_utils.hpp b/libraries/libstratosphere/source/htcfs/htcfs_result_utils.hpp index 1957c07be..5d6c78fc8 100644 --- a/libraries/libstratosphere/source/htcfs/htcfs_result_utils.hpp +++ b/libraries/libstratosphere/source/htcfs/htcfs_result_utils.hpp @@ -26,7 +26,7 @@ namespace ams::htcfs { R_CONVERT(htcfs::ResultInternalError, fs::ResultInternal()) } R_END_TRY_CATCH; - return result; + R_RETURN(result); } } diff --git a/libraries/libstratosphere/source/htcfs/htcfs_working_directory.cpp b/libraries/libstratosphere/source/htcfs/htcfs_working_directory.cpp index 42d976519..88475d0f1 100644 --- a/libraries/libstratosphere/source/htcfs/htcfs_working_directory.cpp +++ b/libraries/libstratosphere/source/htcfs/htcfs_working_directory.cpp @@ -19,11 +19,11 @@ namespace ams::htcfs { Result GetWorkingDirectory(char *dst, size_t dst_size) { - return htcfs::GetClient().GetWorkingDirectory(dst, dst_size); + R_RETURN(htcfs::GetClient().GetWorkingDirectory(dst, dst_size)); } Result GetWorkingDirectorySize(s32 *out) { - return htcfs::GetClient().GetWorkingDirectorySize(out); + R_RETURN(htcfs::GetClient().GetWorkingDirectorySize(out)); } } diff --git a/libraries/libstratosphere/source/htclow/ctrl/htclow_ctrl_service.cpp b/libraries/libstratosphere/source/htclow/ctrl/htclow_ctrl_service.cpp index 4f1356e87..6f39cab53 100644 --- a/libraries/libstratosphere/source/htclow/ctrl/htclow_ctrl_service.cpp +++ b/libraries/libstratosphere/source/htclow/ctrl/htclow_ctrl_service.cpp @@ -122,19 +122,19 @@ namespace ams::htclow::ctrl { switch (header.packet_type) { case HtcctrlPacketType_ConnectFromHost: - return this->ProcessReceiveConnectPacket(); + R_RETURN(this->ProcessReceiveConnectPacket()); case HtcctrlPacketType_ReadyFromHost: - return this->ProcessReceiveReadyPacket(body, body_size); + R_RETURN(this->ProcessReceiveReadyPacket(body, body_size)); case HtcctrlPacketType_SuspendFromHost: - return this->ProcessReceiveSuspendPacket(); + R_RETURN(this->ProcessReceiveSuspendPacket()); case HtcctrlPacketType_ResumeFromHost: - return this->ProcessReceiveResumePacket(); + R_RETURN(this->ProcessReceiveResumePacket()); case HtcctrlPacketType_DisconnectFromHost: - return this->ProcessReceiveDisconnectPacket(); + R_RETURN(this->ProcessReceiveDisconnectPacket()); case HtcctrlPacketType_BeaconQuery: - return this->ProcessReceiveBeaconQueryPacket(); + R_RETURN(this->ProcessReceiveBeaconQueryPacket()); default: - return this->ProcessReceiveUnexpectedPacket(); + R_RETURN(this->ProcessReceiveUnexpectedPacket()); } } @@ -142,7 +142,7 @@ namespace ams::htclow::ctrl { /* Try to transition to sent connect state. */ if (R_FAILED(this->SetState(HtcctrlState_SentConnectFromHost))) { /* We couldn't transition to sent connect. */ - return this->ProcessReceiveUnexpectedPacket(); + R_RETURN(this->ProcessReceiveUnexpectedPacket()); } /* Send a connect packet. */ @@ -160,7 +160,7 @@ namespace ams::htclow::ctrl { /* Check that our version is correct. */ if (m_version < ProtocolVersion) { - return this->ProcessReceiveUnexpectedPacket(); + R_RETURN(this->ProcessReceiveUnexpectedPacket()); } /* Set our version. */ @@ -169,7 +169,7 @@ namespace ams::htclow::ctrl { /* Set our state. */ if (R_FAILED(this->SetState(HtcctrlState_SentReadyFromHost))) { - return this->ProcessReceiveUnexpectedPacket(); + R_RETURN(this->ProcessReceiveUnexpectedPacket()); } /* Ready ourselves. */ @@ -181,7 +181,7 @@ namespace ams::htclow::ctrl { /* Try to set our state to enter sleep. */ if (R_FAILED(this->SetState(HtcctrlState_EnterSleep))) { /* We couldn't transition to sleep. */ - return this->ProcessReceiveUnexpectedPacket(); + R_RETURN(this->ProcessReceiveUnexpectedPacket()); } R_SUCCEED(); @@ -191,7 +191,7 @@ namespace ams::htclow::ctrl { /* If our state is sent-resume, change to readied. */ if (m_state_machine->GetHtcctrlState() != HtcctrlState_SentResumeFromTarget || R_FAILED(this->SetState(HtcctrlState_Ready))) { /* We couldn't perform a valid resume transition. */ - return this->ProcessReceiveUnexpectedPacket(); + R_RETURN(this->ProcessReceiveUnexpectedPacket()); } R_SUCCEED(); diff --git a/libraries/libstratosphere/source/htclow/driver/htclow_socket_driver.cpp b/libraries/libstratosphere/source/htclow/driver/htclow_socket_driver.cpp index 2b68ec389..23b479acb 100644 --- a/libraries/libstratosphere/source/htclow/driver/htclow_socket_driver.cpp +++ b/libraries/libstratosphere/source/htclow/driver/htclow_socket_driver.cpp @@ -226,7 +226,7 @@ namespace ams::htclow::driver { } /* Return our connection result. */ - return m_connect_result; + R_RETURN(m_connect_result); } void SocketDriver::Shutdown() { diff --git a/libraries/libstratosphere/source/htclow/driver/htclow_usb_driver.cpp b/libraries/libstratosphere/source/htclow/driver/htclow_usb_driver.cpp index cbea212ef..fceb0b5f4 100644 --- a/libraries/libstratosphere/source/htclow/driver/htclow_usb_driver.cpp +++ b/libraries/libstratosphere/source/htclow/driver/htclow_usb_driver.cpp @@ -45,7 +45,7 @@ namespace ams::htclow::driver { SetUsbAvailabilityChangeCallback(OnUsbAvailabilityChange, this); /* Initialize the interface. */ - return InitializeUsbInterface(); + R_RETURN(InitializeUsbInterface()); } void UsbDriver::Close() { diff --git a/libraries/libstratosphere/source/htclow/driver/htclow_usb_impl.cpp b/libraries/libstratosphere/source/htclow/driver/htclow_usb_impl.cpp index da3bf7973..24aac8f60 100644 --- a/libraries/libstratosphere/source/htclow/driver/htclow_usb_impl.cpp +++ b/libraries/libstratosphere/source/htclow/driver/htclow_usb_impl.cpp @@ -214,7 +214,7 @@ namespace ams::htclow::driver { R_THROW(htclow::ResultUsbDriverUnknownError()); } } else { - return result; + R_RETURN(result); } } diff --git a/libraries/libstratosphere/source/htclow/htclow_channel.cpp b/libraries/libstratosphere/source/htclow/htclow_channel.cpp index e38767fea..464fe47e5 100644 --- a/libraries/libstratosphere/source/htclow/htclow_channel.cpp +++ b/libraries/libstratosphere/source/htclow/htclow_channel.cpp @@ -30,7 +30,7 @@ namespace ams::htclow { }; /* Open the channel. */ - return m_manager->Open(impl::ConvertChannelType(m_channel)); + R_RETURN(m_manager->Open(impl::ConvertChannelType(m_channel))); } void Channel::Close() { @@ -56,7 +56,7 @@ namespace ams::htclow { this->WaitEvent(m_manager->GetTaskEvent(task_id), false); /* End the flush. */ - return m_manager->ConnectEnd(channel, task_id); + R_RETURN(m_manager->ConnectEnd(channel, task_id)); } Result Channel::Flush() { @@ -68,7 +68,7 @@ namespace ams::htclow { this->WaitEvent(m_manager->GetTaskEvent(task_id), true); /* End the flush. */ - return m_manager->FlushEnd(task_id); + R_RETURN(m_manager->FlushEnd(task_id)); } void Channel::Shutdown() { @@ -101,7 +101,7 @@ namespace ams::htclow { if (htclow::ResultChannelNotExist::Includes(result)) { *out = received; } - return result; + R_RETURN(result); } received += static_cast(cur_received); @@ -134,7 +134,7 @@ namespace ams::htclow { if (total_sent != 0) { break; } else { - return begin_result; + R_RETURN(begin_result); } } @@ -172,7 +172,7 @@ namespace ams::htclow { /* Check pre-conditions. */ AMS_ASSERT(util::IsIntValueRepresentable(size)); - return this->WaitReceiveInternal(size, nullptr); + R_RETURN(this->WaitReceiveInternal(size, nullptr)); } Result Channel::WaitReceive(s64 size, os::EventType *event) { @@ -180,7 +180,7 @@ namespace ams::htclow { AMS_ASSERT(util::IsIntValueRepresentable(size)); AMS_ASSERT(event != nullptr); - return this->WaitReceiveInternal(size, event); + R_RETURN(this->WaitReceiveInternal(size, event)); } void Channel::WaitEvent(os::EventType *event, bool) { @@ -229,7 +229,7 @@ namespace ams::htclow { } /* End the wait. */ - return m_manager->WaitReceiveEnd(task_id); + R_RETURN(m_manager->WaitReceiveEnd(task_id)); } } diff --git a/libraries/libstratosphere/source/htclow/htclow_manager.cpp b/libraries/libstratosphere/source/htclow/htclow_manager.cpp index 88781cf3f..01b9ee384 100644 --- a/libraries/libstratosphere/source/htclow/htclow_manager.cpp +++ b/libraries/libstratosphere/source/htclow/htclow_manager.cpp @@ -29,7 +29,7 @@ namespace ams::htclow { } Result HtclowManager::OpenDriver(impl::DriverType driver_type) { - return m_impl->OpenDriver(driver_type); + R_RETURN(m_impl->OpenDriver(driver_type)); } void HtclowManager::CloseDriver() { @@ -37,11 +37,11 @@ namespace ams::htclow { } Result HtclowManager::Open(impl::ChannelInternalType channel) { - return m_impl->Open(channel); + R_RETURN(m_impl->Open(channel)); } Result HtclowManager::Close(impl::ChannelInternalType channel) { - return m_impl->Close(channel); + R_RETURN(m_impl->Close(channel)); } void HtclowManager::Resume() { @@ -53,11 +53,11 @@ namespace ams::htclow { } Result HtclowManager::ConnectBegin(u32 *out_task_id, impl::ChannelInternalType channel) { - return m_impl->ConnectBegin(out_task_id, channel); + R_RETURN(m_impl->ConnectBegin(out_task_id, channel)); } Result HtclowManager::ConnectEnd(impl::ChannelInternalType channel, u32 task_id) { - return m_impl->ConnectEnd(channel, task_id); + R_RETURN(m_impl->ConnectEnd(channel, task_id)); } void HtclowManager::Disconnect() { @@ -65,11 +65,11 @@ namespace ams::htclow { } Result HtclowManager::FlushBegin(u32 *out_task_id, impl::ChannelInternalType channel) { - return m_impl->FlushBegin(out_task_id, channel); + R_RETURN(m_impl->FlushBegin(out_task_id, channel)); } Result HtclowManager::FlushEnd(u32 task_id) { - return m_impl->FlushEnd(task_id); + R_RETURN(m_impl->FlushEnd(task_id)); } ChannelState HtclowManager::GetChannelState(impl::ChannelInternalType channel) { @@ -97,27 +97,27 @@ namespace ams::htclow { } Result HtclowManager::ReceiveBegin(u32 *out_task_id, impl::ChannelInternalType channel, size_t size) { - return m_impl->ReceiveBegin(out_task_id, channel, size); + R_RETURN(m_impl->ReceiveBegin(out_task_id, channel, size)); } Result HtclowManager::ReceiveEnd(size_t *out, void *dst, size_t dst_size, impl::ChannelInternalType channel, u32 task_id) { - return m_impl->ReceiveEnd(out, dst, dst_size, channel, task_id); + R_RETURN(m_impl->ReceiveEnd(out, dst, dst_size, channel, task_id)); } Result HtclowManager::SendBegin(u32 *out_task_id, size_t *out, const void *src, size_t src_size, impl::ChannelInternalType channel) { - return m_impl->SendBegin(out_task_id, out, src, src_size, channel); + R_RETURN(m_impl->SendBegin(out_task_id, out, src, src_size, channel)); } Result HtclowManager::SendEnd(u32 task_id) { - return m_impl->SendEnd(task_id); + R_RETURN(m_impl->SendEnd(task_id)); } Result HtclowManager::WaitReceiveBegin(u32 *out_task_id, impl::ChannelInternalType channel, size_t size) { - return m_impl->WaitReceiveBegin(out_task_id, channel, size); + R_RETURN(m_impl->WaitReceiveBegin(out_task_id, channel, size)); } Result HtclowManager::WaitReceiveEnd(u32 task_id) { - return m_impl->WaitReceiveEnd(task_id); + R_RETURN(m_impl->WaitReceiveEnd(task_id)); } void HtclowManager::SetConfig(impl::ChannelInternalType channel, const ChannelConfig &config) { @@ -141,7 +141,7 @@ namespace ams::htclow { } Result HtclowManager::Shutdown(impl::ChannelInternalType channel) { - return m_impl->Shutdown(channel); + R_RETURN(m_impl->Shutdown(channel)); } } diff --git a/libraries/libstratosphere/source/htclow/htclow_manager_impl.cpp b/libraries/libstratosphere/source/htclow/htclow_manager_impl.cpp index 4ec8fdc5d..8cc75d983 100644 --- a/libraries/libstratosphere/source/htclow/htclow_manager_impl.cpp +++ b/libraries/libstratosphere/source/htclow/htclow_manager_impl.cpp @@ -75,11 +75,11 @@ namespace ams::htclow { } Result HtclowManagerImpl::Open(impl::ChannelInternalType channel) { - return m_mux.Open(channel); + R_RETURN(m_mux.Open(channel)); } Result HtclowManagerImpl::Close(impl::ChannelInternalType channel) { - return m_mux.Close(channel); + R_RETURN(m_mux.Close(channel)); } void HtclowManagerImpl::Resume() { @@ -118,7 +118,7 @@ namespace ams::htclow { } Result HtclowManagerImpl::ConnectEnd(impl::ChannelInternalType channel, u32 task_id) { - return m_mux.ConnectEnd(channel, task_id); + R_RETURN(m_mux.ConnectEnd(channel, task_id)); } void HtclowManagerImpl::Disconnect() { @@ -126,11 +126,11 @@ namespace ams::htclow { } Result HtclowManagerImpl::FlushBegin(u32 *out_task_id, impl::ChannelInternalType channel) { - return m_mux.FlushBegin(out_task_id, channel); + R_RETURN(m_mux.FlushBegin(out_task_id, channel)); } Result HtclowManagerImpl::FlushEnd(u32 task_id) { - return m_mux.FlushEnd(task_id); + R_RETURN(m_mux.FlushEnd(task_id)); } ChannelState HtclowManagerImpl::GetChannelState(impl::ChannelInternalType channel) { @@ -158,27 +158,27 @@ namespace ams::htclow { } Result HtclowManagerImpl::ReceiveBegin(u32 *out_task_id, impl::ChannelInternalType channel, size_t size) { - return m_mux.ReceiveBegin(out_task_id, channel, size); + R_RETURN(m_mux.ReceiveBegin(out_task_id, channel, size)); } Result HtclowManagerImpl::ReceiveEnd(size_t *out, void *dst, size_t dst_size, impl::ChannelInternalType channel, u32 task_id) { - return m_mux.ReceiveEnd(out, dst, dst_size, channel, task_id); + R_RETURN(m_mux.ReceiveEnd(out, dst, dst_size, channel, task_id)); } Result HtclowManagerImpl::SendBegin(u32 *out_task_id, size_t *out, const void *src, size_t src_size, impl::ChannelInternalType channel) { - return m_mux.SendBegin(out_task_id, out, src, src_size, channel); + R_RETURN(m_mux.SendBegin(out_task_id, out, src, src_size, channel)); } Result HtclowManagerImpl::SendEnd(u32 task_id) { - return m_mux.SendEnd(task_id); + R_RETURN(m_mux.SendEnd(task_id)); } Result HtclowManagerImpl::WaitReceiveBegin(u32 *out_task_id, impl::ChannelInternalType channel, size_t size) { - return m_mux.WaitReceiveBegin(out_task_id, channel, size); + R_RETURN(m_mux.WaitReceiveBegin(out_task_id, channel, size)); } Result HtclowManagerImpl::WaitReceiveEnd(u32 task_id) { - return m_mux.WaitReceiveEnd(task_id); + R_RETURN(m_mux.WaitReceiveEnd(task_id)); } void HtclowManagerImpl::SetConfig(impl::ChannelInternalType channel, const ChannelConfig &config) { @@ -202,7 +202,7 @@ namespace ams::htclow { } Result HtclowManagerImpl::Shutdown(impl::ChannelInternalType channel) { - return m_mux.Shutdown(channel); + R_RETURN(m_mux.Shutdown(channel)); } } diff --git a/libraries/libstratosphere/source/htclow/mux/htclow_mux.cpp b/libraries/libstratosphere/source/htclow/mux/htclow_mux.cpp index d8be2e0b8..16b223f36 100644 --- a/libraries/libstratosphere/source/htclow/mux/htclow_mux.cpp +++ b/libraries/libstratosphere/source/htclow/mux/htclow_mux.cpp @@ -68,7 +68,7 @@ namespace ams::htclow::mux { /* Process for the channel. */ if (auto it = m_channel_impl_map.GetMap().find(header.channel); it != m_channel_impl_map.GetMap().end()) { - return m_channel_impl_map[it->second].ProcessReceivePacket(header, body, body_size); + R_RETURN(m_channel_impl_map[it->second].ProcessReceivePacket(header, body, body_size)); } else { if (header.packet_type == PacketType_Data || header.packet_type == PacketType_MaxData) { this->SendErrorPacket(header.channel); @@ -209,7 +209,7 @@ namespace ams::htclow::mux { R_UNLESS(it != m_channel_impl_map.GetMap().end(), htclow::ResultChannelNotExist()); /* Perform the connection. */ - return m_channel_impl_map[it->second].DoConnectBegin(out_task_id); + R_RETURN(m_channel_impl_map[it->second].DoConnectBegin(out_task_id)); } Result Mux::ConnectEnd(impl::ChannelInternalType channel, u32 task_id) { @@ -230,7 +230,7 @@ namespace ams::htclow::mux { R_UNLESS(it != m_channel_impl_map.GetMap().end(), htclow::ResultChannelNotExist()); /* Perform the disconnection. */ - return m_channel_impl_map[it->second].DoConnectEnd(); + R_RETURN(m_channel_impl_map[it->second].DoConnectEnd()); } ChannelState Mux::GetChannelState(impl::ChannelInternalType channel) { @@ -256,7 +256,7 @@ namespace ams::htclow::mux { R_UNLESS(it != m_channel_impl_map.GetMap().end(), htclow::ResultChannelNotExist()); /* Perform the connection. */ - return m_channel_impl_map[it->second].DoFlush(out_task_id); + R_RETURN(m_channel_impl_map[it->second].DoFlush(out_task_id)); } Result Mux::FlushEnd(u32 task_id) { @@ -291,7 +291,7 @@ namespace ams::htclow::mux { R_UNLESS(it != m_channel_impl_map.GetMap().end(), htclow::ResultChannelNotExist()); /* Perform the connection. */ - return m_channel_impl_map[it->second].DoReceiveBegin(out_task_id, size); + R_RETURN(m_channel_impl_map[it->second].DoReceiveBegin(out_task_id, size)); } Result Mux::ReceiveEnd(size_t *out, void *dst, size_t dst_size, impl::ChannelInternalType channel, u32 task_id) { @@ -308,7 +308,7 @@ namespace ams::htclow::mux { R_UNLESS(it != m_channel_impl_map.GetMap().end(), htclow::ResultChannelNotExist()); /* Perform the receive. */ - return m_channel_impl_map[it->second].DoReceiveEnd(out, dst, dst_size); + R_RETURN(m_channel_impl_map[it->second].DoReceiveEnd(out, dst, dst_size)); } else { *out = 0; R_SUCCEED(); @@ -324,7 +324,7 @@ namespace ams::htclow::mux { R_UNLESS(it != m_channel_impl_map.GetMap().end(), htclow::ResultChannelNotExist()); /* Perform the connection. */ - return m_channel_impl_map[it->second].DoSend(out_task_id, out, src, src_size); + R_RETURN(m_channel_impl_map[it->second].DoSend(out_task_id, out, src, src_size)); } Result Mux::SendEnd(u32 task_id) { @@ -344,7 +344,7 @@ namespace ams::htclow::mux { } Result Mux::WaitReceiveBegin(u32 *out_task_id, impl::ChannelInternalType channel, size_t size) { - return this->ReceiveBegin(out_task_id, channel, size); + R_RETURN(this->ReceiveBegin(out_task_id, channel, size)); } Result Mux::WaitReceiveEnd(u32 task_id) { @@ -420,7 +420,7 @@ namespace ams::htclow::mux { R_UNLESS(it != m_channel_impl_map.GetMap().end(), htclow::ResultChannelNotExist()); /* Perform the shutdown. */ - return m_channel_impl_map[it->second].DoShutdown(); + R_RETURN(m_channel_impl_map[it->second].DoShutdown()); } } diff --git a/libraries/libstratosphere/source/htclow/mux/htclow_mux_channel_impl.cpp b/libraries/libstratosphere/source/htclow/mux/htclow_mux_channel_impl.cpp index c6dd66d39..82ae6c8ef 100644 --- a/libraries/libstratosphere/source/htclow/mux/htclow_mux_channel_impl.cpp +++ b/libraries/libstratosphere/source/htclow/mux/htclow_mux_channel_impl.cpp @@ -67,11 +67,11 @@ namespace ams::htclow::mux { Result ChannelImpl::ProcessReceivePacket(const PacketHeader &header, const void *body, size_t body_size) { switch (header.packet_type) { case PacketType_Data: - return this->ProcessReceiveDataPacket(header.version, header.share, header.offset, body, body_size); + R_RETURN(this->ProcessReceiveDataPacket(header.version, header.share, header.offset, body, body_size)); case PacketType_MaxData: - return this->ProcessReceiveMaxDataPacket(header.version, header.share); + R_RETURN(this->ProcessReceiveMaxDataPacket(header.version, header.share)); case PacketType_Error: - return this->ProcessReceiveErrorPacket(); + R_RETURN(this->ProcessReceiveErrorPacket()); default: R_THROW(htclow::ResultProtocolError()); } diff --git a/libraries/libstratosphere/source/htcs/client/htcs_session.os.horizon.cpp b/libraries/libstratosphere/source/htcs/client/htcs_session.os.horizon.cpp index 6a267bf14..2e643980a 100644 --- a/libraries/libstratosphere/source/htcs/client/htcs_session.os.horizon.cpp +++ b/libraries/libstratosphere/source/htcs/client/htcs_session.os.horizon.cpp @@ -109,12 +109,12 @@ namespace ams::htcs::client { Result RemoteManager::GetPeerNameAny(sf::Out out) { static_assert(sizeof(htcs::HtcsPeerName) == sizeof(::HtcsPeerName)); - return ::htcsGetPeerNameAny(reinterpret_cast<::HtcsPeerName *>(out.GetPointer())); + R_RETURN(::htcsGetPeerNameAny(reinterpret_cast<::HtcsPeerName *>(out.GetPointer()))); } Result RemoteManager::GetDefaultHostName(sf::Out out) { static_assert(sizeof(htcs::HtcsPeerName) == sizeof(::HtcsPeerName)); - return ::htcsGetDefaultHostName(reinterpret_cast<::HtcsPeerName *>(out.GetPointer())); + R_RETURN(::htcsGetDefaultHostName(reinterpret_cast<::HtcsPeerName *>(out.GetPointer()))); } Result RemoteManager::CreateSocket(sf::Out out_err, sf::Out> out, bool enable_disconnection_emulation) { @@ -148,33 +148,33 @@ namespace ams::htcs::client { } Result RemoteManager::EndSelect(sf::Out out_err, sf::Out out_count, const sf::OutMapAliasArray &read_handles, const sf::OutMapAliasArray &write_handles, const sf::OutMapAliasArray &exception_handles, u32 task_id) { - return ::htcsEndSelect(out_err.GetPointer(), out_count.GetPointer(), read_handles.GetPointer(), read_handles.GetSize(), write_handles.GetPointer(), write_handles.GetSize(), exception_handles.GetPointer(), exception_handles.GetSize(), task_id); + R_RETURN(::htcsEndSelect(out_err.GetPointer(), out_count.GetPointer(), read_handles.GetPointer(), read_handles.GetSize(), write_handles.GetPointer(), write_handles.GetSize(), exception_handles.GetPointer(), exception_handles.GetSize(), task_id)); } Result RemoteSocket::Close(sf::Out out_err, sf::Out out_res) { - return ::htcsSocketClose(std::addressof(m_s), out_err.GetPointer(), out_res.GetPointer()); + R_RETURN(::htcsSocketClose(std::addressof(m_s), out_err.GetPointer(), out_res.GetPointer())); } Result RemoteSocket::Connect(sf::Out out_err, sf::Out out_res, const htcs::SockAddrHtcs &address) { static_assert(sizeof(htcs::SockAddrHtcs) == sizeof(::HtcsSockAddr)); - return ::htcsSocketConnect(std::addressof(m_s), out_err.GetPointer(), out_res.GetPointer(), reinterpret_cast(std::addressof(address))); + R_RETURN(::htcsSocketConnect(std::addressof(m_s), out_err.GetPointer(), out_res.GetPointer(), reinterpret_cast(std::addressof(address)))); } Result RemoteSocket::Bind(sf::Out out_err, sf::Out out_res, const htcs::SockAddrHtcs &address) { static_assert(sizeof(htcs::SockAddrHtcs) == sizeof(::HtcsSockAddr)); - return ::htcsSocketBind(std::addressof(m_s), out_err.GetPointer(), out_res.GetPointer(), reinterpret_cast(std::addressof(address))); + R_RETURN(::htcsSocketBind(std::addressof(m_s), out_err.GetPointer(), out_res.GetPointer(), reinterpret_cast(std::addressof(address)))); } Result RemoteSocket::Listen(sf::Out out_err, sf::Out out_res, s32 backlog_count) { - return ::htcsSocketListen(std::addressof(m_s), out_err.GetPointer(), out_res.GetPointer(), backlog_count); + R_RETURN(::htcsSocketListen(std::addressof(m_s), out_err.GetPointer(), out_res.GetPointer(), backlog_count)); } Result RemoteSocket::Shutdown(sf::Out out_err, sf::Out out_res, s32 how) { - return ::htcsSocketShutdown(std::addressof(m_s), out_err.GetPointer(), out_res.GetPointer(), how); + R_RETURN(::htcsSocketShutdown(std::addressof(m_s), out_err.GetPointer(), out_res.GetPointer(), how)); } Result RemoteSocket::Fcntl(sf::Out out_err, sf::Out out_res, s32 command, s32 value) { - return ::htcsSocketFcntl(std::addressof(m_s), out_err.GetPointer(), out_res.GetPointer(), command, value); + R_RETURN(::htcsSocketFcntl(std::addressof(m_s), out_err.GetPointer(), out_res.GetPointer(), command, value)); } Result RemoteSocket::AcceptStart(sf::Out out_task_id, sf::OutCopyHandle out_event) { @@ -205,7 +205,7 @@ namespace ams::htcs::client { } Result RemoteSocket::RecvResults(sf::Out out_err, sf::Out out_size, const sf::OutAutoSelectBuffer &buffer, u32 task_id) { - return ::htcsSocketRecvResults(std::addressof(m_s), out_err.GetPointer(), out_size.GetPointer(), buffer.GetPointer(), buffer.GetSize(), task_id); + R_RETURN(::htcsSocketRecvResults(std::addressof(m_s), out_err.GetPointer(), out_size.GetPointer(), buffer.GetPointer(), buffer.GetSize(), task_id)); } Result RemoteSocket::SendStart(sf::Out out_task_id, sf::OutCopyHandle out_event, const sf::InNonSecureAutoSelectBuffer &buffer, s32 flags) { @@ -217,7 +217,7 @@ namespace ams::htcs::client { } Result RemoteSocket::SendResults(sf::Out out_err, sf::Out out_size, u32 task_id) { - return ::htcsSocketSendResults(std::addressof(m_s), out_err.GetPointer(), out_size.GetPointer(), task_id); + R_RETURN(::htcsSocketSendResults(std::addressof(m_s), out_err.GetPointer(), out_size.GetPointer(), task_id)); } Result RemoteSocket::StartSend(sf::Out out_task_id, sf::OutCopyHandle out_event, sf::Out out_max_size, s64 size, s32 flags) { @@ -229,11 +229,11 @@ namespace ams::htcs::client { } Result RemoteSocket::ContinueSend(sf::Out out_size, sf::Out out_wait, const sf::InNonSecureAutoSelectBuffer &buffer, u32 task_id) { - return ::htcsSocketContinueSend(std::addressof(m_s), out_size.GetPointer(), out_wait.GetPointer(), buffer.GetPointer(), buffer.GetSize(), task_id); + R_RETURN(::htcsSocketContinueSend(std::addressof(m_s), out_size.GetPointer(), out_wait.GetPointer(), buffer.GetPointer(), buffer.GetSize(), task_id)); } Result RemoteSocket::EndSend(sf::Out out_err, sf::Out out_size, u32 task_id) { - return ::htcsSocketEndSend(std::addressof(m_s), out_err.GetPointer(), out_size.GetPointer(), task_id); + R_RETURN(::htcsSocketEndSend(std::addressof(m_s), out_err.GetPointer(), out_size.GetPointer(), task_id)); } Result RemoteSocket::StartRecv(sf::Out out_task_id, sf::OutCopyHandle out_event, s64 size, s32 flags) { @@ -245,11 +245,11 @@ namespace ams::htcs::client { } Result RemoteSocket::EndRecv(sf::Out out_err, sf::Out out_size, const sf::OutAutoSelectBuffer &buffer, u32 task_id) { - return ::htcsSocketEndRecv(std::addressof(m_s), out_err.GetPointer(), out_size.GetPointer(), buffer.GetPointer(), buffer.GetSize(), task_id); + R_RETURN(::htcsSocketEndRecv(std::addressof(m_s), out_err.GetPointer(), out_size.GetPointer(), buffer.GetPointer(), buffer.GetSize(), task_id)); } Result RemoteSocket::GetPrimitive(sf::Out out) { - return ::htcsSocketGetPrimitive(std::addressof(m_s), out.GetPointer()); + R_RETURN(::htcsSocketGetPrimitive(std::addressof(m_s), out.GetPointer())); } } diff --git a/libraries/libstratosphere/source/htcs/impl/htcs_manager.cpp b/libraries/libstratosphere/source/htcs/impl/htcs_manager.cpp index 7ec1c7099..1900c90cf 100644 --- a/libraries/libstratosphere/source/htcs/impl/htcs_manager.cpp +++ b/libraries/libstratosphere/source/htcs/impl/htcs_manager.cpp @@ -205,7 +205,7 @@ namespace ams::htcs::impl { } Result HtcsManager::AcceptStart(u32 *out_task_id, os::NativeHandle *out_handle, s32 desc) { - return m_impl->AcceptStart(out_task_id, out_handle, desc); + R_RETURN(m_impl->AcceptStart(out_task_id, out_handle, desc)); } void HtcsManager::AcceptResults(s32 *out_err, s32 *out_desc, SockAddrHtcs *out_address, u32 task_id, s32 desc) { @@ -228,7 +228,7 @@ namespace ams::htcs::impl { } Result HtcsManager::RecvStart(u32 *out_task_id, os::NativeHandle *out_handle, s64 size, s32 desc, s32 flags) { - return m_impl->RecvStart(out_task_id, out_handle, size, desc, flags); + R_RETURN(m_impl->RecvStart(out_task_id, out_handle, size, desc, flags)); } void HtcsManager::RecvResults(s32 *out_err, s64 *out_size, char *buffer, s64 buffer_size, u32 task_id, s32 desc) { @@ -256,11 +256,11 @@ namespace ams::htcs::impl { } Result HtcsManager::SendStart(u32 *out_task_id, os::NativeHandle *out_handle, const char *buffer, s64 size, s32 desc, s32 flags) { - return m_impl->SendStart(out_task_id, out_handle, buffer, size, desc, flags); + R_RETURN(m_impl->SendStart(out_task_id, out_handle, buffer, size, desc, flags)); } Result HtcsManager::SendLargeStart(u32 *out_task_id, os::NativeHandle *out_handle, const char **buffers, const s64 *sizes, s32 count, s32 desc, s32 flags) { - return m_impl->SendLargeStart(out_task_id, out_handle, buffers, sizes, count, desc, flags); + R_RETURN(m_impl->SendLargeStart(out_task_id, out_handle, buffers, sizes, count, desc, flags)); } void HtcsManager::SendResults(s32 *out_err, s64 *out_size, u32 task_id, s32 desc) { @@ -288,7 +288,7 @@ namespace ams::htcs::impl { } Result HtcsManager::StartSend(u32 *out_task_id, os::NativeHandle *out_handle, s32 desc, s64 size, s32 flags) { - return m_impl->StartSend(out_task_id, out_handle, desc, size, flags); + R_RETURN(m_impl->StartSend(out_task_id, out_handle, desc, size, flags)); } Result HtcsManager::ContinueSend(s64 *out_size, const char *buffer, s64 buffer_size, u32 task_id, s32 desc) { @@ -329,7 +329,7 @@ namespace ams::htcs::impl { } Result HtcsManager::StartRecv(u32 *out_task_id, os::NativeHandle *out_handle, s64 size, s32 desc, s32 flags) { - return m_impl->StartRecv(out_task_id, out_handle, size, desc, flags); + R_RETURN(m_impl->StartRecv(out_task_id, out_handle, size, desc, flags)); } void HtcsManager::EndRecv(s32 *out_err, s64 *out_size, char *buffer, s64 buffer_size, u32 task_id, s32 desc) { diff --git a/libraries/libstratosphere/source/htcs/impl/htcs_manager_impl.cpp b/libraries/libstratosphere/source/htcs/impl/htcs_manager_impl.cpp index ed8e9c6ba..760007416 100644 --- a/libraries/libstratosphere/source/htcs/impl/htcs_manager_impl.cpp +++ b/libraries/libstratosphere/source/htcs/impl/htcs_manager_impl.cpp @@ -47,55 +47,55 @@ namespace ams::htcs::impl { } Result HtcsManagerImpl::CreateSocket(s32 *out_err, s32 *out_desc, bool enable_disconnection_emulation) { - return m_service.CreateSocket(out_err, out_desc, enable_disconnection_emulation); + R_RETURN(m_service.CreateSocket(out_err, out_desc, enable_disconnection_emulation)); } Result HtcsManagerImpl::DestroySocket(s32 desc) { - return m_service.DestroySocket(desc); + R_RETURN(m_service.DestroySocket(desc)); } Result HtcsManagerImpl::Connect(s32 *out_err, s32 desc, const SockAddrHtcs &address) { - return m_service.Connect(out_err, desc, address); + R_RETURN(m_service.Connect(out_err, desc, address)); } Result HtcsManagerImpl::Bind(s32 *out_err, s32 desc, const SockAddrHtcs &address) { - return m_service.Bind(out_err, desc, address); + R_RETURN(m_service.Bind(out_err, desc, address)); } Result HtcsManagerImpl::Listen(s32 *out_err, s32 desc, s32 backlog_count) { - return m_service.Listen(out_err, desc, backlog_count); + R_RETURN(m_service.Listen(out_err, desc, backlog_count)); } Result HtcsManagerImpl::Receive(s32 *out_err, s64 *out_size, char *buffer, size_t size, s32 desc, s32 flags) { - return m_service.Receive(out_err, out_size, buffer, size, desc, flags); + R_RETURN(m_service.Receive(out_err, out_size, buffer, size, desc, flags)); } Result HtcsManagerImpl::Send(s32 *out_err, s64 *out_size, const char *buffer, size_t size, s32 desc, s32 flags) { - return m_service.Send(out_err, out_size, buffer, size, desc, flags); + R_RETURN(m_service.Send(out_err, out_size, buffer, size, desc, flags)); } Result HtcsManagerImpl::Shutdown(s32 *out_err, s32 desc, s32 how) { - return m_service.Shutdown(out_err, desc, how); + R_RETURN(m_service.Shutdown(out_err, desc, how)); } Result HtcsManagerImpl::Fcntl(s32 *out_err, s32 *out_res, s32 desc, s32 command, s32 value) { - return m_service.Fcntl(out_err, out_res, desc, command, value); + R_RETURN(m_service.Fcntl(out_err, out_res, desc, command, value)); } Result HtcsManagerImpl::AcceptStart(u32 *out_task_id, os::NativeHandle *out_handle, s32 desc) { - return m_service.AcceptStart(out_task_id, out_handle, desc); + R_RETURN(m_service.AcceptStart(out_task_id, out_handle, desc)); } Result HtcsManagerImpl::AcceptResults(s32 *out_err, s32 *out_desc, SockAddrHtcs *out_address, u32 task_id, s32 desc) { - return m_service.AcceptResults(out_err, out_desc, out_address, task_id, desc); + R_RETURN(m_service.AcceptResults(out_err, out_desc, out_address, task_id, desc)); } Result HtcsManagerImpl::RecvStart(u32 *out_task_id, os::NativeHandle *out_handle, s64 size, s32 desc, s32 flags) { - return m_service.ReceiveSmallStart(out_task_id, out_handle, size, desc, flags); + R_RETURN(m_service.ReceiveSmallStart(out_task_id, out_handle, size, desc, flags)); } Result HtcsManagerImpl::RecvResults(s32 *out_err, s64 *out_size, char *buffer, s64 buffer_size, u32 task_id, s32 desc) { - return m_service.ReceiveSmallResults(out_err, out_size, buffer, buffer_size, task_id, desc); + R_RETURN(m_service.ReceiveSmallResults(out_err, out_size, buffer, buffer_size, task_id, desc)); } Result HtcsManagerImpl::SendStart(u32 *out_task_id, os::NativeHandle *out_handle, const char *buffer, s64 size, s32 desc, s32 flags) { @@ -110,6 +110,8 @@ namespace ams::htcs::impl { if (R_SUCCEEDED(result) || htcs::ResultCompleted::Includes(result) || htc::ResultTaskQueueNotAvailable::Includes(result)) { *out_task_id = task_id; *out_handle = handle; + + R_SUCCEED(); } else { os::SystemEventType event; os::AttachReadableHandleToSystemEvent(std::addressof(event), handle, true, os::EventClearMode_ManualClear); @@ -120,10 +122,8 @@ namespace ams::htcs::impl { os::DestroySystemEvent(std::addressof(event)); - return result; + R_RETURN(result); } - - R_SUCCEED(); } Result HtcsManagerImpl::SendLargeStart(u32 *out_task_id, os::NativeHandle *out_handle, const char **buffers, const s64 *sizes, s32 count, s32 desc, s32 flags) { @@ -133,27 +133,27 @@ namespace ams::htcs::impl { } Result HtcsManagerImpl::SendResults(s32 *out_err, s64 *out_size, u32 task_id, s32 desc) { - return m_service.SendSmallResults(out_err, out_size, task_id, desc); + R_RETURN(m_service.SendSmallResults(out_err, out_size, task_id, desc)); } Result HtcsManagerImpl::StartSend(u32 *out_task_id, os::NativeHandle *out_handle, s32 desc, s64 size, s32 flags) { - return m_service.SendStart(out_task_id, out_handle, desc, size, flags); + R_RETURN(m_service.SendStart(out_task_id, out_handle, desc, size, flags)); } Result HtcsManagerImpl::ContinueSend(s64 *out_size, const char *buffer, s64 buffer_size, u32 task_id, s32 desc) { - return m_service.SendContinue(out_size, buffer, buffer_size, task_id, desc); + R_RETURN(m_service.SendContinue(out_size, buffer, buffer_size, task_id, desc)); } Result HtcsManagerImpl::EndSend(s32 *out_err, s64 *out_size, u32 task_id, s32 desc) { - return m_service.SendResults(out_err, out_size, task_id, desc); + R_RETURN(m_service.SendResults(out_err, out_size, task_id, desc)); } Result HtcsManagerImpl::StartRecv(u32 *out_task_id, os::NativeHandle *out_handle, s64 size, s32 desc, s32 flags) { - return m_service.ReceiveStart(out_task_id, out_handle, size, desc, flags); + R_RETURN(m_service.ReceiveStart(out_task_id, out_handle, size, desc, flags)); } Result HtcsManagerImpl::EndRecv(s32 *out_err, s64 *out_size, char *buffer, s64 buffer_size, u32 task_id, s32 desc) { - return m_service.ReceiveResults(out_err, out_size, buffer, buffer_size, task_id, desc); + R_RETURN(m_service.ReceiveResults(out_err, out_size, buffer, buffer_size, task_id, desc)); } Result HtcsManagerImpl::StartSelect(u32 *out_task_id, os::NativeHandle *out_handle, Span read_handles, Span write_handles, Span exception_handles, s64 tv_sec, s64 tv_usec) { @@ -179,11 +179,11 @@ namespace ams::htcs::impl { *out_handle = handle; } - return result; + R_RETURN(result); } Result HtcsManagerImpl::EndSelect(s32 *out_err, bool *out_empty, Span read_handles, Span write_handles, Span exception_handles, u32 task_id) { - return m_service.SelectEnd(out_err, out_empty, read_handles, write_handles, exception_handles, task_id); + R_RETURN(m_service.SelectEnd(out_err, out_empty, read_handles, write_handles, exception_handles, task_id)); } } diff --git a/libraries/libstratosphere/source/htcs/impl/htcs_service.cpp b/libraries/libstratosphere/source/htcs/impl/htcs_service.cpp index 61065da3e..4b57f7a5c 100644 --- a/libraries/libstratosphere/source/htcs/impl/htcs_service.cpp +++ b/libraries/libstratosphere/source/htcs/impl/htcs_service.cpp @@ -148,7 +148,7 @@ namespace ams::htcs::impl { s64 cont_size; const Result result = this->SendContinue(std::addressof(cont_size), buffer, size, task_id, desc); if (R_FAILED(result)) { - return this->SendResults(out_err, out_size, task_id, desc); + R_RETURN(this->SendResults(out_err, out_size, task_id, desc)); } /* Wait for the task to complete. */ diff --git a/libraries/libstratosphere/source/htcs/server/htcs_manager_service_object.cpp b/libraries/libstratosphere/source/htcs/server/htcs_manager_service_object.cpp index 3fafbe4a5..6dfb74594 100644 --- a/libraries/libstratosphere/source/htcs/server/htcs_manager_service_object.cpp +++ b/libraries/libstratosphere/source/htcs/server/htcs_manager_service_object.cpp @@ -44,7 +44,7 @@ namespace ams::htcs::server { } Result ManagerServiceObject::CreateSocketOld(sf::Out out_err, sf::Out> out) { - return this->CreateSocket(out_err, out, false); + R_RETURN(this->CreateSocket(out_err, out, false)); } Result ManagerServiceObject::CreateSocket(sf::Out out_err, sf::Out> out, bool enable_disconnection_emulation) { @@ -94,7 +94,7 @@ namespace ams::htcs::server { auto *manager = impl::HtcsManagerHolder::GetHtcsManager(); /* End the select. */ - return manager->EndSelect(out_err.GetPointer(), out_count.GetPointer(), read_handles.ToSpan(), write_handles.ToSpan(), exception_handles.ToSpan(), task_id); + R_RETURN(manager->EndSelect(out_err.GetPointer(), out_count.GetPointer(), read_handles.ToSpan(), write_handles.ToSpan(), exception_handles.ToSpan(), task_id)); } } diff --git a/libraries/libstratosphere/source/htcs/server/htcs_socket_service_object.cpp b/libraries/libstratosphere/source/htcs/server/htcs_socket_service_object.cpp index 09ff2d2ed..059abfd41 100644 --- a/libraries/libstratosphere/source/htcs/server/htcs_socket_service_object.cpp +++ b/libraries/libstratosphere/source/htcs/server/htcs_socket_service_object.cpp @@ -194,7 +194,7 @@ namespace ams::htcs::server { } Result SocketServiceObject::SendStartOld(sf::Out out_task_id, sf::OutCopyHandle out_event, const sf::InAutoSelectBuffer &buffer, s32 flags) { - return this->SendStart(out_task_id, out_event, sf::InNonSecureAutoSelectBuffer(buffer.GetPointer(), buffer.GetSize()), flags); + R_RETURN(this->SendStart(out_task_id, out_event, sf::InNonSecureAutoSelectBuffer(buffer.GetPointer(), buffer.GetSize()), flags)); } Result SocketServiceObject::SendLargeStart(sf::Out out_task_id, sf::OutCopyHandle out_event, const sf::InAutoSelectBuffer &start_buffer, const sf::InAutoSelectBuffer &end_buffer, sf::CopyHandle &&mem_handle, s64 aligned_size, s32 flags) { @@ -257,7 +257,7 @@ namespace ams::htcs::server { } Result SocketServiceObject::ContinueSendOld(sf::Out out_size, sf::Out out_wait, const sf::InAutoSelectBuffer &buffer, u32 task_id) { - return this->ContinueSend(out_size, out_wait, sf::InNonSecureAutoSelectBuffer(buffer.GetPointer(), buffer.GetSize()), task_id); + R_RETURN(this->ContinueSend(out_size, out_wait, sf::InNonSecureAutoSelectBuffer(buffer.GetPointer(), buffer.GetSize()), task_id)); } Result SocketServiceObject::EndSend(sf::Out out_err, sf::Out out_size, u32 task_id) { diff --git a/libraries/libstratosphere/source/i2c/driver/board/nintendo/nx/impl/i2c_bus_accessor.cpp b/libraries/libstratosphere/source/i2c/driver/board/nintendo/nx/impl/i2c_bus_accessor.cpp index ec47109e1..a59c6d65d 100644 --- a/libraries/libstratosphere/source/i2c/driver/board/nintendo/nx/impl/i2c_bus_accessor.cpp +++ b/libraries/libstratosphere/source/i2c/driver/board/nintendo/nx/impl/i2c_bus_accessor.cpp @@ -192,7 +192,7 @@ namespace ams::i2c::driver::board::nintendo::nx::impl { } /* Send the data. */ - return this->Send(static_cast(src), src_size, option, device->GetAddress(), device->GetAddressingMode()); + R_RETURN(this->Send(static_cast(src), src_size, option, device->GetAddress(), device->GetAddressingMode())); } Result I2cBusAccessor::Receive(void *dst, size_t dst_size, I2cDeviceProperty *device, TransactionOption option) { @@ -208,7 +208,7 @@ namespace ams::i2c::driver::board::nintendo::nx::impl { } /* Send the data. */ - return this->Receive(static_cast(dst), dst_size, option, device->GetAddress(), device->GetAddressingMode()); + R_RETURN(this->Receive(static_cast(dst), dst_size, option, device->GetAddress(), device->GetAddressingMode())); } void I2cBusAccessor::SuspendBus() { @@ -399,7 +399,7 @@ namespace ams::i2c::driver::board::nintendo::nx::impl { this->DisableInterruptMask(); os::ClearInterruptEvent(std::addressof(m_interrupt_event)); - return i2c::ResultTimeout(); + R_THROW(i2c::ResultTimeout()); } /* Check and handle any errors. */ @@ -429,7 +429,7 @@ namespace ams::i2c::driver::board::nintendo::nx::impl { this->DisableInterruptMask(); os::ClearInterruptEvent(std::addressof(m_interrupt_event)); - return i2c::ResultTimeout(); + R_THROW(i2c::ResultTimeout()); } } @@ -474,7 +474,7 @@ namespace ams::i2c::driver::board::nintendo::nx::impl { this->DisableInterruptMask(); os::ClearInterruptEvent(std::addressof(m_interrupt_event)); - return i2c::ResultTimeout(); + R_THROW(i2c::ResultTimeout()); } /* Check and handle any errors. */ diff --git a/libraries/libstratosphere/source/i2c/driver/board/nintendo/nx/impl/i2c_bus_accessor.hpp b/libraries/libstratosphere/source/i2c/driver/board/nintendo/nx/impl/i2c_bus_accessor.hpp index ab33ac988..f2c5046af 100644 --- a/libraries/libstratosphere/source/i2c/driver/board/nintendo/nx/impl/i2c_bus_accessor.hpp +++ b/libraries/libstratosphere/source/i2c/driver/board/nintendo/nx/impl/i2c_bus_accessor.hpp @@ -101,13 +101,13 @@ namespace ams::i2c::driver::board::nintendo::nx::impl { Result CheckAndHandleError() { const Result result = this->GetTransactionResult(); this->HandleTransactionError(result); + if (R_FAILED(result)) { this->DisableInterruptMask(); os::ClearInterruptEvent(std::addressof(m_interrupt_event)); - return result; } - R_SUCCEED(); + R_RETURN(result); } public: virtual void InitializeDriver() override; diff --git a/libraries/libstratosphere/source/i2c/driver/i2c_driver_bus_api.cpp b/libraries/libstratosphere/source/i2c/driver/i2c_driver_bus_api.cpp index 48b2cc72a..fcdea948b 100644 --- a/libraries/libstratosphere/source/i2c/driver/i2c_driver_bus_api.cpp +++ b/libraries/libstratosphere/source/i2c/driver/i2c_driver_bus_api.cpp @@ -27,14 +27,10 @@ namespace ams::i2c::driver { Result OpenSessionImpl(I2cSession *out, I2cDeviceProperty *device) { /* Construct the session. */ auto *session = std::construct_at(std::addressof(impl::GetI2cSessionImpl(*out)), DefaultRetryCount, DefaultRetryInterval); - auto session_guard = SCOPE_GUARD { std::destroy_at(session); }; + ON_RESULT_FAILURE { std::destroy_at(session); }; /* Open the session. */ - R_TRY(session->Open(device, ddsf::AccessMode_ReadWrite)); - - /* We succeeded. */ - session_guard.Cancel(); - R_SUCCEED(); + R_RETURN(session->Open(device, ddsf::AccessMode_ReadWrite)); } } @@ -48,9 +44,7 @@ namespace ams::i2c::driver { AMS_ASSERT(device != nullptr); /* Open the session. */ - R_TRY(OpenSessionImpl(out, device)); - - R_SUCCEED(); + R_RETURN(OpenSessionImpl(out, device)); } void CloseSession(I2cSession &session) { @@ -61,14 +55,14 @@ namespace ams::i2c::driver { AMS_ASSERT(src != nullptr); AMS_ABORT_UNLESS(src_size > 0); - return impl::GetOpenI2cSessionImpl(session).Send(src, src_size, option); + R_RETURN(impl::GetOpenI2cSessionImpl(session).Send(src, src_size, option)); } Result Receive(void *dst, size_t dst_size, I2cSession &session, TransactionOption option) { AMS_ASSERT(dst != nullptr); AMS_ABORT_UNLESS(dst_size > 0); - return impl::GetOpenI2cSessionImpl(session).Receive(dst, dst_size, option); + R_RETURN(impl::GetOpenI2cSessionImpl(session).Receive(dst, dst_size, option)); } Result ExecuteCommandList(void *dst, size_t dst_size, I2cSession &session, const void *src, size_t src_size) { @@ -78,14 +72,14 @@ namespace ams::i2c::driver { AMS_ABORT_UNLESS(src_size > 0); AMS_ABORT_UNLESS(dst_size > 0); - return impl::GetOpenI2cSessionImpl(session).ExecuteCommandList(dst, dst_size, src, src_size); + R_RETURN(impl::GetOpenI2cSessionImpl(session).ExecuteCommandList(dst, dst_size, src, src_size)); } Result SetRetryPolicy(I2cSession &session, int max_retry_count, int retry_interval_us) { AMS_ASSERT(max_retry_count > 0); AMS_ASSERT(retry_interval_us > 0); - return impl::GetOpenI2cSessionImpl(session).SetRetryPolicy(max_retry_count, retry_interval_us); + R_RETURN(impl::GetOpenI2cSessionImpl(session).SetRetryPolicy(max_retry_count, retry_interval_us)); } } diff --git a/libraries/libstratosphere/source/i2c/driver/i2c_driver_service_api.cpp b/libraries/libstratosphere/source/i2c/driver/i2c_driver_service_api.cpp index 372ce91d6..f24867fe0 100644 --- a/libraries/libstratosphere/source/i2c/driver/i2c_driver_service_api.cpp +++ b/libraries/libstratosphere/source/i2c/driver/i2c_driver_service_api.cpp @@ -28,7 +28,7 @@ namespace ams::i2c::driver { } Result RegisterDeviceCode(DeviceCode device_code, I2cDeviceProperty *device) { - return impl::RegisterDeviceCode(device_code, device); + R_RETURN(impl::RegisterDeviceCode(device_code, device)); } bool UnregisterDeviceCode(DeviceCode device_code) { diff --git a/libraries/libstratosphere/source/i2c/driver/impl/i2c_i2c_session_impl.cpp b/libraries/libstratosphere/source/i2c/driver/impl/i2c_i2c_session_impl.cpp index 6fffcd515..817e6ac43 100644 --- a/libraries/libstratosphere/source/i2c/driver/impl/i2c_i2c_session_impl.cpp +++ b/libraries/libstratosphere/source/i2c/driver/impl/i2c_i2c_session_impl.cpp @@ -148,7 +148,7 @@ namespace ams::i2c::driver::impl { os::SleepThread(m_retry_interval); continue; } - return i2c::ResultBusBusy(); + R_THROW(i2c::ResultBusBusy()); } } R_END_TRY_CATCH; @@ -160,14 +160,14 @@ namespace ams::i2c::driver::impl { /* Acquire exclusive access to the device. */ std::scoped_lock lk(this->GetDevice().SafeCastTo().GetDriver().SafeCastTo().GetTransactionOrderMutex()); - return this->ExecuteTransactionWithRetry(nullptr, Command::Send, src, src_size, option); + R_RETURN(this->ExecuteTransactionWithRetry(nullptr, Command::Send, src, src_size, option)); } Result I2cSessionImpl::Receive(void *dst, size_t dst_size, TransactionOption option) { /* Acquire exclusive access to the device. */ std::scoped_lock lk(this->GetDevice().SafeCastTo().GetDriver().SafeCastTo().GetTransactionOrderMutex()); - return this->ExecuteTransactionWithRetry(dst, Command::Receive, nullptr, dst_size, option); + R_RETURN(this->ExecuteTransactionWithRetry(dst, Command::Receive, nullptr, dst_size, option)); } Result I2cSessionImpl::ExecuteCommandList(void *dst, size_t dst_size, const void *src, size_t src_size) { diff --git a/libraries/libstratosphere/source/i2c/i2c_client_api.cpp b/libraries/libstratosphere/source/i2c/i2c_client_api.cpp index 6bd5b0d4f..b06b98ab8 100644 --- a/libraries/libstratosphere/source/i2c/i2c_client_api.cpp +++ b/libraries/libstratosphere/source/i2c/i2c_client_api.cpp @@ -130,20 +130,20 @@ namespace ams::i2c { Result Send(const I2cSession &session, const void *src, size_t src_size, TransactionOption option) { const ams::sf::InAutoSelectBuffer buf(src, src_size); - return GetInterface(session)->Send(buf, option); + R_RETURN(GetInterface(session)->Send(buf, option)); } Result Receive(void *dst, size_t dst_size, const I2cSession &session, TransactionOption option) { const ams::sf::OutAutoSelectBuffer buf(dst, dst_size); - return GetInterface(session)->Receive(buf, option); + R_RETURN(GetInterface(session)->Receive(buf, option)); } Result ExecuteCommandList(void *dst, size_t dst_size, const I2cSession &session, const void *src, size_t src_size) { const ams::sf::OutAutoSelectBuffer buf(dst, dst_size); const ams::sf::InPointerArray arr(static_cast(src), src_size); - return GetInterface(session)->ExecuteCommandList(buf, arr); + R_RETURN(GetInterface(session)->ExecuteCommandList(buf, arr)); } void SetRetryPolicy(const I2cSession &session, int max_retry_count, int retry_interval_us) { diff --git a/libraries/libstratosphere/source/i2c/server/i2c_server_manager_impl.cpp b/libraries/libstratosphere/source/i2c/server/i2c_server_manager_impl.cpp index fc9b924b3..94e85aff0 100644 --- a/libraries/libstratosphere/source/i2c/server/i2c_server_manager_impl.cpp +++ b/libraries/libstratosphere/source/i2c/server/i2c_server_manager_impl.cpp @@ -34,7 +34,7 @@ namespace ams::i2c::server { } Result ManagerImpl::OpenSession(ams::sf::Out> out, i2c::I2cDevice device) { - return this->OpenSession2(out, ConvertToDeviceCode(device)); + R_RETURN(this->OpenSession2(out, ConvertToDeviceCode(device))); } Result ManagerImpl::HasDevice(ams::sf::Out out, i2c::I2cDevice device) { diff --git a/libraries/libstratosphere/source/i2c/server/i2c_server_session_impl.hpp b/libraries/libstratosphere/source/i2c/server/i2c_server_session_impl.hpp index 8bb0b1ab3..78f18bbc2 100644 --- a/libraries/libstratosphere/source/i2c/server/i2c_server_session_impl.hpp +++ b/libraries/libstratosphere/source/i2c/server/i2c_server_session_impl.hpp @@ -44,31 +44,31 @@ namespace ams::i2c::server { public: /* Actual commands. */ Result SendOld(const ams::sf::InBuffer &in_data, i2c::TransactionOption option) { - return i2c::driver::Send(m_internal_session, in_data.GetPointer(), in_data.GetSize(), option); + R_RETURN(i2c::driver::Send(m_internal_session, in_data.GetPointer(), in_data.GetSize(), option)); } Result ReceiveOld(const ams::sf::OutBuffer &out_data, i2c::TransactionOption option) { - return i2c::driver::Receive(out_data.GetPointer(), out_data.GetSize(), m_internal_session, option); + R_RETURN(i2c::driver::Receive(out_data.GetPointer(), out_data.GetSize(), m_internal_session, option)); } Result ExecuteCommandListOld(const ams::sf::OutBuffer &rcv_buf, const ams::sf::InPointerArray &command_list){ - return i2c::driver::ExecuteCommandList(rcv_buf.GetPointer(), rcv_buf.GetSize(), m_internal_session, command_list.GetPointer(), command_list.GetSize() * sizeof(i2c::I2cCommand)); + R_RETURN(i2c::driver::ExecuteCommandList(rcv_buf.GetPointer(), rcv_buf.GetSize(), m_internal_session, command_list.GetPointer(), command_list.GetSize() * sizeof(i2c::I2cCommand))); } Result Send(const ams::sf::InAutoSelectBuffer &in_data, i2c::TransactionOption option) { - return i2c::driver::Send(m_internal_session, in_data.GetPointer(), in_data.GetSize(), option); + R_RETURN(i2c::driver::Send(m_internal_session, in_data.GetPointer(), in_data.GetSize(), option)); } Result Receive(const ams::sf::OutAutoSelectBuffer &out_data, i2c::TransactionOption option) { - return i2c::driver::Receive(out_data.GetPointer(), out_data.GetSize(), m_internal_session, option); + R_RETURN(i2c::driver::Receive(out_data.GetPointer(), out_data.GetSize(), m_internal_session, option)); } Result ExecuteCommandList(const ams::sf::OutAutoSelectBuffer &rcv_buf, const ams::sf::InPointerArray &command_list) { - return i2c::driver::ExecuteCommandList(rcv_buf.GetPointer(), rcv_buf.GetSize(), m_internal_session, command_list.GetPointer(), command_list.GetSize() * sizeof(i2c::I2cCommand)); + R_RETURN(i2c::driver::ExecuteCommandList(rcv_buf.GetPointer(), rcv_buf.GetSize(), m_internal_session, command_list.GetPointer(), command_list.GetSize() * sizeof(i2c::I2cCommand))); } Result SetRetryPolicy(s32 max_retry_count, s32 retry_interval_us) { - return i2c::driver::SetRetryPolicy(m_internal_session, max_retry_count, retry_interval_us); + R_RETURN(i2c::driver::SetRetryPolicy(m_internal_session, max_retry_count, retry_interval_us)); } }; static_assert(i2c::sf::IsISession); diff --git a/libraries/libstratosphere/source/kvdb/kvdb_file_key_value_store.cpp b/libraries/libstratosphere/source/kvdb/kvdb_file_key_value_store.cpp index 7e942680d..955ae0ef0 100644 --- a/libraries/libstratosphere/source/kvdb/kvdb_file_key_value_store.cpp +++ b/libraries/libstratosphere/source/kvdb/kvdb_file_key_value_store.cpp @@ -174,7 +174,7 @@ namespace ams::kvdb { } Result FileKeyValueStore::Initialize(const char *dir) { - return this->InitializeWithCache(dir, nullptr, 0, 0); + R_RETURN(this->InitializeWithCache(dir, nullptr, 0, 0)); } Result FileKeyValueStore::InitializeWithCache(const char *dir, void *cache_buffer, size_t cache_buffer_size, size_t cache_capacity) { diff --git a/libraries/libstratosphere/source/ldr/ldr_pm_api.os.horizon.cpp b/libraries/libstratosphere/source/ldr/ldr_pm_api.os.horizon.cpp index 90d6f4f9b..8441977f5 100644 --- a/libraries/libstratosphere/source/ldr/ldr_pm_api.os.horizon.cpp +++ b/libraries/libstratosphere/source/ldr/ldr_pm_api.os.horizon.cpp @@ -20,39 +20,39 @@ namespace ams::ldr::pm { /* Information API. */ Result CreateProcess(os::NativeHandle *out, PinId pin_id, u32 flags, Handle reslimit) { - return ldrPmCreateProcess(pin_id.value, flags, reslimit, out); + R_RETURN(ldrPmCreateProcess(pin_id.value, flags, reslimit, out)); } Result GetProgramInfo(ProgramInfo *out, const ncm::ProgramLocation &loc) { - return ldrPmGetProgramInfo(reinterpret_cast(std::addressof(loc)), reinterpret_cast(out)); + R_RETURN(ldrPmGetProgramInfo(reinterpret_cast(std::addressof(loc)), reinterpret_cast(out))); } Result PinProgram(PinId *out, const ncm::ProgramLocation &loc) { static_assert(sizeof(*out) == sizeof(u64), "PinId definition!"); - return ldrPmPinProgram(reinterpret_cast(std::addressof(loc)), reinterpret_cast(out)); + R_RETURN(ldrPmPinProgram(reinterpret_cast(std::addressof(loc)), reinterpret_cast(out))); } Result UnpinProgram(PinId pin_id) { - return ldrPmUnpinProgram(pin_id.value); + R_RETURN(ldrPmUnpinProgram(pin_id.value)); } Result HasLaunchedBootProgram(bool *out, ncm::ProgramId program_id) { - return ldrPmAtmosphereHasLaunchedBootProgram(out, static_cast(program_id)); + R_RETURN(ldrPmAtmosphereHasLaunchedBootProgram(out, static_cast(program_id))); } Result AtmosphereGetProgramInfo(ProgramInfo *out, cfg::OverrideStatus *out_status, const ncm::ProgramLocation &loc) { static_assert(sizeof(*out_status) == sizeof(CfgOverrideStatus), "CfgOverrideStatus definition!"); - return ldrPmAtmosphereGetProgramInfo(reinterpret_cast(out), reinterpret_cast(out_status), reinterpret_cast(std::addressof(loc))); + R_RETURN(ldrPmAtmosphereGetProgramInfo(reinterpret_cast(out), reinterpret_cast(out_status), reinterpret_cast(std::addressof(loc)))); } Result SetEnabledProgramVerification(bool enabled) { - return ldrPmSetEnabledProgramVerification(enabled); + R_RETURN(ldrPmSetEnabledProgramVerification(enabled)); } Result AtmospherePinProgram(PinId *out, const ncm::ProgramLocation &loc, const cfg::OverrideStatus &status) { static_assert(sizeof(*out) == sizeof(u64), "PinId definition!"); static_assert(sizeof(status) == sizeof(CfgOverrideStatus), "CfgOverrideStatus definition!"); - return ldrPmAtmospherePinProgram(reinterpret_cast(out), reinterpret_cast(std::addressof(loc)), reinterpret_cast(std::addressof(status))); + R_RETURN(ldrPmAtmospherePinProgram(reinterpret_cast(out), reinterpret_cast(std::addressof(loc)), reinterpret_cast(std::addressof(status)))); } } diff --git a/libraries/libstratosphere/source/ldr/ldr_shell_api.os.horizon.cpp b/libraries/libstratosphere/source/ldr/ldr_shell_api.os.horizon.cpp index fee8ddfe6..9f067af18 100644 --- a/libraries/libstratosphere/source/ldr/ldr_shell_api.os.horizon.cpp +++ b/libraries/libstratosphere/source/ldr/ldr_shell_api.os.horizon.cpp @@ -18,7 +18,7 @@ namespace ams::ldr { Result InitializeForShell() { - return ::ldrShellInitialize(); + R_RETURN(::ldrShellInitialize()); } Result FinalizeForShell() { @@ -27,11 +27,11 @@ namespace ams::ldr { } Result SetProgramArgument(ncm::ProgramId program_id, const void *arg, size_t size) { - return ::ldrShellSetProgramArguments(static_cast(program_id), arg, size); + R_RETURN(::ldrShellSetProgramArguments(static_cast(program_id), arg, size)); } Result FlushArguments() { - return ::ldrShellFlushArguments(); + R_RETURN(::ldrShellFlushArguments()); } } diff --git a/libraries/libstratosphere/source/lm/lm_remote_log_service.hpp b/libraries/libstratosphere/source/lm/lm_remote_log_service.hpp index c785283cc..b646173cc 100644 --- a/libraries/libstratosphere/source/lm/lm_remote_log_service.hpp +++ b/libraries/libstratosphere/source/lm/lm_remote_log_service.hpp @@ -40,7 +40,7 @@ namespace ams::lm { } Result SetDestination(u32 destination) { - return serviceDispatchIn(std::addressof(m_srv), 1, destination); + R_RETURN(serviceDispatchIn(std::addressof(m_srv), 1, destination)); } }; static_assert(lm::IsILogger); diff --git a/libraries/libstratosphere/source/lm/srv/lm_sd_card_logger.cpp b/libraries/libstratosphere/source/lm/srv/lm_sd_card_logger.cpp index 1d7d20ad0..6ba8c437d 100644 --- a/libraries/libstratosphere/source/lm/srv/lm_sd_card_logger.cpp +++ b/libraries/libstratosphere/source/lm/srv/lm_sd_card_logger.cpp @@ -197,9 +197,7 @@ namespace ams::lm::srv { .version = LogFileHeaderVersion }; - R_TRY(fs::WriteFile(file, 0, std::addressof(header), sizeof(header), fs::WriteOption::Flush)); - - R_SUCCEED(); + R_RETURN(fs::WriteFile(file, 0, std::addressof(header), sizeof(header), fs::WriteOption::Flush)); } bool WriteLogFileHeader(const char *path) { @@ -213,9 +211,7 @@ namespace ams::lm::srv { ON_SCOPE_EXIT { fs::CloseFile(file); }; /* Write the data. */ - R_TRY(fs::WriteFile(file, offset, data, size, fs::WriteOption::Flush)); - - R_SUCCEED(); + R_RETURN(fs::WriteFile(file, offset, data, size, fs::WriteOption::Flush)); } bool WriteLogFileBody(const char *path, s64 offset, const u8 *data, size_t size) { diff --git a/libraries/libstratosphere/source/lr/lr_registered_location_resolver_impl.cpp b/libraries/libstratosphere/source/lr/lr_registered_location_resolver_impl.cpp index 56d9d0c82..dd7cb67cd 100644 --- a/libraries/libstratosphere/source/lr/lr_registered_location_resolver_impl.cpp +++ b/libraries/libstratosphere/source/lr/lr_registered_location_resolver_impl.cpp @@ -140,11 +140,11 @@ namespace ams::lr { } Result RegisteredLocationResolverImpl::Refresh() { - return this->RefreshImpl(nullptr, 0); + R_RETURN(this->RefreshImpl(nullptr, 0)); } Result RegisteredLocationResolverImpl::RefreshExcluding(const sf::InArray &ids) { - return this->RefreshImpl(ids.GetPointer(), ids.GetSize()); + R_RETURN(this->RefreshImpl(ids.GetPointer(), ids.GetSize())); } } diff --git a/libraries/libstratosphere/source/lr/lr_remote_location_resolver_impl.hpp b/libraries/libstratosphere/source/lr/lr_remote_location_resolver_impl.hpp index d6ba3007d..dd7dcfc40 100644 --- a/libraries/libstratosphere/source/lr/lr_remote_location_resolver_impl.hpp +++ b/libraries/libstratosphere/source/lr/lr_remote_location_resolver_impl.hpp @@ -29,55 +29,55 @@ namespace ams::lr { public: /* Actual commands. */ Result ResolveProgramPath(sf::Out out, ncm::ProgramId id) { - return ::lrLrResolveProgramPath(std::addressof(m_srv), id.value, out->str); + R_RETURN(::lrLrResolveProgramPath(std::addressof(m_srv), id.value, out->str)); } Result RedirectProgramPath(const Path &path, ncm::ProgramId id) { - return ::lrLrRedirectProgramPath(std::addressof(m_srv), id.value, path.str); + R_RETURN(::lrLrRedirectProgramPath(std::addressof(m_srv), id.value, path.str)); } Result ResolveApplicationControlPath(sf::Out out, ncm::ProgramId id) { - return ::lrLrResolveApplicationControlPath(std::addressof(m_srv), id.value, out->str); + R_RETURN(::lrLrResolveApplicationControlPath(std::addressof(m_srv), id.value, out->str)); } Result ResolveApplicationHtmlDocumentPath(sf::Out out, ncm::ProgramId id) { - return ::lrLrResolveApplicationHtmlDocumentPath(std::addressof(m_srv), id.value, out->str); + R_RETURN(::lrLrResolveApplicationHtmlDocumentPath(std::addressof(m_srv), id.value, out->str)); } Result ResolveDataPath(sf::Out out, ncm::DataId id) { - return ::lrLrResolveDataPath(std::addressof(m_srv), id.value, out->str); + R_RETURN(::lrLrResolveDataPath(std::addressof(m_srv), id.value, out->str)); } Result RedirectApplicationControlPathDeprecated(const Path &path, ncm::ProgramId id) { - return ::lrLrRedirectApplicationControlPath(std::addressof(m_srv), id.value, 0, path.str); + R_RETURN(::lrLrRedirectApplicationControlPath(std::addressof(m_srv), id.value, 0, path.str)); } Result RedirectApplicationControlPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) { - return ::lrLrRedirectApplicationControlPath(std::addressof(m_srv), id.value, owner_id.value, path.str); + R_RETURN(::lrLrRedirectApplicationControlPath(std::addressof(m_srv), id.value, owner_id.value, path.str)); } Result RedirectApplicationHtmlDocumentPathDeprecated(const Path &path, ncm::ProgramId id) { - return ::lrLrRedirectApplicationHtmlDocumentPath(std::addressof(m_srv), id.value, 0, path.str); + R_RETURN(::lrLrRedirectApplicationHtmlDocumentPath(std::addressof(m_srv), id.value, 0, path.str)); } Result RedirectApplicationHtmlDocumentPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) { - return ::lrLrRedirectApplicationHtmlDocumentPath(std::addressof(m_srv), id.value, owner_id.value, path.str); + R_RETURN(::lrLrRedirectApplicationHtmlDocumentPath(std::addressof(m_srv), id.value, owner_id.value, path.str)); } Result ResolveApplicationLegalInformationPath(sf::Out out, ncm::ProgramId id) { - return ::lrLrResolveApplicationLegalInformationPath(std::addressof(m_srv), id.value, out->str); + R_RETURN(::lrLrResolveApplicationLegalInformationPath(std::addressof(m_srv), id.value, out->str)); } Result RedirectApplicationLegalInformationPathDeprecated(const Path &path, ncm::ProgramId id) { - return ::lrLrRedirectApplicationLegalInformationPath(std::addressof(m_srv), id.value, 0, path.str); + R_RETURN(::lrLrRedirectApplicationLegalInformationPath(std::addressof(m_srv), id.value, 0, path.str)); } Result RedirectApplicationLegalInformationPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) { - return ::lrLrRedirectApplicationLegalInformationPath(std::addressof(m_srv), id.value, owner_id.value, path.str); + R_RETURN(::lrLrRedirectApplicationLegalInformationPath(std::addressof(m_srv), id.value, owner_id.value, path.str)); } Result Refresh() { - return ::lrLrRefresh(std::addressof(m_srv)); + R_RETURN(::lrLrRefresh(std::addressof(m_srv))); } Result RedirectApplicationProgramPathDeprecated(const Path &path, ncm::ProgramId id) { @@ -104,7 +104,7 @@ namespace ams::lr { } Result EraseProgramRedirection(ncm::ProgramId id) { - return ::lrLrEraseProgramRedirection(std::addressof(m_srv), id.value); + R_RETURN(::lrLrEraseProgramRedirection(std::addressof(m_srv), id.value)); } Result EraseApplicationControlRedirection(ncm::ProgramId id) { diff --git a/libraries/libstratosphere/source/lr/lr_remote_registered_location_resolver_impl.hpp b/libraries/libstratosphere/source/lr/lr_remote_registered_location_resolver_impl.hpp index f0aada3ae..27b7c8b82 100644 --- a/libraries/libstratosphere/source/lr/lr_remote_registered_location_resolver_impl.hpp +++ b/libraries/libstratosphere/source/lr/lr_remote_registered_location_resolver_impl.hpp @@ -30,7 +30,7 @@ namespace ams::lr { public: /* Actual commands. */ Result ResolveProgramPath(sf::Out out, ncm::ProgramId id) { - return ::lrRegLrResolveProgramPath(std::addressof(m_srv), id.value, out->str); + R_RETURN(::lrRegLrResolveProgramPath(std::addressof(m_srv), id.value, out->str)); } Result RegisterProgramPathDeprecated(const Path &path, ncm::ProgramId id) { diff --git a/libraries/libstratosphere/source/ncm/ncm_api.cpp b/libraries/libstratosphere/source/ncm/ncm_api.cpp index 4e1403d4c..e26492d2e 100644 --- a/libraries/libstratosphere/source/ncm/ncm_api.cpp +++ b/libraries/libstratosphere/source/ncm/ncm_api.cpp @@ -55,19 +55,19 @@ namespace ams::ncm { /* Service API. */ Result CreateContentStorage(StorageId storage_id) { - return g_content_manager->CreateContentStorage(storage_id); + R_RETURN(g_content_manager->CreateContentStorage(storage_id)); } Result CreateContentMetaDatabase(StorageId storage_id) { - return g_content_manager->CreateContentMetaDatabase(storage_id); + R_RETURN(g_content_manager->CreateContentMetaDatabase(storage_id)); } Result VerifyContentStorage(StorageId storage_id) { - return g_content_manager->VerifyContentStorage(storage_id); + R_RETURN(g_content_manager->VerifyContentStorage(storage_id)); } Result VerifyContentMetaDatabase(StorageId storage_id) { - return g_content_manager->VerifyContentMetaDatabase(storage_id); + R_RETURN(g_content_manager->VerifyContentMetaDatabase(storage_id)); } Result OpenContentStorage(ContentStorage *out, StorageId storage_id) { @@ -87,41 +87,41 @@ namespace ams::ncm { } Result CleanupContentMetaDatabase(StorageId storage_id) { - return g_content_manager->CleanupContentMetaDatabase(storage_id); + R_RETURN(g_content_manager->CleanupContentMetaDatabase(storage_id)); } Result ActivateContentStorage(StorageId storage_id) { - return g_content_manager->ActivateContentStorage(storage_id); + R_RETURN(g_content_manager->ActivateContentStorage(storage_id)); } Result InactivateContentStorage(StorageId storage_id) { - return g_content_manager->InactivateContentStorage(storage_id); + R_RETURN(g_content_manager->InactivateContentStorage(storage_id)); } Result ActivateContentMetaDatabase(StorageId storage_id) { /* On < 2.0.0, this command doesn't exist, and databases are activated as needed on open. */ R_SUCCEED_IF(hos::GetVersion() < hos::Version_2_0_0); - return g_content_manager->ActivateContentMetaDatabase(storage_id); + R_RETURN(g_content_manager->ActivateContentMetaDatabase(storage_id)); } Result InactivateContentMetaDatabase(StorageId storage_id) { /* On < 2.0.0, this command doesn't exist. */ R_SUCCEED_IF(hos::GetVersion() < hos::Version_2_0_0); - return g_content_manager->InactivateContentMetaDatabase(storage_id); + R_RETURN(g_content_manager->InactivateContentMetaDatabase(storage_id)); } Result InvalidateRightsIdCache() { - return g_content_manager->InvalidateRightsIdCache(); + R_RETURN(g_content_manager->InvalidateRightsIdCache()); } /* Deprecated API. */ Result CloseContentStorageForcibly(StorageId storage_id) { AMS_ABORT_UNLESS(hos::GetVersion() == hos::Version_1_0_0); - return g_content_manager->CloseContentStorageForcibly(storage_id); + R_RETURN(g_content_manager->CloseContentStorageForcibly(storage_id)); } Result CloseContentMetaDatabaseForcibly(StorageId storage_id) { AMS_ABORT_UNLESS(hos::GetVersion() == hos::Version_1_0_0); - return g_content_manager->CloseContentMetaDatabaseForcibly(storage_id); + R_RETURN(g_content_manager->CloseContentMetaDatabaseForcibly(storage_id)); } } diff --git a/libraries/libstratosphere/source/ncm/ncm_content_management_utils.cpp b/libraries/libstratosphere/source/ncm/ncm_content_management_utils.cpp index f1864b838..ee79288d9 100644 --- a/libraries/libstratosphere/source/ncm/ncm_content_management_utils.cpp +++ b/libraries/libstratosphere/source/ncm/ncm_content_management_utils.cpp @@ -28,7 +28,7 @@ namespace ams::ncm { const size_t path_len = util::SNPrintf(package_path, sizeof(package_path), "%s%s", package_root_path, entry_path); AMS_ABORT_UNLESS(path_len < MaxPackagePathLength); - return fs::ConvertToFsCommonPath(dst, dst_size, package_path); + R_RETURN(fs::ConvertToFsCommonPath(dst, dst_size, package_path)); } Result LoadContentMeta(ncm::AutoBuffer *out, const char *package_root_path, const fs::DirectoryEntry &entry) { @@ -37,7 +37,7 @@ namespace ams::ncm { char path[MaxPackagePathLength]; R_TRY(ConvertToFsCommonPath(path, sizeof(path), package_root_path, entry.name)); - return ncm::ReadContentMetaPathWithoutExtendedDataOrDigest(out, path); + R_RETURN(ncm::ReadContentMetaPathWithoutExtendedDataOrDigest(out, path)); } template @@ -123,7 +123,7 @@ namespace ams::ncm { } /* Commit our changes. */ - return m_db->Commit(); + R_RETURN(m_db->Commit()); } Result ContentMetaDatabaseBuilder::BuildFromPackage(const char *package_root_path) { @@ -144,11 +144,11 @@ namespace ams::ncm { R_UNLESS(content_id, ncm::ResultInvalidPackageFormat()); /* Build using the meta. */ - return this->BuildFromPackageContentMeta(package_meta.Get(), package_meta.GetSize(), ContentInfo::Make(*content_id, entry.file_size, ContentType::Meta)); + R_RETURN(this->BuildFromPackageContentMeta(package_meta.Get(), package_meta.GetSize(), ContentInfo::Make(*content_id, entry.file_size, ContentType::Meta))); })); /* Commit our changes. */ - return m_db->Commit(); + R_RETURN(m_db->Commit()); } Result ContentMetaDatabaseBuilder::Cleanup() { @@ -171,7 +171,7 @@ namespace ams::ncm { } /* Commit our deletions. */ - return m_db->Commit(); + R_RETURN(m_db->Commit()); } Result ListApplicationPackage(s32 *out_count, ApplicationId *out_ids, size_t max_out_ids, const char *package_root_path) { diff --git a/libraries/libstratosphere/source/ncm/ncm_content_manager_impl.cpp b/libraries/libstratosphere/source/ncm/ncm_content_manager_impl.cpp index d173075c7..f93883924 100644 --- a/libraries/libstratosphere/source/ncm/ncm_content_manager_impl.cpp +++ b/libraries/libstratosphere/source/ncm/ncm_content_manager_impl.cpp @@ -272,7 +272,7 @@ namespace ams::ncm { R_TRY(impl::CopyFile(savedata_db_path, bis_db_path)); /* Commit the import. */ - return fs::CommitSaveData(root->mount_name); + R_RETURN(fs::CommitSaveData(root->mount_name)); } Result ContentManagerImpl::BuildContentMetaDatabase(StorageId storage_id) { @@ -289,10 +289,10 @@ namespace ams::ncm { /* Create a builder, and build. */ ContentMetaDatabaseBuilder builder(std::addressof(meta_db)); - return builder.BuildFromStorage(std::addressof(storage)); + R_RETURN(builder.BuildFromStorage(std::addressof(storage))); } else { /* On 5.0.0+, building just performs an import. */ - return this->ImportContentMetaDatabase(storage_id, false); + R_RETURN(this->ImportContentMetaDatabase(storage_id, false)); } } @@ -398,7 +398,7 @@ namespace ams::ncm { R_TRY(fs::EnsureDirectory(root->path)); /* Initialize content and placeholder directories for the root. */ - return ContentStorageImpl::InitializeBase(root->path); + R_RETURN(ContentStorageImpl::InitializeBase(root->path)); } Result ContentManagerImpl::CreateContentMetaDatabase(StorageId storage_id) { @@ -418,7 +418,7 @@ namespace ams::ncm { R_TRY(fs::EnsureDirectory(root->path)); /* Commit our changes. */ - return fs::CommitSaveData(root->mount_name); + R_RETURN(fs::CommitSaveData(root->mount_name)); } Result ContentManagerImpl::VerifyContentStorage(StorageId storage_id) { @@ -438,7 +438,7 @@ namespace ams::ncm { ON_SCOPE_EXIT { fs::Unmount(mount_name.str); }; /* Ensure the root, content and placeholder directories exist for the storage. */ - return ContentStorageImpl::VerifyBase(path); + R_RETURN(ContentStorageImpl::VerifyBase(path)); } Result ContentManagerImpl::VerifyContentMetaDatabase(StorageId storage_id) { @@ -509,11 +509,11 @@ namespace ams::ncm { } Result ContentManagerImpl::CloseContentStorageForcibly(StorageId storage_id) { - return this->InactivateContentStorage(storage_id); + R_RETURN(this->InactivateContentStorage(storage_id)); } Result ContentManagerImpl::CloseContentMetaDatabaseForcibly(StorageId storage_id) { - return this->InactivateContentMetaDatabase(storage_id); + R_RETURN(this->InactivateContentMetaDatabase(storage_id)); } Result ContentManagerImpl::CleanupContentMetaDatabase(StorageId storage_id) { @@ -527,7 +527,7 @@ namespace ams::ncm { R_TRY(this->GetContentMetaDatabaseRoot(std::addressof(root), storage_id)); /* Delete save data for the content meta database root. */ - return fs::DeleteSaveData(root->info.space_id, root->info.id); + R_RETURN(fs::DeleteSaveData(root->info.space_id, root->info.id)); } Result ContentManagerImpl::ActivateContentStorage(StorageId storage_id) { diff --git a/libraries/libstratosphere/source/ncm/ncm_content_meta_database_impl.cpp b/libraries/libstratosphere/source/ncm/ncm_content_meta_database_impl.cpp index eed8f0d13..e19f8fc99 100644 --- a/libraries/libstratosphere/source/ncm/ncm_content_meta_database_impl.cpp +++ b/libraries/libstratosphere/source/ncm/ncm_content_meta_database_impl.cpp @@ -51,7 +51,7 @@ namespace ams::ncm { Result ContentMetaDatabaseImpl::Set(const ContentMetaKey &key, const sf::InBuffer &value) { R_TRY(this->EnsureEnabled()); - return m_kvs->Set(key, value.GetPointer(), value.GetSize()); + R_RETURN(m_kvs->Set(key, value.GetPointer(), value.GetSize())); } Result ContentMetaDatabaseImpl::Get(sf::Out out_size, const ContentMetaKey &key, const sf::OutBuffer &out_value) { @@ -78,7 +78,7 @@ namespace ams::ncm { } Result ContentMetaDatabaseImpl::GetContentIdByType(sf::Out out_content_id, const ContentMetaKey &key, ContentType type) { - return this->GetContentIdImpl(out_content_id.GetPointer(), key, type, util::nullopt); + R_RETURN(this->GetContentIdImpl(out_content_id.GetPointer(), key, type, util::nullopt)); } Result ContentMetaDatabaseImpl::ListContentInfo(sf::Out out_count, const sf::OutArray &out_info, const ContentMetaKey &key, s32 offset) { @@ -340,7 +340,7 @@ namespace ams::ncm { /* Save and commit. */ R_TRY(m_kvs->Save()); - return fs::CommitSaveData(m_mount_name); + R_RETURN(fs::CommitSaveData(m_mount_name)); } Result ContentMetaDatabaseImpl::HasContent(sf::Out out, const ContentMetaKey &key, const ContentId &content_id) { @@ -435,7 +435,7 @@ namespace ams::ncm { } Result ContentMetaDatabaseImpl::GetContentIdByTypeAndIdOffset(sf::Out out_content_id, const ContentMetaKey &key, ContentType type, u8 id_offset) { - return this->GetContentIdImpl(out_content_id.GetPointer(), key, type, util::make_optional(id_offset)); + R_RETURN(this->GetContentIdImpl(out_content_id.GetPointer(), key, type, util::make_optional(id_offset))); } Result ContentMetaDatabaseImpl::GetCount(sf::Out out_count) { diff --git a/libraries/libstratosphere/source/ncm/ncm_content_meta_database_impl_base.hpp b/libraries/libstratosphere/source/ncm/ncm_content_meta_database_impl_base.hpp index 367a09141..d22fd18f5 100644 --- a/libraries/libstratosphere/source/ncm/ncm_content_meta_database_impl_base.hpp +++ b/libraries/libstratosphere/source/ncm/ncm_content_meta_database_impl_base.hpp @@ -50,7 +50,7 @@ namespace ams::ncm { Result GetContentMetaPointer(const void **out_value_ptr, size_t *out_size, const ContentMetaKey &key) const { R_TRY(this->GetContentMetaSize(out_size, key)); - return m_kvs->GetValuePointer(reinterpret_cast(out_value_ptr), key); + R_RETURN(m_kvs->GetValuePointer(reinterpret_cast(out_value_ptr), key)); } public: /* Actual commands. */ diff --git a/libraries/libstratosphere/source/ncm/ncm_content_meta_utils.cpp b/libraries/libstratosphere/source/ncm/ncm_content_meta_utils.cpp index 9caf41c02..b036c384e 100644 --- a/libraries/libstratosphere/source/ncm/ncm_content_meta_utils.cpp +++ b/libraries/libstratosphere/source/ncm/ncm_content_meta_utils.cpp @@ -21,7 +21,7 @@ namespace ams::ncm { namespace { Result MountContentMetaByRemoteFileSystemProxy(const char *mount_name, const char *path) { - return fs::MountContent(mount_name, path, fs::ContentType_Meta); + R_RETURN(fs::MountContent(mount_name, path, fs::ContentType_Meta)); } constinit MountContentMetaFunction g_mount_content_meta_func = MountContentMetaByRemoteFileSystemProxy; @@ -219,7 +219,7 @@ namespace ams::ncm { R_UNLESS(force_refer_to_base, ncm::ResultInvalidFirmwareVariation()); /* Force a referral to base. */ - return ReadMetaInfoListFromBase(); + R_RETURN(ReadMetaInfoListFromBase()); } /* Obtain the variation info. */ diff --git a/libraries/libstratosphere/source/ncm/ncm_content_storage_impl.cpp b/libraries/libstratosphere/source/ncm/ncm_content_storage_impl.cpp index 8e9d4faf9..1928303c2 100644 --- a/libraries/libstratosphere/source/ncm/ncm_content_storage_impl.cpp +++ b/libraries/libstratosphere/source/ncm/ncm_content_storage_impl.cpp @@ -36,7 +36,7 @@ namespace ams::ncm { Result EnsureContentDirectory(ContentId id, MakeContentPathFunction func, const char *root_path) { PathString path; MakeContentPath(std::addressof(path), id, func, root_path); - return fs::EnsureParentDirectory(path); + R_RETURN(fs::EnsureParentDirectory(path)); } Result DeleteContentFile(ContentId id, MakeContentPathFunction func, const char *root_path) { @@ -121,7 +121,7 @@ namespace ams::ncm { template Result TraverseDirectory(const char *root_path, int max_level, F f) { bool should_continue = false; - return TraverseDirectory(std::addressof(should_continue), root_path, max_level, f); + R_RETURN(TraverseDirectory(std::addressof(should_continue), root_path, max_level, f)); } bool IsContentPath(const char *path) { @@ -205,7 +205,7 @@ namespace ams::ncm { m_path.Assign(dir); /* Open the directory. */ - return this->OpenCurrentDirectory(); + R_RETURN(this->OpenCurrentDirectory()); } Result ContentStorageImpl::ContentIterator::GetNext(util::optional *out) { @@ -291,7 +291,7 @@ namespace ams::ncm { m_path = m_path.MakeSubString(0, i + 1); /* Try to load again from the parent directory. */ - return this->LoadEntries(); + R_RETURN(this->LoadEntries()); } ContentStorageImpl::~ContentStorageImpl() { @@ -307,7 +307,7 @@ namespace ams::ncm { /* Create the placeholder directory. */ PlaceHolderAccessor::MakeBaseDirectoryPath(std::addressof(path), root_path); - return fs::EnsureDirectory(path); + R_RETURN(fs::EnsureDirectory(path)); } Result ContentStorageImpl::CleanupBase(const char *root_path) { @@ -319,7 +319,7 @@ namespace ams::ncm { /* Create the placeholder directory. */ PlaceHolderAccessor::MakeBaseDirectoryPath(std::addressof(path), root_path); - return CleanDirectoryRecursively(path); + R_RETURN(CleanDirectoryRecursively(path)); } Result ContentStorageImpl::VerifyBase(const char *root_path) { @@ -399,12 +399,12 @@ namespace ams::ncm { Result ContentStorageImpl::CreatePlaceHolder(PlaceHolderId placeholder_id, ContentId content_id, s64 size) { R_TRY(this->EnsureEnabled()); R_TRY(EnsureContentDirectory(content_id, m_make_content_path_func, m_root_path)); - return m_placeholder_accessor.CreatePlaceHolderFile(placeholder_id, size); + R_RETURN(m_placeholder_accessor.CreatePlaceHolderFile(placeholder_id, size)); } Result ContentStorageImpl::DeletePlaceHolder(PlaceHolderId placeholder_id) { R_TRY(this->EnsureEnabled()); - return m_placeholder_accessor.DeletePlaceHolderFile(placeholder_id); + R_RETURN(m_placeholder_accessor.DeletePlaceHolderFile(placeholder_id)); } Result ContentStorageImpl::HasPlaceHolder(sf::Out out, PlaceHolderId placeholder_id) { @@ -425,7 +425,7 @@ namespace ams::ncm { /* Ensure offset is valid. */ R_UNLESS(offset >= 0, ncm::ResultInvalidOffset()); R_TRY(this->EnsureEnabled()); - return m_placeholder_accessor.WritePlaceHolderFile(placeholder_id, offset, data.GetPointer(), data.GetSize()); + R_RETURN(m_placeholder_accessor.WritePlaceHolderFile(placeholder_id, offset, data.GetPointer(), data.GetSize())); } Result ContentStorageImpl::Register(PlaceHolderId placeholder_id, ContentId content_id) { @@ -452,7 +452,7 @@ namespace ams::ncm { Result ContentStorageImpl::Delete(ContentId content_id) { R_TRY(this->EnsureEnabled()); this->InvalidateFileCache(); - return DeleteContentFile(content_id, m_make_content_path_func, m_root_path); + R_RETURN(DeleteContentFile(content_id, m_make_content_path_func, m_root_path)); } Result ContentStorageImpl::Has(sf::Out out, ContentId content_id) { @@ -692,7 +692,7 @@ namespace ams::ncm { Result ContentStorageImpl::SetPlaceHolderSize(PlaceHolderId placeholder_id, s64 size) { R_TRY(this->EnsureEnabled()); - return m_placeholder_accessor.SetPlaceHolderFileSize(placeholder_id, size); + R_RETURN(m_placeholder_accessor.SetPlaceHolderFileSize(placeholder_id, size)); } Result ContentStorageImpl::ReadContentIdFile(const sf::OutBuffer &buf, ContentId content_id, s64 offset) { @@ -708,7 +708,7 @@ namespace ams::ncm { R_TRY(this->OpenContentIdFile(content_id)); /* Read from the requested offset up to the requested size. */ - return fs::ReadFile(m_cached_file_handle, offset, buf.GetPointer(), buf.GetSize()); + R_RETURN(fs::ReadFile(m_cached_file_handle, offset, buf.GetPointer(), buf.GetSize())); } Result ContentStorageImpl::GetRightsIdFromPlaceHolderIdDeprecated(sf::Out out_rights_id, PlaceHolderId placeholder_id) { @@ -729,7 +729,7 @@ namespace ams::ncm { R_TRY(this->GetPlaceHolderPath(std::addressof(path), placeholder_id)); /* Get the rights id for the placeholder id. */ - return GetRightsId(out_rights_id.GetPointer(), path); + R_RETURN(GetRightsId(out_rights_id.GetPointer(), path)); } Result ContentStorageImpl::GetRightsIdFromContentIdDeprecated(sf::Out out_rights_id, ContentId content_id) { @@ -786,15 +786,15 @@ namespace ams::ncm { ON_SCOPE_EXIT { fs::CloseFile(file); }; /* Write the provided data to the file. */ - return fs::WriteFile(file, offset, data.GetPointer(), data.GetSize(), fs::WriteOption::Flush); + R_RETURN(fs::WriteFile(file, offset, data.GetPointer(), data.GetSize(), fs::WriteOption::Flush)); } Result ContentStorageImpl::GetFreeSpaceSize(sf::Out out_size) { - return fs::GetFreeSpaceSize(out_size.GetPointer(), m_root_path); + R_RETURN(fs::GetFreeSpaceSize(out_size.GetPointer(), m_root_path)); } Result ContentStorageImpl::GetTotalSpaceSize(sf::Out out_size) { - return fs::GetTotalSpaceSize(out_size.GetPointer(), m_root_path); + R_RETURN(fs::GetTotalSpaceSize(out_size.GetPointer(), m_root_path)); } Result ContentStorageImpl::FlushPlaceHolder() { diff --git a/libraries/libstratosphere/source/ncm/ncm_host_content_storage_impl.cpp b/libraries/libstratosphere/source/ncm/ncm_host_content_storage_impl.cpp index 1f3b648a8..df28cc613 100644 --- a/libraries/libstratosphere/source/ncm/ncm_host_content_storage_impl.cpp +++ b/libraries/libstratosphere/source/ncm/ncm_host_content_storage_impl.cpp @@ -72,7 +72,7 @@ namespace ams::ncm { Result HostContentStorageImpl::GetPath(sf::Out out, ContentId content_id) { R_TRY(this->EnsureEnabled()); - return m_registered_content->GetPath(out.GetPointer(), content_id); + R_RETURN(m_registered_content->GetPath(out.GetPointer(), content_id)); } Result HostContentStorageImpl::GetPlaceHolderPath(sf::Out out, PlaceHolderId placeholder_id) { @@ -201,7 +201,7 @@ namespace ams::ncm { Result HostContentStorageImpl::RegisterPath(const ContentId &content_id, const Path &path) { AMS_ABORT_UNLESS(spl::IsDevelopment()); - return m_registered_content->RegisterPath(content_id, path); + R_RETURN(m_registered_content->RegisterPath(content_id, path)); } Result HostContentStorageImpl::ClearRegisteredPath() { diff --git a/libraries/libstratosphere/source/ncm/ncm_install_task_base.cpp b/libraries/libstratosphere/source/ncm/ncm_install_task_base.cpp index 57b8b5106..13edcb2e0 100644 --- a/libraries/libstratosphere/source/ncm/ncm_install_task_base.cpp +++ b/libraries/libstratosphere/source/ncm/ncm_install_task_base.cpp @@ -74,7 +74,7 @@ namespace ams::ncm { m_data = data; m_config = config; - return data->GetProgress(std::addressof(m_progress)); + R_RETURN(data->GetProgress(std::addressof(m_progress))); } Result InstallTaskBase::Prepare() { @@ -173,7 +173,7 @@ namespace ams::ncm { } /* Signal prepare is completed. */ - return this->OnPrepareComplete(); + R_RETURN(this->OnPrepareComplete()); } Result InstallTaskBase::Cleanup() { @@ -960,11 +960,11 @@ namespace ams::ncm { } Result InstallTaskBase::CountInstallContentMetaData(s32 *out_count) { - return m_data->Count(out_count); + R_RETURN(m_data->Count(out_count)); } Result InstallTaskBase::GetInstallContentMetaData(InstallContentMeta *out_content_meta, s32 index) { - return m_data->Get(out_content_meta, index); + R_RETURN(m_data->Get(out_content_meta, index)); } Result InstallTaskBase::DeleteInstallContentMetaData(const ContentMetaKey *keys, s32 num_keys) { @@ -985,7 +985,7 @@ namespace ams::ncm { } /* Delete the data if count < 1. */ - return m_data->Delete(keys, num_keys); + R_RETURN(m_data->Delete(keys, num_keys)); } Result InstallTaskBase::GetInstallContentMetaDataFromPath(AutoBuffer *out, const Path &path, const InstallContentInfo &content_info, util::optional source_version) { @@ -1344,7 +1344,7 @@ namespace ams::ncm { /* List rights ids if the reader's key matches ours. */ if (reader.GetKey() == key) { - return this->ListRightsIdsByInstallContentMeta(out_count, out_span, content_meta, offset); + R_RETURN(this->ListRightsIdsByInstallContentMeta(out_count, out_span, content_meta, offset)); } } diff --git a/libraries/libstratosphere/source/ncm/ncm_install_task_data.cpp b/libraries/libstratosphere/source/ncm/ncm_install_task_data.cpp index 9b99e39d7..362876163 100644 --- a/libraries/libstratosphere/source/ncm/ncm_install_task_data.cpp +++ b/libraries/libstratosphere/source/ncm/ncm_install_task_data.cpp @@ -49,7 +49,7 @@ namespace ams::ncm { } Result InstallTaskDataBase::Update(const InstallContentMeta &content_meta, s32 index) { - return this->Update(index, content_meta.data.get(), content_meta.size); + R_RETURN(this->Update(index, content_meta.data.get(), content_meta.size)); } Result InstallTaskDataBase::Has(bool *out, u64 id) { @@ -223,13 +223,13 @@ namespace ams::ncm { /* Create an initial header and write it to the file. */ const Header header = MakeInitialHeader(max_entries); - return fs::WriteFile(file, 0, std::addressof(header), sizeof(Header), fs::WriteOption::Flush); + R_RETURN(fs::WriteFile(file, 0, std::addressof(header), sizeof(Header), fs::WriteOption::Flush)); } Result FileInstallTaskData::Initialize(const char *path) { std::strncpy(m_path, path, sizeof(m_path)); m_path[sizeof(m_path) - 1] = '\x00'; - return this->Read(std::addressof(m_header), sizeof(Header), 0); + R_RETURN(this->Read(std::addressof(m_header), sizeof(Header), 0)); } Result FileInstallTaskData::GetProgress(InstallProgress *out_progress) { @@ -267,17 +267,17 @@ namespace ams::ncm { Result FileInstallTaskData::SetState(InstallProgressState state) { m_header.progress_state = state; - return this->WriteHeader(); + R_RETURN(this->WriteHeader()); } Result FileInstallTaskData::SetLastResult(Result result) { m_header.last_result = result; - return this->WriteHeader(); + R_RETURN(this->WriteHeader()); } Result FileInstallTaskData::SetSystemUpdateTaskApplyInfo(SystemUpdateTaskApplyInfo info) { m_header.system_update_task_apply_info = info; - return this->WriteHeader(); + R_RETURN(this->WriteHeader()); } Result FileInstallTaskData::Push(const void *data, size_t data_size) { @@ -297,7 +297,7 @@ namespace ams::ncm { m_header.count++; /* Write the updated header. */ - return this->WriteHeader(); + R_RETURN(this->WriteHeader()); } Result FileInstallTaskData::Count(s32 *out) { @@ -319,7 +319,7 @@ namespace ams::ncm { /* Read the entry to the output buffer. */ R_UNLESS(entry_info.size <= static_cast(out_size), ncm::ResultBufferInsufficient()); - return this->Read(out, out_size, entry_info.offset); + R_RETURN(this->Read(out, out_size, entry_info.offset)); } Result FileInstallTaskData::Update(s32 index, const void *data, size_t data_size) { @@ -329,7 +329,7 @@ namespace ams::ncm { /* Data size must match existing data size. */ R_UNLESS(entry_info.size == static_cast(data_size), ncm::ResultBufferInsufficient()); - return this->Write(data, data_size, entry_info.offset); + R_RETURN(this->Write(data, data_size, entry_info.offset)); } Result FileInstallTaskData::Delete(const ContentMetaKey *keys, s32 num_keys) { @@ -363,35 +363,35 @@ namespace ams::ncm { /* Change from our current data to the new data. */ m_header = install_task_data.m_header; R_TRY(fs::DeleteFile(m_path)); - return fs::RenameFile(tmp_path, m_path); + R_RETURN(fs::RenameFile(tmp_path, m_path)); } Result FileInstallTaskData::Cleanup() { m_header = MakeInitialHeader(m_header.max_entries); - return this->WriteHeader(); + R_RETURN(this->WriteHeader()); } Result FileInstallTaskData::GetEntryInfo(EntryInfo *out_entry_info, s32 index) { AMS_ABORT_UNLESS(static_cast(index) < m_header.count); - return this->Read(out_entry_info, sizeof(EntryInfo), GetEntryInfoOffset(index)); + R_RETURN(this->Read(out_entry_info, sizeof(EntryInfo), GetEntryInfoOffset(index))); } Result FileInstallTaskData::Write(const void *data, size_t size, s64 offset) { fs::FileHandle file; R_TRY(fs::OpenFile(std::addressof(file), m_path, fs::OpenMode_Write | fs::OpenMode_AllowAppend)); ON_SCOPE_EXIT { fs::CloseFile(file); }; - return fs::WriteFile(file, offset, data, size, fs::WriteOption::Flush); + R_RETURN(fs::WriteFile(file, offset, data, size, fs::WriteOption::Flush)); } Result FileInstallTaskData::Read(void *out, size_t out_size, s64 offset) { fs::FileHandle file; R_TRY(fs::OpenFile(std::addressof(file), m_path, fs::OpenMode_Read)); ON_SCOPE_EXIT { fs::CloseFile(file); }; - return fs::ReadFile(file, offset, out, out_size); + R_RETURN(fs::ReadFile(file, offset, out, out_size)); } Result FileInstallTaskData::WriteHeader() { - return this->Write(std::addressof(m_header), sizeof(Header), 0); + R_RETURN(this->Write(std::addressof(m_header), sizeof(Header), 0)); } } \ No newline at end of file diff --git a/libraries/libstratosphere/source/ncm/ncm_package_install_task.cpp b/libraries/libstratosphere/source/ncm/ncm_package_install_task.cpp index dce80d674..f953b036f 100644 --- a/libraries/libstratosphere/source/ncm/ncm_package_install_task.cpp +++ b/libraries/libstratosphere/source/ncm/ncm_package_install_task.cpp @@ -23,7 +23,7 @@ namespace ams::ncm { } Result PackageInstallTask::Initialize(const char *package_root, StorageId storage_id, void *buffer, size_t buffer_size, bool ignore_ticket) { - return PackageInstallTaskBase::Initialize(package_root, buffer, buffer_size, storage_id, std::addressof(m_data), ignore_ticket ? InstallConfig_IgnoreTicket : InstallConfig_None); + R_RETURN(PackageInstallTaskBase::Initialize(package_root, buffer, buffer_size, storage_id, std::addressof(m_data), ignore_ticket ? InstallConfig_IgnoreTicket : InstallConfig_None)); } Result PackageInstallTask::GetInstallContentMetaInfo(InstallContentMetaInfo *out_info, const ContentMetaKey &key) { diff --git a/libraries/libstratosphere/source/ncm/ncm_package_system_downgrade_task.cpp b/libraries/libstratosphere/source/ncm/ncm_package_system_downgrade_task.cpp index b2b991a64..f8abab57b 100644 --- a/libraries/libstratosphere/source/ncm/ncm_package_system_downgrade_task.cpp +++ b/libraries/libstratosphere/source/ncm/ncm_package_system_downgrade_task.cpp @@ -63,14 +63,14 @@ namespace ams::ncm { Result PackageSystemDowngradeTask::Commit() { R_TRY(this->PreCommit()); - return InstallTaskBase::Commit(); + R_RETURN(InstallTaskBase::Commit()); } Result PackageSystemDowngradeTask::PrepareContentMetaIfLatest(const ContentMetaKey &key) { /* Get and prepare install content meta info. We aren't concerned if our key is older. */ InstallContentMetaInfo install_content_meta_info; R_TRY(this->GetInstallContentMetaInfo(std::addressof(install_content_meta_info), key)); - return this->PrepareContentMeta(install_content_meta_info, key, util::nullopt); + R_RETURN(this->PrepareContentMeta(install_content_meta_info, key, util::nullopt)); } } diff --git a/libraries/libstratosphere/source/ncm/ncm_package_system_update_task.cpp b/libraries/libstratosphere/source/ncm/ncm_package_system_update_task.cpp index 8f2e49721..5332d7e60 100644 --- a/libraries/libstratosphere/source/ncm/ncm_package_system_update_task.cpp +++ b/libraries/libstratosphere/source/ncm/ncm_package_system_update_task.cpp @@ -117,11 +117,11 @@ namespace ams::ncm { R_TRY(this->GetContentInfoOfContentMeta(std::addressof(info), key)); /* Prepare the content meta. */ - return this->PrepareContentMeta(InstallContentMetaInfo::MakeUnverifiable(info.GetId(), info.GetSize(), key), key, util::nullopt); + R_RETURN(this->PrepareContentMeta(InstallContentMetaInfo::MakeUnverifiable(info.GetId(), info.GetSize(), key), key, util::nullopt)); } Result PackageSystemUpdateTask::PrepareDependency() { - return this->PrepareSystemUpdateDependency(); + R_RETURN(this->PrepareSystemUpdateDependency()); } Result PackageSystemUpdateTask::GetContentInfoOfContentMeta(ContentInfo *out, const ContentMetaKey &key) { diff --git a/libraries/libstratosphere/source/ncm/ncm_placeholder_accessor.cpp b/libraries/libstratosphere/source/ncm/ncm_placeholder_accessor.cpp index a5298d388..4b392c218 100644 --- a/libraries/libstratosphere/source/ncm/ncm_placeholder_accessor.cpp +++ b/libraries/libstratosphere/source/ncm/ncm_placeholder_accessor.cpp @@ -52,7 +52,7 @@ namespace ams::ncm { Result PlaceHolderAccessor::EnsurePlaceHolderDirectory(PlaceHolderId placeholder_id) { PathString path; this->MakePath(std::addressof(path), placeholder_id); - return fs::EnsureParentDirectory(path); + R_RETURN(fs::EnsureParentDirectory(path)); } Result PlaceHolderAccessor::GetPlaceHolderIdFromFileName(PlaceHolderId *out, const char *name) { @@ -84,7 +84,7 @@ namespace ams::ncm { this->MakePath(std::addressof(placeholder_path), placeholder_id); /* Open the placeholder file. */ - return fs::OpenFile(out_handle, placeholder_path, fs::OpenMode_Write); + R_RETURN(fs::OpenFile(out_handle, placeholder_path, fs::OpenMode_Write)); } bool PlaceHolderAccessor::LoadFromCache(fs::FileHandle *out_handle, PlaceHolderId placeholder_id) { @@ -203,7 +203,7 @@ namespace ams::ncm { ON_SCOPE_EXIT { this->StoreToCache(placeholder_id, file); }; /* Write data to the placeholder file. */ - return fs::WriteFile(file, offset, buffer, size, m_delay_flush ? fs::WriteOption::Flush : fs::WriteOption::None); + R_RETURN(fs::WriteFile(file, offset, buffer, size, m_delay_flush ? fs::WriteOption::Flush : fs::WriteOption::None)); } Result PlaceHolderAccessor::SetPlaceHolderFileSize(PlaceHolderId placeholder_id, s64 size) { @@ -217,7 +217,7 @@ namespace ams::ncm { ON_SCOPE_EXIT { fs::CloseFile(file); }; /* Set the size of the placeholder file. */ - return fs::SetFileSize(file, size); + R_RETURN(fs::SetFileSize(file, size)); } Result PlaceHolderAccessor::TryGetPlaceHolderFileSize(bool *found_in_cache, s64 *out_size, PlaceHolderId placeholder_id) { diff --git a/libraries/libstratosphere/source/ncm/ncm_remote_content_manager_impl.hpp b/libraries/libstratosphere/source/ncm/ncm_remote_content_manager_impl.hpp index 7fda59ee5..25b412d6b 100644 --- a/libraries/libstratosphere/source/ncm/ncm_remote_content_manager_impl.hpp +++ b/libraries/libstratosphere/source/ncm/ncm_remote_content_manager_impl.hpp @@ -31,19 +31,19 @@ namespace ams::ncm { ~RemoteContentManagerImpl() { ::ncmExit(); } public: Result CreateContentStorage(StorageId storage_id) { - return ::ncmCreateContentStorage(static_cast(storage_id)); + R_RETURN(::ncmCreateContentStorage(static_cast(storage_id))); } Result CreateContentMetaDatabase(StorageId storage_id) { - return ::ncmCreateContentMetaDatabase(static_cast(storage_id)); + R_RETURN(::ncmCreateContentMetaDatabase(static_cast(storage_id))); } Result VerifyContentStorage(StorageId storage_id) { - return ::ncmVerifyContentStorage(static_cast(storage_id)); + R_RETURN(::ncmVerifyContentStorage(static_cast(storage_id))); } Result VerifyContentMetaDatabase(StorageId storage_id) { - return ::ncmVerifyContentMetaDatabase(static_cast(storage_id)); + R_RETURN(::ncmVerifyContentMetaDatabase(static_cast(storage_id))); } Result OpenContentStorage(sf::Out> out, StorageId storage_id) { @@ -63,35 +63,35 @@ namespace ams::ncm { } Result CloseContentStorageForcibly(StorageId storage_id) { - return ::ncmCloseContentStorageForcibly(static_cast(storage_id)); + R_RETURN(::ncmCloseContentStorageForcibly(static_cast(storage_id))); } Result CloseContentMetaDatabaseForcibly(StorageId storage_id) { - return ::ncmCloseContentMetaDatabaseForcibly(static_cast(storage_id)); + R_RETURN(::ncmCloseContentMetaDatabaseForcibly(static_cast(storage_id))); } Result CleanupContentMetaDatabase(StorageId storage_id) { - return ::ncmCleanupContentMetaDatabase(static_cast(storage_id)); + R_RETURN(::ncmCleanupContentMetaDatabase(static_cast(storage_id))); } Result ActivateContentStorage(StorageId storage_id) { - return ::ncmActivateContentStorage(static_cast(storage_id)); + R_RETURN(::ncmActivateContentStorage(static_cast(storage_id))); } Result InactivateContentStorage(StorageId storage_id) { - return ::ncmInactivateContentStorage(static_cast(storage_id)); + R_RETURN(::ncmInactivateContentStorage(static_cast(storage_id))); } Result ActivateContentMetaDatabase(StorageId storage_id) { - return ::ncmActivateContentMetaDatabase(static_cast(storage_id)); + R_RETURN(::ncmActivateContentMetaDatabase(static_cast(storage_id))); } Result InactivateContentMetaDatabase(StorageId storage_id) { - return ::ncmInactivateContentMetaDatabase(static_cast(storage_id)); + R_RETURN(::ncmInactivateContentMetaDatabase(static_cast(storage_id))); } Result InvalidateRightsIdCache() { - return ::ncmInvalidateRightsIdCache(); + R_RETURN(::ncmInvalidateRightsIdCache()); } Result GetMemoryReport(sf::Out out) { diff --git a/libraries/libstratosphere/source/ncm/ncm_remote_content_meta_database_impl.hpp b/libraries/libstratosphere/source/ncm/ncm_remote_content_meta_database_impl.hpp index f4a111ca8..9107e7295 100644 --- a/libraries/libstratosphere/source/ncm/ncm_remote_content_meta_database_impl.hpp +++ b/libraries/libstratosphere/source/ncm/ncm_remote_content_meta_database_impl.hpp @@ -73,88 +73,88 @@ namespace ams::ncm { } public: Result Set(const ContentMetaKey &key, const sf::InBuffer &value) { - return ncmContentMetaDatabaseSet(std::addressof(m_srv), Convert(key), value.GetPointer(), value.GetSize()); + R_RETURN(ncmContentMetaDatabaseSet(std::addressof(m_srv), Convert(key), value.GetPointer(), value.GetSize())); } Result Get(sf::Out out_size, const ContentMetaKey &key, const sf::OutBuffer &out_value) { - return ncmContentMetaDatabaseGet(std::addressof(m_srv), Convert(key), out_size.GetPointer(), out_value.GetPointer(), out_value.GetSize()); + R_RETURN(ncmContentMetaDatabaseGet(std::addressof(m_srv), Convert(key), out_size.GetPointer(), out_value.GetPointer(), out_value.GetSize())); } Result Remove(const ContentMetaKey &key) { - return ncmContentMetaDatabaseRemove(std::addressof(m_srv), Convert(key)); + R_RETURN(ncmContentMetaDatabaseRemove(std::addressof(m_srv), Convert(key))); } Result GetContentIdByType(sf::Out out_content_id, const ContentMetaKey &key, ContentType type) { - return ncmContentMetaDatabaseGetContentIdByType(std::addressof(m_srv), Convert(out_content_id.GetPointer()), Convert(key), static_cast<::NcmContentType>(type)); + R_RETURN(ncmContentMetaDatabaseGetContentIdByType(std::addressof(m_srv), Convert(out_content_id.GetPointer()), Convert(key), static_cast<::NcmContentType>(type))); } Result ListContentInfo(sf::Out out_entries_written, const sf::OutArray &out_info, const ContentMetaKey &key, s32 offset) { - return ncmContentMetaDatabaseListContentInfo(std::addressof(m_srv), out_entries_written.GetPointer(), Convert(out_info.GetPointer()), out_info.GetSize(), Convert(key), offset); + R_RETURN(ncmContentMetaDatabaseListContentInfo(std::addressof(m_srv), out_entries_written.GetPointer(), Convert(out_info.GetPointer()), out_info.GetSize(), Convert(key), offset)); } Result List(sf::Out out_entries_total, sf::Out out_entries_written, const sf::OutArray &out_info, ContentMetaType meta_type, ApplicationId application_id, u64 min, u64 max, ContentInstallType install_type) { - return ncmContentMetaDatabaseList(std::addressof(m_srv), out_entries_total.GetPointer(), out_entries_written.GetPointer(), Convert(out_info.GetPointer()), out_info.GetSize(), static_cast<::NcmContentMetaType>(meta_type), application_id.value, min, max, static_cast<::NcmContentInstallType>(install_type)); + R_RETURN(ncmContentMetaDatabaseList(std::addressof(m_srv), out_entries_total.GetPointer(), out_entries_written.GetPointer(), Convert(out_info.GetPointer()), out_info.GetSize(), static_cast<::NcmContentMetaType>(meta_type), application_id.value, min, max, static_cast<::NcmContentInstallType>(install_type))); } Result GetLatestContentMetaKey(sf::Out out_key, u64 id) { - return ncmContentMetaDatabaseGetLatestContentMetaKey(std::addressof(m_srv), Convert(out_key.GetPointer()), static_cast(id)); + R_RETURN(ncmContentMetaDatabaseGetLatestContentMetaKey(std::addressof(m_srv), Convert(out_key.GetPointer()), static_cast(id))); } Result ListApplication(sf::Out out_entries_total, sf::Out out_entries_written, const sf::OutArray &out_keys, ContentMetaType meta_type) { - return ncmContentMetaDatabaseListApplication(std::addressof(m_srv), out_entries_total.GetPointer(), out_entries_written.GetPointer(), Convert(out_keys.GetPointer()), out_keys.GetSize(), static_cast<::NcmContentMetaType>(meta_type)); + R_RETURN(ncmContentMetaDatabaseListApplication(std::addressof(m_srv), out_entries_total.GetPointer(), out_entries_written.GetPointer(), Convert(out_keys.GetPointer()), out_keys.GetSize(), static_cast<::NcmContentMetaType>(meta_type))); } Result Has(sf::Out out, const ContentMetaKey &key) { - return ncmContentMetaDatabaseHas(std::addressof(m_srv), out.GetPointer(), Convert(key)); + R_RETURN(ncmContentMetaDatabaseHas(std::addressof(m_srv), out.GetPointer(), Convert(key))); } Result HasAll(sf::Out out, const sf::InArray &keys) { - return ncmContentMetaDatabaseHasAll(std::addressof(m_srv), out.GetPointer(), Convert(keys.GetPointer()), keys.GetSize()); + R_RETURN(ncmContentMetaDatabaseHasAll(std::addressof(m_srv), out.GetPointer(), Convert(keys.GetPointer()), keys.GetSize())); } Result GetSize(sf::Out out_size, const ContentMetaKey &key) { - return ncmContentMetaDatabaseGetSize(std::addressof(m_srv), out_size.GetPointer(), Convert(key)); + R_RETURN(ncmContentMetaDatabaseGetSize(std::addressof(m_srv), out_size.GetPointer(), Convert(key))); } Result GetRequiredSystemVersion(sf::Out out_version, const ContentMetaKey &key) { - return ncmContentMetaDatabaseGetRequiredSystemVersion(std::addressof(m_srv), out_version.GetPointer(), Convert(key)); + R_RETURN(ncmContentMetaDatabaseGetRequiredSystemVersion(std::addressof(m_srv), out_version.GetPointer(), Convert(key))); } Result GetPatchId(sf::Out out_patch_id, const ContentMetaKey &key) { - return ncmContentMetaDatabaseGetPatchId(std::addressof(m_srv), reinterpret_cast(out_patch_id.GetPointer()), Convert(key)); + R_RETURN(ncmContentMetaDatabaseGetPatchId(std::addressof(m_srv), reinterpret_cast(out_patch_id.GetPointer()), Convert(key))); } Result DisableForcibly() { - return ncmContentMetaDatabaseDisableForcibly(std::addressof(m_srv)); + R_RETURN(ncmContentMetaDatabaseDisableForcibly(std::addressof(m_srv))); } Result LookupOrphanContent(const sf::OutArray &out_orphaned, const sf::InArray &content_ids) { - return ncmContentMetaDatabaseLookupOrphanContent(std::addressof(m_srv), out_orphaned.GetPointer(), Convert(content_ids.GetPointer()), std::min(out_orphaned.GetSize(), content_ids.GetSize())); + R_RETURN(ncmContentMetaDatabaseLookupOrphanContent(std::addressof(m_srv), out_orphaned.GetPointer(), Convert(content_ids.GetPointer()), std::min(out_orphaned.GetSize(), content_ids.GetSize()))); } Result Commit() { - return ncmContentMetaDatabaseCommit(std::addressof(m_srv)); + R_RETURN(ncmContentMetaDatabaseCommit(std::addressof(m_srv))); } Result HasContent(sf::Out out, const ContentMetaKey &key, const ContentId &content_id) { - return ncmContentMetaDatabaseHasContent(std::addressof(m_srv), out.GetPointer(), Convert(key), Convert(content_id)); + R_RETURN(ncmContentMetaDatabaseHasContent(std::addressof(m_srv), out.GetPointer(), Convert(key), Convert(content_id))); } Result ListContentMetaInfo(sf::Out out_entries_written, const sf::OutArray &out_meta_info, const ContentMetaKey &key, s32 offset) { - return ncmContentMetaDatabaseListContentMetaInfo(std::addressof(m_srv), out_entries_written.GetPointer(), out_meta_info.GetPointer(), out_meta_info.GetSize(), Convert(key), offset); + R_RETURN(ncmContentMetaDatabaseListContentMetaInfo(std::addressof(m_srv), out_entries_written.GetPointer(), out_meta_info.GetPointer(), out_meta_info.GetSize(), Convert(key), offset)); } Result GetAttributes(sf::Out out_attributes, const ContentMetaKey &key) { static_assert(sizeof(ContentMetaAttribute) == sizeof(u8)); - return ncmContentMetaDatabaseGetAttributes(std::addressof(m_srv), Convert(key), out_attributes.GetPointer()); + R_RETURN(ncmContentMetaDatabaseGetAttributes(std::addressof(m_srv), Convert(key), out_attributes.GetPointer())); } Result GetRequiredApplicationVersion(sf::Out out_version, const ContentMetaKey &key) { - return ncmContentMetaDatabaseGetRequiredApplicationVersion(std::addressof(m_srv), out_version.GetPointer(), Convert(key)); + R_RETURN(ncmContentMetaDatabaseGetRequiredApplicationVersion(std::addressof(m_srv), out_version.GetPointer(), Convert(key))); } Result GetContentIdByTypeAndIdOffset(sf::Out out_content_id, const ContentMetaKey &key, ContentType type, u8 id_offset) { - return ncmContentMetaDatabaseGetContentIdByTypeAndIdOffset(std::addressof(m_srv), Convert(out_content_id.GetPointer()), Convert(key), static_cast<::NcmContentType>(type), id_offset); + R_RETURN(ncmContentMetaDatabaseGetContentIdByTypeAndIdOffset(std::addressof(m_srv), Convert(out_content_id.GetPointer()), Convert(key), static_cast<::NcmContentType>(type), id_offset)); } Result GetCount(sf::Out out_count) { diff --git a/libraries/libstratosphere/source/ncm/ncm_remote_content_storage_impl.hpp b/libraries/libstratosphere/source/ncm/ncm_remote_content_storage_impl.hpp index 0736bcde1..94b648a7c 100644 --- a/libraries/libstratosphere/source/ncm/ncm_remote_content_storage_impl.hpp +++ b/libraries/libstratosphere/source/ncm/ncm_remote_content_storage_impl.hpp @@ -58,81 +58,81 @@ namespace ams::ncm { } public: Result GeneratePlaceHolderId(sf::Out out) { - return ncmContentStorageGeneratePlaceHolderId(std::addressof(m_srv), Convert(out.GetPointer())); + R_RETURN(ncmContentStorageGeneratePlaceHolderId(std::addressof(m_srv), Convert(out.GetPointer()))); } Result CreatePlaceHolder(PlaceHolderId placeholder_id, ContentId content_id, s64 size) { static_assert(alignof(ContentId) < alignof(PlaceHolderId)); - return ncmContentStorageCreatePlaceHolder(std::addressof(m_srv), Convert(content_id), Convert(placeholder_id), size); + R_RETURN(ncmContentStorageCreatePlaceHolder(std::addressof(m_srv), Convert(content_id), Convert(placeholder_id), size)); } Result DeletePlaceHolder(PlaceHolderId placeholder_id) { - return ncmContentStorageDeletePlaceHolder(std::addressof(m_srv), Convert(placeholder_id)); + R_RETURN(ncmContentStorageDeletePlaceHolder(std::addressof(m_srv), Convert(placeholder_id))); } Result HasPlaceHolder(sf::Out out, PlaceHolderId placeholder_id) { - return ncmContentStorageHasPlaceHolder(std::addressof(m_srv), out.GetPointer(), Convert(placeholder_id)); + R_RETURN(ncmContentStorageHasPlaceHolder(std::addressof(m_srv), out.GetPointer(), Convert(placeholder_id))); } Result WritePlaceHolder(PlaceHolderId placeholder_id, s64 offset, const sf::InBuffer &data) { - return ncmContentStorageWritePlaceHolder(std::addressof(m_srv), Convert(placeholder_id), offset, data.GetPointer(), data.GetSize()); + R_RETURN(ncmContentStorageWritePlaceHolder(std::addressof(m_srv), Convert(placeholder_id), offset, data.GetPointer(), data.GetSize())); } Result Register(PlaceHolderId placeholder_id, ContentId content_id) { static_assert(alignof(ContentId) < alignof(PlaceHolderId)); - return ncmContentStorageRegister(std::addressof(m_srv), Convert(content_id), Convert(placeholder_id)); + R_RETURN(ncmContentStorageRegister(std::addressof(m_srv), Convert(content_id), Convert(placeholder_id))); } Result Delete(ContentId content_id) { - return ncmContentStorageDelete(std::addressof(m_srv), Convert(content_id)); + R_RETURN(ncmContentStorageDelete(std::addressof(m_srv), Convert(content_id))); } Result Has(sf::Out out, ContentId content_id) { - return ncmContentStorageHas(std::addressof(m_srv), out.GetPointer(), Convert(content_id)); + R_RETURN(ncmContentStorageHas(std::addressof(m_srv), out.GetPointer(), Convert(content_id))); } Result GetPath(sf::Out out, ContentId content_id) { - return ncmContentStorageGetPath(std::addressof(m_srv), out.GetPointer()->str, sizeof(out.GetPointer()->str), Convert(content_id)); + R_RETURN(ncmContentStorageGetPath(std::addressof(m_srv), out.GetPointer()->str, sizeof(out.GetPointer()->str), Convert(content_id))); } Result GetPlaceHolderPath(sf::Out out, PlaceHolderId placeholder_id) { - return ncmContentStorageGetPlaceHolderPath(std::addressof(m_srv), out.GetPointer()->str, sizeof(out.GetPointer()->str), Convert(placeholder_id)); + R_RETURN(ncmContentStorageGetPlaceHolderPath(std::addressof(m_srv), out.GetPointer()->str, sizeof(out.GetPointer()->str), Convert(placeholder_id))); } Result CleanupAllPlaceHolder() { - return ncmContentStorageCleanupAllPlaceHolder(std::addressof(m_srv)); + R_RETURN(ncmContentStorageCleanupAllPlaceHolder(std::addressof(m_srv))); } Result ListPlaceHolder(sf::Out out_count, const sf::OutArray &out_buf) { - return ncmContentStorageListPlaceHolder(std::addressof(m_srv), Convert(out_buf.GetPointer()), out_buf.GetSize(), out_count.GetPointer()); + R_RETURN(ncmContentStorageListPlaceHolder(std::addressof(m_srv), Convert(out_buf.GetPointer()), out_buf.GetSize(), out_count.GetPointer())); } Result GetContentCount(sf::Out out_count) { - return ncmContentStorageGetContentCount(std::addressof(m_srv), out_count.GetPointer()); + R_RETURN(ncmContentStorageGetContentCount(std::addressof(m_srv), out_count.GetPointer())); } Result ListContentId(sf::Out out_count, const sf::OutArray &out_buf, s32 offset) { - return ncmContentStorageListContentId(std::addressof(m_srv), Convert(out_buf.GetPointer()), out_buf.GetSize(), out_count.GetPointer(), offset); + R_RETURN(ncmContentStorageListContentId(std::addressof(m_srv), Convert(out_buf.GetPointer()), out_buf.GetSize(), out_count.GetPointer(), offset)); } Result GetSizeFromContentId(sf::Out out_size, ContentId content_id) { - return ncmContentStorageGetSizeFromContentId(std::addressof(m_srv), out_size.GetPointer(), Convert(content_id)); + R_RETURN(ncmContentStorageGetSizeFromContentId(std::addressof(m_srv), out_size.GetPointer(), Convert(content_id))); } Result DisableForcibly() { - return ncmContentStorageDisableForcibly(std::addressof(m_srv)); + R_RETURN(ncmContentStorageDisableForcibly(std::addressof(m_srv))); } Result RevertToPlaceHolder(PlaceHolderId placeholder_id, ContentId old_content_id, ContentId new_content_id) { - return ncmContentStorageRevertToPlaceHolder(std::addressof(m_srv), Convert(placeholder_id), Convert(old_content_id), Convert(new_content_id)); + R_RETURN(ncmContentStorageRevertToPlaceHolder(std::addressof(m_srv), Convert(placeholder_id), Convert(old_content_id), Convert(new_content_id))); } Result SetPlaceHolderSize(PlaceHolderId placeholder_id, s64 size) { - return ncmContentStorageSetPlaceHolderSize(std::addressof(m_srv), Convert(placeholder_id), size); + R_RETURN(ncmContentStorageSetPlaceHolderSize(std::addressof(m_srv), Convert(placeholder_id), size)); } Result ReadContentIdFile(const sf::OutBuffer &buf, ContentId content_id, s64 offset) { - return ncmContentStorageReadContentIdFile(std::addressof(m_srv), buf.GetPointer(), buf.GetSize(), Convert(content_id), offset); + R_RETURN(ncmContentStorageReadContentIdFile(std::addressof(m_srv), buf.GetPointer(), buf.GetSize(), Convert(content_id), offset)); } Result GetRightsIdFromPlaceHolderIdDeprecated(sf::Out out_rights_id, PlaceHolderId placeholder_id) { @@ -172,41 +172,41 @@ namespace ams::ncm { } Result WriteContentForDebug(ContentId content_id, s64 offset, const sf::InBuffer &data) { - return ncmContentStorageWriteContentForDebug(std::addressof(m_srv), Convert(content_id), offset, data.GetPointer(), data.GetSize()); + R_RETURN(ncmContentStorageWriteContentForDebug(std::addressof(m_srv), Convert(content_id), offset, data.GetPointer(), data.GetSize())); } Result GetFreeSpaceSize(sf::Out out_size) { - return ncmContentStorageGetFreeSpaceSize(std::addressof(m_srv), out_size.GetPointer()); + R_RETURN(ncmContentStorageGetFreeSpaceSize(std::addressof(m_srv), out_size.GetPointer())); } Result GetTotalSpaceSize(sf::Out out_size) { - return ncmContentStorageGetTotalSpaceSize(std::addressof(m_srv), out_size.GetPointer()); + R_RETURN(ncmContentStorageGetTotalSpaceSize(std::addressof(m_srv), out_size.GetPointer())); } Result FlushPlaceHolder() { - return ncmContentStorageFlushPlaceHolder(std::addressof(m_srv)); + R_RETURN(ncmContentStorageFlushPlaceHolder(std::addressof(m_srv))); } Result GetSizeFromPlaceHolderId(sf::Out out_size, PlaceHolderId placeholder_id) { - return ncmContentStorageGetSizeFromPlaceHolderId(std::addressof(m_srv), out_size.GetPointer(), Convert(placeholder_id)); + R_RETURN(ncmContentStorageGetSizeFromPlaceHolderId(std::addressof(m_srv), out_size.GetPointer(), Convert(placeholder_id))); } Result RepairInvalidFileAttribute() { - return ncmContentStorageRepairInvalidFileAttribute(std::addressof(m_srv)); + R_RETURN(ncmContentStorageRepairInvalidFileAttribute(std::addressof(m_srv))); } Result GetRightsIdFromPlaceHolderIdWithCache(sf::Out out_rights_id, PlaceHolderId placeholder_id, ContentId cache_content_id) { static_assert(sizeof(::NcmRightsId) == sizeof(ncm::RightsId)); ::NcmRightsId *out = reinterpret_cast<::NcmRightsId *>(out_rights_id.GetPointer()); - return ncmContentStorageGetRightsIdFromPlaceHolderIdWithCache(std::addressof(m_srv), out, Convert(placeholder_id), Convert(cache_content_id)); + R_RETURN(ncmContentStorageGetRightsIdFromPlaceHolderIdWithCache(std::addressof(m_srv), out, Convert(placeholder_id), Convert(cache_content_id))); } Result RegisterPath(const ContentId &content_id, const Path &path) { - return ncmContentStorageRegisterPath(std::addressof(m_srv), Convert(content_id), path.str); + R_RETURN(ncmContentStorageRegisterPath(std::addressof(m_srv), Convert(content_id), path.str)); } Result ClearRegisteredPath() { - return ncmContentStorageClearRegisteredPath(std::addressof(m_srv)); + R_RETURN(ncmContentStorageClearRegisteredPath(std::addressof(m_srv))); } }; static_assert(ncm::IsIContentStorage); diff --git a/libraries/libstratosphere/source/nim/nim_network_install_manager_api.cpp b/libraries/libstratosphere/source/nim/nim_network_install_manager_api.cpp index a2eaffd02..c7e3ac590 100644 --- a/libraries/libstratosphere/source/nim/nim_network_install_manager_api.cpp +++ b/libraries/libstratosphere/source/nim/nim_network_install_manager_api.cpp @@ -40,7 +40,7 @@ namespace ams::nim { /* Service API. */ Result DestroySystemUpdateTask(const SystemUpdateTaskId &id) { static_assert(sizeof(SystemUpdateTaskId) == sizeof(::NimSystemUpdateTaskId)); - return nimDestroySystemUpdateTask(reinterpret_cast(std::addressof(id))); + R_RETURN(nimDestroySystemUpdateTask(reinterpret_cast(std::addressof(id)))); } s32 ListSystemUpdateTask(SystemUpdateTaskId *out_list, size_t out_list_size) { diff --git a/libraries/libstratosphere/source/os/impl/os_multiple_wait_impl.cpp b/libraries/libstratosphere/source/os/impl/os_multiple_wait_impl.cpp index b4f07fd6f..41b8640c9 100644 --- a/libraries/libstratosphere/source/os/impl/os_multiple_wait_impl.cpp +++ b/libraries/libstratosphere/source/os/impl/os_multiple_wait_impl.cpp @@ -26,6 +26,18 @@ namespace ams::os::impl { m_target_impl.SetCurrentThreadHandleForCancelWait(); MultiWaitHolderBase *holder = this->LinkHoldersToObjectList(); + /* When we're done, cleanup and set output. */ + ON_SCOPE_EXIT { + /* Unlink holders from the current object list. */ + this->UnlinkHoldersFromObjectList(); + + /* Clear cancel wait. */ + m_target_impl.ClearCurrentThreadHandleForCancelWait(); + + /* Set output holder. */ + *out = holder; + }; + /* Check if we've been signaled. */ { std::scoped_lock lk(m_cs_wait); @@ -35,28 +47,16 @@ namespace ams::os::impl { } /* Process object array. */ - Result wait_result = ResultSuccess(); if (holder != nullptr) { - if (reply && reply_target != os::InvalidNativeHandle) { - s32 index; - wait_result = m_target_impl.TimedReplyAndReceive(std::addressof(index), nullptr, 0, 0, reply_target, TimeSpan::FromNanoSeconds(0)); - if (R_FAILED(wait_result)) { - holder = nullptr; - } - } + R_SUCCEED_IF(!(reply && reply_target != os::InvalidNativeHandle)); + + ON_RESULT_FAILURE { holder = nullptr; }; + + s32 index; + R_RETURN(m_target_impl.TimedReplyAndReceive(std::addressof(index), nullptr, 0, 0, reply_target, TimeSpan::FromNanoSeconds(0))) } else { - wait_result = this->WaitAnyHandleImpl(std::addressof(holder), infinite, timeout, reply, reply_target); + R_RETURN(this->WaitAnyHandleImpl(std::addressof(holder), infinite, timeout, reply, reply_target)); } - - /* Unlink holders from the current object list. */ - this->UnlinkHoldersFromObjectList(); - - m_target_impl.ClearCurrentThreadHandleForCancelWait(); - - /* Set output holder. */ - *out = holder; - - return wait_result; } Result MultiWaitImpl::WaitAnyHandleImpl(MultiWaitHolderBase **out, bool infinite, TimeSpan timeout, bool reply, NativeHandle reply_target) { @@ -93,7 +93,7 @@ namespace ams::os::impl { if (index == WaitInvalid) { *out = nullptr; - return wait_result; + R_RETURN(wait_result); } switch (index) { @@ -104,11 +104,11 @@ namespace ams::os::impl { std::scoped_lock lk(m_cs_wait); m_signaled_holder = min_timeout_object; *out = min_timeout_object; - return wait_result; + R_RETURN(wait_result); } } else { *out = nullptr; - return wait_result; + R_RETURN(wait_result); } break; case WaitCancelled: @@ -116,7 +116,7 @@ namespace ams::os::impl { std::scoped_lock lk(m_cs_wait); if (m_signaled_holder) { *out = m_signaled_holder; - return wait_result; + R_RETURN(wait_result); } } break; @@ -128,7 +128,7 @@ namespace ams::os::impl { std::scoped_lock lk(m_cs_wait); m_signaled_holder = objects[index]; *out = objects[index]; - return wait_result; + R_RETURN(wait_result); } else { AMS_ABORT_UNLESS(MaximumHandleCount > 0); } diff --git a/libraries/libstratosphere/source/os/impl/os_multiple_wait_impl.hpp b/libraries/libstratosphere/source/os/impl/os_multiple_wait_impl.hpp index a079a518a..079eb685e 100644 --- a/libraries/libstratosphere/source/os/impl/os_multiple_wait_impl.hpp +++ b/libraries/libstratosphere/source/os/impl/os_multiple_wait_impl.hpp @@ -77,7 +77,7 @@ namespace ams::os::impl { } Result ReplyAndReceive(MultiWaitHolderBase **out, NativeHandle reply_target) { - return this->WaitAnyImpl(out, true, TimeSpan::FromNanoSeconds(std::numeric_limits::max()), true, reply_target); + R_RETURN(this->WaitAnyImpl(out, true, TimeSpan::FromNanoSeconds(std::numeric_limits::max()), true, reply_target)); } /* List management. */ diff --git a/libraries/libstratosphere/source/os/impl/os_multiple_wait_target_impl.os.horizon.cpp b/libraries/libstratosphere/source/os/impl/os_multiple_wait_target_impl.os.horizon.cpp index 546200210..a45f3d573 100644 --- a/libraries/libstratosphere/source/os/impl/os_multiple_wait_target_impl.os.horizon.cpp +++ b/libraries/libstratosphere/source/os/impl/os_multiple_wait_target_impl.os.horizon.cpp @@ -47,8 +47,8 @@ namespace ams::os::impl { static_assert(MultiWaitImpl::WaitInvalid != -1); R_TRY_CATCH(svc::ReplyAndReceive(std::addressof(index), arr, num, reply_target, ns)) { - R_CATCH(svc::ResultTimedOut) { *out_index = MultiWaitImpl::WaitTimedOut; return R_CURRENT_RESULT; } - R_CATCH(svc::ResultCancelled) { *out_index = MultiWaitImpl::WaitCancelled; return R_CURRENT_RESULT; } + R_CATCH(svc::ResultTimedOut) { *out_index = MultiWaitImpl::WaitTimedOut; R_THROW(R_CURRENT_RESULT); } + R_CATCH(svc::ResultCancelled) { *out_index = MultiWaitImpl::WaitCancelled; R_THROW(R_CURRENT_RESULT); } R_CATCH(svc::ResultSessionClosed) { if (index == -1) { *out_index = MultiWaitImpl::WaitInvalid; diff --git a/libraries/libstratosphere/source/os/impl/os_multiple_wait_target_impl.os.horizon.hpp b/libraries/libstratosphere/source/os/impl/os_multiple_wait_target_impl.os.horizon.hpp index ca8f0f597..c8d3134c0 100644 --- a/libraries/libstratosphere/source/os/impl/os_multiple_wait_target_impl.os.horizon.hpp +++ b/libraries/libstratosphere/source/os/impl/os_multiple_wait_target_impl.os.horizon.hpp @@ -33,11 +33,11 @@ namespace ams::os::impl { void CancelWait(); Result WaitAny(s32 *out_index, NativeHandle arr[], s32 array_size, s32 num) { - return this->WaitSynchronizationN(out_index, num, arr, array_size, svc::WaitInfinite); + R_RETURN(this->WaitSynchronizationN(out_index, num, arr, array_size, svc::WaitInfinite)); } Result TryWaitAny(s32 *out_index, NativeHandle arr[], s32 array_size, s32 num) { - return this->WaitSynchronizationN(out_index, num, arr, array_size, 0); + R_RETURN(this->WaitSynchronizationN(out_index, num, arr, array_size, 0)); } Result TimedWaitAny(s32 *out_index, NativeHandle arr[], s32 array_size, s32 num, TimeSpan ts) { @@ -45,15 +45,15 @@ namespace ams::os::impl { if (timeout < 0) { timeout = 0; } - return this->WaitSynchronizationN(out_index, num, arr, array_size, timeout); + R_RETURN(this->WaitSynchronizationN(out_index, num, arr, array_size, timeout)); } Result ReplyAndReceive(s32 *out_index, NativeHandle arr[], s32 array_size, s32 num, NativeHandle reply_target) { - return this->ReplyAndReceiveN(out_index, num, arr, array_size, std::numeric_limits::max(), reply_target); + R_RETURN(this->ReplyAndReceiveN(out_index, num, arr, array_size, std::numeric_limits::max(), reply_target)); } Result TimedReplyAndReceive(s32 *out_index, NativeHandle arr[], s32 array_size, s32 num, NativeHandle reply_target, TimeSpan ts) { - return this->ReplyAndReceiveN(out_index, num, arr, array_size, ts.GetNanoSeconds(), reply_target); + R_RETURN(this->ReplyAndReceiveN(out_index, num, arr, array_size, ts.GetNanoSeconds(), reply_target)); } void SetCurrentThreadHandleForCancelWait() { diff --git a/libraries/libstratosphere/source/os/impl/os_multiple_wait_target_impl.os.linux.hpp b/libraries/libstratosphere/source/os/impl/os_multiple_wait_target_impl.os.linux.hpp index b735efaa4..ba3c97775 100644 --- a/libraries/libstratosphere/source/os/impl/os_multiple_wait_target_impl.os.linux.hpp +++ b/libraries/libstratosphere/source/os/impl/os_multiple_wait_target_impl.os.linux.hpp @@ -35,23 +35,23 @@ namespace ams::os::impl { void CancelWait(); Result WaitAny(s32 *out_index, NativeHandle arr[], s32 array_size, s32 num) { - return this->PollNativeHandlesImpl(out_index, num, arr, array_size, static_cast(-1)); + R_RETURN(this->PollNativeHandlesImpl(out_index, num, arr, array_size, static_cast(-1))); } Result TryWaitAny(s32 *out_index, NativeHandle arr[], s32 array_size, s32 num) { - return this->PollNativeHandlesImpl(out_index, num, arr, array_size, 0); + R_RETURN(this->PollNativeHandlesImpl(out_index, num, arr, array_size, 0)); } Result TimedWaitAny(s32 *out_index, NativeHandle arr[], s32 array_size, s32 num, TimeSpan ts) { - return this->PollNativeHandlesImpl(out_index, num, arr, array_size, ts.GetNanoSeconds()); + R_RETURN(this->PollNativeHandlesImpl(out_index, num, arr, array_size, ts.GetNanoSeconds())); } Result ReplyAndReceive(s32 *out_index, NativeHandle arr[], s32 array_size, s32 num, NativeHandle reply_target) { - return this->ReplyAndReceiveImpl(out_index, num, arr, array_size, std::numeric_limits::max(), reply_target); + R_RETURN(this->ReplyAndReceiveImpl(out_index, num, arr, array_size, std::numeric_limits::max(), reply_target)); } Result TimedReplyAndReceive(s32 *out_index, NativeHandle arr[], s32 array_size, s32 num, NativeHandle reply_target, TimeSpan ts) { - return this->ReplyAndReceiveImpl(out_index, num, arr, array_size, ts.GetNanoSeconds(), reply_target); + R_RETURN(this->ReplyAndReceiveImpl(out_index, num, arr, array_size, ts.GetNanoSeconds(), reply_target)); } void SetCurrentThreadHandleForCancelWait() { diff --git a/libraries/libstratosphere/source/os/impl/os_multiple_wait_target_impl.os.macos.hpp b/libraries/libstratosphere/source/os/impl/os_multiple_wait_target_impl.os.macos.hpp index 6da54d4dc..02a628e4d 100644 --- a/libraries/libstratosphere/source/os/impl/os_multiple_wait_target_impl.os.macos.hpp +++ b/libraries/libstratosphere/source/os/impl/os_multiple_wait_target_impl.os.macos.hpp @@ -36,23 +36,23 @@ namespace ams::os::impl { void CancelWait(); Result WaitAny(s32 *out_index, NativeHandle arr[], s32 array_size, s32 num) { - return this->PollNativeHandlesImpl(out_index, num, arr, array_size, static_cast(-1)); + R_RETURN(this->PollNativeHandlesImpl(out_index, num, arr, array_size, static_cast(-1))); } Result TryWaitAny(s32 *out_index, NativeHandle arr[], s32 array_size, s32 num) { - return this->PollNativeHandlesImpl(out_index, num, arr, array_size, 0); + R_RETURN(this->PollNativeHandlesImpl(out_index, num, arr, array_size, 0)); } Result TimedWaitAny(s32 *out_index, NativeHandle arr[], s32 array_size, s32 num, TimeSpan ts) { - return this->PollNativeHandlesImpl(out_index, num, arr, array_size, ts.GetNanoSeconds()); + R_RETURN(this->PollNativeHandlesImpl(out_index, num, arr, array_size, ts.GetNanoSeconds())); } Result ReplyAndReceive(s32 *out_index, NativeHandle arr[], s32 array_size, s32 num, NativeHandle reply_target) { - return this->ReplyAndReceiveImpl(out_index, num, arr, array_size, std::numeric_limits::max(), reply_target); + R_RETURN(this->ReplyAndReceiveImpl(out_index, num, arr, array_size, std::numeric_limits::max(), reply_target)); } Result TimedReplyAndReceive(s32 *out_index, NativeHandle arr[], s32 array_size, s32 num, NativeHandle reply_target, TimeSpan ts) { - return this->ReplyAndReceiveImpl(out_index, num, arr, array_size, ts.GetNanoSeconds(), reply_target); + R_RETURN(this->ReplyAndReceiveImpl(out_index, num, arr, array_size, ts.GetNanoSeconds(), reply_target)); } void SetCurrentThreadHandleForCancelWait() { diff --git a/libraries/libstratosphere/source/os/impl/os_multiple_wait_target_impl.os.windows.hpp b/libraries/libstratosphere/source/os/impl/os_multiple_wait_target_impl.os.windows.hpp index 07dd1403d..5e4200c2d 100644 --- a/libraries/libstratosphere/source/os/impl/os_multiple_wait_target_impl.os.windows.hpp +++ b/libraries/libstratosphere/source/os/impl/os_multiple_wait_target_impl.os.windows.hpp @@ -44,21 +44,21 @@ namespace ams::os::impl { } Result WaitAny(s32 *out_index, NativeHandle arr[], s32 array_size, s32 num) { - return this->WaitForMultipleObjectsImpl(out_index, num, arr, array_size, INFINITE); + R_RETURN(this->WaitForMultipleObjectsImpl(out_index, num, arr, array_size, INFINITE)); } Result TryWaitAny(s32 *out_index, NativeHandle arr[], s32 array_size, s32 num) { - return this->WaitForMultipleObjectsImpl(out_index, num, arr, array_size, 0); + R_RETURN(this->WaitForMultipleObjectsImpl(out_index, num, arr, array_size, 0)); } Result TimedWaitAny(s32 *out_index, NativeHandle arr[], s32 array_size, s32 num, TimeSpan ts); Result ReplyAndReceive(s32 *out_index, NativeHandle arr[], s32 array_size, s32 num, NativeHandle reply_target) { - return this->ReplyAndReceiveImpl(out_index, num, arr, array_size, std::numeric_limits::max(), reply_target); + R_RETURN(this->ReplyAndReceiveImpl(out_index, num, arr, array_size, std::numeric_limits::max(), reply_target)); } Result TimedReplyAndReceive(s32 *out_index, NativeHandle arr[], s32 array_size, s32 num, NativeHandle reply_target, TimeSpan ts) { - return this->ReplyAndReceiveImpl(out_index, num, arr, array_size, ts.GetNanoSeconds(), reply_target); + R_RETURN(this->ReplyAndReceiveImpl(out_index, num, arr, array_size, ts.GetNanoSeconds(), reply_target)); } void SetCurrentThreadHandleForCancelWait() { diff --git a/libraries/libstratosphere/source/os/impl/os_process_handle_impl.os.horizon.hpp b/libraries/libstratosphere/source/os/impl/os_process_handle_impl.os.horizon.hpp index d9bff09ca..9add0c2bf 100644 --- a/libraries/libstratosphere/source/os/impl/os_process_handle_impl.os.horizon.hpp +++ b/libraries/libstratosphere/source/os/impl/os_process_handle_impl.os.horizon.hpp @@ -25,11 +25,11 @@ namespace ams::os::impl { } static ALWAYS_INLINE Result GetProcessId(ProcessId *out, NativeHandle handle) { - return svc::GetProcessId(std::addressof(out->value), handle); + R_RETURN(svc::GetProcessId(std::addressof(out->value), handle)); } static ALWAYS_INLINE Result GetProgramId(ncm::ProgramId *out, NativeHandle handle) { - return svc::GetInfo(std::addressof(out->value), svc::InfoType_ProgramId, handle, 0); + R_RETURN(svc::GetInfo(std::addressof(out->value), svc::InfoType_ProgramId, handle, 0)); } }; diff --git a/libraries/libstratosphere/source/os/impl/os_thread_manager.cpp b/libraries/libstratosphere/source/os/impl/os_thread_manager.cpp index 3db465401..f374dee8e 100644 --- a/libraries/libstratosphere/source/os/impl/os_thread_manager.cpp +++ b/libraries/libstratosphere/source/os/impl/os_thread_manager.cpp @@ -152,7 +152,7 @@ namespace ams::os::impl { } Result ThreadManager::CreateThread(ThreadType *thread, ThreadFunction function, void *argument, void *stack, size_t stack_size, s32 priority) { - return this->CreateThread(thread, function, argument, stack, stack_size, priority, m_impl.GetDefaultCoreNumber()); + R_RETURN(this->CreateThread(thread, function, argument, stack, stack_size, priority, m_impl.GetDefaultCoreNumber())); } void ThreadManager::DestroyThread(ThreadType *thread) { diff --git a/libraries/libstratosphere/source/os/os_process_handle_api.cpp b/libraries/libstratosphere/source/os/os_process_handle_api.cpp index f95126b09..d1f822a84 100644 --- a/libraries/libstratosphere/source/os/os_process_handle_api.cpp +++ b/libraries/libstratosphere/source/os/os_process_handle_api.cpp @@ -33,11 +33,11 @@ namespace ams { } Result GetProcessId(os::ProcessId *out, NativeHandle handle) { - return ::ams::os::impl::ProcessHandleImpl::GetProcessId(out, handle); + R_RETURN(::ams::os::impl::ProcessHandleImpl::GetProcessId(out, handle)); } Result GetProgramId(ncm::ProgramId *out, NativeHandle handle) { - return ::ams::os::impl::ProcessHandleImpl::GetProgramId(out, handle); + R_RETURN(::ams::os::impl::ProcessHandleImpl::GetProgramId(out, handle)); } } diff --git a/libraries/libstratosphere/source/os/os_sdk_reply_and_receive.cpp b/libraries/libstratosphere/source/os/os_sdk_reply_and_receive.cpp index e51ad8a68..288879d27 100644 --- a/libraries/libstratosphere/source/os/os_sdk_reply_and_receive.cpp +++ b/libraries/libstratosphere/source/os/os_sdk_reply_and_receive.cpp @@ -41,7 +41,7 @@ namespace ams::os { impl::MultiWaitHolderBase *holder_base; ON_SCOPE_EXIT { *out = CastToMultiWaitHolder(holder_base); }; - return impl.ReplyAndReceive(std::addressof(holder_base), reply_target); + R_RETURN(impl.ReplyAndReceive(std::addressof(holder_base), reply_target)); } } diff --git a/libraries/libstratosphere/source/os/os_sdk_thread_local_storage_api.cpp b/libraries/libstratosphere/source/os/os_sdk_thread_local_storage_api.cpp index 2acdfdbdb..ec81ecad1 100644 --- a/libraries/libstratosphere/source/os/os_sdk_thread_local_storage_api.cpp +++ b/libraries/libstratosphere/source/os/os_sdk_thread_local_storage_api.cpp @@ -22,7 +22,7 @@ namespace ams::os { /* TODO: Nintendo reserves half the TLS slots for SDK usage. */ /* We don't have that ability...how should this work? */ Result SdkAllocateTlsSlot(TlsSlot *out, TlsDestructor destructor) { - return os::AllocateTlsSlot(out, destructor); + R_RETURN(os::AllocateTlsSlot(out, destructor)); } #else Result SdkAllocateTlsSlot(TlsSlot *out, TlsDestructor destructor) { diff --git a/libraries/libstratosphere/source/os/os_thread.cpp b/libraries/libstratosphere/source/os/os_thread.cpp index 272b524b2..6b397189e 100644 --- a/libraries/libstratosphere/source/os/os_thread.cpp +++ b/libraries/libstratosphere/source/os/os_thread.cpp @@ -47,12 +47,12 @@ namespace ams::os { Result CreateThread(ThreadType *thread, ThreadFunction function, void *argument, void *stack, size_t stack_size, s32 priority, s32 ideal_core) { ValidateThreadArguments(thread, stack, stack_size, priority); AMS_ASSERT(GetThreadAvailableCoreMask() & (1ul << ideal_core)); - return impl::GetThreadManager().CreateThread(thread, function, argument, stack, stack_size, priority, ideal_core); + R_RETURN(impl::GetThreadManager().CreateThread(thread, function, argument, stack, stack_size, priority, ideal_core)); } Result CreateThread(ThreadType *thread, ThreadFunction function, void *argument, void *stack, size_t stack_size, s32 priority) { ValidateThreadArguments(thread, stack, stack_size, priority); - return impl::GetThreadManager().CreateThread(thread, function, argument, stack, stack_size, priority); + R_RETURN(impl::GetThreadManager().CreateThread(thread, function, argument, stack, stack_size, priority)); } void DestroyThread(ThreadType *thread) { diff --git a/libraries/libstratosphere/source/pgl/pgl_remote_event_observer.hpp b/libraries/libstratosphere/source/pgl/pgl_remote_event_observer.hpp index 133fa963d..96f45f6eb 100644 --- a/libraries/libstratosphere/source/pgl/pgl_remote_event_observer.hpp +++ b/libraries/libstratosphere/source/pgl/pgl_remote_event_observer.hpp @@ -32,26 +32,26 @@ namespace ams::pgl { Result GetProcessEventHandle(ams::sf::OutCopyHandle out) { ::Event ev; - R_TRY(::pglEventObserverGetProcessEvent(std::addressof(m_observer), std::addressof(ev))); - out.SetValue(ev.revent, true); - R_SUCCEED(); + ON_RESULT_SUCCESS { out.SetValue(ev.revent, true); }; + + R_RETURN(::pglEventObserverGetProcessEvent(std::addressof(m_observer), std::addressof(ev))); } Result GetProcessEventInfo(ams::sf::Out out) { static_assert(sizeof(*out.GetPointer()) == sizeof(::PmProcessEventInfo)); - return ::pglEventObserverGetProcessEventInfo(std::addressof(m_observer), reinterpret_cast<::PmProcessEventInfo *>(out.GetPointer())); + R_RETURN(::pglEventObserverGetProcessEventInfo(std::addressof(m_observer), reinterpret_cast<::PmProcessEventInfo *>(out.GetPointer()))); } Result GetProcessEventHandle(ams::tipc::OutCopyHandle out) { ::Event ev; - R_TRY(::pglEventObserverGetProcessEvent(std::addressof(m_observer), std::addressof(ev))); - out.SetValue(ev.revent); - R_SUCCEED(); + ON_RESULT_SUCCESS { out.SetValue(ev.revent); }; + + R_RETURN(::pglEventObserverGetProcessEvent(std::addressof(m_observer), std::addressof(ev))); } Result GetProcessEventInfo(ams::tipc::Out out) { static_assert(sizeof(*out.GetPointer()) == sizeof(::PmProcessEventInfo)); - return ::pglEventObserverGetProcessEventInfo(std::addressof(m_observer), reinterpret_cast<::PmProcessEventInfo *>(out.GetPointer())); + R_RETURN(::pglEventObserverGetProcessEventInfo(std::addressof(m_observer), reinterpret_cast<::PmProcessEventInfo *>(out.GetPointer()))); } }; static_assert(pgl::sf::IsIEventObserver); diff --git a/libraries/libstratosphere/source/pgl/pgl_shell_api.cpp b/libraries/libstratosphere/source/pgl/pgl_shell_api.cpp index 1e2a87eb6..8bbd0da0b 100644 --- a/libraries/libstratosphere/source/pgl/pgl_shell_api.cpp +++ b/libraries/libstratosphere/source/pgl/pgl_shell_api.cpp @@ -58,7 +58,7 @@ namespace ams::pgl { #if defined(ATMOSPHERE_OS_HORIZON) Result Initialize() { - return ::pglInitialize(); + R_RETURN(::pglInitialize()); } void Finalize() { @@ -68,50 +68,50 @@ namespace ams::pgl { Result LaunchProgram(os::ProcessId *out, const ncm::ProgramLocation &loc, u32 process_flags, u8 pgl_flags) { static_assert(sizeof(*out) == sizeof(u64)); static_assert(sizeof(loc) == sizeof(::NcmProgramLocation)); - return ::pglLaunchProgram(reinterpret_cast(out), reinterpret_cast(std::addressof(loc)), process_flags, pgl_flags); + R_RETURN(::pglLaunchProgram(reinterpret_cast(out), reinterpret_cast(std::addressof(loc)), process_flags, pgl_flags)); } Result TerminateProcess(os::ProcessId process_id) { - return ::pglTerminateProcess(static_cast(process_id)); + R_RETURN(::pglTerminateProcess(static_cast(process_id))); } Result LaunchProgramFromHost(os::ProcessId *out, const char *content_path, u32 process_flags) { static_assert(sizeof(*out) == sizeof(u64)); - return ::pglLaunchProgramFromHost(reinterpret_cast(out), content_path, process_flags); + R_RETURN(::pglLaunchProgramFromHost(reinterpret_cast(out), content_path, process_flags)); } Result GetHostContentMetaInfo(pgl::ContentMetaInfo *out, const char *content_path) { static_assert(sizeof(*out) == sizeof(::PglContentMetaInfo)); - return ::pglGetHostContentMetaInfo(reinterpret_cast<::PglContentMetaInfo *>(out), content_path); + R_RETURN(::pglGetHostContentMetaInfo(reinterpret_cast<::PglContentMetaInfo *>(out), content_path)); } Result GetApplicationProcessId(os::ProcessId *out) { static_assert(sizeof(*out) == sizeof(u64)); - return ::pglGetApplicationProcessId(reinterpret_cast(out)); + R_RETURN(::pglGetApplicationProcessId(reinterpret_cast(out))); } Result BoostSystemMemoryResourceLimit(u64 size) { - return ::pglBoostSystemMemoryResourceLimit(size); + R_RETURN(::pglBoostSystemMemoryResourceLimit(size)); } Result IsProcessTracked(bool *out, os::ProcessId process_id) { - return ::pglIsProcessTracked(out, static_cast(process_id)); + R_RETURN(::pglIsProcessTracked(out, static_cast(process_id))); } Result EnableApplicationCrashReport(bool enabled) { - return ::pglEnableApplicationCrashReport(enabled); + R_RETURN(::pglEnableApplicationCrashReport(enabled)); } Result IsApplicationCrashReportEnabled(bool *out) { - return ::pglIsApplicationCrashReportEnabled(out); + R_RETURN(::pglIsApplicationCrashReportEnabled(out)); } Result EnableApplicationAllThreadDumpOnCrash(bool enabled) { - return ::pglEnableApplicationAllThreadDumpOnCrash(enabled); + R_RETURN(::pglEnableApplicationAllThreadDumpOnCrash(enabled)); } Result TriggerApplicationSnapShotDumper(const char *arg, SnapShotDumpType dump_type) { - return ::pglTriggerApplicationSnapShotDumper(static_cast<::PglSnapShotDumpType>(dump_type), arg); + R_RETURN(::pglTriggerApplicationSnapShotDumper(static_cast<::PglSnapShotDumpType>(dump_type), arg)); } Result GetEventObserver(pgl::EventObserver *out) { diff --git a/libraries/libstratosphere/source/pgl/srv/pgl_srv_shell.cpp b/libraries/libstratosphere/source/pgl/srv/pgl_srv_shell.cpp index c22b0605f..577f59560 100644 --- a/libraries/libstratosphere/source/pgl/srv/pgl_srv_shell.cpp +++ b/libraries/libstratosphere/source/pgl/srv/pgl_srv_shell.cpp @@ -400,7 +400,7 @@ namespace ams::pgl::srv { Result TerminateProcess(os::ProcessId process_id) { /* Ask PM to terminate the process. */ - return pm::shell::TerminateProcess(process_id); + R_RETURN(pm::shell::TerminateProcess(process_id)); } Result GetApplicationProcessId(os::ProcessId *out) { @@ -415,7 +415,7 @@ namespace ams::pgl::srv { Result BoostSystemMemoryResourceLimit(u64 size) { /* Ask PM to boost the limit. */ - return pm::shell::BoostSystemMemoryResourceLimit(size); + R_RETURN(pm::shell::BoostSystemMemoryResourceLimit(size)); } bool IsProcessTracked(os::ProcessId process_id) { @@ -493,7 +493,7 @@ namespace ams::pgl::srv { /* Launch the snapshot dumper, clearing the global tracker process id. */ ON_SCOPE_EXIT { g_ssd_process_id = os::InvalidProcessId; }; - return TriggerSnapShotDumper(process_id, dump_type, arg); + R_RETURN(TriggerSnapShotDumper(process_id, dump_type, arg)); } } diff --git a/libraries/libstratosphere/source/pgl/srv/pgl_srv_shell_event_observer.cpp b/libraries/libstratosphere/source/pgl/srv/pgl_srv_shell_event_observer.cpp index 72852a212..047123d36 100644 --- a/libraries/libstratosphere/source/pgl/srv/pgl_srv_shell_event_observer.cpp +++ b/libraries/libstratosphere/source/pgl/srv/pgl_srv_shell_event_observer.cpp @@ -71,7 +71,7 @@ namespace ams::pgl::srv { } Result ShellEventObserverCmif::GetProcessEventInfo(ams::sf::Out out) { - return this->PopEventInfo(out.GetPointer()); + R_RETURN(this->PopEventInfo(out.GetPointer())); } Result ShellEventObserverTipc::GetProcessEventHandle(ams::tipc::OutCopyHandle out) { @@ -80,7 +80,7 @@ namespace ams::pgl::srv { } Result ShellEventObserverTipc::GetProcessEventInfo(ams::tipc::Out out) { - return this->PopEventInfo(out.GetPointer()); + R_RETURN(this->PopEventInfo(out.GetPointer())); } } diff --git a/libraries/libstratosphere/source/pgl/srv/pgl_srv_shell_host_utils.cpp b/libraries/libstratosphere/source/pgl/srv/pgl_srv_shell_host_utils.cpp index 7cbacc8a1..4ab05b0c3 100644 --- a/libraries/libstratosphere/source/pgl/srv/pgl_srv_shell_host_utils.cpp +++ b/libraries/libstratosphere/source/pgl/srv/pgl_srv_shell_host_utils.cpp @@ -133,8 +133,8 @@ namespace ams::pgl::srv { Result GetContentPath(lr::Path *out, ncm::ContentType type, util::optional index) const { switch (m_extension_type) { - case ExtensionType::Nsp: return this->GetContentPathInNsp(out, type, index); - case ExtensionType::Nspd: return this->GetContentPathInNspd(out, type, index); + case ExtensionType::Nsp: R_RETURN(this->GetContentPathInNsp(out, type, index)); + case ExtensionType::Nspd: R_RETURN(this->GetContentPathInNspd(out, type, index)); AMS_UNREACHABLE_DEFAULT_CASE(); } } @@ -263,7 +263,7 @@ namespace ams::pgl::srv { R_UNLESS(has_content, pgl::ResultContentMetaNotFound()); /* Read the content meta buffer. */ - return ncm::ReadContentMetaPathWithoutExtendedDataOrDigest(std::addressof(m_content_meta_buffer), meta_path.str); + R_RETURN(ncm::ReadContentMetaPathWithoutExtendedDataOrDigest(std::addressof(m_content_meta_buffer), meta_path.str)); } Result SearchContent(bool *out, lr::Path *out_path, const char *extension, fs::OpenDirectoryMode mode) const { @@ -332,7 +332,7 @@ namespace ams::pgl::srv { host_resolver.RedirectProgramPath(content_path, reader.GetProgramId()); /* Launch the program. */ - return pgl::srv::LaunchProgram(out, ncm::ProgramLocation::Make(reader.GetProgramId(), ncm::StorageId::Host), pm_flags, pgl::LaunchFlags_None); + R_RETURN(pgl::srv::LaunchProgram(out, ncm::ProgramLocation::Make(reader.GetProgramId(), ncm::StorageId::Host), pm_flags, pgl::LaunchFlags_None)); } Result GetHostContentMetaInfo(pgl::ContentMetaInfo *out, const char *package_path) { diff --git a/libraries/libstratosphere/source/pgl/srv/pgl_srv_shell_interface.cpp b/libraries/libstratosphere/source/pgl/srv/pgl_srv_shell_interface.cpp index 009dcc254..52e43a5e3 100644 --- a/libraries/libstratosphere/source/pgl/srv/pgl_srv_shell_interface.cpp +++ b/libraries/libstratosphere/source/pgl/srv/pgl_srv_shell_interface.cpp @@ -22,29 +22,29 @@ namespace ams::pgl::srv { Result ShellInterfaceCommon::LaunchProgramImpl(os::ProcessId *out, const ncm::ProgramLocation &loc, u32 pm_flags, u8 pgl_flags) { - return pgl::srv::LaunchProgram(out, loc, pm_flags, pgl_flags); + R_RETURN(pgl::srv::LaunchProgram(out, loc, pm_flags, pgl_flags)); } Result ShellInterfaceCommon::TerminateProcessImpl(os::ProcessId process_id) { - return pgl::srv::TerminateProcess(process_id); + R_RETURN(pgl::srv::TerminateProcess(process_id)); } Result ShellInterfaceCommon::LaunchProgramFromHostImpl(os::ProcessId *out, const void *content_path, size_t content_path_size, u32 pm_flags) { AMS_UNUSED(content_path_size); - return pgl::srv::LaunchProgramFromHost(out, static_cast(content_path), pm_flags); + R_RETURN(pgl::srv::LaunchProgramFromHost(out, static_cast(content_path), pm_flags)); } Result ShellInterfaceCommon::GetHostContentMetaInfoImpl(pgl::ContentMetaInfo *out, const void *content_path, size_t content_path_size) { AMS_UNUSED(content_path_size); - return pgl::srv::GetHostContentMetaInfo(out, static_cast(content_path)); + R_RETURN(pgl::srv::GetHostContentMetaInfo(out, static_cast(content_path))); } Result ShellInterfaceCommon::GetApplicationProcessIdImpl(os::ProcessId *out) { - return pgl::srv::GetApplicationProcessId(out); + R_RETURN(pgl::srv::GetApplicationProcessId(out)); } Result ShellInterfaceCommon::BoostSystemMemoryResourceLimitImpl(u64 size) { - return pgl::srv::BoostSystemMemoryResourceLimit(size); + R_RETURN(pgl::srv::BoostSystemMemoryResourceLimit(size)); } Result ShellInterfaceCommon::IsProcessTrackedImpl(bool *out, os::ProcessId process_id) { @@ -69,51 +69,51 @@ namespace ams::pgl::srv { Result ShellInterfaceCommon::TriggerApplicationSnapShotDumperImpl(SnapShotDumpType dump_type, const void *arg, size_t arg_size) { AMS_UNUSED(arg_size); - return pgl::srv::TriggerApplicationSnapShotDumper(dump_type, static_cast(arg)); + R_RETURN(pgl::srv::TriggerApplicationSnapShotDumper(dump_type, static_cast(arg))); } Result ShellInterfaceCmif::LaunchProgram(ams::sf::Out out, const ncm::ProgramLocation &loc, u32 pm_flags, u8 pgl_flags) { - return this->LaunchProgramImpl(out.GetPointer(), loc, pm_flags, pgl_flags); + R_RETURN(this->LaunchProgramImpl(out.GetPointer(), loc, pm_flags, pgl_flags)); } Result ShellInterfaceCmif::TerminateProcess(os::ProcessId process_id) { - return this->TerminateProcessImpl(process_id); + R_RETURN(this->TerminateProcessImpl(process_id)); } Result ShellInterfaceCmif::LaunchProgramFromHost(ams::sf::Out out, const ams::sf::InBuffer &content_path, u32 pm_flags) { - return this->LaunchProgramFromHostImpl(out.GetPointer(), content_path.GetPointer(), content_path.GetSize(), pm_flags); + R_RETURN(this->LaunchProgramFromHostImpl(out.GetPointer(), content_path.GetPointer(), content_path.GetSize(), pm_flags)); } Result ShellInterfaceCmif::GetHostContentMetaInfo(ams::sf::Out out, const ams::sf::InBuffer &content_path) { - return this->GetHostContentMetaInfoImpl(out.GetPointer(), content_path.GetPointer(), content_path.GetSize()); + R_RETURN(this->GetHostContentMetaInfoImpl(out.GetPointer(), content_path.GetPointer(), content_path.GetSize())); } Result ShellInterfaceCmif::GetApplicationProcessId(ams::sf::Out out) { - return this->GetApplicationProcessIdImpl(out.GetPointer()); + R_RETURN(this->GetApplicationProcessIdImpl(out.GetPointer())); } Result ShellInterfaceCmif::BoostSystemMemoryResourceLimit(u64 size) { - return this->BoostSystemMemoryResourceLimitImpl(size); + R_RETURN(this->BoostSystemMemoryResourceLimitImpl(size)); } Result ShellInterfaceCmif::IsProcessTracked(ams::sf::Out out, os::ProcessId process_id) { - return this->IsProcessTrackedImpl(out.GetPointer(), process_id); + R_RETURN(this->IsProcessTrackedImpl(out.GetPointer(), process_id)); } Result ShellInterfaceCmif::EnableApplicationCrashReport(bool enabled) { - return this->EnableApplicationCrashReportImpl(enabled); + R_RETURN(this->EnableApplicationCrashReportImpl(enabled)); } Result ShellInterfaceCmif::IsApplicationCrashReportEnabled(ams::sf::Out out) { - return this->IsApplicationCrashReportEnabledImpl(out.GetPointer()); + R_RETURN(this->IsApplicationCrashReportEnabledImpl(out.GetPointer())); } Result ShellInterfaceCmif::EnableApplicationAllThreadDumpOnCrash(bool enabled) { - return this->EnableApplicationAllThreadDumpOnCrashImpl(enabled); + R_RETURN(this->EnableApplicationAllThreadDumpOnCrashImpl(enabled)); } Result ShellInterfaceCmif::TriggerApplicationSnapShotDumper(SnapShotDumpType dump_type, const ams::sf::InBuffer &arg) { - return this->TriggerApplicationSnapShotDumperImpl(dump_type, arg.GetPointer(), arg.GetSize()); + R_RETURN(this->TriggerApplicationSnapShotDumperImpl(dump_type, arg.GetPointer(), arg.GetSize())); } Result ShellInterfaceCmif::GetShellEventObserver(ams::sf::Out> out) { @@ -131,47 +131,47 @@ namespace ams::pgl::srv { } Result ShellInterfaceTipc::LaunchProgram(ams::tipc::Out out, const ncm::ProgramLocation loc, u32 pm_flags, u8 pgl_flags) { - return this->LaunchProgramImpl(out.GetPointer(), loc, pm_flags, pgl_flags); + R_RETURN(this->LaunchProgramImpl(out.GetPointer(), loc, pm_flags, pgl_flags)); } Result ShellInterfaceTipc::TerminateProcess(os::ProcessId process_id) { - return this->TerminateProcessImpl(process_id); + R_RETURN(this->TerminateProcessImpl(process_id)); } Result ShellInterfaceTipc::LaunchProgramFromHost(ams::tipc::Out out, const ams::tipc::InBuffer content_path, u32 pm_flags) { - return this->LaunchProgramFromHostImpl(out.GetPointer(), content_path.GetPointer(), content_path.GetSize(), pm_flags); + R_RETURN(this->LaunchProgramFromHostImpl(out.GetPointer(), content_path.GetPointer(), content_path.GetSize(), pm_flags)); } Result ShellInterfaceTipc::GetHostContentMetaInfo(ams::tipc::Out out, const ams::tipc::InBuffer content_path) { - return this->GetHostContentMetaInfoImpl(out.GetPointer(), content_path.GetPointer(), content_path.GetSize()); + R_RETURN(this->GetHostContentMetaInfoImpl(out.GetPointer(), content_path.GetPointer(), content_path.GetSize())); } Result ShellInterfaceTipc::GetApplicationProcessId(ams::tipc::Out out) { - return this->GetApplicationProcessIdImpl(out.GetPointer()); + R_RETURN(this->GetApplicationProcessIdImpl(out.GetPointer())); } Result ShellInterfaceTipc::BoostSystemMemoryResourceLimit(u64 size) { - return this->BoostSystemMemoryResourceLimitImpl(size); + R_RETURN(this->BoostSystemMemoryResourceLimitImpl(size)); } Result ShellInterfaceTipc::IsProcessTracked(ams::tipc::Out out, os::ProcessId process_id) { - return this->IsProcessTrackedImpl(out.GetPointer(), process_id); + R_RETURN(this->IsProcessTrackedImpl(out.GetPointer(), process_id)); } Result ShellInterfaceTipc::EnableApplicationCrashReport(bool enabled) { - return this->EnableApplicationCrashReportImpl(enabled); + R_RETURN(this->EnableApplicationCrashReportImpl(enabled)); } Result ShellInterfaceTipc::IsApplicationCrashReportEnabled(ams::tipc::Out out) { - return this->IsApplicationCrashReportEnabledImpl(out.GetPointer()); + R_RETURN(this->IsApplicationCrashReportEnabledImpl(out.GetPointer())); } Result ShellInterfaceTipc::EnableApplicationAllThreadDumpOnCrash(bool enabled) { - return this->EnableApplicationAllThreadDumpOnCrashImpl(enabled); + R_RETURN(this->EnableApplicationAllThreadDumpOnCrashImpl(enabled)); } Result ShellInterfaceTipc::GetShellEventObserver(ams::tipc::OutMoveHandle out) { - return pgl::srv::AllocateShellEventObserverForTipc(out.GetPointer()); + R_RETURN(pgl::srv::AllocateShellEventObserverForTipc(out.GetPointer())); } } diff --git a/libraries/libstratosphere/source/pm/pm_dmnt_api.cpp b/libraries/libstratosphere/source/pm/pm_dmnt_api.cpp index cbbc9c19a..2eed37653 100644 --- a/libraries/libstratosphere/source/pm/pm_dmnt_api.cpp +++ b/libraries/libstratosphere/source/pm/pm_dmnt_api.cpp @@ -22,19 +22,19 @@ namespace ams::pm::dmnt { /* Debug Monitor API. */ #if defined(ATMOSPHERE_OS_HORIZON) Result StartProcess(os::ProcessId process_id) { - return pmdmntStartProcess(static_cast(process_id)); + R_RETURN(pmdmntStartProcess(static_cast(process_id))); } Result GetProgramId(ncm::ProgramId *out_program_id, os::ProcessId process_id) { - return pmdmntGetProgramId(reinterpret_cast(out_program_id), static_cast(process_id)); + R_RETURN(pmdmntGetProgramId(reinterpret_cast(out_program_id), static_cast(process_id))); } Result GetProcessId(os::ProcessId *out_process_id, const ncm::ProgramId program_id) { - return pmdmntGetProcessId(reinterpret_cast(out_process_id), static_cast(program_id)); + R_RETURN(pmdmntGetProcessId(reinterpret_cast(out_process_id), static_cast(program_id))); } Result GetApplicationProcessId(os::ProcessId *out_process_id) { - return pmdmntGetApplicationProcessId(reinterpret_cast(out_process_id)); + R_RETURN(pmdmntGetApplicationProcessId(reinterpret_cast(out_process_id))); } Result HookToCreateApplicationProcess(os::NativeHandle *out_handle) { @@ -49,13 +49,13 @@ namespace ams::pm::dmnt { *out_loc = {}; *out_status = {}; static_assert(sizeof(*out_status) == sizeof(CfgOverrideStatus)); - return pmdmntAtmosphereGetProcessInfo(out_handle, reinterpret_cast(out_loc), reinterpret_cast(out_status), static_cast(process_id)); + R_RETURN(pmdmntAtmosphereGetProcessInfo(out_handle, reinterpret_cast(out_loc), reinterpret_cast(out_status), static_cast(process_id))); } Result AtmosphereGetCurrentLimitInfo(u64 *out_current_value, u64 *out_limit_value, ResourceLimitGroup group, svc::LimitableResource resource) { *out_current_value = 0; *out_limit_value = 0; - return pmdmntAtmosphereGetCurrentLimitInfo(out_current_value, out_limit_value, group, resource); + R_RETURN(pmdmntAtmosphereGetCurrentLimitInfo(out_current_value, out_limit_value, group, resource)); } #endif diff --git a/libraries/libstratosphere/source/pm/pm_info_api.cpp b/libraries/libstratosphere/source/pm/pm_info_api.cpp index 5273e90cc..182c09c8a 100644 --- a/libraries/libstratosphere/source/pm/pm_info_api.cpp +++ b/libraries/libstratosphere/source/pm/pm_info_api.cpp @@ -21,28 +21,28 @@ namespace ams::pm::info { /* Information API. */ #if defined(ATMOSPHERE_OS_HORIZON) Result GetProgramId(ncm::ProgramId *out_program_id, os::ProcessId process_id) { - return pminfoGetProgramId(reinterpret_cast(out_program_id), static_cast(process_id)); + R_RETURN(pminfoGetProgramId(reinterpret_cast(out_program_id), static_cast(process_id))); } Result GetProcessId(os::ProcessId *out_process_id, ncm::ProgramId program_id) { - return pminfoAtmosphereGetProcessId(reinterpret_cast(out_process_id), static_cast(program_id)); + R_RETURN(pminfoAtmosphereGetProcessId(reinterpret_cast(out_process_id), static_cast(program_id))); } Result GetAppletCurrentResourceLimitValues(pm::ResourceLimitValues *out) { static_assert(sizeof(pm::ResourceLimitValues) == sizeof(::PmResourceLimitValues)); - return pminfoGetAppletCurrentResourceLimitValues(reinterpret_cast(out)); + R_RETURN(pminfoGetAppletCurrentResourceLimitValues(reinterpret_cast(out))); } Result GetAppletPeakResourceLimitValues(pm::ResourceLimitValues *out) { static_assert(sizeof(pm::ResourceLimitValues) == sizeof(::PmResourceLimitValues)); - return pminfoGetAppletPeakResourceLimitValues(reinterpret_cast(out)); + R_RETURN(pminfoGetAppletPeakResourceLimitValues(reinterpret_cast(out))); } Result GetProcessInfo(ncm::ProgramLocation *out_loc, cfg::OverrideStatus *out_status, os::ProcessId process_id) { *out_loc = {}; *out_status = {}; static_assert(sizeof(*out_status) == sizeof(CfgOverrideStatus)); - return pminfoAtmosphereGetProcessInfo(reinterpret_cast(out_loc), reinterpret_cast(out_status), static_cast(process_id)); + R_RETURN(pminfoAtmosphereGetProcessInfo(reinterpret_cast(out_loc), reinterpret_cast(out_status), static_cast(process_id))); } bool HasLaunchedBootProgram(ncm::ProgramId program_id) { @@ -65,7 +65,7 @@ namespace ams::pm::info { os::ProcessId process_id; R_TRY(GetProcessId(std::addressof(process_id), program_id)); - return IsHblProcessId(out, process_id); + R_RETURN(IsHblProcessId(out, process_id)); } #endif diff --git a/libraries/libstratosphere/source/pm/pm_shell_api.cpp b/libraries/libstratosphere/source/pm/pm_shell_api.cpp index 001cbb25c..03470e47f 100644 --- a/libraries/libstratosphere/source/pm/pm_shell_api.cpp +++ b/libraries/libstratosphere/source/pm/pm_shell_api.cpp @@ -22,11 +22,11 @@ namespace ams::pm::shell { Result WEAK_SYMBOL LaunchProgram(os::ProcessId *out, const ncm::ProgramLocation &loc, u32 launch_flags) { static_assert(sizeof(ncm::ProgramLocation) == sizeof(NcmProgramLocation)); static_assert(alignof(ncm::ProgramLocation) == alignof(NcmProgramLocation)); - return pmshellLaunchProgram(launch_flags, reinterpret_cast(std::addressof(loc)), reinterpret_cast(out)); + R_RETURN(pmshellLaunchProgram(launch_flags, reinterpret_cast(std::addressof(loc)), reinterpret_cast(out))); } Result TerminateProcess(os::ProcessId process_id) { - return ::pmshellTerminateProcess(static_cast(process_id)); + R_RETURN(::pmshellTerminateProcess(static_cast(process_id))); } Result GetProcessEventEvent(os::SystemEvent *out) { @@ -38,24 +38,24 @@ namespace ams::pm::shell { Result GetProcessEventInfo(ProcessEventInfo *out) { static_assert(sizeof(*out) == sizeof(::PmProcessEventInfo)); - return ::pmshellGetProcessEventInfo(reinterpret_cast<::PmProcessEventInfo *>(out)); + R_RETURN(::pmshellGetProcessEventInfo(reinterpret_cast<::PmProcessEventInfo *>(out))); } Result GetApplicationProcessIdForShell(os::ProcessId *out) { static_assert(sizeof(*out) == sizeof(u64)); - return ::pmshellGetApplicationProcessIdForShell(reinterpret_cast(out)); + R_RETURN(::pmshellGetApplicationProcessIdForShell(reinterpret_cast(out))); } Result BoostSystemMemoryResourceLimit(u64 size) { - return ::pmshellBoostSystemMemoryResourceLimit(size); + R_RETURN(::pmshellBoostSystemMemoryResourceLimit(size)); } Result BoostApplicationThreadResourceLimit() { - return ::pmshellBoostApplicationThreadResourceLimit(); + R_RETURN(::pmshellBoostApplicationThreadResourceLimit()); } Result BoostSystemThreadResourceLimit() { - return ::pmshellBoostSystemThreadResourceLimit(); + R_RETURN(::pmshellBoostSystemThreadResourceLimit()); } #endif diff --git a/libraries/libstratosphere/source/powctl/impl/board/nintendo/nx/powctl_bq24193_driver.cpp b/libraries/libstratosphere/source/powctl/impl/board/nintendo/nx/powctl_bq24193_driver.cpp index 0e440f666..74d58275f 100644 --- a/libraries/libstratosphere/source/powctl/impl/board/nintendo/nx/powctl_bq24193_driver.cpp +++ b/libraries/libstratosphere/source/powctl/impl/board/nintendo/nx/powctl_bq24193_driver.cpp @@ -268,19 +268,19 @@ namespace ams::powctl::impl::board::nintendo::nx { } Result Bq24193Driver::SetPreChargeCurrentLimit(int ma) { - return ReadWriteRegister(m_i2c_session, bq24193::PreChargeTerminationCurrentControl, 0xF0, bq24193::EncodePreChargeCurrentLimit(ma)); + R_RETURN(ReadWriteRegister(m_i2c_session, bq24193::PreChargeTerminationCurrentControl, 0xF0, bq24193::EncodePreChargeCurrentLimit(ma))); } Result Bq24193Driver::SetTerminationCurrentLimit(int ma) { - return ReadWriteRegister(m_i2c_session, bq24193::PreChargeTerminationCurrentControl, 0x0F, bq24193::EncodeTerminationCurrentLimit(ma)); + R_RETURN(ReadWriteRegister(m_i2c_session, bq24193::PreChargeTerminationCurrentControl, 0x0F, bq24193::EncodeTerminationCurrentLimit(ma))); } Result Bq24193Driver::SetMinimumSystemVoltageLimit(int mv) { - return ReadWriteRegister(m_i2c_session, bq24193::PowerOnConfiguration, 0x0E, bq24193::EncodeMinimumSystemVoltageLimit(mv)); + R_RETURN(ReadWriteRegister(m_i2c_session, bq24193::PowerOnConfiguration, 0x0E, bq24193::EncodeMinimumSystemVoltageLimit(mv))); } Result Bq24193Driver::SetChargingSafetyTimerEnabled(bool en) { - return ReadWriteRegister(m_i2c_session, bq24193::ChargeTerminationTimerControl, 0x08, en ? 0x08 : 0x00); + R_RETURN(ReadWriteRegister(m_i2c_session, bq24193::ChargeTerminationTimerControl, 0x08, en ? 0x08 : 0x00)); } Result Bq24193Driver::GetForce20PercentChargeCurrent(bool *out) { @@ -294,7 +294,7 @@ namespace ams::powctl::impl::board::nintendo::nx { } Result Bq24193Driver::SetForce20PercentChargeCurrent(bool en) { - return ReadWriteRegister(m_i2c_session, bq24193::ChargeCurrentControl, 0x01, en ? 0x01 : 0x00); + R_RETURN(ReadWriteRegister(m_i2c_session, bq24193::ChargeCurrentControl, 0x01, en ? 0x01 : 0x00)); } Result Bq24193Driver::GetFastChargeCurrentLimit(int *out_ma) { @@ -308,7 +308,7 @@ namespace ams::powctl::impl::board::nintendo::nx { } Result Bq24193Driver::SetFastChargeCurrentLimit(int ma) { - return ReadWriteRegister(m_i2c_session, bq24193::ChargeCurrentControl, 0xFC, bq24193::EncodeFastChargeCurrentLimit(ma)); + R_RETURN(ReadWriteRegister(m_i2c_session, bq24193::ChargeCurrentControl, 0xFC, bq24193::EncodeFastChargeCurrentLimit(ma))); } Result Bq24193Driver::GetChargeVoltageLimit(int *out_mv) { @@ -322,11 +322,11 @@ namespace ams::powctl::impl::board::nintendo::nx { } Result Bq24193Driver::SetChargeVoltageLimit(int mv) { - return ReadWriteRegister(m_i2c_session, bq24193::ChargeVoltageControl, 0xFC, bq24193::EncodeChargeVoltageLimit(mv)); + R_RETURN(ReadWriteRegister(m_i2c_session, bq24193::ChargeVoltageControl, 0xFC, bq24193::EncodeChargeVoltageLimit(mv))); } Result Bq24193Driver::SetChargerConfiguration(bq24193::ChargerConfiguration cfg) { - return ReadWriteRegister(m_i2c_session, bq24193::PowerOnConfiguration, 0x30, bq24193::EncodeChargerConfiguration(cfg)); + R_RETURN(ReadWriteRegister(m_i2c_session, bq24193::PowerOnConfiguration, 0x30, bq24193::EncodeChargerConfiguration(cfg))); } Result Bq24193Driver::IsHiZEnabled(bool *out) { @@ -340,7 +340,7 @@ namespace ams::powctl::impl::board::nintendo::nx { } Result Bq24193Driver::SetHiZEnabled(bool en) { - return ReadWriteRegister(m_i2c_session, bq24193::InputSourceControl, 0x80, en ? 0x80 : 0x00); + R_RETURN(ReadWriteRegister(m_i2c_session, bq24193::InputSourceControl, 0x80, en ? 0x80 : 0x00)); } Result Bq24193Driver::GetInputCurrentLimit(int *out_ma) { @@ -354,15 +354,15 @@ namespace ams::powctl::impl::board::nintendo::nx { } Result Bq24193Driver::SetInputCurrentLimit(int ma) { - return ReadWriteRegister(m_i2c_session, bq24193::InputSourceControl, 0x07, bq24193::EncodeInputCurrentLimit(ma)); + R_RETURN(ReadWriteRegister(m_i2c_session, bq24193::InputSourceControl, 0x07, bq24193::EncodeInputCurrentLimit(ma))); } Result Bq24193Driver::SetInputVoltageLimit(int mv) { - return ReadWriteRegister(m_i2c_session, bq24193::InputSourceControl, 0x78, bq24193::EncodeInputVoltageLimit(mv)); + R_RETURN(ReadWriteRegister(m_i2c_session, bq24193::InputSourceControl, 0x78, bq24193::EncodeInputVoltageLimit(mv))); } Result Bq24193Driver::SetBoostModeCurrentLimit(int ma) { - return ReadWriteRegister(m_i2c_session, bq24193::PowerOnConfiguration, 0x01, bq24193::EncodeBoostModeCurrentLimit(ma)); + R_RETURN(ReadWriteRegister(m_i2c_session, bq24193::PowerOnConfiguration, 0x01, bq24193::EncodeBoostModeCurrentLimit(ma))); } Result Bq24193Driver::GetChargerStatus(bq24193::ChargerStatus *out) { @@ -376,11 +376,11 @@ namespace ams::powctl::impl::board::nintendo::nx { } Result Bq24193Driver::ResetWatchdogTimer() { - return ReadWriteRegister(m_i2c_session, bq24193::PowerOnConfiguration, 0x40, 0x40); + R_RETURN(ReadWriteRegister(m_i2c_session, bq24193::PowerOnConfiguration, 0x40, 0x40)); } Result Bq24193Driver::SetWatchdogTimerSetting(int seconds) { - return ReadWriteRegister(m_i2c_session, bq24193::ChargeTerminationTimerControl, 0x30, bq24193::EncodeWatchdogTimerSetting(seconds)); + R_RETURN(ReadWriteRegister(m_i2c_session, bq24193::ChargeTerminationTimerControl, 0x30, bq24193::EncodeWatchdogTimerSetting(seconds))); } Result Bq24193Driver::GetBatteryCompensation(int *out_mo) { @@ -394,7 +394,7 @@ namespace ams::powctl::impl::board::nintendo::nx { } Result Bq24193Driver::SetBatteryCompensation(int mo) { - return ReadWriteRegister(m_i2c_session, bq24193::IrCompensationThermalRegulationControl, 0xE0, bq24193::EncodeBatteryCompensation(mo)); + R_RETURN(ReadWriteRegister(m_i2c_session, bq24193::IrCompensationThermalRegulationControl, 0xE0, bq24193::EncodeBatteryCompensation(mo))); } Result Bq24193Driver::GetVoltageClamp(int *out_mv) { @@ -408,7 +408,7 @@ namespace ams::powctl::impl::board::nintendo::nx { } Result Bq24193Driver::SetVoltageClamp(int mv) { - return ReadWriteRegister(m_i2c_session, bq24193::IrCompensationThermalRegulationControl, 0x1C, bq24193::EncodeVoltageClamp(mv)); + R_RETURN(ReadWriteRegister(m_i2c_session, bq24193::IrCompensationThermalRegulationControl, 0x1C, bq24193::EncodeVoltageClamp(mv))); } } \ No newline at end of file diff --git a/libraries/libstratosphere/source/powctl/impl/board/nintendo/nx/powctl_max17050_driver.cpp b/libraries/libstratosphere/source/powctl/impl/board/nintendo/nx/powctl_max17050_driver.cpp index 8c9365187..76d041cde 100644 --- a/libraries/libstratosphere/source/powctl/impl/board/nintendo/nx/powctl_max17050_driver.cpp +++ b/libraries/libstratosphere/source/powctl/impl/board/nintendo/nx/powctl_max17050_driver.cpp @@ -175,11 +175,11 @@ namespace ams::powctl::impl::board::nintendo::nx { } ALWAYS_INLINE Result ReadRegister(const i2c::I2cSession &session, u8 address, u16 *out) { - return i2c::ReadSingleRegister(session, address, out); + R_RETURN(i2c::ReadSingleRegister(session, address, out)); } ALWAYS_INLINE Result WriteRegister(const i2c::I2cSession &session, u8 address, u16 val) { - return i2c::WriteSingleRegister(session, address, val); + R_RETURN(i2c::WriteSingleRegister(session, address, val)); } ALWAYS_INLINE bool WriteValidateRegister(const i2c::I2cSession &session, u8 address, u16 val) { @@ -364,15 +364,15 @@ namespace ams::powctl::impl::board::nintendo::nx { } Result Max17050Driver::SetMaximumShutdownTimerThreshold() { - return WriteRegister(m_i2c_session, max17050::ShdnTimer, 0xE000); + R_RETURN(WriteRegister(m_i2c_session, max17050::ShdnTimer, 0xE000)); } Result Max17050Driver::SetAlertByChargePercentage() { - return ReadWriteRegister(m_i2c_session, max17050::MiscCfg, 0x0003, 0x0000); + R_RETURN(ReadWriteRegister(m_i2c_session, max17050::MiscCfg, 0x0003, 0x0000)); } Result Max17050Driver::SetAlertByVoltageFuelGaugePercentage() { - return ReadWriteRegister(m_i2c_session, max17050::MiscCfg, 0x0003, 0x0003); + R_RETURN(ReadWriteRegister(m_i2c_session, max17050::MiscCfg, 0x0003, 0x0003)); } bool Max17050Driver::IsPowerOnReset() { @@ -385,11 +385,11 @@ namespace ams::powctl::impl::board::nintendo::nx { } Result Max17050Driver::LockVoltageFuelGauge() { - return WriteRegister(m_i2c_session, max17050::SocVfAccess, 0x0000); + R_RETURN(WriteRegister(m_i2c_session, max17050::SocVfAccess, 0x0000)); } Result Max17050Driver::UnlockVoltageFuelGauge() { - return WriteRegister(m_i2c_session, max17050::SocVfAccess, 0x0080); + R_RETURN(WriteRegister(m_i2c_session, max17050::SocVfAccess, 0x0080)); } Result Max17050Driver::LockModelTable() { @@ -541,22 +541,22 @@ namespace ams::powctl::impl::board::nintendo::nx { Result Max17050Driver::SetChargePercentageMinimumAlertThreshold(int percentage) { R_TRY(this->SetAlertByChargePercentage()); - return ReadWriteRegister(m_i2c_session, max17050::SocAlrtThreshold, 0x00FF, static_cast(percentage)); + R_RETURN(ReadWriteRegister(m_i2c_session, max17050::SocAlrtThreshold, 0x00FF, static_cast(percentage))); } Result Max17050Driver::SetChargePercentageMaximumAlertThreshold(int percentage) { R_TRY(this->SetAlertByChargePercentage()); - return ReadWriteRegister(m_i2c_session, max17050::SocAlrtThreshold, 0xFF00, static_cast(static_cast(percentage)) << 8); + R_RETURN(ReadWriteRegister(m_i2c_session, max17050::SocAlrtThreshold, 0xFF00, static_cast(static_cast(percentage)) << 8)); } Result Max17050Driver::SetVoltageFuelGaugePercentageMinimumAlertThreshold(int percentage) { R_TRY(this->SetAlertByVoltageFuelGaugePercentage()); - return ReadWriteRegister(m_i2c_session, max17050::SocAlrtThreshold, 0x00FF, static_cast(percentage)); + R_RETURN(ReadWriteRegister(m_i2c_session, max17050::SocAlrtThreshold, 0x00FF, static_cast(percentage))); } Result Max17050Driver::SetVoltageFuelGaugePercentageMaximumAlertThreshold(int percentage) { R_TRY(this->SetAlertByVoltageFuelGaugePercentage()); - return ReadWriteRegister(m_i2c_session, max17050::SocAlrtThreshold, 0xFF00, static_cast(static_cast(percentage)) << 8); + R_RETURN(ReadWriteRegister(m_i2c_session, max17050::SocAlrtThreshold, 0xFF00, static_cast(static_cast(percentage)) << 8)); } Result Max17050Driver::SetFullChargeThreshold(double percentage) { @@ -564,7 +564,7 @@ namespace ams::powctl::impl::board::nintendo::nx { const u16 val = static_cast(static_cast(percentage * (1 << 8))); /* Set the threshold. */ - return WriteRegister(m_i2c_session, max17050::FullSocThr, val); + R_RETURN(WriteRegister(m_i2c_session, max17050::FullSocThr, val)); } Result Max17050Driver::GetAverageCurrent(double *out, double sense_resistor) { @@ -610,7 +610,7 @@ namespace ams::powctl::impl::board::nintendo::nx { } Result Max17050Driver::SetNeedToRestoreParameters(bool en) { - return ReadWriteRegister(m_i2c_session, max17050::MiscCfg, 0x8000, en ? 0x8000 : 0); + R_RETURN(ReadWriteRegister(m_i2c_session, max17050::MiscCfg, 0x8000, en ? 0x8000 : 0)); } Result Max17050Driver::IsI2cShutdownEnabled(bool *out) { @@ -624,14 +624,14 @@ namespace ams::powctl::impl::board::nintendo::nx { } Result Max17050Driver::SetI2cShutdownEnabled(bool en) { - return ReadWriteRegister(m_i2c_session, max17050::Config, 0x0040, en ? 0x0040 : 0); + R_RETURN(ReadWriteRegister(m_i2c_session, max17050::Config, 0x0040, en ? 0x0040 : 0)); } Result Max17050Driver::GetStatus(u16 *out) { /* Validate parameters. */ AMS_ABORT_UNLESS(out != nullptr); - return ReadRegister(m_i2c_session, max17050::Status, out); + R_RETURN(ReadRegister(m_i2c_session, max17050::Status, out)); } Result Max17050Driver::GetCycles(u16 *out) { @@ -645,7 +645,7 @@ namespace ams::powctl::impl::board::nintendo::nx { } Result Max17050Driver::ResetCycles() { - return WriteRegister(m_i2c_session, max17050::Cycles, 0x0060); + R_RETURN(WriteRegister(m_i2c_session, max17050::Cycles, 0x0060)); } Result Max17050Driver::GetAge(double *out) { @@ -688,11 +688,11 @@ namespace ams::powctl::impl::board::nintendo::nx { } Result Max17050Driver::SetTemperatureMinimumAlertThreshold(int c) { - return ReadWriteRegister(m_i2c_session, max17050::TAlrtThreshold, 0x00FF, static_cast(c)); + R_RETURN(ReadWriteRegister(m_i2c_session, max17050::TAlrtThreshold, 0x00FF, static_cast(c))); } Result Max17050Driver::SetTemperatureMaximumAlertThreshold(int c) { - return ReadWriteRegister(m_i2c_session, max17050::TAlrtThreshold, 0xFF00, static_cast(static_cast(c)) << 8); + R_RETURN(ReadWriteRegister(m_i2c_session, max17050::TAlrtThreshold, 0xFF00, static_cast(static_cast(c)) << 8)); } Result Max17050Driver::GetVCell(int *out) { @@ -748,11 +748,11 @@ namespace ams::powctl::impl::board::nintendo::nx { } Result Max17050Driver::SetVoltageMinimumAlertThreshold(int mv) { - return ReadWriteRegister(m_i2c_session, max17050::VAlrtThreshold, 0x00FF, static_cast(util::DivideUp(mv, 20))); + R_RETURN(ReadWriteRegister(m_i2c_session, max17050::VAlrtThreshold, 0x00FF, static_cast(util::DivideUp(mv, 20)))); } Result Max17050Driver::SetVoltageMaximumAlertThreshold(int mv) { - return ReadWriteRegister(m_i2c_session, max17050::VAlrtThreshold, 0xFF00, static_cast(static_cast(mv / 20)) << 8); + R_RETURN(ReadWriteRegister(m_i2c_session, max17050::VAlrtThreshold, 0xFF00, static_cast(static_cast(mv / 20)) << 8)); } } diff --git a/libraries/libstratosphere/source/powctl/powctl_battery_api.cpp b/libraries/libstratosphere/source/powctl/powctl_battery_api.cpp index 89593ae07..09ec1a8a5 100644 --- a/libraries/libstratosphere/source/powctl/powctl_battery_api.cpp +++ b/libraries/libstratosphere/source/powctl/powctl_battery_api.cpp @@ -41,7 +41,7 @@ namespace ams::powctl { auto &device = impl.GetDevice().SafeCastTo(); /* Call into the driver. */ - return device.GetDriver().SafeCastTo().GetBatteryChargePercentage(out_percent, std::addressof(device)); + R_RETURN(device.GetDriver().SafeCastTo().GetBatteryChargePercentage(out_percent, std::addressof(device))); } Result GetBatteryVoltageFuelGaugePercentage(float *out_percent, Session &session) { @@ -55,7 +55,7 @@ namespace ams::powctl { auto &device = impl.GetDevice().SafeCastTo(); /* Call into the driver. */ - return device.GetDriver().SafeCastTo().GetBatteryVoltageFuelGaugePercentage(out_percent, std::addressof(device)); + R_RETURN(device.GetDriver().SafeCastTo().GetBatteryVoltageFuelGaugePercentage(out_percent, std::addressof(device))); } Result GetBatteryFullCapacity(int *out_mah, Session &session) { @@ -69,7 +69,7 @@ namespace ams::powctl { auto &device = impl.GetDevice().SafeCastTo(); /* Call into the driver. */ - return device.GetDriver().SafeCastTo().GetBatteryFullCapacity(out_mah, std::addressof(device)); + R_RETURN(device.GetDriver().SafeCastTo().GetBatteryFullCapacity(out_mah, std::addressof(device))); } Result GetBatteryRemainingCapacity(int *out_mah, Session &session) { @@ -83,7 +83,7 @@ namespace ams::powctl { auto &device = impl.GetDevice().SafeCastTo(); /* Call into the driver. */ - return device.GetDriver().SafeCastTo().GetBatteryRemainingCapacity(out_mah, std::addressof(device)); + R_RETURN(device.GetDriver().SafeCastTo().GetBatteryRemainingCapacity(out_mah, std::addressof(device))); } Result SetBatteryChargePercentageMinimumAlertThreshold(Session &session, float percentage) { @@ -97,7 +97,7 @@ namespace ams::powctl { auto &device = impl.GetDevice().SafeCastTo(); /* Call into the driver. */ - return device.GetDriver().SafeCastTo().SetBatteryChargePercentageMinimumAlertThreshold(std::addressof(device), percentage); + R_RETURN(device.GetDriver().SafeCastTo().SetBatteryChargePercentageMinimumAlertThreshold(std::addressof(device), percentage)); } Result SetBatteryChargePercentageMaximumAlertThreshold(Session &session, float percentage) { @@ -111,7 +111,7 @@ namespace ams::powctl { auto &device = impl.GetDevice().SafeCastTo(); /* Call into the driver. */ - return device.GetDriver().SafeCastTo().SetBatteryChargePercentageMaximumAlertThreshold(std::addressof(device), percentage); + R_RETURN(device.GetDriver().SafeCastTo().SetBatteryChargePercentageMaximumAlertThreshold(std::addressof(device), percentage)); } Result SetBatteryVoltageFuelGaugePercentageMinimumAlertThreshold(Session &session, float percentage) { @@ -125,7 +125,7 @@ namespace ams::powctl { auto &device = impl.GetDevice().SafeCastTo(); /* Call into the driver. */ - return device.GetDriver().SafeCastTo().SetBatteryVoltageFuelGaugePercentageMinimumAlertThreshold(std::addressof(device), percentage); + R_RETURN(device.GetDriver().SafeCastTo().SetBatteryVoltageFuelGaugePercentageMinimumAlertThreshold(std::addressof(device), percentage)); } Result SetBatteryVoltageFuelGaugePercentageMaximumAlertThreshold(Session &session, float percentage) { @@ -139,7 +139,7 @@ namespace ams::powctl { auto &device = impl.GetDevice().SafeCastTo(); /* Call into the driver. */ - return device.GetDriver().SafeCastTo().SetBatteryVoltageFuelGaugePercentageMaximumAlertThreshold(std::addressof(device), percentage); + R_RETURN(device.GetDriver().SafeCastTo().SetBatteryVoltageFuelGaugePercentageMaximumAlertThreshold(std::addressof(device), percentage)); } Result SetBatteryFullChargeThreshold(Session &session, float percentage) { @@ -153,7 +153,7 @@ namespace ams::powctl { auto &device = impl.GetDevice().SafeCastTo(); /* Call into the driver. */ - return device.GetDriver().SafeCastTo().SetBatteryFullChargeThreshold(std::addressof(device), percentage); + R_RETURN(device.GetDriver().SafeCastTo().SetBatteryFullChargeThreshold(std::addressof(device), percentage)); } Result GetBatteryAverageCurrent(int *out_ma, Session &session) { @@ -167,7 +167,7 @@ namespace ams::powctl { auto &device = impl.GetDevice().SafeCastTo(); /* Call into the driver. */ - return device.GetDriver().SafeCastTo().GetBatteryAverageCurrent(out_ma, std::addressof(device)); + R_RETURN(device.GetDriver().SafeCastTo().GetBatteryAverageCurrent(out_ma, std::addressof(device))); } Result GetBatteryCurrent(int *out_ma, Session &session) { @@ -181,7 +181,7 @@ namespace ams::powctl { auto &device = impl.GetDevice().SafeCastTo(); /* Call into the driver. */ - return device.GetDriver().SafeCastTo().GetBatteryCurrent(out_ma, std::addressof(device)); + R_RETURN(device.GetDriver().SafeCastTo().GetBatteryCurrent(out_ma, std::addressof(device))); } Result GetBatteryInternalState(void *dst, size_t *out_size, Session &session, size_t dst_size) { @@ -195,7 +195,7 @@ namespace ams::powctl { auto &device = impl.GetDevice().SafeCastTo(); /* Call into the driver. */ - return device.GetDriver().SafeCastTo().GetBatteryInternalState(dst, out_size, std::addressof(device), dst_size); + R_RETURN(device.GetDriver().SafeCastTo().GetBatteryInternalState(dst, out_size, std::addressof(device), dst_size)); } Result SetBatteryInternalState(Session &session, const void *src, size_t src_size) { @@ -209,7 +209,7 @@ namespace ams::powctl { auto &device = impl.GetDevice().SafeCastTo(); /* Call into the driver. */ - return device.GetDriver().SafeCastTo().SetBatteryInternalState(std::addressof(device), src, src_size); + R_RETURN(device.GetDriver().SafeCastTo().SetBatteryInternalState(std::addressof(device), src, src_size)); } Result GetBatteryNeedToRestoreParameters(bool *out, Session &session) { @@ -223,7 +223,7 @@ namespace ams::powctl { auto &device = impl.GetDevice().SafeCastTo(); /* Call into the driver. */ - return device.GetDriver().SafeCastTo().GetBatteryNeedToRestoreParameters(out, std::addressof(device)); + R_RETURN(device.GetDriver().SafeCastTo().GetBatteryNeedToRestoreParameters(out, std::addressof(device))); } Result SetBatteryNeedToRestoreParameters(Session &session, bool en) { @@ -237,7 +237,7 @@ namespace ams::powctl { auto &device = impl.GetDevice().SafeCastTo(); /* Call into the driver. */ - return device.GetDriver().SafeCastTo().SetBatteryNeedToRestoreParameters(std::addressof(device), en); + R_RETURN(device.GetDriver().SafeCastTo().SetBatteryNeedToRestoreParameters(std::addressof(device), en)); } Result IsBatteryI2cShutdownEnabled(bool *out, Session &session) { @@ -251,7 +251,7 @@ namespace ams::powctl { auto &device = impl.GetDevice().SafeCastTo(); /* Call into the driver. */ - return device.GetDriver().SafeCastTo().IsBatteryI2cShutdownEnabled(out, std::addressof(device)); + R_RETURN(device.GetDriver().SafeCastTo().IsBatteryI2cShutdownEnabled(out, std::addressof(device))); } Result SetBatteryI2cShutdownEnabled(Session &session, bool en) { @@ -265,7 +265,7 @@ namespace ams::powctl { auto &device = impl.GetDevice().SafeCastTo(); /* Call into the driver. */ - return device.GetDriver().SafeCastTo().SetBatteryI2cShutdownEnabled(std::addressof(device), en); + R_RETURN(device.GetDriver().SafeCastTo().SetBatteryI2cShutdownEnabled(std::addressof(device), en)); } Result IsBatteryPresent(bool *out, Session &session) { @@ -279,7 +279,7 @@ namespace ams::powctl { auto &device = impl.GetDevice().SafeCastTo(); /* Call into the driver. */ - return device.GetDriver().SafeCastTo().IsBatteryPresent(out, std::addressof(device)); + R_RETURN(device.GetDriver().SafeCastTo().IsBatteryPresent(out, std::addressof(device))); } Result GetBatteryCycles(int *out, Session &session) { @@ -293,7 +293,7 @@ namespace ams::powctl { auto &device = impl.GetDevice().SafeCastTo(); /* Call into the driver. */ - return device.GetDriver().SafeCastTo().GetBatteryCycles(out, std::addressof(device)); + R_RETURN(device.GetDriver().SafeCastTo().GetBatteryCycles(out, std::addressof(device))); } Result SetBatteryCycles(Session &session, int cycles) { @@ -307,7 +307,7 @@ namespace ams::powctl { auto &device = impl.GetDevice().SafeCastTo(); /* Call into the driver. */ - return device.GetDriver().SafeCastTo().SetBatteryCycles(std::addressof(device), cycles); + R_RETURN(device.GetDriver().SafeCastTo().SetBatteryCycles(std::addressof(device), cycles)); } Result GetBatteryAge(float *out_percent, Session &session) { @@ -321,7 +321,7 @@ namespace ams::powctl { auto &device = impl.GetDevice().SafeCastTo(); /* Call into the driver. */ - return device.GetDriver().SafeCastTo().GetBatteryAge(out_percent, std::addressof(device)); + R_RETURN(device.GetDriver().SafeCastTo().GetBatteryAge(out_percent, std::addressof(device))); } Result GetBatteryTemperature(float *out_c, Session &session) { @@ -335,7 +335,7 @@ namespace ams::powctl { auto &device = impl.GetDevice().SafeCastTo(); /* Call into the driver. */ - return device.GetDriver().SafeCastTo().GetBatteryTemperature(out_c, std::addressof(device)); + R_RETURN(device.GetDriver().SafeCastTo().GetBatteryTemperature(out_c, std::addressof(device))); } Result GetBatteryMaximumTemperature(float *out_c, Session &session) { @@ -349,7 +349,7 @@ namespace ams::powctl { auto &device = impl.GetDevice().SafeCastTo(); /* Call into the driver. */ - return device.GetDriver().SafeCastTo().GetBatteryMaximumTemperature(out_c, std::addressof(device)); + R_RETURN(device.GetDriver().SafeCastTo().GetBatteryMaximumTemperature(out_c, std::addressof(device))); } Result SetBatteryTemperatureMinimumAlertThreshold(Session &session, float c) { @@ -363,7 +363,7 @@ namespace ams::powctl { auto &device = impl.GetDevice().SafeCastTo(); /* Call into the driver. */ - return device.GetDriver().SafeCastTo().SetBatteryTemperatureMinimumAlertThreshold(std::addressof(device), c); + R_RETURN(device.GetDriver().SafeCastTo().SetBatteryTemperatureMinimumAlertThreshold(std::addressof(device), c)); } Result SetBatteryTemperatureMaximumAlertThreshold(Session &session, float c) { @@ -377,7 +377,7 @@ namespace ams::powctl { auto &device = impl.GetDevice().SafeCastTo(); /* Call into the driver. */ - return device.GetDriver().SafeCastTo().SetBatteryTemperatureMaximumAlertThreshold(std::addressof(device), c); + R_RETURN(device.GetDriver().SafeCastTo().SetBatteryTemperatureMaximumAlertThreshold(std::addressof(device), c)); } Result GetBatteryVCell(int *out_mv, Session &session) { @@ -391,7 +391,7 @@ namespace ams::powctl { auto &device = impl.GetDevice().SafeCastTo(); /* Call into the driver. */ - return device.GetDriver().SafeCastTo().GetBatteryVCell(out_mv, std::addressof(device)); + R_RETURN(device.GetDriver().SafeCastTo().GetBatteryVCell(out_mv, std::addressof(device))); } Result GetBatteryAverageVCell(int *out_mv, Session &session) { @@ -405,7 +405,7 @@ namespace ams::powctl { auto &device = impl.GetDevice().SafeCastTo(); /* Call into the driver. */ - return device.GetDriver().SafeCastTo().GetBatteryAverageVCell(out_mv, std::addressof(device)); + R_RETURN(device.GetDriver().SafeCastTo().GetBatteryAverageVCell(out_mv, std::addressof(device))); } Result GetBatteryAverageVCellTime(TimeSpan *out, Session &session) { @@ -419,7 +419,7 @@ namespace ams::powctl { auto &device = impl.GetDevice().SafeCastTo(); /* Call into the driver. */ - return device.GetDriver().SafeCastTo().GetBatteryAverageVCellTime(out, std::addressof(device)); + R_RETURN(device.GetDriver().SafeCastTo().GetBatteryAverageVCellTime(out, std::addressof(device))); } Result GetBatteryOpenCircuitVoltage(int *out_mv, Session &session) { @@ -433,7 +433,7 @@ namespace ams::powctl { auto &device = impl.GetDevice().SafeCastTo(); /* Call into the driver. */ - return device.GetDriver().SafeCastTo().GetBatteryOpenCircuitVoltage(out_mv, std::addressof(device)); + R_RETURN(device.GetDriver().SafeCastTo().GetBatteryOpenCircuitVoltage(out_mv, std::addressof(device))); } Result SetBatteryVoltageMinimumAlertThreshold(Session &session, int mv) { @@ -447,7 +447,7 @@ namespace ams::powctl { auto &device = impl.GetDevice().SafeCastTo(); /* Call into the driver. */ - return device.GetDriver().SafeCastTo().SetBatteryVoltageMinimumAlertThreshold(std::addressof(device), mv); + R_RETURN(device.GetDriver().SafeCastTo().SetBatteryVoltageMinimumAlertThreshold(std::addressof(device), mv)); } Result SetBatteryVoltageMaximumAlertThreshold(Session &session, int mv) { @@ -461,7 +461,7 @@ namespace ams::powctl { auto &device = impl.GetDevice().SafeCastTo(); /* Call into the driver. */ - return device.GetDriver().SafeCastTo().SetBatteryVoltageMaximumAlertThreshold(std::addressof(device), mv); + R_RETURN(device.GetDriver().SafeCastTo().SetBatteryVoltageMaximumAlertThreshold(std::addressof(device), mv)); } } \ No newline at end of file diff --git a/libraries/libstratosphere/source/powctl/powctl_charger_api.cpp b/libraries/libstratosphere/source/powctl/powctl_charger_api.cpp index 9dac2b3d6..51f3b6409 100644 --- a/libraries/libstratosphere/source/powctl/powctl_charger_api.cpp +++ b/libraries/libstratosphere/source/powctl/powctl_charger_api.cpp @@ -41,7 +41,7 @@ namespace ams::powctl { auto &device = impl.GetDevice().SafeCastTo(); /* Call into the driver. */ - return device.GetDriver().SafeCastTo().GetChargerChargeCurrentState(out, std::addressof(device)); + R_RETURN(device.GetDriver().SafeCastTo().GetChargerChargeCurrentState(out, std::addressof(device))); } Result SetChargerChargeCurrentState(Session &session, ChargeCurrentState state) { @@ -55,7 +55,7 @@ namespace ams::powctl { auto &device = impl.GetDevice().SafeCastTo(); /* Call into the driver. */ - return device.GetDriver().SafeCastTo().SetChargerChargeCurrentState(std::addressof(device), state); + R_RETURN(device.GetDriver().SafeCastTo().SetChargerChargeCurrentState(std::addressof(device), state)); } Result GetChargerFastChargeCurrentLimit(int *out_ma, Session &session) { @@ -69,7 +69,7 @@ namespace ams::powctl { auto &device = impl.GetDevice().SafeCastTo(); /* Call into the driver. */ - return device.GetDriver().SafeCastTo().GetChargerFastChargeCurrentLimit(out_ma, std::addressof(device)); + R_RETURN(device.GetDriver().SafeCastTo().GetChargerFastChargeCurrentLimit(out_ma, std::addressof(device))); } Result SetChargerFastChargeCurrentLimit(Session &session, int ma) { @@ -83,7 +83,7 @@ namespace ams::powctl { auto &device = impl.GetDevice().SafeCastTo(); /* Call into the driver. */ - return device.GetDriver().SafeCastTo().SetChargerFastChargeCurrentLimit(std::addressof(device), ma); + R_RETURN(device.GetDriver().SafeCastTo().SetChargerFastChargeCurrentLimit(std::addressof(device), ma)); } Result GetChargerChargeVoltageLimit(int *out_mv, Session &session) { @@ -97,7 +97,7 @@ namespace ams::powctl { auto &device = impl.GetDevice().SafeCastTo(); /* Call into the driver. */ - return device.GetDriver().SafeCastTo().GetChargerChargeVoltageLimit(out_mv, std::addressof(device)); + R_RETURN(device.GetDriver().SafeCastTo().GetChargerChargeVoltageLimit(out_mv, std::addressof(device))); } Result SetChargerChargeVoltageLimit(Session &session, int mv) { @@ -111,7 +111,7 @@ namespace ams::powctl { auto &device = impl.GetDevice().SafeCastTo(); /* Call into the driver. */ - return device.GetDriver().SafeCastTo().SetChargerChargeVoltageLimit(std::addressof(device), mv); + R_RETURN(device.GetDriver().SafeCastTo().SetChargerChargeVoltageLimit(std::addressof(device), mv)); } Result SetChargerChargerConfiguration(Session &session, ChargerConfiguration cfg) { @@ -125,7 +125,7 @@ namespace ams::powctl { auto &device = impl.GetDevice().SafeCastTo(); /* Call into the driver. */ - return device.GetDriver().SafeCastTo().SetChargerChargerConfiguration(std::addressof(device), cfg); + R_RETURN(device.GetDriver().SafeCastTo().SetChargerChargerConfiguration(std::addressof(device), cfg)); } Result IsChargerHiZEnabled(bool *out, Session &session) { @@ -139,7 +139,7 @@ namespace ams::powctl { auto &device = impl.GetDevice().SafeCastTo(); /* Call into the driver. */ - return device.GetDriver().SafeCastTo().IsChargerHiZEnabled(out, std::addressof(device)); + R_RETURN(device.GetDriver().SafeCastTo().IsChargerHiZEnabled(out, std::addressof(device))); } Result SetChargerHiZEnabled(Session &session, bool en) { @@ -153,7 +153,7 @@ namespace ams::powctl { auto &device = impl.GetDevice().SafeCastTo(); /* Call into the driver. */ - return device.GetDriver().SafeCastTo().SetChargerHiZEnabled(std::addressof(device), en); + R_RETURN(device.GetDriver().SafeCastTo().SetChargerHiZEnabled(std::addressof(device), en)); } Result GetChargerInputCurrentLimit(int *out_ma, Session &session) { @@ -167,7 +167,7 @@ namespace ams::powctl { auto &device = impl.GetDevice().SafeCastTo(); /* Call into the driver. */ - return device.GetDriver().SafeCastTo().GetChargerInputCurrentLimit(out_ma, std::addressof(device)); + R_RETURN(device.GetDriver().SafeCastTo().GetChargerInputCurrentLimit(out_ma, std::addressof(device))); } Result SetChargerInputCurrentLimit(Session &session, int ma) { @@ -181,7 +181,7 @@ namespace ams::powctl { auto &device = impl.GetDevice().SafeCastTo(); /* Call into the driver. */ - return device.GetDriver().SafeCastTo().SetChargerInputCurrentLimit(std::addressof(device), ma); + R_RETURN(device.GetDriver().SafeCastTo().SetChargerInputCurrentLimit(std::addressof(device), ma)); } Result SetChargerInputVoltageLimit(Session &session, int mv) { @@ -195,7 +195,7 @@ namespace ams::powctl { auto &device = impl.GetDevice().SafeCastTo(); /* Call into the driver. */ - return device.GetDriver().SafeCastTo().SetChargerInputVoltageLimit(std::addressof(device), mv); + R_RETURN(device.GetDriver().SafeCastTo().SetChargerInputVoltageLimit(std::addressof(device), mv)); } Result SetChargerBoostModeCurrentLimit(Session &session, int ma) { @@ -209,7 +209,7 @@ namespace ams::powctl { auto &device = impl.GetDevice().SafeCastTo(); /* Call into the driver. */ - return device.GetDriver().SafeCastTo().SetChargerBoostModeCurrentLimit(std::addressof(device), ma); + R_RETURN(device.GetDriver().SafeCastTo().SetChargerBoostModeCurrentLimit(std::addressof(device), ma)); } Result GetChargerChargerStatus(ChargerStatus *out, Session &session) { @@ -223,7 +223,7 @@ namespace ams::powctl { auto &device = impl.GetDevice().SafeCastTo(); /* Call into the driver. */ - return device.GetDriver().SafeCastTo().GetChargerChargerStatus(out, std::addressof(device)); + R_RETURN(device.GetDriver().SafeCastTo().GetChargerChargerStatus(out, std::addressof(device))); } Result IsChargerWatchdogTimerEnabled(bool *out, Session &session) { @@ -237,7 +237,7 @@ namespace ams::powctl { auto &device = impl.GetDevice().SafeCastTo(); /* Call into the driver. */ - return device.GetDriver().SafeCastTo().IsChargerWatchdogTimerEnabled(out, std::addressof(device)); + R_RETURN(device.GetDriver().SafeCastTo().IsChargerWatchdogTimerEnabled(out, std::addressof(device))); } Result SetChargerWatchdogTimerEnabled(Session &session, bool en) { @@ -251,7 +251,7 @@ namespace ams::powctl { auto &device = impl.GetDevice().SafeCastTo(); /* Call into the driver. */ - return device.GetDriver().SafeCastTo().SetChargerWatchdogTimerEnabled(std::addressof(device), en); + R_RETURN(device.GetDriver().SafeCastTo().SetChargerWatchdogTimerEnabled(std::addressof(device), en)); } Result SetChargerWatchdogTimerTimeout(Session &session, TimeSpan timeout) { @@ -265,7 +265,7 @@ namespace ams::powctl { auto &device = impl.GetDevice().SafeCastTo(); /* Call into the driver. */ - return device.GetDriver().SafeCastTo().SetChargerWatchdogTimerTimeout(std::addressof(device), timeout); + R_RETURN(device.GetDriver().SafeCastTo().SetChargerWatchdogTimerTimeout(std::addressof(device), timeout)); } Result ResetChargerWatchdogTimer(Session &session); @@ -281,7 +281,7 @@ namespace ams::powctl { auto &device = impl.GetDevice().SafeCastTo(); /* Call into the driver. */ - return device.GetDriver().SafeCastTo().GetChargerBatteryCompensation(out_mo, std::addressof(device)); + R_RETURN(device.GetDriver().SafeCastTo().GetChargerBatteryCompensation(out_mo, std::addressof(device))); } Result SetChargerBatteryCompensation(Session &session, int mo) { @@ -295,7 +295,7 @@ namespace ams::powctl { auto &device = impl.GetDevice().SafeCastTo(); /* Call into the driver. */ - return device.GetDriver().SafeCastTo().SetChargerBatteryCompensation(std::addressof(device), mo); + R_RETURN(device.GetDriver().SafeCastTo().SetChargerBatteryCompensation(std::addressof(device), mo)); } Result GetChargerVoltageClamp(int *out_mv, Session &session) { @@ -309,7 +309,7 @@ namespace ams::powctl { auto &device = impl.GetDevice().SafeCastTo(); /* Call into the driver. */ - return device.GetDriver().SafeCastTo().GetChargerVoltageClamp(out_mv, std::addressof(device)); + R_RETURN(device.GetDriver().SafeCastTo().GetChargerVoltageClamp(out_mv, std::addressof(device))); } Result SetChargerVoltageClamp(Session &session, int mv) { @@ -323,7 +323,7 @@ namespace ams::powctl { auto &device = impl.GetDevice().SafeCastTo(); /* Call into the driver. */ - return device.GetDriver().SafeCastTo().SetChargerVoltageClamp(std::addressof(device), mv); + R_RETURN(device.GetDriver().SafeCastTo().SetChargerVoltageClamp(std::addressof(device), mv)); } } \ No newline at end of file diff --git a/libraries/libstratosphere/source/psc/psc_pm_module.os.horizon.cpp b/libraries/libstratosphere/source/psc/psc_pm_module.os.horizon.cpp index 363693d12..356424438 100644 --- a/libraries/libstratosphere/source/psc/psc_pm_module.os.horizon.cpp +++ b/libraries/libstratosphere/source/psc/psc_pm_module.os.horizon.cpp @@ -69,7 +69,7 @@ namespace ams::psc { Result PmModule::GetRequest(PmState *out_state, PmFlagSet *out_flags) { R_UNLESS(m_initialized, psc::ResultNotInitialized()); - return m_intf->GetRequest(out_state, out_flags); + R_RETURN(m_intf->GetRequest(out_state, out_flags)); } Result PmModule::Acknowledge(PmState state, Result res) { @@ -77,9 +77,9 @@ namespace ams::psc { R_UNLESS(m_initialized, psc::ResultNotInitialized()); if (hos::GetVersion() >= hos::Version_5_1_0) { - return m_intf->AcknowledgeEx(state); + R_RETURN(m_intf->AcknowledgeEx(state)); } else { - return m_intf->Acknowledge(); + R_RETURN(m_intf->Acknowledge()); } } diff --git a/libraries/libstratosphere/source/psc/psc_remote_pm_module.hpp b/libraries/libstratosphere/source/psc/psc_remote_pm_module.hpp index e8a205639..48d9d7f1b 100644 --- a/libraries/libstratosphere/source/psc/psc_remote_pm_module.hpp +++ b/libraries/libstratosphere/source/psc/psc_remote_pm_module.hpp @@ -38,21 +38,21 @@ namespace ams::psc { Result GetRequest(ams::sf::Out out_state, ams::sf::Out out_flags) { static_assert(sizeof(PmState) == sizeof(::PscPmState)); static_assert(sizeof(PmFlagSet) == sizeof(u32)); - return ::pscPmModuleGetRequest(std::addressof(m_module), reinterpret_cast<::PscPmState *>(out_state.GetPointer()), reinterpret_cast(out_flags.GetPointer())); + R_RETURN(::pscPmModuleGetRequest(std::addressof(m_module), reinterpret_cast<::PscPmState *>(out_state.GetPointer()), reinterpret_cast(out_flags.GetPointer()))); } Result Acknowledge() { /* NOTE: libnx does not separate acknowledge/acknowledgeEx. */ - return ::pscPmModuleAcknowledge(std::addressof(m_module), static_cast<::PscPmState>(0)); + R_RETURN(::pscPmModuleAcknowledge(std::addressof(m_module), static_cast<::PscPmState>(0))); } Result Finalize() { - return ::pscPmModuleFinalize(std::addressof(m_module)); + R_RETURN(::pscPmModuleFinalize(std::addressof(m_module))); } Result AcknowledgeEx(PmState state) { static_assert(sizeof(state) == sizeof(::PscPmState)); - return ::pscPmModuleAcknowledge(std::addressof(m_module), static_cast<::PscPmState>(state)); + R_RETURN(::pscPmModuleAcknowledge(std::addressof(m_module), static_cast<::PscPmState>(state))); } }; static_assert(psc::sf::IsIPmModule); diff --git a/libraries/libstratosphere/source/pwm/driver/board/nintendo/nx/impl/pwm_pwm_driver_impl.cpp b/libraries/libstratosphere/source/pwm/driver/board/nintendo/nx/impl/pwm_pwm_driver_impl.cpp index e3c100914..e5cd5c820 100644 --- a/libraries/libstratosphere/source/pwm/driver/board/nintendo/nx/impl/pwm_pwm_driver_impl.cpp +++ b/libraries/libstratosphere/source/pwm/driver/board/nintendo/nx/impl/pwm_pwm_driver_impl.cpp @@ -170,7 +170,7 @@ namespace ams::pwm::driver::board::nintendo::nx::impl { const int duty = static_cast(((scale * 256.0) / 100.0) + 0.5); /* Set the duty. */ - return this->SetDuty(device, duty); + R_RETURN(this->SetDuty(device, duty)); } Result PwmDriverImpl::GetScale(double *out, IPwmDevice *device) { @@ -229,7 +229,7 @@ namespace ams::pwm::driver::board::nintendo::nx::impl { }); /* Disable clock to pwm. */ - return pcv::SetClockEnabled(pcv::Module_Pwm, false); + R_RETURN(pcv::SetClockEnabled(pcv::Module_Pwm, false)); } void PwmDriverImpl::Resume() { diff --git a/libraries/libstratosphere/source/pwm/driver/impl/pwm_channel_session_impl.cpp b/libraries/libstratosphere/source/pwm/driver/impl/pwm_channel_session_impl.cpp index cb8dd8306..82dcee595 100644 --- a/libraries/libstratosphere/source/pwm/driver/impl/pwm_channel_session_impl.cpp +++ b/libraries/libstratosphere/source/pwm/driver/impl/pwm_channel_session_impl.cpp @@ -62,7 +62,7 @@ namespace ams::pwm::driver::impl { IPwmDevice &device = this->GetDevice().SafeCastTo(); /* Invoke the driver handler. */ - return device.GetDriver().SafeCastTo().SetPeriod(std::addressof(device), period); + R_RETURN(device.GetDriver().SafeCastTo().SetPeriod(std::addressof(device), period)); } Result ChannelSessionImpl::GetPeriod(TimeSpan *out) { @@ -70,7 +70,7 @@ namespace ams::pwm::driver::impl { IPwmDevice &device = this->GetDevice().SafeCastTo(); /* Invoke the driver handler. */ - return device.GetDriver().SafeCastTo().GetPeriod(out, std::addressof(device)); + R_RETURN(device.GetDriver().SafeCastTo().GetPeriod(out, std::addressof(device))); } Result ChannelSessionImpl::SetDuty(int duty) { @@ -78,7 +78,7 @@ namespace ams::pwm::driver::impl { IPwmDevice &device = this->GetDevice().SafeCastTo(); /* Invoke the driver handler. */ - return device.GetDriver().SafeCastTo().SetDuty(std::addressof(device), duty); + R_RETURN(device.GetDriver().SafeCastTo().SetDuty(std::addressof(device), duty)); } Result ChannelSessionImpl::GetDuty(int *out) { @@ -86,7 +86,7 @@ namespace ams::pwm::driver::impl { IPwmDevice &device = this->GetDevice().SafeCastTo(); /* Invoke the driver handler. */ - return device.GetDriver().SafeCastTo().GetDuty(out, std::addressof(device)); + R_RETURN(device.GetDriver().SafeCastTo().GetDuty(out, std::addressof(device))); } Result ChannelSessionImpl::SetEnabled(bool en) { @@ -94,7 +94,7 @@ namespace ams::pwm::driver::impl { IPwmDevice &device = this->GetDevice().SafeCastTo(); /* Invoke the driver handler. */ - return device.GetDriver().SafeCastTo().SetEnabled(std::addressof(device), en); + R_RETURN(device.GetDriver().SafeCastTo().SetEnabled(std::addressof(device), en)); } Result ChannelSessionImpl::GetEnabled(bool *out) { @@ -102,7 +102,7 @@ namespace ams::pwm::driver::impl { IPwmDevice &device = this->GetDevice().SafeCastTo(); /* Invoke the driver handler. */ - return device.GetDriver().SafeCastTo().GetEnabled(out, std::addressof(device)); + R_RETURN(device.GetDriver().SafeCastTo().GetEnabled(out, std::addressof(device))); } Result ChannelSessionImpl::SetScale(double scale) { @@ -110,7 +110,7 @@ namespace ams::pwm::driver::impl { IPwmDevice &device = this->GetDevice().SafeCastTo(); /* Invoke the driver handler. */ - return device.GetDriver().SafeCastTo().SetScale(std::addressof(device), scale); + R_RETURN(device.GetDriver().SafeCastTo().SetScale(std::addressof(device), scale)); } Result ChannelSessionImpl::GetScale(double *out) { @@ -118,7 +118,7 @@ namespace ams::pwm::driver::impl { IPwmDevice &device = this->GetDevice().SafeCastTo(); /* Invoke the driver handler. */ - return device.GetDriver().SafeCastTo().GetScale(out, std::addressof(device)); + R_RETURN(device.GetDriver().SafeCastTo().GetScale(out, std::addressof(device))); } } diff --git a/libraries/libstratosphere/source/pwm/driver/pwm_driver_channel_api.cpp b/libraries/libstratosphere/source/pwm/driver/pwm_driver_channel_api.cpp index 85d64a3e9..b0e900a9b 100644 --- a/libraries/libstratosphere/source/pwm/driver/pwm_driver_channel_api.cpp +++ b/libraries/libstratosphere/source/pwm/driver/pwm_driver_channel_api.cpp @@ -25,14 +25,10 @@ namespace ams::pwm::driver { Result OpenSessionImpl(ChannelSession *out, IPwmDevice *device) { /* Construct the session. */ auto *session = std::construct_at(std::addressof(impl::GetChannelSessionImpl(*out))); - auto session_guard = SCOPE_GUARD { std::destroy_at(session); }; + ON_RESULT_FAILURE { std::destroy_at(session); }; /* Open the session. */ - R_TRY(session->Open(device, ddsf::AccessMode_ReadWrite)); - - /* We succeeded. */ - session_guard.Cancel(); - R_SUCCEED(); + R_RETURN(session->Open(device, ddsf::AccessMode_ReadWrite)); } } diff --git a/libraries/libstratosphere/source/pwm/driver/pwm_driver_service_api.cpp b/libraries/libstratosphere/source/pwm/driver/pwm_driver_service_api.cpp index f82363387..d86e2c6e6 100644 --- a/libraries/libstratosphere/source/pwm/driver/pwm_driver_service_api.cpp +++ b/libraries/libstratosphere/source/pwm/driver/pwm_driver_service_api.cpp @@ -28,7 +28,7 @@ namespace ams::pwm::driver { } Result RegisterDeviceCode(DeviceCode device_code, IPwmDevice *device) { - return impl::RegisterDeviceCode(device_code, device); + R_RETURN(impl::RegisterDeviceCode(device_code, device)); } bool UnregisterDeviceCode(DeviceCode device_code) { diff --git a/libraries/libstratosphere/source/pwm/server/pwm_server_manager_impl.cpp b/libraries/libstratosphere/source/pwm/server/pwm_server_manager_impl.cpp index 95562daa9..4eb9fd51c 100644 --- a/libraries/libstratosphere/source/pwm/server/pwm_server_manager_impl.cpp +++ b/libraries/libstratosphere/source/pwm/server/pwm_server_manager_impl.cpp @@ -34,7 +34,7 @@ namespace ams::pwm::server { } Result ManagerImpl::OpenSession(ams::sf::Out> out, pwm::ChannelName channel_name) { - return this->OpenSession2(out, ConvertToDeviceCode(channel_name)); + R_RETURN(this->OpenSession2(out, ConvertToDeviceCode(channel_name))); } Result ManagerImpl::OpenSession2(ams::sf::Out> out, DeviceCode device_code) { diff --git a/libraries/libstratosphere/source/scs/scs_shell.cpp b/libraries/libstratosphere/source/scs/scs_shell.cpp index 3ebf317b3..841b36e41 100644 --- a/libraries/libstratosphere/source/scs/scs_shell.cpp +++ b/libraries/libstratosphere/source/scs/scs_shell.cpp @@ -369,7 +369,7 @@ namespace ams::scs { std::scoped_lock lk(g_manager_mutex); /* Register the socket. */ - return g_socket_info_manager.Register(socket, id); + R_RETURN(g_socket_info_manager.Register(socket, id)); } void UnregisterSocket(s32 socket) { diff --git a/libraries/libstratosphere/source/settings/impl/settings_configuration_id_impl.cpp b/libraries/libstratosphere/source/settings/impl/settings_configuration_id_impl.cpp index b2f166c6b..bd21de01e 100644 --- a/libraries/libstratosphere/source/settings/impl/settings_configuration_id_impl.cpp +++ b/libraries/libstratosphere/source/settings/impl/settings_configuration_id_impl.cpp @@ -21,7 +21,7 @@ namespace ams::settings::impl { Result GetConfigurationId1(settings::factory::ConfigurationId1 *out) { #if defined(ATMOSPHERE_OS_HORIZON) static_assert(sizeof(*out) == sizeof(::SetCalConfigurationId1)); - return ::setcalGetConfigurationId1(reinterpret_cast<::SetCalConfigurationId1 *>(out)); + R_RETURN(::setcalGetConfigurationId1(reinterpret_cast<::SetCalConfigurationId1 *>(out))); #else AMS_UNUSED(out); AMS_ABORT("TODO"); diff --git a/libraries/libstratosphere/source/settings/impl/settings_error_report_impl.cpp b/libraries/libstratosphere/source/settings/impl/settings_error_report_impl.cpp index 0d44d4db3..81f56bdbb 100644 --- a/libraries/libstratosphere/source/settings/impl/settings_error_report_impl.cpp +++ b/libraries/libstratosphere/source/settings/impl/settings_error_report_impl.cpp @@ -21,7 +21,7 @@ namespace ams::settings::impl { Result GetErrorReportSharePermission(s32 *out) { #if defined(ATMOSPHERE_OS_HORIZON) static_assert(sizeof(*out) == sizeof(::SetSysErrorReportSharePermission)); - return ::setsysGetErrorReportSharePermission(reinterpret_cast<::SetSysErrorReportSharePermission *>(out)); + R_RETURN(::setsysGetErrorReportSharePermission(reinterpret_cast<::SetSysErrorReportSharePermission *>(out))); #else AMS_UNUSED(out); AMS_ABORT("TODO"); diff --git a/libraries/libstratosphere/source/settings/impl/settings_firmware_version_impl.cpp b/libraries/libstratosphere/source/settings/impl/settings_firmware_version_impl.cpp index 938c2a12e..b0a12062d 100644 --- a/libraries/libstratosphere/source/settings/impl/settings_firmware_version_impl.cpp +++ b/libraries/libstratosphere/source/settings/impl/settings_firmware_version_impl.cpp @@ -21,7 +21,7 @@ namespace ams::settings::impl { Result GetFirmwareVersion(settings::system::FirmwareVersion *out) { #if defined(ATMOSPHERE_OS_HORIZON) static_assert(sizeof(*out) == sizeof(::SetSysFirmwareVersion)); - return ::setsysGetFirmwareVersion(reinterpret_cast<::SetSysFirmwareVersion *>(out)); + R_RETURN(::setsysGetFirmwareVersion(reinterpret_cast<::SetSysFirmwareVersion *>(out))); #else AMS_UNUSED(out); AMS_ABORT("TODO"); diff --git a/libraries/libstratosphere/source/settings/impl/settings_key_value_store.cpp b/libraries/libstratosphere/source/settings/impl/settings_key_value_store.cpp index 97b4728c2..d15e42c19 100644 --- a/libraries/libstratosphere/source/settings/impl/settings_key_value_store.cpp +++ b/libraries/libstratosphere/source/settings/impl/settings_key_value_store.cpp @@ -300,7 +300,7 @@ namespace ams::settings::impl { AMS_ASSERT(out != nullptr); /* Get the map. */ - return GetKeyValueStoreMap(out, false); + R_RETURN(GetKeyValueStoreMap(out, false)); } Result GetKeyValueStoreMap(Map **out, bool force_load) { @@ -338,7 +338,7 @@ namespace ams::settings::impl { AMS_ASSERT(out != nullptr); /* Get the map. */ - return GetKeyValueStoreMap(out, true); + R_RETURN(GetKeyValueStoreMap(out, true)); } Result GetMapValueOfKeyValueStoreItemForDebug(MapValue *out, const KeyValueStoreItemForDebug &item) { @@ -536,7 +536,7 @@ namespace ams::settings::impl { AMS_ASSERT(data != nullptr); /* Load the key value store map. */ - return LoadKeyValueStoreMapDefault(out, *data); + R_RETURN(LoadKeyValueStoreMapDefault(out, *data)); } template @@ -708,7 +708,7 @@ namespace ams::settings::impl { } /* Load the value. */ - return load(*out, key, type, value_buffer, value_size); + R_RETURN(load(*out, key, type, value_buffer, value_size)); } Result LoadKeyValueStoreMapForDebug(Map *out, SystemSaveData *system_save_data, SystemSaveData *fwdbg_system_save_data, SystemSaveData *pfcfg_system_save_data) { @@ -885,7 +885,7 @@ namespace ams::settings::impl { AMS_ASSERT(system_save_data != nullptr); /* Save the current values of the key value store map. */ - return SaveKeyValueStoreMapCurrent(*system_save_data, map); + R_RETURN(SaveKeyValueStoreMapCurrent(*system_save_data, map)); } template @@ -933,13 +933,13 @@ namespace ams::settings::impl { } /* Commit the save data. */ - return data.Commit(false); + R_RETURN(data.Commit(false)); } template Result SaveKeyValueStoreMapCurrent(T &data, const Map &map) { /* Save the current values in the map to the data. */ - return SaveKeyValueStoreMap(data, map, [](u8 *out_type, const void **out_value_buffer, u32 *out_value_size, const MapValue &map_value) -> bool { + R_RETURN(SaveKeyValueStoreMap(data, map, [](u8 *out_type, const void **out_value_buffer, u32 *out_value_size, const MapValue &map_value) -> bool { /* Check preconditions. */ AMS_ASSERT(out_type != nullptr); AMS_ASSERT(out_value_buffer != nullptr); @@ -955,13 +955,13 @@ namespace ams::settings::impl { *out_value_buffer = map_value.current_value; *out_value_size = map_value.current_value_size; return true; - }); + })); } template Result SaveKeyValueStoreMapDefault(T &data, const Map &map) { /* Save the default values in the map to the data. */ - return SaveKeyValueStoreMap(data, map, [](u8 *out_type, const void **out_value_buffer, u32 *out_value_size, const MapValue &map_value) -> bool { + R_RETURN(SaveKeyValueStoreMap(data, map, [](u8 *out_type, const void **out_value_buffer, u32 *out_value_size, const MapValue &map_value) -> bool { /* Check preconditions. */ AMS_ASSERT(out_type != nullptr); AMS_ASSERT(out_value_buffer != nullptr); @@ -972,11 +972,11 @@ namespace ams::settings::impl { *out_value_buffer = map_value.default_value; *out_value_size = map_value.default_value_size; return true; - }); + })); } Result SaveKeyValueStoreMapDefaultForDebug(SystemSaveData &data, const Map &map) { - return SaveKeyValueStoreMapDefault(data, map); + R_RETURN(SaveKeyValueStoreMapDefault(data, map)); } template @@ -1161,16 +1161,17 @@ namespace ams::settings::impl { map_value.current_value_size = map_value.default_value_size; map_value.current_value = map_value.default_value; - /* Attempt to save the key value store map. */ - if (const auto result = SaveKeyValueStoreMap(*map); R_FAILED(result)) { + /* If we fail, revert the map. */ + ON_RESULT_FAILURE { /* Revert to the previous value. */ map_value.current_value_size = prev_value_size; map_value.current_value = prev_value; - /* Attempt to save the map again. Nintendo does not check the result of this. */ SaveKeyValueStoreMap(*map); - return result; - } + }; + + /* Attempt to save the key value store map. */ + R_TRY(SaveKeyValueStoreMap(*map)); /* If present, free the previous value. */ if (prev_value != nullptr && prev_value != map_value.default_value) { @@ -1222,31 +1223,27 @@ namespace ams::settings::impl { std::memcpy(value_buffer, buffer, value_size); } + /* When we're done, free the unused value buffer. */ + ON_SCOPE_EXIT { + if (value_buffer != nullptr && value_buffer != map_value.default_value) { + FreeToHeap(value_buffer, value_size); + } + }; + /* Swap the current value with the new value. */ std::swap(map_value.current_value_size, value_size); std::swap(map_value.current_value, value_buffer); - /* Attempt to save the key value store map. */ - const auto result = SaveKeyValueStoreMap(*map); - - /* If we failed, revert to the previous value. */ - if (R_FAILED(result)) { + /* If we fail, revert. */ + ON_RESULT_FAILURE { std::swap(map_value.current_value_size, value_size); std::swap(map_value.current_value, value_buffer); - } - /* Free the now unused value. */ - if (value_buffer != nullptr && value_buffer != map_value.default_value) { - FreeToHeap(value_buffer, value_size); - } - - /* If we failed, attempt to save the map again. Note that Nintendo does not check the result of this. */ - if (R_FAILED(result)) { SaveKeyValueStoreMap(*map); - return result; - } + }; - R_SUCCEED(); + /* Attempt to save the key value store map. */ + R_RETURN(SaveKeyValueStoreMap(*map)); } Result AddKeyValueStoreItemForDebug(const KeyValueStoreItemForDebug * const items, size_t items_count) { @@ -1476,7 +1473,7 @@ namespace ams::settings::impl { std::scoped_lock lk(g_key_value_store_mutex); /* Read the firmware debug system data. */ - return ReadSystemDataFirmwareDebug(out_count, out_buffer, out_buffer_size); + R_RETURN(ReadSystemDataFirmwareDebug(out_count, out_buffer, out_buffer_size)); } Result ReadKeyValueStorePlatformConfiguration(u64 *out_count, char * const out_buffer, size_t out_buffer_size) { @@ -1488,7 +1485,7 @@ namespace ams::settings::impl { std::scoped_lock lk(g_key_value_store_mutex); /* Read the platform configuration system data. */ - return ReadSystemDataPlatformConfiguration(out_count, out_buffer, out_buffer_size); + R_RETURN(ReadSystemDataPlatformConfiguration(out_count, out_buffer, out_buffer_size)); } Result ReadKeyValueStoreSaveData(u64 *out_count, char * const out_buffer, size_t out_buffer_size) { @@ -1500,7 +1497,7 @@ namespace ams::settings::impl { std::scoped_lock lk(g_key_value_store_mutex); /* Read the system save data. */ - return ReadSystemSaveData(out_count, out_buffer, out_buffer_size); + R_RETURN(ReadSystemSaveData(out_count, out_buffer, out_buffer_size)); } Result ReloadKeyValueStoreForDebug(SystemSaveData *system_save_data, SystemSaveData *fwdbg_system_data, SystemSaveData *pfcfg_system_data) { @@ -1518,7 +1515,7 @@ namespace ams::settings::impl { AMS_ASSERT(map != nullptr); /* Load the key value store map. */ - return LoadKeyValueStoreMapForDebug(map, system_save_data, fwdbg_system_data, pfcfg_system_data); + R_RETURN(LoadKeyValueStoreMapForDebug(map, system_save_data, fwdbg_system_data, pfcfg_system_data)); } Result ReloadKeyValueStoreForDebug() { @@ -1531,7 +1528,7 @@ namespace ams::settings::impl { AMS_ASSERT(map != nullptr); /* Load the key value store map. */ - return LoadKeyValueStoreMap(map); + R_RETURN(LoadKeyValueStoreMap(map)); } Result ResetKeyValueStoreSaveData() { @@ -1566,7 +1563,7 @@ namespace ams::settings::impl { } /* Save the key value store map. */ - return SaveKeyValueStoreMap(*map); + R_RETURN(SaveKeyValueStoreMap(*map)); } Result SaveKeyValueStoreAllForDebug(SystemSaveData *data) { @@ -1585,7 +1582,7 @@ namespace ams::settings::impl { R_TRY(SaveKeyValueStoreMapDefaultForDebug(*data, *map)); /* Save the key value store map. */ - return SaveKeyValueStoreMap(*map); + R_RETURN(SaveKeyValueStoreMap(*map)); } } diff --git a/libraries/libstratosphere/source/settings/impl/settings_platform_region_impl.cpp b/libraries/libstratosphere/source/settings/impl/settings_platform_region_impl.cpp index dd5e98e66..f359decca 100644 --- a/libraries/libstratosphere/source/settings/impl/settings_platform_region_impl.cpp +++ b/libraries/libstratosphere/source/settings/impl/settings_platform_region_impl.cpp @@ -21,7 +21,7 @@ namespace ams::settings::impl { Result GetPlatformRegion(s32 *out) { #if defined(ATMOSPHERE_OS_HORIZON) static_assert(sizeof(*out) == sizeof(::SetSysPlatformRegion)); - return ::setsysGetPlatformRegion(reinterpret_cast<::SetSysPlatformRegion *>(out)); + R_RETURN(::setsysGetPlatformRegion(reinterpret_cast<::SetSysPlatformRegion *>(out))); #else AMS_UNUSED(out); AMS_ABORT("TODO"); diff --git a/libraries/libstratosphere/source/settings/impl/settings_product_model_impl.cpp b/libraries/libstratosphere/source/settings/impl/settings_product_model_impl.cpp index dd60dac06..ed56dd8bb 100644 --- a/libraries/libstratosphere/source/settings/impl/settings_product_model_impl.cpp +++ b/libraries/libstratosphere/source/settings/impl/settings_product_model_impl.cpp @@ -21,7 +21,7 @@ namespace ams::settings::impl { Result GetProductModel(s32 *out) { #if defined(ATMOSPHERE_OS_HORIZON) static_assert(sizeof(*out) == sizeof(::SetSysProductModel)); - return ::setsysGetProductModel(reinterpret_cast<::SetSysProductModel *>(out)); + R_RETURN(::setsysGetProductModel(reinterpret_cast<::SetSysProductModel *>(out))); #else AMS_UNUSED(out); AMS_ABORT("TODO"); diff --git a/libraries/libstratosphere/source/settings/impl/settings_region_impl.cpp b/libraries/libstratosphere/source/settings/impl/settings_region_impl.cpp index 1347b607e..180536107 100644 --- a/libraries/libstratosphere/source/settings/impl/settings_region_impl.cpp +++ b/libraries/libstratosphere/source/settings/impl/settings_region_impl.cpp @@ -21,7 +21,7 @@ namespace ams::settings::impl { Result GetRegionCode(s32 *out) { #if defined(ATMOSPHERE_OS_HORIZON) static_assert(sizeof(*out) == sizeof(::SetRegion)); - return ::setGetRegionCode(reinterpret_cast<::SetRegion *>(out)); + R_RETURN(::setGetRegionCode(reinterpret_cast<::SetRegion *>(out))); #else AMS_UNUSED(out); AMS_ABORT("TODO"); diff --git a/libraries/libstratosphere/source/settings/impl/settings_serial_number_impl.cpp b/libraries/libstratosphere/source/settings/impl/settings_serial_number_impl.cpp index b048f407f..66ceba15b 100644 --- a/libraries/libstratosphere/source/settings/impl/settings_serial_number_impl.cpp +++ b/libraries/libstratosphere/source/settings/impl/settings_serial_number_impl.cpp @@ -21,7 +21,7 @@ namespace ams::settings::impl { Result GetSerialNumber(settings::factory::SerialNumber *out) { #if defined(ATMOSPHERE_OS_HORIZON) static_assert(sizeof(*out) == sizeof(::SetCalSerialNumber)); - return ::setcalGetSerialNumber(reinterpret_cast<::SetCalSerialNumber *>(out)); + R_RETURN(::setcalGetSerialNumber(reinterpret_cast<::SetCalSerialNumber *>(out))); #else AMS_UNUSED(out); AMS_ABORT("TODO"); @@ -31,7 +31,7 @@ namespace ams::settings::impl { Result GetSerialNumber(settings::system::SerialNumber *out) { #if defined(ATMOSPHERE_OS_HORIZON) static_assert(sizeof(*out) == sizeof(::SetSysSerialNumber)); - return ::setsysGetSerialNumber(reinterpret_cast<::SetSysSerialNumber *>(out)); + R_RETURN(::setsysGetSerialNumber(reinterpret_cast<::SetSysSerialNumber *>(out))); #else AMS_UNUSED(out); AMS_ABORT("TODO"); diff --git a/libraries/libstratosphere/source/settings/impl/settings_system_data.cpp b/libraries/libstratosphere/source/settings/impl/settings_system_data.cpp index 27037ebe2..204a370c6 100644 --- a/libraries/libstratosphere/source/settings/impl/settings_system_data.cpp +++ b/libraries/libstratosphere/source/settings/impl/settings_system_data.cpp @@ -48,7 +48,7 @@ namespace ams::settings::impl { Result LazyFileAccessor::Open(const char *path, int mode) { /* Open our file. */ - return fs::OpenFile(std::addressof(m_file), path, mode); + R_RETURN(fs::OpenFile(std::addressof(m_file), path, mode)); } void LazyFileAccessor::Close() { @@ -98,7 +98,7 @@ namespace ams::settings::impl { /* If the read is too big for the cache, read the data directly. */ if (size > sizeof(m_buffer)) { - return fs::ReadFile(m_file, offset, dst, size); + R_RETURN(fs::ReadFile(m_file, offset, dst, size)); } /* Get the file size. */ @@ -107,7 +107,7 @@ namespace ams::settings::impl { /* If the file is too small, read the data directly. */ if (file_size < offset + static_cast(size)) { - return fs::ReadFile(m_file, offset, dst, size); + R_RETURN(fs::ReadFile(m_file, offset, dst, size)); } /* Determine the read size. */ @@ -152,11 +152,11 @@ namespace ams::settings::impl { } Result SystemData::Mount() { - return fs::MountSystemData(m_mount_name, m_system_data_id); + R_RETURN(fs::MountSystemData(m_mount_name, m_system_data_id)); } Result SystemData::OpenToRead() { - return GetLazyFileAccessor().Open(m_file_path, fs::OpenMode_Read); + R_RETURN(GetLazyFileAccessor().Open(m_file_path, fs::OpenMode_Read)); } void SystemData::Close() { @@ -164,7 +164,7 @@ namespace ams::settings::impl { } Result SystemData::Read(s64 offset, void *dst, size_t size) { - return GetLazyFileAccessor().Read(offset, dst, size); + R_RETURN(GetLazyFileAccessor().Read(offset, dst, size)); } } diff --git a/libraries/libstratosphere/source/settings/impl/settings_system_save_data.cpp b/libraries/libstratosphere/source/settings/impl/settings_system_save_data.cpp index 31cac7684..3f4f8b8cd 100644 --- a/libraries/libstratosphere/source/settings/impl/settings_system_save_data.cpp +++ b/libraries/libstratosphere/source/settings/impl/settings_system_save_data.cpp @@ -454,23 +454,23 @@ namespace ams::settings::impl { } /* Mount the save data. */ - return fs::MountSystemSaveData(m_mount_name, m_save_data_space_id, m_system_save_data_id); + R_RETURN(fs::MountSystemSaveData(m_mount_name, m_save_data_space_id, m_system_save_data_id)); } Result SystemSaveData::Commit(bool synchronous) { - return GetLazyFileAccessor().Commit(m_mount_name, synchronous); + R_RETURN(GetLazyFileAccessor().Commit(m_mount_name, synchronous)); } Result SystemSaveData::Create(s64 size) { - return GetLazyFileAccessor().Create(m_mount_name, size); + R_RETURN(GetLazyFileAccessor().Create(m_mount_name, size)); } Result SystemSaveData::OpenToRead() { - return GetLazyFileAccessor().Open(m_mount_name, fs::OpenMode_Read); + R_RETURN(GetLazyFileAccessor().Open(m_mount_name, fs::OpenMode_Read)); } Result SystemSaveData::OpenToWrite() { - return GetLazyFileAccessor().Open(m_mount_name, fs::OpenMode_Write); + R_RETURN(GetLazyFileAccessor().Open(m_mount_name, fs::OpenMode_Write)); } void SystemSaveData::Close() { @@ -481,14 +481,14 @@ namespace ams::settings::impl { AMS_ASSERT(offset >= 0); AMS_ASSERT(buf != nullptr); - return GetLazyFileAccessor().Read(offset, buf, size); + R_RETURN(GetLazyFileAccessor().Read(offset, buf, size)); } Result SystemSaveData::Write(s64 offset, const void *buf, size_t size) { AMS_ASSERT(offset >= 0); AMS_ASSERT(buf != nullptr); - return GetLazyFileAccessor().Write(offset, buf, size); + R_RETURN(GetLazyFileAccessor().Write(offset, buf, size)); } Result SystemSaveData::Flush() { @@ -497,7 +497,7 @@ namespace ams::settings::impl { } Result SystemSaveData::SetFileSize(s64 size) { - return GetLazyFileAccessor().SetFileSize(size); + R_RETURN(GetLazyFileAccessor().SetFileSize(size)); } } diff --git a/libraries/libstratosphere/source/settings/settings_serial_number.cpp b/libraries/libstratosphere/source/settings/settings_serial_number.cpp index b2fb4a50f..806b7621a 100644 --- a/libraries/libstratosphere/source/settings/settings_serial_number.cpp +++ b/libraries/libstratosphere/source/settings/settings_serial_number.cpp @@ -19,13 +19,13 @@ namespace ams::settings::factory { Result GetSerialNumber(SerialNumber *out) { - const Result result = settings::impl::GetSerialNumber(out); + R_TRY_CATCH(settings::impl::GetSerialNumber(out)) { + /* It's not a fatal error if the calib filesystem is corrupted. */ + R_CATCH_RETHROW(settings::ResultCalibrationDataFileSystemCorrupted) + R_CATCH_RETHROW(settings::ResultCalibrationDataCrcError) + } R_END_TRY_CATCH_WITH_ABORT_UNLESS; - if (!settings::ResultCalibrationDataFileSystemCorrupted::Includes(result) && !settings::ResultCalibrationDataCrcError::Includes(result)) { - R_ABORT_UNLESS(result); - } - - return result; + R_SUCCEED(); } } diff --git a/libraries/libstratosphere/source/sf/cmif/sf_cmif_domain_service_object.cpp b/libraries/libstratosphere/source/sf/cmif/sf_cmif_domain_service_object.cpp index ab55a9958..edda86f50 100644 --- a/libraries/libstratosphere/source/sf/cmif/sf_cmif_domain_service_object.cpp +++ b/libraries/libstratosphere/source/sf/cmif/sf_cmif_domain_service_object.cpp @@ -18,12 +18,12 @@ namespace ams::sf::cmif { Result DomainServiceObjectDispatchTable::ProcessMessage(ServiceDispatchContext &ctx, const cmif::PointerAndSize &in_raw_data) const { - return this->ProcessMessageImpl(ctx, static_cast(ctx.srv_obj)->GetServerDomain(), in_raw_data); + R_RETURN(this->ProcessMessageImpl(ctx, static_cast(ctx.srv_obj)->GetServerDomain(), in_raw_data)); } #if AMS_SF_MITM_SUPPORTED Result DomainServiceObjectDispatchTable::ProcessMessageForMitm(ServiceDispatchContext &ctx, const cmif::PointerAndSize &in_raw_data) const { - return this->ProcessMessageForMitmImpl(ctx, static_cast(ctx.srv_obj)->GetServerDomain(), in_raw_data); + R_RETURN(this->ProcessMessageForMitmImpl(ctx, static_cast(ctx.srv_obj)->GetServerDomain(), in_raw_data)); } #endif @@ -50,14 +50,14 @@ namespace ams::sf::cmif { ctx.processor->SetImplementationProcessor(std::addressof(domain_processor)); } ctx.srv_obj = target_object.GetServiceObjectUnsafe(); - return target_object.ProcessMessage(ctx, in_message_raw_data); + R_RETURN(target_object.ProcessMessage(ctx, in_message_raw_data)); } case CmifDomainRequestType_Close: /* TODO: N doesn't error check here. Should we? */ domain->UnregisterObject(target_object_id); R_SUCCEED(); default: - return sf::cmif::ResultInvalidInHeader(); + R_THROW(sf::cmif::ResultInvalidInHeader()); } } @@ -75,7 +75,7 @@ namespace ams::sf::cmif { /* Mitm. If we don't have a target object, we should forward to let the server handle. */ if (!target_object) { - return ctx.session->ForwardRequest(ctx); + R_RETURN(ctx.session->ForwardRequest(ctx)); } R_UNLESS(in_header->data_size + in_header->num_in_objects * sizeof(DomainObjectId) <= in_domain_raw_data.GetSize(), sf::cmif::ResultInvalidHeaderSize()); @@ -90,7 +90,7 @@ namespace ams::sf::cmif { ctx.processor->SetImplementationProcessor(std::addressof(domain_processor)); } ctx.srv_obj = target_object.GetServiceObjectUnsafe(); - return target_object.ProcessMessage(ctx, in_message_raw_data); + R_RETURN(target_object.ProcessMessage(ctx, in_message_raw_data)); } case CmifDomainRequestType_Close: { @@ -98,7 +98,7 @@ namespace ams::sf::cmif { /* If the object is not in the domain, tell the server to close it. */ if (!target_object) { - return ctx.session->ForwardRequest(ctx); + R_RETURN(ctx.session->ForwardRequest(ctx)); } /* If the object is in the domain, close our copy of it. Mitm objects are required to close their associated domain id, so this shouldn't cause desynch. */ @@ -106,7 +106,7 @@ namespace ams::sf::cmif { R_SUCCEED(); } default: - return sf::cmif::ResultInvalidInHeader(); + R_THROW(sf::cmif::ResultInvalidInHeader()); } } #endif @@ -118,7 +118,7 @@ namespace ams::sf::cmif { /* Nintendo reserves domain object IDs here. We do this later, to support mitm semantics. */ /* Pass onwards. */ - return m_impl_processor->PrepareForProcess(ctx, runtime_metadata); + R_RETURN(m_impl_processor->PrepareForProcess(ctx, runtime_metadata)); } Result DomainServiceObjectProcessor::GetInObjects(ServiceObjectHolder *in_objects) const { diff --git a/libraries/libstratosphere/source/sf/cmif/sf_cmif_service_dispatch.cpp b/libraries/libstratosphere/source/sf/cmif/sf_cmif_service_dispatch.cpp index ff89fc85f..7013f98f3 100644 --- a/libraries/libstratosphere/source/sf/cmif/sf_cmif_service_dispatch.cpp +++ b/libraries/libstratosphere/source/sf/cmif/sf_cmif_service_dispatch.cpp @@ -105,13 +105,13 @@ namespace ams::sf::cmif { /* Forward any meta-context change result. */ if (sf::impl::ResultRequestContextChanged::Includes(command_result)) { - return command_result; + R_RETURN(command_result); } /* Otherwise, ensure that we're able to write the output header. */ if (out_header == nullptr) { AMS_ABORT_UNLESS(R_FAILED(command_result)); - return command_result; + R_RETURN(command_result); } /* Write output header to raw data. */ @@ -138,7 +138,7 @@ namespace ams::sf::cmif { /* If we didn't find a handler, forward the request. */ if (cmd_handler == nullptr) { - return ctx.session->ForwardRequest(ctx); + R_RETURN(ctx.session->ForwardRequest(ctx)); } /* Invoke handler. */ @@ -147,18 +147,18 @@ namespace ams::sf::cmif { /* If we should, forward the request to the forward session. */ if (sm::mitm::ResultShouldForwardToSession::Includes(command_result)) { - return ctx.session->ForwardRequest(ctx); + R_RETURN(ctx.session->ForwardRequest(ctx)); } /* Forward any meta-context change result. */ if (sf::impl::ResultRequestContextChanged::Includes(command_result)) { - return command_result; + R_RETURN(command_result); } /* Otherwise, ensure that we're able to write the output header. */ if (out_header == nullptr) { AMS_ABORT_UNLESS(R_FAILED(command_result)); - return command_result; + R_RETURN(command_result); } /* Write output header to raw data. */ diff --git a/libraries/libstratosphere/source/sf/hipc/sf_hipc_api.os.horizon.cpp b/libraries/libstratosphere/source/sf/hipc/sf_hipc_api.os.horizon.cpp index 8df6b7d8f..20dc6dd86 100644 --- a/libraries/libstratosphere/source/sf/hipc/sf_hipc_api.os.horizon.cpp +++ b/libraries/libstratosphere/source/sf/hipc/sf_hipc_api.os.horizon.cpp @@ -23,9 +23,9 @@ namespace ams::sf::hipc { s32 unused_index; if (message_buf == hipc::GetMessageBufferOnTls()) { /* Consider: AMS_ABORT_UNLESS(message_buf_size == TlsMessageBufferSize); */ - return svc::ReplyAndReceive(&unused_index, &session_handle, 1, svc::InvalidHandle, std::numeric_limits::max()); + R_RETURN(svc::ReplyAndReceive(&unused_index, &session_handle, 1, svc::InvalidHandle, std::numeric_limits::max())); } else { - return svc::ReplyAndReceiveWithUserBuffer(&unused_index, reinterpret_cast(message_buf), message_buf_size, &session_handle, 1, svc::InvalidHandle, std::numeric_limits::max()); + R_RETURN(svc::ReplyAndReceiveWithUserBuffer(&unused_index, reinterpret_cast(message_buf), message_buf_size, &session_handle, 1, svc::InvalidHandle, std::numeric_limits::max())); } } @@ -33,9 +33,9 @@ namespace ams::sf::hipc { s32 unused_index; if (message_buf == hipc::GetMessageBufferOnTls()) { /* Consider: AMS_ABORT_UNLESS(message_buf_size == TlsMessageBufferSize); */ - return svc::ReplyAndReceive(&unused_index, &session_handle, 0, session_handle, 0); + R_RETURN(svc::ReplyAndReceive(&unused_index, &session_handle, 0, session_handle, 0)); } else { - return svc::ReplyAndReceiveWithUserBuffer(&unused_index, reinterpret_cast(message_buf), message_buf_size, &session_handle, 0, session_handle, 0); + R_RETURN(svc::ReplyAndReceiveWithUserBuffer(&unused_index, reinterpret_cast(message_buf), message_buf_size, &session_handle, 0, session_handle, 0)); } } diff --git a/libraries/libstratosphere/source/sf/hipc/sf_hipc_server_domain_session_manager.cpp b/libraries/libstratosphere/source/sf/hipc/sf_hipc_server_domain_session_manager.cpp index 17c257226..6f16fa0e7 100644 --- a/libraries/libstratosphere/source/sf/hipc/sf_hipc_server_domain_session_manager.cpp +++ b/libraries/libstratosphere/source/sf/hipc/sf_hipc_server_domain_session_manager.cpp @@ -181,7 +181,7 @@ namespace ams::sf::hipc { } Result CloneCurrentObject(sf::OutMoveHandle out) { - return this->CloneCurrentObjectImpl(out, m_manager); + R_RETURN(this->CloneCurrentObjectImpl(out, m_manager)); } void QueryPointerBufferSize(sf::Out out) { @@ -189,7 +189,7 @@ namespace ams::sf::hipc { } Result CloneCurrentObjectEx(sf::OutMoveHandle out, u32 tag) { - return this->CloneCurrentObjectImpl(out, m_manager->GetSessionManagerByTag(tag)); + R_RETURN(this->CloneCurrentObjectImpl(out, m_manager->GetSessionManagerByTag(tag))); } }; static_assert(IsIHipcManager); @@ -201,7 +201,7 @@ namespace ams::sf::hipc { /* Note: This is safe, as no additional references to the hipc manager can ever be stored. */ /* The shared pointer to stack object is definitely gross, though. */ UnmanagedServiceObject hipc_manager(this, session); - return this->DispatchRequest(cmif::ServiceObjectHolder(hipc_manager.GetShared()), session, in_message, out_message); + R_RETURN(this->DispatchRequest(cmif::ServiceObjectHolder(hipc_manager.GetShared()), session, in_message, out_message)); } } diff --git a/libraries/libstratosphere/source/sf/hipc/sf_hipc_server_manager.cpp b/libraries/libstratosphere/source/sf/hipc/sf_hipc_server_manager.cpp index b831344c7..b4d959b24 100644 --- a/libraries/libstratosphere/source/sf/hipc/sf_hipc_server_manager.cpp +++ b/libraries/libstratosphere/source/sf/hipc/sf_hipc_server_manager.cpp @@ -96,9 +96,9 @@ namespace ams::sf::hipc { /* Create new session. */ if (server->m_static_object) { - return this->AcceptSession(server->m_port_handle, server->m_static_object.Clone()); + R_RETURN(this->AcceptSession(server->m_port_handle, server->m_static_object.Clone())); } else { - return this->OnNeedsToAccept(server->m_index, server); + R_RETURN(this->OnNeedsToAccept(server->m_index, server)); } } @@ -110,7 +110,7 @@ namespace ams::sf::hipc { ON_SCOPE_EXIT { this->LinkToDeferredList(server); }; /* Create resources for new session. */ - return this->OnNeedsToAccept(server->m_index, server); + R_RETURN(this->OnNeedsToAccept(server->m_index, server)); } #endif @@ -164,13 +164,13 @@ namespace ams::sf::hipc { Result ServerManagerBase::Process(os::MultiWaitHolderType *holder) { switch (static_cast(os::GetMultiWaitHolderUserData(holder))) { case UserDataTag::Server: - return this->ProcessForServer(holder); + R_RETURN(this->ProcessForServer(holder)); case UserDataTag::Session: - return this->ProcessForSession(holder); + R_RETURN(this->ProcessForSession(holder)); #if AMS_SF_MITM_SUPPORTED case UserDataTag::MitmServer: AMS_ABORT_UNLESS(this->CanManageMitmServers()); - return this->ProcessForMitmServer(holder); + R_RETURN(this->ProcessForMitmServer(holder)); #endif AMS_UNREACHABLE_DEFAULT_CASE(); } diff --git a/libraries/libstratosphere/source/sf/hipc/sf_hipc_server_session_manager.cpp b/libraries/libstratosphere/source/sf/hipc/sf_hipc_server_session_manager.cpp index bc25555ca..692ed092b 100644 --- a/libraries/libstratosphere/source/sf/hipc/sf_hipc_server_session_manager.cpp +++ b/libraries/libstratosphere/source/sf/hipc/sf_hipc_server_session_manager.cpp @@ -164,26 +164,26 @@ namespace ams::sf::hipc { Result ServerSessionManager::RegisterSession(os::NativeHandle session_handle, cmif::ServiceObjectHolder &&obj) { /* We don't actually care about what happens to the session. It'll get linked. */ ServerSession *session_ptr = nullptr; - return this->RegisterSession(std::addressof(session_ptr), session_handle, std::forward(obj)); + R_RETURN(this->RegisterSession(std::addressof(session_ptr), session_handle, std::forward(obj))); } Result ServerSessionManager::AcceptSession(os::NativeHandle port_handle, cmif::ServiceObjectHolder &&obj) { /* We don't actually care about what happens to the session. It'll get linked. */ ServerSession *session_ptr = nullptr; - return this->AcceptSession(std::addressof(session_ptr), port_handle, std::forward(obj)); + R_RETURN(this->AcceptSession(std::addressof(session_ptr), port_handle, std::forward(obj))); } #if AMS_SF_MITM_SUPPORTED Result ServerSessionManager::RegisterMitmSession(os::NativeHandle mitm_session_handle, cmif::ServiceObjectHolder &&obj, std::shared_ptr<::Service> &&fsrv) { /* We don't actually care about what happens to the session. It'll get linked. */ ServerSession *session_ptr = nullptr; - return this->RegisterMitmSession(std::addressof(session_ptr), mitm_session_handle, std::forward(obj), std::forward>(fsrv)); + R_RETURN(this->RegisterMitmSession(std::addressof(session_ptr), mitm_session_handle, std::forward(obj), std::forward>(fsrv))); } Result ServerSessionManager::AcceptMitmSession(os::NativeHandle mitm_port_handle, cmif::ServiceObjectHolder &&obj, std::shared_ptr<::Service> &&fsrv) { /* We don't actually care about what happens to the session. It'll get linked. */ ServerSession *session_ptr = nullptr; - return this->AcceptMitmSession(std::addressof(session_ptr), mitm_port_handle, std::forward(obj), std::forward>(fsrv)); + R_RETURN(this->AcceptMitmSession(std::addressof(session_ptr), mitm_port_handle, std::forward(obj), std::forward>(fsrv))); } #endif @@ -243,10 +243,7 @@ namespace ams::sf::hipc { default: { R_TRY_CATCH(this->ProcessRequestImpl(session, message, message)) { - R_CATCH(sf::impl::ResultRequestContextChanged) { - /* A meta message changing the request context has been sent. */ - return R_CURRENT_RESULT; - } + R_CATCH_RETHROW(sf::impl::ResultRequestContextChanged) /* A meta message changing the request context has been sent. */ R_CATCH_ALL() { /* All other results indicate something went very wrong. */ this->CloseSessionImpl(session); @@ -285,12 +282,12 @@ namespace ams::sf::hipc { switch (cmif_command_type) { case CmifCommandType_Request: case CmifCommandType_RequestWithContext: - return this->DispatchRequest(session->m_srv_obj_holder.Clone(), session, in_message, out_message); + R_RETURN(this->DispatchRequest(session->m_srv_obj_holder.Clone(), session, in_message, out_message)); case CmifCommandType_Control: case CmifCommandType_ControlWithContext: - return this->DispatchManagerRequest(session, in_message, out_message); + R_RETURN(this->DispatchManagerRequest(session, in_message, out_message)); default: - return sf::hipc::ResultUnknownCommandType(); + R_THROW(sf::hipc::ResultUnknownCommandType()); } } diff --git a/libraries/libstratosphere/source/sm/sm_api.cpp b/libraries/libstratosphere/source/sm/sm_api.cpp index a145023f6..4487bbc95 100644 --- a/libraries/libstratosphere/source/sm/sm_api.cpp +++ b/libraries/libstratosphere/source/sm/sm_api.cpp @@ -47,24 +47,24 @@ namespace ams::sm { /* Ordinary SM API. */ Result GetServiceHandle(os::NativeHandle *out, ServiceName name) { - return smGetServiceOriginal(out, impl::ConvertName(name)); + R_RETURN(smGetServiceOriginal(out, impl::ConvertName(name))); } Result RegisterService(os::NativeHandle *out, ServiceName name, size_t max_sessions, bool is_light) { - return smRegisterService(out, impl::ConvertName(name), is_light, static_cast(max_sessions)); + R_RETURN(smRegisterService(out, impl::ConvertName(name), is_light, static_cast(max_sessions))); } Result UnregisterService(ServiceName name) { - return smUnregisterService(impl::ConvertName(name)); + R_RETURN(smUnregisterService(impl::ConvertName(name))); } /* Atmosphere extensions. */ Result HasService(bool *out, ServiceName name) { - return smAtmosphereHasService(out, impl::ConvertName(name)); + R_RETURN(smAtmosphereHasService(out, impl::ConvertName(name))); } Result WaitService(ServiceName name) { - return smAtmosphereWaitService(impl::ConvertName(name)); + R_RETURN(smAtmosphereWaitService(impl::ConvertName(name))); } #else Result Initialize() { diff --git a/libraries/libstratosphere/source/sm/sm_manager_api.cpp b/libraries/libstratosphere/source/sm/sm_manager_api.cpp index 3a74fa1f6..6def5da81 100644 --- a/libraries/libstratosphere/source/sm/sm_manager_api.cpp +++ b/libraries/libstratosphere/source/sm/sm_manager_api.cpp @@ -26,20 +26,20 @@ namespace ams::sm::manager { /* Manager API. */ Result RegisterProcess(os::ProcessId process_id, ncm::ProgramId program_id, cfg::OverrideStatus status, const void *acid, size_t acid_size, const void *aci, size_t aci_size) { static_assert(sizeof(status) == sizeof(CfgOverrideStatus), "CfgOverrideStatus definition"); - return smManagerAtmosphereRegisterProcess(static_cast(process_id), static_cast(program_id), reinterpret_cast(std::addressof(status)), acid, acid_size, aci, aci_size); + R_RETURN(smManagerAtmosphereRegisterProcess(static_cast(process_id), static_cast(program_id), reinterpret_cast(std::addressof(status)), acid, acid_size, aci, aci_size)); } Result UnregisterProcess(os::ProcessId process_id) { - return smManagerUnregisterProcess(static_cast(process_id)); + R_RETURN(smManagerUnregisterProcess(static_cast(process_id))); } /* Atmosphere extensions. */ Result EndInitialDefers() { - return smManagerAtmosphereEndInitialDefers(); + R_RETURN(smManagerAtmosphereEndInitialDefers()); } Result HasMitm(bool *out, ServiceName name) { - return smManagerAtmosphereHasMitm(out, impl::ConvertName(name)); + R_RETURN(smManagerAtmosphereHasMitm(out, impl::ConvertName(name))); } #endif diff --git a/libraries/libstratosphere/source/sm/sm_mitm_api.cpp b/libraries/libstratosphere/source/sm/sm_mitm_api.cpp index fa31d0ac8..7efd46ea6 100644 --- a/libraries/libstratosphere/source/sm/sm_mitm_api.cpp +++ b/libraries/libstratosphere/source/sm/sm_mitm_api.cpp @@ -22,35 +22,35 @@ namespace ams::sm::mitm { #if AMS_SF_MITM_SUPPORTED /* Mitm API. */ Result InstallMitm(os::NativeHandle *out_port, os::NativeHandle *out_query, ServiceName name) { - return impl::DoWithPerThreadSession([&](TipcService *fwd) { - return smAtmosphereMitmInstall(fwd, out_port, out_query, impl::ConvertName(name)); - }); + R_RETURN(impl::DoWithPerThreadSession([&](TipcService *fwd) { + R_RETURN(smAtmosphereMitmInstall(fwd, out_port, out_query, impl::ConvertName(name))); + })); } Result UninstallMitm(ServiceName name) { - return smAtmosphereMitmUninstall(impl::ConvertName(name)); + R_RETURN(smAtmosphereMitmUninstall(impl::ConvertName(name))); } Result DeclareFutureMitm(ServiceName name) { - return smAtmosphereMitmDeclareFuture(impl::ConvertName(name)); + R_RETURN(smAtmosphereMitmDeclareFuture(impl::ConvertName(name))); } Result ClearFutureMitm(ServiceName name) { - return smAtmosphereMitmClearFuture(impl::ConvertName(name)); + R_RETURN(smAtmosphereMitmClearFuture(impl::ConvertName(name))); } Result AcknowledgeSession(Service *out_service, MitmProcessInfo *out_info, ServiceName name) { return impl::DoWithMitmAcknowledgementSession([&]() { - return smAtmosphereMitmAcknowledgeSession(out_service, reinterpret_cast(out_info), impl::ConvertName(name)); + R_RETURN(smAtmosphereMitmAcknowledgeSession(out_service, reinterpret_cast(out_info), impl::ConvertName(name))); }); } Result HasMitm(bool *out, ServiceName name) { - return smAtmosphereHasMitm(out, impl::ConvertName(name)); + R_RETURN(smAtmosphereHasMitm(out, impl::ConvertName(name))); } Result WaitMitm(ServiceName name) { - return smAtmosphereWaitMitm(impl::ConvertName(name)); + R_RETURN(smAtmosphereWaitMitm(impl::ConvertName(name))); } #endif #endif diff --git a/libraries/libstratosphere/source/sm/sm_utils.hpp b/libraries/libstratosphere/source/sm/sm_utils.hpp index 2edc9830b..5b4d3fce1 100644 --- a/libraries/libstratosphere/source/sm/sm_utils.hpp +++ b/libraries/libstratosphere/source/sm/sm_utils.hpp @@ -35,7 +35,7 @@ namespace ams::sm::impl { R_ABORT_UNLESS(smAtmosphereMitmInitialize()); ON_SCOPE_EXIT { smAtmosphereMitmExit(); }; - return f(); + R_RETURN(f()); } } @@ -48,7 +48,7 @@ namespace ams::sm::impl { } { ON_SCOPE_EXIT { smAtmosphereCloseSession(std::addressof(srv)); }; - return f(std::addressof(srv)); + R_RETURN(f(std::addressof(srv))); } } diff --git a/libraries/libstratosphere/source/socket/impl/socket_api.os.horizon.cpp b/libraries/libstratosphere/source/socket/impl/socket_api.os.horizon.cpp index 45d600e12..676817e75 100644 --- a/libraries/libstratosphere/source/socket/impl/socket_api.os.horizon.cpp +++ b/libraries/libstratosphere/source/socket/impl/socket_api.os.horizon.cpp @@ -251,7 +251,7 @@ namespace ams::socket::impl { } Result Initialize(const Config &config) { - return InitializeCommon(config); + R_RETURN(InitializeCommon(config)); } Result Finalize() { diff --git a/libraries/libstratosphere/source/socket/socket_api.cpp b/libraries/libstratosphere/source/socket/socket_api.cpp index bd1949d68..c2ca6aeaa 100644 --- a/libraries/libstratosphere/source/socket/socket_api.cpp +++ b/libraries/libstratosphere/source/socket/socket_api.cpp @@ -43,15 +43,15 @@ namespace ams::socket { } Result Initialize(const Config &config) { - return impl::Initialize(config); + R_RETURN(impl::Initialize(config)); } Result Finalize() { - return impl::Finalize(); + R_RETURN(impl::Finalize()); } Result InitializeAllocatorForInternal(void *buffer, size_t size) { - return impl::InitializeAllocatorForInternal(buffer, size); + R_RETURN(impl::InitializeAllocatorForInternal(buffer, size)); } ssize_t RecvFrom(s32 desc, void *buffer, size_t buffer_size, MsgFlag flags, SockAddr *out_address, SockLenT *out_addr_len){ diff --git a/libraries/libstratosphere/source/spl/impl/spl_api_impl.cpp b/libraries/libstratosphere/source/spl/impl/spl_api_impl.cpp index 397932369..acec07407 100644 --- a/libraries/libstratosphere/source/spl/impl/spl_api_impl.cpp +++ b/libraries/libstratosphere/source/spl/impl/spl_api_impl.cpp @@ -386,7 +386,7 @@ namespace ams::spl::impl { u8 seed[Drbg::SeedSize]; if (smc::Result res = smc::GenerateRandomBytes(seed, sizeof(seed)); res != smc::Result::Success) { - return smc::ConvertResult(res); + R_RETURN(smc::ConvertResult(res)); } util::GetReference(g_drbg).Reseed(seed, sizeof(seed), nullptr, 0); @@ -409,9 +409,9 @@ namespace ams::spl::impl { std::memcpy(layout.data, src, src_size); if (g_is_modern_device_unique_data) { - return smc::ConvertResult(smc::DecryptDeviceUniqueData(layout.data, src_size, access_key, key_source, static_cast(option))); + R_RETURN(smc::ConvertResult(smc::DecryptDeviceUniqueData(layout.data, src_size, access_key, key_source, static_cast(option)))); } else { - return smc::ConvertResult(smc::DecryptAndStoreGcKey(layout.data, src_size, access_key, key_source, option)); + R_RETURN(smc::ConvertResult(smc::DecryptAndStoreGcKey(layout.data, src_size, access_key, key_source, option))); } } @@ -444,12 +444,12 @@ namespace ams::spl::impl { smc::AsyncOperationKey op_key; smc::Result res = smc::ModularExponentiateWithStorageKey(std::addressof(op_key), layout.base, layout.mod, mode); if (res != smc::Result::Success) { - return smc::ConvertResult(res); + R_RETURN(smc::ConvertResult(res)); } res = WaitAndGetResultData(g_work_buffer, out_size, op_key); if (res != smc::Result::Success) { - return smc::ConvertResult(res); + R_RETURN(smc::ConvertResult(res)); } } @@ -490,12 +490,12 @@ namespace ams::spl::impl { smc::AsyncOperationKey op_key; smc::Result res = smc::PrepareEsDeviceUniqueKey(std::addressof(op_key), layout.base, layout.mod, label_digest, label_digest_size, smc::GetPrepareEsDeviceUniqueKeyOption(type, generation)); if (res != smc::Result::Success) { - return smc::ConvertResult(res); + R_RETURN(smc::ConvertResult(res)); } res = WaitAndGetResultData(g_work_buffer, sizeof(*out_access_key), op_key); if (res != smc::Result::Success) { - return smc::ConvertResult(res); + R_RETURN(smc::ConvertResult(res)); } } @@ -537,7 +537,7 @@ namespace ams::spl::impl { res = smc::Result::Success; } - return smc::ConvertResult(res); + R_RETURN(smc::ConvertResult(res)); } Result ModularExponentiate(void *out, size_t out_size, const void *base, size_t base_size, const void *exp, size_t exp_size, const void *mod, size_t mod_size) { @@ -573,12 +573,12 @@ namespace ams::spl::impl { smc::AsyncOperationKey op_key; smc::Result res = smc::ModularExponentiate(std::addressof(op_key), layout.base, layout.exp, exp_size, layout.mod); if (res != smc::Result::Success) { - return smc::ConvertResult(res); + R_RETURN(smc::ConvertResult(res)); } res = WaitAndGetResultData(g_work_buffer, out_size, op_key); if (res != smc::Result::Success) { - return smc::ConvertResult(res); + R_RETURN(smc::ConvertResult(res)); } } @@ -629,7 +629,7 @@ namespace ams::spl::impl { /* Crypto. */ Result GenerateAesKek(AccessKey *out_access_key, const KeySource &key_source, u32 generation, u32 option) { - return smc::ConvertResult(smc::GenerateAesKek(out_access_key, key_source, generation, option)); + R_RETURN(smc::ConvertResult(smc::GenerateAesKek(out_access_key, key_source, generation, option))); } Result LoadAesKey(s32 keyslot, const AccessKey &access_key, const KeySource &key_source) { @@ -653,14 +653,14 @@ namespace ams::spl::impl { R_TRY(LoadAesKey(keyslot_holder.GetIndex(), access_key, KeyGenerationSource)); - return smc::ConvertResult(DecryptAes(out_key, keyslot_holder.GetIndex(), std::addressof(key_source))); + R_RETURN(smc::ConvertResult(DecryptAes(out_key, keyslot_holder.GetIndex(), std::addressof(key_source)))); } Result DecryptAesKey(AesKey *out_key, const KeySource &key_source, u32 generation, u32 option) { AccessKey access_key; R_TRY(GenerateAesKek(std::addressof(access_key), AesKeyDecryptionSource, generation, option)); - return GenerateAesKey(out_key, access_key, key_source); + R_RETURN(GenerateAesKey(out_key, access_key, key_source)); } Result ComputeCtr(void *dst, size_t dst_size, s32 keyslot, const void *src, size_t src_size, const IvCtr &iv_ctr) { @@ -718,12 +718,12 @@ namespace ams::spl::impl { smc::AsyncOperationKey op_key; smc::Result res = smc::ComputeAes(std::addressof(op_key), dst_ll_addr, mode, iv_ctr, src_ll_addr, src_size); if (res != smc::Result::Success) { - return smc::ConvertResult(res); + R_RETURN(smc::ConvertResult(res)); } res = WaitAndGetResult(op_key); if (res != smc::Result::Success) { - return smc::ConvertResult(res); + R_RETURN(smc::ConvertResult(res)); } } os::FlushDataCache(dst, dst_size); @@ -737,12 +737,12 @@ namespace ams::spl::impl { smc::AsyncOperationKey op_key; smc::Result res = smc::ComputeAes(std::addressof(op_key), reinterpret_cast(dst), mode, iv_ctr, reinterpret_cast(src), src_size); if (res != smc::Result::Success) { - return smc::ConvertResult(res); + R_RETURN(smc::ConvertResult(res)); } res = WaitAndGetResult(op_key); if (res != smc::Result::Success) { - return smc::ConvertResult(res); + R_RETURN(smc::ConvertResult(res)); } } #endif @@ -754,7 +754,7 @@ namespace ams::spl::impl { R_UNLESS(size <= sizeof(g_work_buffer), spl::ResultInvalidBufferSize()); std::memcpy(g_work_buffer, data, size); - return smc::ConvertResult(smc::ComputeCmac(out_cmac, GetPhysicalAesKeySlot(keyslot, true), g_work_buffer, size)); + R_RETURN(smc::ConvertResult(smc::ComputeCmac(out_cmac, GetPhysicalAesKeySlot(keyslot, true), g_work_buffer, size))); } Result AllocateAesKeySlot(s32 *out_keyslot) { @@ -842,22 +842,22 @@ namespace ams::spl::impl { std::memcpy(dst, layout.data, copy_size); } - return smc::ConvertResult(smc_res); + R_RETURN(smc::ConvertResult(smc_res)); } /* SSL */ Result DecryptAndStoreSslClientCertKey(const void *src, size_t src_size, const AccessKey &access_key, const KeySource &key_source) { - return DecryptAndStoreDeviceUniqueKey(src, src_size, access_key, key_source, static_cast(smc::DeviceUniqueDataMode::DecryptAndStoreSslKey)); + R_RETURN(DecryptAndStoreDeviceUniqueKey(src, src_size, access_key, key_source, static_cast(smc::DeviceUniqueDataMode::DecryptAndStoreSslKey))); } Result ModularExponentiateWithSslClientCertKey(void *out, size_t out_size, const void *base, size_t base_size, const void *mod, size_t mod_size) { - return ModularExponentiateWithStorageKey(out, out_size, base, base_size, mod, mod_size, smc::ModularExponentiateWithStorageKeyMode::Ssl); + R_RETURN(ModularExponentiateWithStorageKey(out, out_size, base, base_size, mod, mod_size, smc::ModularExponentiateWithStorageKeyMode::Ssl)); } /* ES */ Result LoadEsDeviceKey(const void *src, size_t src_size, const AccessKey &access_key, const KeySource &key_source, u32 option) { if (g_is_modern_device_unique_data) { - return DecryptAndStoreDeviceUniqueKey(src, src_size, access_key, key_source, option); + R_RETURN(DecryptAndStoreDeviceUniqueKey(src, src_size, access_key, key_source, option)); } else { struct LoadEsDeviceKeyLayout { u8 data[DeviceUniqueDataMetaDataSize + 2 * Rsa2048BlockSize + 0x10]; @@ -869,33 +869,33 @@ namespace ams::spl::impl { std::memcpy(layout.data, src, src_size); - return smc::ConvertResult(smc::LoadEsDeviceKey(layout.data, src_size, access_key, key_source, option)); + R_RETURN(smc::ConvertResult(smc::LoadEsDeviceKey(layout.data, src_size, access_key, key_source, option))); } } Result PrepareEsTitleKey(AccessKey *out_access_key, const void *base, size_t base_size, const void *mod, size_t mod_size, const void *label_digest, size_t label_digest_size, u32 generation) { - return PrepareEsDeviceUniqueKey(out_access_key, base, base_size, mod, mod_size, label_digest, label_digest_size, smc::EsDeviceUniqueKeyType::TitleKey, generation); + R_RETURN(PrepareEsDeviceUniqueKey(out_access_key, base, base_size, mod, mod_size, label_digest, label_digest_size, smc::EsDeviceUniqueKeyType::TitleKey, generation)); } Result PrepareCommonEsTitleKey(AccessKey *out_access_key, const KeySource &key_source, u32 generation) { - return smc::ConvertResult(smc::PrepareCommonEsTitleKey(out_access_key, key_source, generation)); + R_RETURN(smc::ConvertResult(smc::PrepareCommonEsTitleKey(out_access_key, key_source, generation))); } Result DecryptAndStoreDrmDeviceCertKey(const void *src, size_t src_size, const AccessKey &access_key, const KeySource &key_source) { - return DecryptAndStoreDeviceUniqueKey(src, src_size, access_key, key_source, static_cast(smc::DeviceUniqueDataMode::DecryptAndStoreDrmDeviceCertKey)); + R_RETURN(DecryptAndStoreDeviceUniqueKey(src, src_size, access_key, key_source, static_cast(smc::DeviceUniqueDataMode::DecryptAndStoreDrmDeviceCertKey))); } Result ModularExponentiateWithDrmDeviceCertKey(void *out, size_t out_size, const void *base, size_t base_size, const void *mod, size_t mod_size) { - return ModularExponentiateWithStorageKey(out, out_size, base, base_size, mod, mod_size, smc::ModularExponentiateWithStorageKeyMode::DrmDeviceCert); + R_RETURN(ModularExponentiateWithStorageKey(out, out_size, base, base_size, mod, mod_size, smc::ModularExponentiateWithStorageKeyMode::DrmDeviceCert)); } Result PrepareEsArchiveKey(AccessKey *out_access_key, const void *base, size_t base_size, const void *mod, size_t mod_size, const void *label_digest, size_t label_digest_size, u32 generation) { - return PrepareEsDeviceUniqueKey(out_access_key, base, base_size, mod, mod_size, label_digest, label_digest_size, smc::EsDeviceUniqueKeyType::ArchiveKey, generation); + R_RETURN(PrepareEsDeviceUniqueKey(out_access_key, base, base_size, mod, mod_size, label_digest, label_digest_size, smc::EsDeviceUniqueKeyType::ArchiveKey, generation)); } /* FS */ Result DecryptAndStoreGcKey(const void *src, size_t src_size, const AccessKey &access_key, const KeySource &key_source, u32 option) { - return DecryptAndStoreDeviceUniqueKey(src, src_size, access_key, key_source, option); + R_RETURN(DecryptAndStoreDeviceUniqueKey(src, src_size, access_key, key_source, option)); } Result DecryptGcMessage(u32 *out_size, void *dst, size_t dst_size, const void *base, size_t base_size, const void *mod, size_t mod_size, const void *label_digest, size_t label_digest_size) { @@ -914,7 +914,7 @@ namespace ams::spl::impl { } Result GenerateSpecificAesKey(AesKey *out_key, const KeySource &key_source, u32 generation, u32 which) { - return smc::ConvertResult(smc::GenerateSpecificAesKey(out_key, key_source, generation, which)); + R_RETURN(smc::ConvertResult(smc::GenerateSpecificAesKey(out_key, key_source, generation, which))); } Result LoadPreparedAesKey(s32 keyslot, const AccessKey &access_key) { @@ -937,7 +937,7 @@ namespace ams::spl::impl { const smc::Result smc_res = smc::GetConfig(hash, 4, ConfigItem::Package2Hash); if (smc_res != smc::Result::Success) { - return smc::ConvertResult(smc_res); + R_RETURN(smc::ConvertResult(smc_res)); } std::memcpy(dst, hash, sizeof(hash)); @@ -970,7 +970,7 @@ namespace ams::spl::impl { std::memcpy(dst, layout.data, std::min(dst_size, src_size)); } - return smc::ConvertResult(smc_res); + R_RETURN(smc::ConvertResult(smc_res)); } } diff --git a/libraries/libstratosphere/source/spl/spl_api.os.horizon.cpp b/libraries/libstratosphere/source/spl/spl_api.os.horizon.cpp index 04e62b88b..2e7da9e92 100644 --- a/libraries/libstratosphere/source/spl/spl_api.os.horizon.cpp +++ b/libraries/libstratosphere/source/spl/spl_api.os.horizon.cpp @@ -34,18 +34,18 @@ namespace ams::spl { constinit InitializeMode g_initialize_mode = InitializeMode::None; Result AllocateAesKeySlotImpl(s32 *out) { - return serviceDispatchOut(splCryptoGetServiceSession(), 21, *out); + R_RETURN(serviceDispatchOut(splCryptoGetServiceSession(), 21, *out)); } Result DeallocateAesKeySlotImpl(s32 slot) { - return serviceDispatchIn(splCryptoGetServiceSession(), 22, slot); + R_RETURN(serviceDispatchIn(splCryptoGetServiceSession(), 22, slot)); } Result GetAesKeySlotAvailableEventImpl(os::NativeHandle *out) { - return serviceDispatch(splCryptoGetServiceSession(), 23, + R_RETURN(serviceDispatch(splCryptoGetServiceSession(), 23, .out_handle_attrs = { SfOutHandleAttr_HipcCopy }, .out_handles = out, - ); + )); } void GetAesKeySlotAvailableEvent(os::SystemEvent *out) { @@ -153,27 +153,27 @@ namespace ams::spl { } Result AllocateAesKeySlot(s32 *out_slot) { - return WaitAvailableKeySlotAndExecute([&]() -> Result { - return AllocateAesKeySlotImpl(out_slot); - }); + R_RETURN(WaitAvailableKeySlotAndExecute([&]() -> Result { + R_RETURN(AllocateAesKeySlotImpl(out_slot)); + })); } Result DeallocateAesKeySlot(s32 slot) { - return DeallocateAesKeySlotImpl(slot); + R_RETURN(DeallocateAesKeySlotImpl(slot)); } Result GenerateAesKek(AccessKey *access_key, const void *key_source, size_t key_source_size, s32 generation, u32 option) { AMS_ASSERT(key_source_size == sizeof(KeySource)); AMS_UNUSED(key_source_size); - return splCryptoGenerateAesKek(key_source, generation, option, static_cast(access_key)); + R_RETURN(splCryptoGenerateAesKek(key_source, generation, option, static_cast(access_key))); } Result LoadAesKey(s32 slot, const AccessKey &access_key, const void *key_source, size_t key_source_size) { AMS_ASSERT(key_source_size == sizeof(KeySource)); AMS_UNUSED(key_source_size); - return splCryptoLoadAesKey(std::addressof(access_key), key_source, static_cast(slot)); + R_RETURN(splCryptoLoadAesKey(std::addressof(access_key), key_source, static_cast(slot))); } Result GenerateAesKey(void *dst, size_t dst_size, const AccessKey &access_key, const void *key_source, size_t key_source_size) { @@ -181,9 +181,9 @@ namespace ams::spl { AMS_ASSERT(key_source_size == sizeof(KeySource)); AMS_UNUSED(dst_size, key_source_size); - return WaitAvailableKeySlotAndExecute([&]() -> Result { - return splCryptoGenerateAesKey(std::addressof(access_key), key_source, dst); - }); + R_RETURN(WaitAvailableKeySlotAndExecute([&]() -> Result { + R_RETURN(splCryptoGenerateAesKey(std::addressof(access_key), key_source, dst)); + })); } Result GenerateSpecificAesKey(void *dst, size_t dst_size, const void *key_source, size_t key_source_size, s32 generation, u32 option) { @@ -191,7 +191,7 @@ namespace ams::spl { AMS_ASSERT(key_source_size == sizeof(KeySource)); AMS_UNUSED(dst_size, key_source_size); - return splFsGenerateSpecificAesKey(key_source, static_cast(generation), option, dst); + R_RETURN(splFsGenerateSpecificAesKey(key_source, static_cast(generation), option, dst)); } Result ComputeCtr(void *dst, size_t dst_size, s32 slot, const void *src, size_t src_size, const void *iv, size_t iv_size) { @@ -199,7 +199,7 @@ namespace ams::spl { AMS_ASSERT(dst_size >= src_size); AMS_UNUSED(dst_size, iv_size); - return splCryptoCryptAesCtr(src, dst, src_size, static_cast(slot), iv); + R_RETURN(splCryptoCryptAesCtr(src, dst, src_size, static_cast(slot), iv)); } Result DecryptAesKey(void *dst, size_t dst_size, const void *key_source, size_t key_source_size, s32 generation, u32 option) { @@ -207,17 +207,17 @@ namespace ams::spl { AMS_ASSERT(key_source_size == sizeof(KeySource)); AMS_UNUSED(dst_size, key_source_size); - return WaitAvailableKeySlotAndExecute([&]() -> Result { - return splCryptoDecryptAesKey(key_source, static_cast(generation), option, dst); - }); + R_RETURN(WaitAvailableKeySlotAndExecute([&]() -> Result { + R_RETURN(splCryptoDecryptAesKey(key_source, static_cast(generation), option, dst)); + })); } Result GetConfig(u64 *out, ConfigItem item) { - return splGetConfig(static_cast<::SplConfigItem>(item), out); + R_RETURN(splGetConfig(static_cast<::SplConfigItem>(item), out)); } Result SetConfig(ConfigItem item, u64 v) { - return splSetConfig(static_cast<::SplConfigItem>(item), v); + R_RETURN(splSetConfig(static_cast<::SplConfigItem>(item), v)); } bool IsDevelopment() { @@ -249,7 +249,7 @@ namespace ams::spl { u32 v; std::memcpy(std::addressof(v), std::addressof(boot_reason), sizeof(v)); - return splSetBootReason(v); + R_RETURN(splSetBootReason(v)); } Result GetBootReason(BootReasonValue *out) { @@ -278,19 +278,19 @@ namespace ams::spl { Result GetPackage2Hash(void *dst, size_t dst_size) { AMS_ASSERT(dst_size >= crypto::Sha256Generator::HashSize); AMS_UNUSED(dst_size); - return splFsGetPackage2Hash(dst); + R_RETURN(splFsGetPackage2Hash(dst)); } Result GenerateRandomBytes(void *out, size_t buffer_size) { - return splGetRandomBytes(out, buffer_size); + R_RETURN(splGetRandomBytes(out, buffer_size)); } Result LoadPreparedAesKey(s32 slot, const AccessKey &access_key) { if (g_initialize_mode == InitializeMode::Fs) { - return splFsLoadTitlekey(std::addressof(access_key), static_cast(slot)); + R_RETURN(splFsLoadTitlekey(std::addressof(access_key), static_cast(slot))); } else { /* TODO: libnx binding not available. */ - /* return splEsLoadTitlekey(std::addressof(access_key), static_cast(slot)); */ + /* R_RETURN(splEsLoadTitlekey(std::addressof(access_key), static_cast(slot))); */ AMS_ABORT_UNLESS(false); } } diff --git a/libraries/libstratosphere/source/sprofile/srv/sprofile_srv_profile_controller_for_debug_impl.cpp b/libraries/libstratosphere/source/sprofile/srv/sprofile_srv_profile_controller_for_debug_impl.cpp index 37e04a298..1bf965f21 100644 --- a/libraries/libstratosphere/source/sprofile/srv/sprofile_srv_profile_controller_for_debug_impl.cpp +++ b/libraries/libstratosphere/source/sprofile/srv/sprofile_srv_profile_controller_for_debug_impl.cpp @@ -20,11 +20,11 @@ namespace ams::sprofile::srv { Result ProfileControllerForDebugImpl::Reset() { - return m_manager->ResetSaveData(); + R_RETURN(m_manager->ResetSaveData()); } Result ProfileControllerForDebugImpl::GetRaw(sf::Out out_type, sf::Out out_value, sprofile::Identifier profile, sprofile::Identifier key) { - return m_manager->GetRaw(out_type.GetPointer(), out_value.GetPointer(), profile, key); + R_RETURN(m_manager->GetRaw(out_type.GetPointer(), out_value.GetPointer(), profile, key)); } } diff --git a/libraries/libstratosphere/source/sprofile/srv/sprofile_srv_profile_importer_impl.cpp b/libraries/libstratosphere/source/sprofile/srv/sprofile_srv_profile_importer_impl.cpp index 8535c5604..7e64a3a48 100644 --- a/libraries/libstratosphere/source/sprofile/srv/sprofile_srv_profile_importer_impl.cpp +++ b/libraries/libstratosphere/source/sprofile/srv/sprofile_srv_profile_importer_impl.cpp @@ -20,15 +20,15 @@ namespace ams::sprofile::srv { Result ProfileImporterImpl::ImportProfile(const sprofile::srv::ProfileDataForImportData &import) { - return m_manager->ImportProfile(import); + R_RETURN(m_manager->ImportProfile(import)); } Result ProfileImporterImpl::Commit() { - return m_manager->Commit(); + R_RETURN(m_manager->Commit()); } Result ProfileImporterImpl::ImportMetadata(const sprofile::srv::ProfileMetadataForImportMetadata &import) { - return m_manager->ImportMetadata(import); + R_RETURN(m_manager->ImportMetadata(import)); } } diff --git a/libraries/libstratosphere/source/sprofile/srv/sprofile_srv_profile_reader_impl.cpp b/libraries/libstratosphere/source/sprofile/srv/sprofile_srv_profile_reader_impl.cpp index 511e9c161..b601764af 100644 --- a/libraries/libstratosphere/source/sprofile/srv/sprofile_srv_profile_reader_impl.cpp +++ b/libraries/libstratosphere/source/sprofile/srv/sprofile_srv_profile_reader_impl.cpp @@ -20,23 +20,23 @@ namespace ams::sprofile::srv { Result ProfileReaderImpl::GetSigned64(sf::Out out, sprofile::Identifier profile, sprofile::Identifier key) { - return m_manager->GetSigned64(out.GetPointer(), profile, key); + R_RETURN(m_manager->GetSigned64(out.GetPointer(), profile, key)); } Result ProfileReaderImpl::GetUnsigned64(sf::Out out, sprofile::Identifier profile, sprofile::Identifier key) { - return m_manager->GetUnsigned64(out.GetPointer(), profile, key); + R_RETURN(m_manager->GetUnsigned64(out.GetPointer(), profile, key)); } Result ProfileReaderImpl::GetSigned32(sf::Out out, sprofile::Identifier profile, sprofile::Identifier key) { - return m_manager->GetSigned32(out.GetPointer(), profile, key); + R_RETURN(m_manager->GetSigned32(out.GetPointer(), profile, key)); } Result ProfileReaderImpl::GetUnsigned32(sf::Out out, sprofile::Identifier profile, sprofile::Identifier key) { - return m_manager->GetUnsigned32(out.GetPointer(), profile, key); + R_RETURN(m_manager->GetUnsigned32(out.GetPointer(), profile, key)); } Result ProfileReaderImpl::GetByte(sf::Out out, sprofile::Identifier profile, sprofile::Identifier key) { - return m_manager->GetByte(out.GetPointer(), profile, key); + R_RETURN(m_manager->GetByte(out.GetPointer(), profile, key)); } } diff --git a/libraries/libstratosphere/source/sprofile/srv/sprofile_srv_service_for_bg_agent.cpp b/libraries/libstratosphere/source/sprofile/srv/sprofile_srv_service_for_bg_agent.cpp index d99891d09..c8e4e5036 100644 --- a/libraries/libstratosphere/source/sprofile/srv/sprofile_srv_service_for_bg_agent.cpp +++ b/libraries/libstratosphere/source/sprofile/srv/sprofile_srv_service_for_bg_agent.cpp @@ -92,7 +92,7 @@ namespace ams::sprofile::srv { } Result ServiceForBgAgent::Reset() { - return m_profile_manager->ResetSaveData(); + R_RETURN(m_profile_manager->ResetSaveData()); } } diff --git a/libraries/libstratosphere/source/sprofile/srv/sprofile_srv_service_for_system_process.cpp b/libraries/libstratosphere/source/sprofile/srv/sprofile_srv_service_for_system_process.cpp index aee7a533b..e569bd142 100644 --- a/libraries/libstratosphere/source/sprofile/srv/sprofile_srv_service_for_system_process.cpp +++ b/libraries/libstratosphere/source/sprofile/srv/sprofile_srv_service_for_system_process.cpp @@ -32,7 +32,7 @@ namespace ams::sprofile::srv { } Result ServiceForSystemProcess::OpenProfileUpdateObserver(sf::Out> out) { - return m_profile_manager->GetUpdateObserverManager().OpenObserver(out, m_memory_resource); + R_RETURN(m_profile_manager->GetUpdateObserverManager().OpenObserver(out, m_memory_resource)); } Result ServiceForSystemProcess::OpenProfileControllerForDebug(sf::Out> out) { diff --git a/libraries/libstratosphere/source/time/time_api.cpp b/libraries/libstratosphere/source/time/time_api.cpp index e774637ef..a3a491a59 100644 --- a/libraries/libstratosphere/source/time/time_api.cpp +++ b/libraries/libstratosphere/source/time/time_api.cpp @@ -73,18 +73,18 @@ namespace ams::time { } Result Initialize() { - return InitializeImpl(InitializeMode_Normal); + R_RETURN(InitializeImpl(InitializeMode_Normal)); } Result InitializeForSystem() { - return InitializeImpl(InitializeMode_System); + R_RETURN(InitializeImpl(InitializeMode_System)); } Result InitializeForSystemUser() { if (hos::GetVersion() >= hos::Version_9_0_0) { - return InitializeImpl(InitializeMode_SystemUser); + R_RETURN(InitializeImpl(InitializeMode_SystemUser)); } else { - return InitializeImpl(InitializeMode_Normal); + R_RETURN(InitializeImpl(InitializeMode_Normal)); } } @@ -116,7 +116,7 @@ namespace ams::time { } Result GetElapsedSecondsBetween(s64 *out, const SteadyClockTimePoint &from, const SteadyClockTimePoint &to) { - return impl::util::GetSpanBetween(out, from, to); + R_RETURN(impl::util::GetSpanBetween(out, from, to)); } } diff --git a/libraries/libstratosphere/source/time/time_standard_network_system_clock.cpp b/libraries/libstratosphere/source/time/time_standard_network_system_clock.cpp index 295a2f6e0..695d94bf3 100644 --- a/libraries/libstratosphere/source/time/time_standard_network_system_clock.cpp +++ b/libraries/libstratosphere/source/time/time_standard_network_system_clock.cpp @@ -20,7 +20,7 @@ namespace ams::time { Result StandardNetworkSystemClock::GetCurrentTime(PosixTime *out) { #if defined(ATMOSPHERE_OS_HORIZON) static_assert(sizeof(*out) == sizeof(u64)); - return ::timeGetCurrentTime(::TimeType_NetworkSystemClock, reinterpret_cast(out)); + R_RETURN(::timeGetCurrentTime(::TimeType_NetworkSystemClock, reinterpret_cast(out))); #else AMS_UNUSED(out); AMS_ABORT("TODO"); diff --git a/libraries/libstratosphere/source/time/time_standard_steady_clock.cpp b/libraries/libstratosphere/source/time/time_standard_steady_clock.cpp index 4e8496a37..869f8f714 100644 --- a/libraries/libstratosphere/source/time/time_standard_steady_clock.cpp +++ b/libraries/libstratosphere/source/time/time_standard_steady_clock.cpp @@ -20,7 +20,7 @@ namespace ams::time { Result GetStandardSteadyClockCurrentTimePoint(SteadyClockTimePoint *out) { #if defined(ATMOSPHERE_OS_HORIZON) static_assert(sizeof(*out) == sizeof(::TimeSteadyClockTimePoint)); - return ::timeGetStandardSteadyClockTimePoint(reinterpret_cast<::TimeSteadyClockTimePoint *>(out)); + R_RETURN(::timeGetStandardSteadyClockTimePoint(reinterpret_cast<::TimeSteadyClockTimePoint *>(out))); #else AMS_UNUSED(out); AMS_ABORT("TODO"); @@ -42,7 +42,7 @@ namespace ams::time { } Result StandardSteadyClock::GetCurrentTimePoint(SteadyClockTimePoint *out) { - return GetStandardSteadyClockCurrentTimePoint(out); + R_RETURN(GetStandardSteadyClockCurrentTimePoint(out)); } StandardSteadyClock::time_point StandardSteadyClock::now() { diff --git a/libraries/libstratosphere/source/time/time_standard_user_system_clock.cpp b/libraries/libstratosphere/source/time/time_standard_user_system_clock.cpp index 0663585bd..a5137d754 100644 --- a/libraries/libstratosphere/source/time/time_standard_user_system_clock.cpp +++ b/libraries/libstratosphere/source/time/time_standard_user_system_clock.cpp @@ -20,7 +20,7 @@ namespace ams::time { Result StandardUserSystemClock::GetCurrentTime(PosixTime *out) { #if defined(ATMOSPHERE_OS_HORIZON) static_assert(sizeof(*out) == sizeof(u64)); - return ::timeGetCurrentTime(::TimeType_UserSystemClock, reinterpret_cast(out)); + R_RETURN(::timeGetCurrentTime(::TimeType_UserSystemClock, reinterpret_cast(out))); #else AMS_UNUSED(out); AMS_ABORT("TODO"); diff --git a/libraries/libstratosphere/source/updater/updater_api.cpp b/libraries/libstratosphere/source/updater/updater_api.cpp index e1703c1f6..0be30741d 100644 --- a/libraries/libstratosphere/source/updater/updater_api.cpp +++ b/libraries/libstratosphere/source/updater/updater_api.cpp @@ -124,15 +124,15 @@ namespace ams::updater { } R_END_TRY_CATCH; /* We've either just verified or just repaired. Either way, we don't need to verify any more. */ - return SetVerificationNeeded(mode, work_buffer, work_buffer_size, false); + R_RETURN(SetVerificationNeeded(mode, work_buffer, work_buffer_size, false)); } Result VerifyBootImages(ncm::SystemDataId data_id, BootModeType mode, void *work_buffer, size_t work_buffer_size, BootImageUpdateType boot_image_update_type) { switch (mode) { case BootModeType::Normal: - return VerifyBootImagesNormal(data_id, work_buffer, work_buffer_size, boot_image_update_type); + R_RETURN(VerifyBootImagesNormal(data_id, work_buffer, work_buffer_size, boot_image_update_type)); case BootModeType::Safe: - return VerifyBootImagesSafe(data_id, work_buffer, work_buffer_size, boot_image_update_type); + R_RETURN(VerifyBootImagesSafe(data_id, work_buffer, work_buffer_size, boot_image_update_type)); AMS_UNREACHABLE_DEFAULT_CASE(); } } @@ -438,7 +438,7 @@ namespace ams::updater { u8 file_hash[crypto::Sha256Generator::HashSize]; crypto::GenerateSha256(file_hash, sizeof(file_hash), bct, BctSize); - return CompareHash(file_hash, stored_hash, sizeof(file_hash)); + R_RETURN(CompareHash(file_hash, stored_hash, sizeof(file_hash))); } Result GetPackage2Hash(void *dst_hash, size_t package2_size, void *work_buffer, size_t work_buffer_size, Package2Type which) { @@ -446,7 +446,7 @@ namespace ams::updater { R_TRY(accessor.Initialize()); ON_SCOPE_EXIT { accessor.Finalize(); }; - return accessor.GetHash(dst_hash, package2_size, work_buffer, work_buffer_size, Package2Partition::Package2); + R_RETURN(accessor.GetHash(dst_hash, package2_size, work_buffer, work_buffer_size, Package2Partition::Package2)); } Result WritePackage2(void *work_buffer, size_t work_buffer_size, Package2Type which, BootImageUpdateType boot_image_update_type) { @@ -454,7 +454,7 @@ namespace ams::updater { R_TRY(accessor.Initialize()); ON_SCOPE_EXIT { accessor.Finalize(); }; - return accessor.Write(GetPackage2Path(boot_image_update_type), work_buffer, work_buffer_size, Package2Partition::Package2); + R_RETURN(accessor.Write(GetPackage2Path(boot_image_update_type), work_buffer, work_buffer_size, Package2Partition::Package2)); } Result CompareHash(const void *lhs, const void *rhs, size_t size) { @@ -522,19 +522,19 @@ namespace ams::updater { } Result MarkVerifyingRequired(BootModeType mode, void *work_buffer, size_t work_buffer_size) { - return SetVerificationNeeded(mode, work_buffer, work_buffer_size, true); + R_RETURN(SetVerificationNeeded(mode, work_buffer, work_buffer_size, true)); } Result MarkVerified(BootModeType mode, void *work_buffer, size_t work_buffer_size) { - return SetVerificationNeeded(mode, work_buffer, work_buffer_size, false); + R_RETURN(SetVerificationNeeded(mode, work_buffer, work_buffer_size, false)); } Result UpdateBootImagesFromPackage(ncm::SystemDataId data_id, BootModeType mode, void *work_buffer, size_t work_buffer_size, BootImageUpdateType boot_image_update_type) { switch (mode) { case BootModeType::Normal: - return UpdateBootImagesNormal(data_id, work_buffer, work_buffer_size, boot_image_update_type); + R_RETURN(UpdateBootImagesNormal(data_id, work_buffer, work_buffer_size, boot_image_update_type)); case BootModeType::Safe: - return UpdateBootImagesSafe(data_id, work_buffer, work_buffer_size, boot_image_update_type); + R_RETURN(UpdateBootImagesSafe(data_id, work_buffer, work_buffer_size, boot_image_update_type)); AMS_UNREACHABLE_DEFAULT_CASE(); } } diff --git a/libraries/libstratosphere/source/updater/updater_bis_management.cpp b/libraries/libstratosphere/source/updater/updater_bis_management.cpp index fc94ee011..354829ed6 100644 --- a/libraries/libstratosphere/source/updater/updater_bis_management.cpp +++ b/libraries/libstratosphere/source/updater/updater_bis_management.cpp @@ -49,7 +49,7 @@ namespace ams::updater { } Result BisAccessor::Initialize() { - return fs::OpenBisPartition(std::addressof(m_storage), m_partition_id); + R_RETURN(fs::OpenBisPartition(std::addressof(m_storage), m_partition_id)); } void BisAccessor::Finalize() { @@ -58,12 +58,12 @@ namespace ams::updater { Result BisAccessor::Read(void *dst, size_t size, u64 offset) { AMS_ABORT_UNLESS((offset % SectorAlignment) == 0); - return m_storage->Read(static_cast(offset), dst, size); + R_RETURN(m_storage->Read(static_cast(offset), dst, size)); } Result BisAccessor::Write(u64 offset, const void *src, size_t size) { AMS_ABORT_UNLESS((offset % SectorAlignment) == 0); - return m_storage->Write(static_cast(offset), src, size); + R_RETURN(m_storage->Write(static_cast(offset), src, size)); } Result BisAccessor::Write(u64 offset, size_t size, const char *bip_path, void *work_buffer, size_t work_buffer_size) { @@ -149,7 +149,7 @@ namespace ams::updater { size_t read_size; R_TRY(this->Read(&read_size, eks_work_buffer, EksSize, Boot0Partition::Eks)); - return this->UpdateEksManually(dst_bct, eks_work_buffer); + R_RETURN(this->UpdateEksManually(dst_bct, eks_work_buffer)); } Result Boot0Accessor::UpdateEksManually(void *dst_bct, const void *src_eks) { diff --git a/libraries/libstratosphere/source/updater/updater_bis_management.hpp b/libraries/libstratosphere/source/updater/updater_bis_management.hpp index 2d6039f01..8a6e978ee 100644 --- a/libraries/libstratosphere/source/updater/updater_bis_management.hpp +++ b/libraries/libstratosphere/source/updater/updater_bis_management.hpp @@ -140,32 +140,31 @@ namespace ams::updater { const auto entry = FindEntry(which); AMS_ABORT_UNLESS(size >= entry->size); - R_TRY(BisAccessor::Read(dst, entry->size, entry->offset)); + ON_RESULT_SUCCESS { *out_size = entry->size; }; - *out_size = entry->size; - R_SUCCEED(); + R_RETURN(BisAccessor::Read(dst, entry->size, entry->offset)); } Result Write(const void *src, size_t size, EnumType which) { const auto entry = FindEntry(which); AMS_ABORT_UNLESS(size <= entry->size); AMS_ABORT_UNLESS((size % BisAccessor::SectorAlignment) == 0); - return BisAccessor::Write(entry->offset, src, size); + R_RETURN(BisAccessor::Write(entry->offset, src, size)); } Result Write(const char *bip_path, void *work_buffer, size_t work_buffer_size, EnumType which) { const auto entry = FindEntry(which); - return BisAccessor::Write(entry->offset, entry->size, bip_path, work_buffer, work_buffer_size); + R_RETURN(BisAccessor::Write(entry->offset, entry->size, bip_path, work_buffer, work_buffer_size)); } Result Clear(void *work_buffer, size_t work_buffer_size, EnumType which) { const auto entry = FindEntry(which); - return BisAccessor::Clear(entry->offset, entry->size, work_buffer, work_buffer_size); + R_RETURN(BisAccessor::Clear(entry->offset, entry->size, work_buffer, work_buffer_size)); } Result GetHash(void *dst, u64 hash_size, void *work_buffer, size_t work_buffer_size, EnumType which) { const auto entry = FindEntry(which); - return BisAccessor::GetHash(dst, entry->offset, entry->size, hash_size, work_buffer, work_buffer_size); + R_RETURN(BisAccessor::GetHash(dst, entry->offset, entry->size, hash_size, work_buffer, work_buffer_size)); } }; diff --git a/libraries/libstratosphere/source/updater/updater_bis_save.cpp b/libraries/libstratosphere/source/updater/updater_bis_save.cpp index 085bb9537..666ab79f8 100644 --- a/libraries/libstratosphere/source/updater/updater_bis_save.cpp +++ b/libraries/libstratosphere/source/updater/updater_bis_save.cpp @@ -45,11 +45,11 @@ namespace ams::updater { Result BisSave::Load() { size_t read_size; - return m_accessor.Read(std::addressof(read_size), m_save_buffer, SaveSize, Boot0Partition::BctSave); + R_RETURN(m_accessor.Read(std::addressof(read_size), m_save_buffer, SaveSize, Boot0Partition::BctSave)); } Result BisSave::Save() { - return m_accessor.Write(m_save_buffer, SaveSize, Boot0Partition::BctSave); + R_RETURN(m_accessor.Write(m_save_buffer, SaveSize, Boot0Partition::BctSave)); } bool BisSave::GetNeedsVerification(BootModeType mode) { diff --git a/libraries/libstratosphere/source/updater/updater_files.cpp b/libraries/libstratosphere/source/updater/updater_files.cpp index da22ba6cc..15cf0df7c 100644 --- a/libraries/libstratosphere/source/updater/updater_files.cpp +++ b/libraries/libstratosphere/source/updater/updater_files.cpp @@ -27,7 +27,7 @@ namespace ams::updater { ON_SCOPE_EXIT { fs::CloseFile(file); }; std::memset(dst, 0, dst_size); - return fs::ReadFile(out_size, file, 0, dst, dst_size, fs::ReadOption()); + R_RETURN(fs::ReadFile(out_size, file, 0, dst, dst_size, fs::ReadOption())); } Result GetFileHash(size_t *out_size, void *dst_hash, const char *path, void *work_buffer, size_t work_buffer_size) { diff --git a/libraries/libstratosphere/source/usb/usb_device.cpp b/libraries/libstratosphere/source/usb/usb_device.cpp index 17d6feb91..15a01d111 100644 --- a/libraries/libstratosphere/source/usb/usb_device.cpp +++ b/libraries/libstratosphere/source/usb/usb_device.cpp @@ -176,27 +176,27 @@ namespace ams::usb { /* Check that we have a service. */ AMS_ABORT_UNLESS(m_ds_service != nullptr); - return m_ds_service->GetState(out); + R_RETURN(m_ds_service->GetState(out)); } Result DsClient::ClearDeviceData() { - return m_ds_service->ClearDeviceData(); + R_RETURN(m_ds_service->ClearDeviceData()); } Result DsClient::AddUsbStringDescriptor(u8 *out_index, UsbStringDescriptor *desc) { - return m_ds_service->AddUsbStringDescriptor(out_index, sf::InBuffer(reinterpret_cast(desc), sizeof(*desc))); + R_RETURN(m_ds_service->AddUsbStringDescriptor(out_index, sf::InBuffer(reinterpret_cast(desc), sizeof(*desc)))); } Result DsClient::DeleteUsbStringDescriptor(u8 index) { - return m_ds_service->DeleteUsbStringDescriptor(index); + R_RETURN(m_ds_service->DeleteUsbStringDescriptor(index)); } Result DsClient::SetUsbDeviceDescriptor(UsbDeviceDescriptor *desc, UsbDeviceSpeed speed) { - return m_ds_service->SetUsbDeviceDescriptor(sf::InBuffer(reinterpret_cast(desc), sizeof(*desc)), speed); + R_RETURN(m_ds_service->SetUsbDeviceDescriptor(sf::InBuffer(reinterpret_cast(desc), sizeof(*desc)), speed)); } Result DsClient::SetBinaryObjectStore(u8 *data, int size) { - return m_ds_service->SetBinaryObjectStore(sf::InBuffer(reinterpret_cast(data), size)); + R_RETURN(m_ds_service->SetBinaryObjectStore(sf::InBuffer(reinterpret_cast(data), size))); } Result DsClient::AddInterface(DsInterface *intf, sf::SharedPointer *out_srv, uint8_t bInterfaceNumber) { @@ -326,7 +326,7 @@ namespace ams::usb { } Result DsInterface::AppendConfigurationData(UsbDeviceSpeed speed, void *data, u32 size) { - return m_interface->AppendConfigurationData(m_interface_num, speed, sf::InBuffer(data, size)); + R_RETURN(m_interface->AppendConfigurationData(m_interface_num, speed, sf::InBuffer(data, size))); } bool DsInterface::IsInitialized() { @@ -350,7 +350,7 @@ namespace ams::usb { /* Check that we have a service. */ AMS_ABORT_UNLESS(m_interface != nullptr); - return m_interface->GetSetupPacket(sf::OutBuffer(out, sizeof(*out))); + R_RETURN(m_interface->GetSetupPacket(sf::OutBuffer(out, sizeof(*out)))); } Result DsInterface::Enable() { @@ -561,12 +561,12 @@ namespace ams::usb { result = this->CtrlIn(nullptr, nullptr, 0); } - /* If we failed, stall. */ + /* If we fail, stall. */ if (R_FAILED(result)) { result = this->CtrlStall(); } - return result; + R_RETURN(result); } Result DsInterface::CtrlWrite(u32 *out_transferred, void *dst, u32 size) { @@ -589,7 +589,7 @@ namespace ams::usb { result = this->CtrlStall(); } - return result; + R_RETURN(result); } Result DsInterface::CtrlDone() { @@ -607,7 +607,7 @@ namespace ams::usb { result = this->CtrlStall(); } - return result; + R_RETURN(result); } Result DsInterface::CtrlStall() { @@ -623,7 +623,7 @@ namespace ams::usb { /* Check that we have a service. */ AMS_ABORT_UNLESS(m_interface != nullptr); - return m_interface->CtrlStall(); + R_RETURN(m_interface->CtrlStall()); } Result DsEndpoint::Initialize(DsInterface *interface, u8 bEndpointAddress) { @@ -783,7 +783,7 @@ namespace ams::usb { /* Check that we have a service. */ AMS_ABORT_UNLESS(m_endpoint != nullptr); - return m_endpoint->GetUrbReport(out); + R_RETURN(m_endpoint->GetUrbReport(out)); } Result DsEndpoint::Cancel() { @@ -796,7 +796,7 @@ namespace ams::usb { /* Check that we have a service. */ AMS_ABORT_UNLESS(m_endpoint != nullptr); - return m_endpoint->Cancel(); + R_RETURN(m_endpoint->Cancel()); } Result DsEndpoint::SetZeroLengthTransfer(bool zlt) { @@ -809,7 +809,7 @@ namespace ams::usb { /* Check that we have a service. */ AMS_ABORT_UNLESS(m_endpoint != nullptr); - return m_endpoint->SetZlt(zlt); + R_RETURN(m_endpoint->SetZlt(zlt)); } } diff --git a/libraries/libstratosphere/source/usb/usb_remote_ds_endpoint.cpp b/libraries/libstratosphere/source/usb/usb_remote_ds_endpoint.cpp index 61d80d4fb..ef2844235 100644 --- a/libraries/libstratosphere/source/usb/usb_remote_ds_endpoint.cpp +++ b/libraries/libstratosphere/source/usb/usb_remote_ds_endpoint.cpp @@ -26,12 +26,12 @@ namespace ams::usb { } in = { size, address }; serviceAssumeDomain(std::addressof(m_srv)); - return serviceDispatchInOut(std::addressof(m_srv), 0, in, *out_urb_id); + R_RETURN(serviceDispatchInOut(std::addressof(m_srv), 0, in, *out_urb_id)); } Result RemoteDsEndpoint::Cancel() { serviceAssumeDomain(std::addressof(m_srv)); - return serviceDispatch(std::addressof(m_srv), 1); + R_RETURN(serviceDispatch(std::addressof(m_srv), 1)); } Result RemoteDsEndpoint::GetCompletionEvent(sf::OutCopyHandle out) { @@ -49,19 +49,19 @@ namespace ams::usb { Result RemoteDsEndpoint::GetUrbReport(sf::Out out) { serviceAssumeDomain(std::addressof(m_srv)); - return serviceDispatchOut(std::addressof(m_srv), 3, *out); + R_RETURN(serviceDispatchOut(std::addressof(m_srv), 3, *out)); } Result RemoteDsEndpoint::Stall() { serviceAssumeDomain(std::addressof(m_srv)); - return serviceDispatch(std::addressof(m_srv), 4); + R_RETURN(serviceDispatch(std::addressof(m_srv), 4)); } Result RemoteDsEndpoint::SetZlt(bool zlt) { const u8 in = zlt ? 1 : 0; serviceAssumeDomain(std::addressof(m_srv)); - return serviceDispatchIn(std::addressof(m_srv), 5, in); + R_RETURN(serviceDispatchIn(std::addressof(m_srv), 5, in)); } #endif diff --git a/libraries/libstratosphere/source/usb/usb_remote_ds_interface.cpp b/libraries/libstratosphere/source/usb/usb_remote_ds_interface.cpp index a41855b8c..aadcb08e2 100644 --- a/libraries/libstratosphere/source/usb/usb_remote_ds_interface.cpp +++ b/libraries/libstratosphere/source/usb/usb_remote_ds_interface.cpp @@ -62,7 +62,7 @@ namespace ams::usb { } in = { size, address }; serviceAssumeDomain(std::addressof(m_srv)); - return serviceDispatchInOut(std::addressof(m_srv), hos::GetVersion() >= hos::Version_11_0_0 ? 3 : 5, in, *out_urb_id); + R_RETURN(serviceDispatchInOut(std::addressof(m_srv), hos::GetVersion() >= hos::Version_11_0_0 ? 3 : 5, in, *out_urb_id)); } Result RemoteDsInterface::CtrlOutAsync(sf::Out out_urb_id, u64 address, u32 size) { @@ -72,7 +72,7 @@ namespace ams::usb { } in = { size, address }; serviceAssumeDomain(std::addressof(m_srv)); - return serviceDispatchInOut(std::addressof(m_srv), hos::GetVersion() >= hos::Version_11_0_0 ? 4 : 6, in, *out_urb_id); + R_RETURN(serviceDispatchInOut(std::addressof(m_srv), hos::GetVersion() >= hos::Version_11_0_0 ? 4 : 6, in, *out_urb_id)); } Result RemoteDsInterface::GetCtrlInCompletionEvent(sf::OutCopyHandle out) { @@ -90,7 +90,7 @@ namespace ams::usb { Result RemoteDsInterface::GetCtrlInUrbReport(sf::Out out) { serviceAssumeDomain(std::addressof(m_srv)); - return serviceDispatchOut(std::addressof(m_srv), hos::GetVersion() >= hos::Version_11_0_0 ? 6 : 8, *out); + R_RETURN(serviceDispatchOut(std::addressof(m_srv), hos::GetVersion() >= hos::Version_11_0_0 ? 6 : 8, *out)); } Result RemoteDsInterface::GetCtrlOutCompletionEvent(sf::OutCopyHandle out) { @@ -108,12 +108,12 @@ namespace ams::usb { Result RemoteDsInterface::GetCtrlOutUrbReport(sf::Out out) { serviceAssumeDomain(std::addressof(m_srv)); - return serviceDispatchOut(std::addressof(m_srv), hos::GetVersion() >= hos::Version_11_0_0 ? 8 : 10, *out); + R_RETURN(serviceDispatchOut(std::addressof(m_srv), hos::GetVersion() >= hos::Version_11_0_0 ? 8 : 10, *out)); } Result RemoteDsInterface::CtrlStall() { serviceAssumeDomain(std::addressof(m_srv)); - return serviceDispatch(std::addressof(m_srv), hos::GetVersion() >= hos::Version_11_0_0 ? 9 : 11); + R_RETURN(serviceDispatch(std::addressof(m_srv), hos::GetVersion() >= hos::Version_11_0_0 ? 9 : 11)); } Result RemoteDsInterface::AppendConfigurationData(u8 bInterfaceNumber, usb::UsbDeviceSpeed device_speed, const sf::InBuffer &data) { @@ -141,14 +141,14 @@ namespace ams::usb { R_SUCCEED_IF(hos::GetVersion() >= hos::Version_11_0_0); serviceAssumeDomain(std::addressof(m_srv)); - return serviceDispatch(std::addressof(m_srv), 3); + R_RETURN(serviceDispatch(std::addressof(m_srv), 3)); } Result RemoteDsInterface::Disable() { R_SUCCEED_IF(hos::GetVersion() >= hos::Version_11_0_0); serviceAssumeDomain(std::addressof(m_srv)); - return serviceDispatch(std::addressof(m_srv), 3); + R_RETURN(serviceDispatch(std::addressof(m_srv), 3)); } #endif diff --git a/libraries/libstratosphere/source/usb/usb_remote_ds_service.cpp b/libraries/libstratosphere/source/usb/usb_remote_ds_service.cpp index 1baea6642..817563fe9 100644 --- a/libraries/libstratosphere/source/usb/usb_remote_ds_service.cpp +++ b/libraries/libstratosphere/source/usb/usb_remote_ds_service.cpp @@ -70,12 +70,12 @@ namespace ams::usb { Result RemoteDsService::GetState(sf::Out out) { serviceAssumeDomain(std::addressof(m_srv)); - return serviceDispatchOut(std::addressof(m_srv), hos::GetVersion() >= hos::Version_11_0_0 ? 3 : 4, *out); + R_RETURN(serviceDispatchOut(std::addressof(m_srv), hos::GetVersion() >= hos::Version_11_0_0 ? 3 : 4, *out)); } Result RemoteDsService::ClearDeviceData() { serviceAssumeDomain(std::addressof(m_srv)); - return serviceDispatch(std::addressof(m_srv), hos::GetVersion() >= hos::Version_11_0_0 ? 4 : 5); + R_RETURN(serviceDispatch(std::addressof(m_srv), hos::GetVersion() >= hos::Version_11_0_0 ? 4 : 5)); } Result RemoteDsService::AddUsbStringDescriptor(sf::Out out, const sf::InBuffer &desc) { @@ -88,7 +88,7 @@ namespace ams::usb { Result RemoteDsService::DeleteUsbStringDescriptor(u8 index) { serviceAssumeDomain(std::addressof(m_srv)); - return serviceDispatchIn(std::addressof(m_srv), hos::GetVersion() >= hos::Version_11_0_0 ? 6 : 7, index); + R_RETURN(serviceDispatchIn(std::addressof(m_srv), hos::GetVersion() >= hos::Version_11_0_0 ? 6 : 7, index)); } Result RemoteDsService::SetUsbDeviceDescriptor(const sf::InBuffer &desc, usb::UsbDeviceSpeed speed) { @@ -109,12 +109,12 @@ namespace ams::usb { Result RemoteDsService::Enable() { serviceAssumeDomain(std::addressof(m_srv)); - return serviceDispatch(std::addressof(m_srv), hos::GetVersion() >= hos::Version_11_0_0 ? 9 : 10); + R_RETURN(serviceDispatch(std::addressof(m_srv), hos::GetVersion() >= hos::Version_11_0_0 ? 9 : 10)); } Result RemoteDsService::Disable() { serviceAssumeDomain(std::addressof(m_srv)); - return serviceDispatch(std::addressof(m_srv), hos::GetVersion() >= hos::Version_11_0_0 ? 10 : 11); + R_RETURN(serviceDispatch(std::addressof(m_srv), hos::GetVersion() >= hos::Version_11_0_0 ? 10 : 11)); } #endif diff --git a/libraries/libvapours/include/vapours/results/results_common.hpp b/libraries/libvapours/include/vapours/results/results_common.hpp index 2ddbf37dd..b6fcf9c9a 100644 --- a/libraries/libvapours/include/vapours/results/results_common.hpp +++ b/libraries/libvapours/include/vapours/results/results_common.hpp @@ -431,7 +431,7 @@ namespace ams::result::impl { /* =================================================================== */ /// Returns a result. -#define R_THROW(res_expr) \ +#define R_RETURN(res_expr) \ { \ const ::ams::Result _tmp_r_throw_rc = (res_expr); \ if constexpr (std::same_as) { __TmpCurrentResultReference = _tmp_r_throw_rc; } \ @@ -439,7 +439,10 @@ namespace ams::result::impl { } /// Returns ResultSuccess() -#define R_SUCCEED() R_THROW(::ams::ResultSuccess()) +#define R_SUCCEED() R_RETURN(::ams::ResultSuccess()) + +/// Throws a result. +#define R_THROW(res_expr) R_RETURN(res_expr) /// Evaluates an expression that returns a result, and returns the result if it would fail. #define R_TRY(res_expr) \ @@ -449,9 +452,6 @@ namespace ams::result::impl { } \ } -/// Return a result. -#define R_RETURN(res_expr) R_THROW(res_expr) - #if defined(ATMOSPHERE_BOARD_NINTENDO_NX) && defined(ATMOSPHERE_IS_STRATOSPHERE) && !defined(AMS_ENABLE_DETAILED_ASSERTIONS) && !defined(AMS_BUILD_FOR_DEBUGGING) && !defined(AMS_BUILD_FOR_AUDITING) #define AMS_CALL_ON_RESULT_ASSERTION_IMPL(cond, val) do { ::ams::diag::impl::FatalErrorByResultForNx(val); AMS_INFINITE_LOOP(); AMS_ASSUME(false); } while (false) #define AMS_CALL_ON_RESULT_ABORT_IMPL(cond, val) do { ::ams::diag::impl::FatalErrorByResultForNx(val); AMS_INFINITE_LOOP(); AMS_ASSUME(false); } while (false) diff --git a/libraries/libvapours/source/sdmmc/impl/sdmmc_base_device_accessor.cpp b/libraries/libvapours/source/sdmmc/impl/sdmmc_base_device_accessor.cpp index 71a0cdf7b..75e8fe366 100644 --- a/libraries/libvapours/source/sdmmc/impl/sdmmc_base_device_accessor.cpp +++ b/libraries/libvapours/source/sdmmc/impl/sdmmc_base_device_accessor.cpp @@ -131,7 +131,7 @@ namespace ams::sdmmc::impl { Result BaseDeviceAccessor::IssueCommandGoIdleState() const { /* Issue the command. */ Command command(CommandIndex_GoIdleState, 0, ResponseType_R0, false); - return m_host_controller->IssueCommand(std::addressof(command)); + R_RETURN(m_host_controller->IssueCommand(std::addressof(command))); } Result BaseDeviceAccessor::IssueCommandAllSendCid(void *dst, size_t dst_size) const { @@ -155,7 +155,7 @@ namespace ams::sdmmc::impl { const u32 arg = static_cast(m_base_device->GetRca()) << 16; /* Issue the command. */ - return this->IssueCommandAndCheckR1(CommandIndex_SelectCard, arg, true, DeviceState_Unknown); + R_RETURN(this->IssueCommandAndCheckR1(CommandIndex_SelectCard, arg, true, DeviceState_Unknown)); } Result BaseDeviceAccessor::IssueCommandSendCsd(void *dst, size_t dst_size) const { @@ -183,12 +183,12 @@ namespace ams::sdmmc::impl { const u32 arg = static_cast(m_base_device->GetRca()) << 16; /* Issue the command. */ - return this->IssueCommandAndCheckR1(out_device_status, CommandIndex_SendStatus, arg, false, DeviceState_Tran, status_ignore_mask); + R_RETURN(this->IssueCommandAndCheckR1(out_device_status, CommandIndex_SendStatus, arg, false, DeviceState_Tran, status_ignore_mask)); } Result BaseDeviceAccessor::IssueCommandSetBlockLenToSectorSize() const { /* Issue the command. */ - return this->IssueCommandAndCheckR1(CommandIndex_SetBlockLen, SectorSize, false, DeviceState_Tran); + R_RETURN(this->IssueCommandAndCheckR1(CommandIndex_SetBlockLen, SectorSize, false, DeviceState_Tran)); } Result BaseDeviceAccessor::IssueCommandMultipleBlock(u32 *out_num_transferred_blocks, u32 sector_index, u32 num_sectors, void *buf, bool is_read) const { @@ -237,7 +237,7 @@ namespace ams::sdmmc::impl { } /* Return the result we chose. */ - return result_to_return; + R_RETURN(result_to_return); } /* Get the responses. */ @@ -339,7 +339,7 @@ namespace ams::sdmmc::impl { if (R_FAILED(result)) { /* Log that we failed after a re-startup. */ this->PushErrorLog(true, "%s %X %X:%X", is_read ? "R" : "W", cur_sector_index, cur_sectors, result.GetValue()); - return result; + R_RETURN(result); } /* Log that we succeeded after a retry. */ diff --git a/libraries/libvapours/source/sdmmc/impl/sdmmc_base_device_accessor.hpp b/libraries/libvapours/source/sdmmc/impl/sdmmc_base_device_accessor.hpp index d31dce079..be263739b 100644 --- a/libraries/libvapours/source/sdmmc/impl/sdmmc_base_device_accessor.hpp +++ b/libraries/libvapours/source/sdmmc/impl/sdmmc_base_device_accessor.hpp @@ -419,18 +419,18 @@ namespace ams::sdmmc::impl { } Result CheckRemoved() const { - return m_base_device->CheckRemoved(); + R_RETURN(m_base_device->CheckRemoved()); } Result IssueCommandAndCheckR1(u32 *out_response, u32 command_index, u32 command_arg, bool is_busy, DeviceState expected_state, u32 status_ignore_mask) const; Result IssueCommandAndCheckR1(u32 command_index, u32 command_arg, bool is_busy, DeviceState expected_state, u32 status_ignore_mask) const { u32 dummy; - return this->IssueCommandAndCheckR1(std::addressof(dummy), command_index, command_arg, is_busy, expected_state, status_ignore_mask); + R_RETURN(this->IssueCommandAndCheckR1(std::addressof(dummy), command_index, command_arg, is_busy, expected_state, status_ignore_mask)); } Result IssueCommandAndCheckR1(u32 command_index, u32 command_arg, bool is_busy, DeviceState expected_state) const { - return this->IssueCommandAndCheckR1(command_index, command_arg, is_busy, expected_state, 0); + R_RETURN(this->IssueCommandAndCheckR1(command_index, command_arg, is_busy, expected_state, 0)); } Result IssueCommandGoIdleState() const; @@ -441,11 +441,11 @@ namespace ams::sdmmc::impl { Result IssueCommandSendStatus(u32 status_ignore_mask) const { u32 dummy; - return this->IssueCommandSendStatus(std::addressof(dummy), status_ignore_mask); + R_RETURN(this->IssueCommandSendStatus(std::addressof(dummy), status_ignore_mask)); } Result IssueCommandSendStatus() const { - return this->IssueCommandSendStatus(0); + R_RETURN(this->IssueCommandSendStatus(0)); } Result IssueCommandSetBlockLenToSectorSize() const; diff --git a/libraries/libvapours/source/sdmmc/impl/sdmmc_gc_asic_device_accessor.cpp b/libraries/libvapours/source/sdmmc/impl/sdmmc_gc_asic_device_accessor.cpp index 6c18f3e9f..919461d08 100644 --- a/libraries/libvapours/source/sdmmc/impl/sdmmc_gc_asic_device_accessor.cpp +++ b/libraries/libvapours/source/sdmmc/impl/sdmmc_gc_asic_device_accessor.cpp @@ -88,7 +88,7 @@ namespace ams::sdmmc::impl { return_result = result; } } - return return_result; + R_RETURN(return_result); } /* Get the response. */ diff --git a/libraries/libvapours/source/sdmmc/impl/sdmmc_i_host_controller.hpp b/libraries/libvapours/source/sdmmc/impl/sdmmc_i_host_controller.hpp index 920c5669d..5df6ede72 100644 --- a/libraries/libvapours/source/sdmmc/impl/sdmmc_i_host_controller.hpp +++ b/libraries/libvapours/source/sdmmc/impl/sdmmc_i_host_controller.hpp @@ -177,11 +177,11 @@ namespace ams::sdmmc::impl { virtual Result IssueStopTransmissionCommand(u32 *out_response) = 0; ALWAYS_INLINE Result IssueCommand(const Command *command, TransferData *xfer_data) { - return this->IssueCommand(command, xfer_data, nullptr); + R_RETURN(this->IssueCommand(command, xfer_data, nullptr)); } ALWAYS_INLINE Result IssueCommand(const Command *command) { - return this->IssueCommand(command, nullptr, nullptr); + R_RETURN(this->IssueCommand(command, nullptr, nullptr)); } virtual void GetLastResponse(u32 *out_response, size_t response_size, ResponseType response_type) const = 0; diff --git a/libraries/libvapours/source/sdmmc/impl/sdmmc_mmc_device_accessor.cpp b/libraries/libvapours/source/sdmmc/impl/sdmmc_mmc_device_accessor.cpp index 790bca026..2e2b84292 100644 --- a/libraries/libvapours/source/sdmmc/impl/sdmmc_mmc_device_accessor.cpp +++ b/libraries/libvapours/source/sdmmc/impl/sdmmc_mmc_device_accessor.cpp @@ -357,15 +357,15 @@ namespace ams::sdmmc::impl { IHostController *hc = BaseDeviceAccessor::GetHostController(); if (hc->IsSupportedTuning() && hc->GetBusPower() == BusPower_1_8V) { if (hc->GetBusWidth() == BusWidth_8Bit && IsSupportedHs400(device_type) && max_sm == SpeedMode_MmcHs400) { - return this->ChangeToHs400(); + R_RETURN(this->ChangeToHs400()); } else if ((hc->GetBusWidth() == BusWidth_8Bit || hc->GetBusWidth() == BusWidth_4Bit) && IsSupportedHs200(device_type) && (max_sm == SpeedMode_MmcHs400 || max_sm == SpeedMode_MmcHs200)) { - return this->ChangeToHs200(); + R_RETURN(this->ChangeToHs200()); } } /* Check if we can switch to high speed. */ if (IsSupportedHighSpeed(device_type)) { - return this->ChangeToHighSpeed(true); + R_RETURN(this->ChangeToHighSpeed(true)); } /* We can't, so stay at normal speeds. */ @@ -492,7 +492,7 @@ namespace ams::sdmmc::impl { /* We failed to start up with all sets of parameters. */ BaseDeviceAccessor::PushErrorTimeStamp(); - return result; + R_RETURN(result); } Result MmcDeviceAccessor::OnReadWrite(u32 sector_index, u32 num_sectors, void *buf, size_t buf_size, bool is_read) { @@ -505,7 +505,7 @@ namespace ams::sdmmc::impl { } /* Do the read/write. */ - return BaseDeviceAccessor::ReadWriteMultiple(sector_index, num_sectors, sector_index_alignment, buf, buf_size, is_read); + R_RETURN(BaseDeviceAccessor::ReadWriteMultiple(sector_index, num_sectors, sector_index_alignment, buf, buf_size, is_read)); } Result MmcDeviceAccessor::ReStartup() { @@ -516,7 +516,7 @@ namespace ams::sdmmc::impl { Result result = this->StartupMmcDevice(m_max_bus_width, m_max_speed_mode, m_work_buffer, m_work_buffer_size); if (R_FAILED(result)) { BaseDeviceAccessor::PushErrorLog(false, "S %d %d:%X", m_max_bus_width, m_max_speed_mode, result.GetValue()); - return result; + R_RETURN(result); } R_SUCCEED(); @@ -676,7 +676,7 @@ namespace ams::sdmmc::impl { /* Otherwise, check if we should reject the error. */ if (!sdmmc::ResultUnexpectedDeviceState::Includes(result)) { - return result; + R_RETURN(result); } /* Check if timeout has been exceeded. */ diff --git a/libraries/libvapours/source/sdmmc/impl/sdmmc_sd_card_device_accessor.cpp b/libraries/libvapours/source/sdmmc/impl/sdmmc_sd_card_device_accessor.cpp index e611159a7..113c5dddf 100644 --- a/libraries/libvapours/source/sdmmc/impl/sdmmc_sd_card_device_accessor.cpp +++ b/libraries/libvapours/source/sdmmc/impl/sdmmc_sd_card_device_accessor.cpp @@ -709,7 +709,7 @@ namespace ams::sdmmc::impl { } #endif - return result; + R_RETURN(result); } Result SdCardDeviceAccessor::OnReadWrite(u32 sector_index, u32 num_sectors, void *buf, size_t buf_size, bool is_read) { @@ -724,7 +724,7 @@ namespace ams::sdmmc::impl { } #endif - return result; + R_RETURN(result); } Result SdCardDeviceAccessor::ReStartup() { @@ -737,7 +737,7 @@ namespace ams::sdmmc::impl { AMS_SDMMC_CHECK_SD_CARD_REMOVED(); BaseDeviceAccessor::PushErrorLog(false, "S %d %d:%X", m_max_bus_width, m_max_speed_mode, result.GetValue()); - return result; + R_RETURN(result); } R_SUCCEED(); @@ -825,7 +825,7 @@ namespace ams::sdmmc::impl { #endif /* Activate the base device. */ - return BaseDeviceAccessor::Activate(); + R_RETURN(BaseDeviceAccessor::Activate()); } Result SdCardDeviceAccessor::GetSpeedMode(SpeedMode *out_speed_mode) const { diff --git a/libraries/libvapours/source/sdmmc/impl/sdmmc_sd_host_standard_controller.cpp b/libraries/libvapours/source/sdmmc/impl/sdmmc_sd_host_standard_controller.cpp index 540203a29..35b3a3907 100644 --- a/libraries/libvapours/source/sdmmc/impl/sdmmc_sd_host_standard_controller.cpp +++ b/libraries/libvapours/source/sdmmc/impl/sdmmc_sd_host_standard_controller.cpp @@ -461,10 +461,10 @@ namespace ams::sdmmc::impl { this->AbortTransaction(); } - return result; + R_RETURN(result); } else if (sdmmc::ResultDeviceRemoved::Includes(result)) { /* Otherwise, check if the device was removed. */ - return result; + R_RETURN(result); } else { /* If the device wasn't removed, cancel our transaction. */ this->AbortTransaction(); @@ -495,7 +495,7 @@ namespace ams::sdmmc::impl { } else { /* Otherwise, we have a generic failure. */ this->AbortTransaction(); - return result; + R_RETURN(result); } } } @@ -538,13 +538,13 @@ namespace ams::sdmmc::impl { } else { /* Abort the transaction. */ this->AbortTransaction(); - return result; + R_RETURN(result); } - return result; + R_RETURN(result); } else if (sdmmc::ResultDeviceRemoved::Includes(result)) { /* Otherwise, check if the device was removed. */ - return result; + R_RETURN(result); } else { /* Otherwise, timeout if the transfer hasn't advanced. */ if (last_block_count != reg::Read(m_registers->block_count)) { @@ -597,7 +597,7 @@ namespace ams::sdmmc::impl { } else { /* Otherwise, we have a generic failure. */ this->AbortTransaction(); - return result; + R_RETURN(result); } } } @@ -967,7 +967,7 @@ namespace ams::sdmmc::impl { /* After we issue the command, we need to wait 8 device clocks. */ ON_SCOPE_EXIT { WaitClocks(8, m_device_clock_frequency_khz); }; - return this->IssueCommandWithDeviceClock(command, xfer_data, out_num_transferred_blocks); + R_RETURN(this->IssueCommandWithDeviceClock(command, xfer_data, out_num_transferred_blocks)); } } @@ -996,7 +996,7 @@ namespace ams::sdmmc::impl { /* After we issue the command, we need to wait 8 device clocks. */ ON_SCOPE_EXIT { WaitClocks(8, m_device_clock_frequency_khz); }; - return this->IssueStopTransmissionCommandWithDeviceClock(out_response); + R_RETURN(this->IssueStopTransmissionCommandWithDeviceClock(out_response)); } } diff --git a/libraries/libvapours/source/sdmmc/impl/sdmmc_sdmmc_controller.board.nintendo_nx.cpp b/libraries/libvapours/source/sdmmc/impl/sdmmc_sdmmc_controller.board.nintendo_nx.cpp index f16467e38..e86240833 100644 --- a/libraries/libvapours/source/sdmmc/impl/sdmmc_sdmmc_controller.board.nintendo_nx.cpp +++ b/libraries/libvapours/source/sdmmc/impl/sdmmc_sdmmc_controller.board.nintendo_nx.cpp @@ -499,7 +499,7 @@ namespace ams::sdmmc::impl { SdHostStandardController::AbortTransaction(); R_THROW(sdmmc::ResultIssueTuningCommandSoftwareTimeout()); } else { - return result; + R_RETURN(result); } } #else @@ -804,7 +804,7 @@ namespace ams::sdmmc::impl { this->CalibrateDriveStrength(SdHostStandardController::GetBusPower()); } - return SdHostStandardController::IssueCommand(command, xfer_data, out_num_transferred_blocks); + R_RETURN(SdHostStandardController::IssueCommand(command, xfer_data, out_num_transferred_blocks)); } Result SdmmcController::IssueStopTransmissionCommand(u32 *out_response) { @@ -813,7 +813,7 @@ namespace ams::sdmmc::impl { this->CalibrateDriveStrength(SdHostStandardController::GetBusPower()); } - return SdHostStandardController::IssueStopTransmissionCommand(out_response); + R_RETURN(SdHostStandardController::IssueStopTransmissionCommand(out_response)); } Result SdmmcController::Tuning(SpeedMode speed_mode, u32 command_index) { @@ -957,7 +957,7 @@ namespace ams::sdmmc::impl { /* Nintendo sets the current bus power regardless of whether the call succeeds. */ ON_SCOPE_EXIT { m_current_bus_power = BusPower_3_3V; }; - /* TODO: return pcv::PowerOn(pcv::PowerControlTarget_SdCard, 3300000); */ + /* TODO: R_RETURN(pcv::PowerOn(pcv::PowerControlTarget_SdCard, 3300000)); */ R_SUCCEED(); } @@ -986,7 +986,7 @@ namespace ams::sdmmc::impl { /* Nintendo sets the current bus power regardless of whether the call succeeds. */ ON_SCOPE_EXIT { m_current_bus_power = BusPower_1_8V; }; - /* TODO: return pcv::ChangeVoltage(pcv::PowerControlTarget_SdCard, 1800000); */ + /* TODO: R_RETURN(pcv::ChangeVoltage(pcv::PowerControlTarget_SdCard, 1800000)); */ R_SUCCEED(); } @@ -1013,11 +1013,11 @@ namespace ams::sdmmc::impl { Result Sdmmc1Controller::PowerOn(BusPower bus_power) { #if defined(AMS_SDMMC_USE_PCV_CLOCK_RESET_CONTROL) if (m_is_pcv_control) { - return this->PowerOnForPcvControl(bus_power); + R_RETURN(this->PowerOnForPcvControl(bus_power)); } else #endif { - return this->PowerOnForRegisterControl(bus_power); + R_RETURN(this->PowerOnForRegisterControl(bus_power)); } } @@ -1035,11 +1035,11 @@ namespace ams::sdmmc::impl { Result Sdmmc1Controller::LowerBusPower() { #if defined(AMS_SDMMC_USE_PCV_CLOCK_RESET_CONTROL) if (m_is_pcv_control) { - return this->LowerBusPowerForPcvControl(); + R_RETURN(this->LowerBusPowerForPcvControl()); } else #endif { - return this->LowerBusPowerForRegisterControl(); + R_RETURN(this->LowerBusPowerForRegisterControl()); } } diff --git a/libraries/libvapours/source/sdmmc/sdmmc_common.cpp b/libraries/libvapours/source/sdmmc/sdmmc_common.cpp index 067362ac8..3a0fde18b 100644 --- a/libraries/libvapours/source/sdmmc/sdmmc_common.cpp +++ b/libraries/libvapours/source/sdmmc/sdmmc_common.cpp @@ -99,7 +99,7 @@ namespace ams::sdmmc { } Result Activate(Port port) { - return GetDeviceAccessor(port)->Activate(); + R_RETURN(GetDeviceAccessor(port)->Activate()); } void Deactivate(Port port) { @@ -107,35 +107,35 @@ namespace ams::sdmmc { } Result Read(void *dst, size_t dst_size, Port port, u32 sector_index, u32 num_sectors) { - return GetDeviceAccessor(port)->ReadWrite(sector_index, num_sectors, dst, dst_size, true); + R_RETURN(GetDeviceAccessor(port)->ReadWrite(sector_index, num_sectors, dst, dst_size, true)); } Result Write(Port port, u32 sector_index, u32 num_sectors, const void *src, size_t src_size) { - return GetDeviceAccessor(port)->ReadWrite(sector_index, num_sectors, const_cast(src), src_size, false); + R_RETURN(GetDeviceAccessor(port)->ReadWrite(sector_index, num_sectors, const_cast(src), src_size, false)); } Result CheckConnection(SpeedMode *out_speed_mode, BusWidth *out_bus_width, Port port) { - return GetDeviceAccessor(port)->CheckConnection(out_speed_mode, out_bus_width); + R_RETURN(GetDeviceAccessor(port)->CheckConnection(out_speed_mode, out_bus_width)); } Result GetDeviceSpeedMode(SpeedMode *out, Port port) { - return GetDeviceAccessor(port)->GetSpeedMode(out); + R_RETURN(GetDeviceAccessor(port)->GetSpeedMode(out)); } Result GetDeviceMemoryCapacity(u32 *out_num_sectors, Port port) { - return GetDeviceAccessor(port)->GetMemoryCapacity(out_num_sectors); + R_RETURN(GetDeviceAccessor(port)->GetMemoryCapacity(out_num_sectors)); } Result GetDeviceStatus(u32 *out_device_status, Port port) { - return GetDeviceAccessor(port)->GetDeviceStatus(out_device_status); + R_RETURN(GetDeviceAccessor(port)->GetDeviceStatus(out_device_status)); } Result GetDeviceCid(void *out, size_t out_size, Port port) { - return GetDeviceAccessor(port)->GetCid(out, out_size); + R_RETURN(GetDeviceAccessor(port)->GetCid(out, out_size)); } Result GetDeviceCsd(void *out, size_t out_size, Port port) { - return GetDeviceAccessor(port)->GetCsd(out, out_size); + R_RETURN(GetDeviceAccessor(port)->GetCsd(out, out_size)); } void GetAndClearErrorInfo(ErrorInfo *out_error_info, size_t *out_log_size, char *out_log_buffer, size_t log_buffer_size, Port port) { diff --git a/libraries/libvapours/source/sdmmc/sdmmc_gc_asic.cpp b/libraries/libvapours/source/sdmmc/sdmmc_gc_asic.cpp index 5dcd700a6..ac84ef387 100644 --- a/libraries/libvapours/source/sdmmc/sdmmc_gc_asic.cpp +++ b/libraries/libvapours/source/sdmmc/sdmmc_gc_asic.cpp @@ -51,27 +51,27 @@ namespace ams::sdmmc { } Result AwakenGcAsic(Port port) { - return GetGcAsicDeviceAccessor(port)->AwakenGcAsic(); + R_RETURN(GetGcAsicDeviceAccessor(port)->AwakenGcAsic()); } Result WriteGcAsicOperation(Port port, const void *op_buf, size_t op_buf_size) { - return GetGcAsicDeviceAccessor(port)->WriteGcAsicOperation(op_buf, op_buf_size); + R_RETURN(GetGcAsicDeviceAccessor(port)->WriteGcAsicOperation(op_buf, op_buf_size)); } Result FinishGcAsicOperation(Port port) { - return GetGcAsicDeviceAccessor(port)->FinishGcAsicOperation(); + R_RETURN(GetGcAsicDeviceAccessor(port)->FinishGcAsicOperation()); } Result AbortGcAsicOperation(Port port) { - return GetGcAsicDeviceAccessor(port)->AbortGcAsicOperation(); + R_RETURN(GetGcAsicDeviceAccessor(port)->AbortGcAsicOperation()); } Result SleepGcAsic(Port port) { - return GetGcAsicDeviceAccessor(port)->SleepGcAsic(); + R_RETURN(GetGcAsicDeviceAccessor(port)->SleepGcAsic()); } Result UpdateGcAsicKey(Port port) { - return GetGcAsicDeviceAccessor(port)->UpdateGcAsicKey(); + R_RETURN(GetGcAsicDeviceAccessor(port)->UpdateGcAsicKey()); } void SignalGcRemovedEvent(Port port) { diff --git a/libraries/libvapours/source/sdmmc/sdmmc_mmc.cpp b/libraries/libvapours/source/sdmmc/sdmmc_mmc.cpp index 568957c00..fc657d3bd 100644 --- a/libraries/libvapours/source/sdmmc/sdmmc_mmc.cpp +++ b/libraries/libvapours/source/sdmmc/sdmmc_mmc.cpp @@ -59,23 +59,23 @@ namespace ams::sdmmc { } Result SelectMmcPartition(Port port, MmcPartition mmc_partition) { - return GetMmcDeviceAccessor(port)->SelectMmcPartition(mmc_partition); + R_RETURN(GetMmcDeviceAccessor(port)->SelectMmcPartition(mmc_partition)); } Result EraseMmc(Port port) { - return GetMmcDeviceAccessor(port)->EraseMmc(); + R_RETURN(GetMmcDeviceAccessor(port)->EraseMmc()); } Result GetMmcBootPartitionCapacity(u32 *out_num_sectors, Port port) { - return GetMmcDeviceAccessor(port)->GetMmcBootPartitionCapacity(out_num_sectors); + R_RETURN(GetMmcDeviceAccessor(port)->GetMmcBootPartitionCapacity(out_num_sectors)); } Result GetMmcExtendedCsd(void *out_buffer, size_t buffer_size, Port port) { - return GetMmcDeviceAccessor(port)->GetMmcExtendedCsd(out_buffer, buffer_size); + R_RETURN(GetMmcDeviceAccessor(port)->GetMmcExtendedCsd(out_buffer, buffer_size)); } Result CheckMmcConnection(SpeedMode *out_speed_mode, BusWidth *out_bus_width, Port port) { - return GetMmcDeviceAccessor(port)->CheckConnection(out_speed_mode, out_bus_width); + R_RETURN(GetMmcDeviceAccessor(port)->CheckConnection(out_speed_mode, out_bus_width)); } } diff --git a/libraries/libvapours/source/sdmmc/sdmmc_sd_card.cpp b/libraries/libvapours/source/sdmmc/sdmmc_sd_card.cpp index 578193459..faf83831c 100644 --- a/libraries/libvapours/source/sdmmc/sdmmc_sd_card.cpp +++ b/libraries/libvapours/source/sdmmc/sdmmc_sd_card.cpp @@ -59,27 +59,27 @@ namespace ams::sdmmc { } Result GetSdCardProtectedAreaCapacity(u32 *out_num_sectors, Port port) { - return GetSdCardDeviceAccessor(port)->GetSdCardProtectedAreaCapacity(out_num_sectors); + R_RETURN(GetSdCardDeviceAccessor(port)->GetSdCardProtectedAreaCapacity(out_num_sectors)); } Result GetSdCardScr(void *dst, size_t dst_size, Port port) { - return GetSdCardDeviceAccessor(port)->GetSdCardScr(dst, dst_size); + R_RETURN(GetSdCardDeviceAccessor(port)->GetSdCardScr(dst, dst_size)); } Result GetSdCardSwitchFunctionStatus(void *dst, size_t dst_size, Port port, SdCardSwitchFunction switch_function) { - return GetSdCardDeviceAccessor(port)->GetSdCardSwitchFunctionStatus(dst, dst_size, switch_function); + R_RETURN(GetSdCardDeviceAccessor(port)->GetSdCardSwitchFunctionStatus(dst, dst_size, switch_function)); } Result GetSdCardCurrentConsumption(u16 *out_current_consumption, Port port, SpeedMode speed_mode) { - return GetSdCardDeviceAccessor(port)->GetSdCardCurrentConsumption(out_current_consumption, speed_mode); + R_RETURN(GetSdCardDeviceAccessor(port)->GetSdCardCurrentConsumption(out_current_consumption, speed_mode)); } Result GetSdCardSdStatus(void *dst, size_t dst_size, Port port) { - return GetSdCardDeviceAccessor(port)->GetSdCardSdStatus(dst, dst_size); + R_RETURN(GetSdCardDeviceAccessor(port)->GetSdCardSdStatus(dst, dst_size)); } Result CheckSdCardConnection(SpeedMode *out_speed_mode, BusWidth *out_bus_width, Port port) { - return GetSdCardDeviceAccessor(port)->CheckConnection(out_speed_mode, out_bus_width); + R_RETURN(GetSdCardDeviceAccessor(port)->CheckConnection(out_speed_mode, out_bus_width)); } bool IsSdCardInserted(Port port) { diff --git a/stratosphere/ams_mitm/source/amsmitm_fs_utils.cpp b/stratosphere/ams_mitm/source/amsmitm_fs_utils.cpp index 6b0c88b85..e232ecf5a 100644 --- a/stratosphere/ams_mitm/source/amsmitm_fs_utils.cpp +++ b/stratosphere/ams_mitm/source/amsmitm_fs_utils.cpp @@ -44,12 +44,12 @@ namespace ams::mitm::fs { Result CreateSdFile(const char *path, s64 size, s32 option) { R_TRY(EnsureSdInitialized()); - return fsFsCreateFile(std::addressof(g_sd_filesystem), path, size, option); + R_RETURN(fsFsCreateFile(std::addressof(g_sd_filesystem), path, size, option)); } Result DeleteSdFile(const char *path) { R_TRY(EnsureSdInitialized()); - return fsFsDeleteFile(std::addressof(g_sd_filesystem), path); + R_RETURN(fsFsDeleteFile(std::addressof(g_sd_filesystem), path)); } bool HasSdFile(const char *path) { @@ -74,82 +74,82 @@ namespace ams::mitm::fs { Result DeleteAtmosphereSdFile(const char *path) { char fixed_path[ams::fs::EntryNameLengthMax + 1]; FormatAtmosphereSdPath(fixed_path, sizeof(fixed_path), path); - return DeleteSdFile(fixed_path); + R_RETURN(DeleteSdFile(fixed_path)); } Result CreateAtmosphereSdFile(const char *path, s64 size, s32 option) { char fixed_path[ams::fs::EntryNameLengthMax + 1]; FormatAtmosphereSdPath(fixed_path, sizeof(fixed_path), path); - return CreateSdFile(fixed_path, size, option); + R_RETURN(CreateSdFile(fixed_path, size, option)); } Result OpenSdFile(FsFile *out, const char *path, u32 mode) { R_TRY(EnsureSdInitialized()); - return fsFsOpenFile(std::addressof(g_sd_filesystem), path, mode, out); + R_RETURN(fsFsOpenFile(std::addressof(g_sd_filesystem), path, mode, out)); } Result OpenAtmosphereSdFile(FsFile *out, const char *path, u32 mode) { char fixed_path[ams::fs::EntryNameLengthMax + 1]; FormatAtmosphereSdPath(fixed_path, sizeof(fixed_path), path); - return OpenSdFile(out, fixed_path, mode); + R_RETURN(OpenSdFile(out, fixed_path, mode)); } Result OpenAtmosphereSdFile(FsFile *out, ncm::ProgramId program_id, const char *path, u32 mode) { char fixed_path[ams::fs::EntryNameLengthMax + 1]; FormatAtmosphereSdPath(fixed_path, sizeof(fixed_path), program_id, path); - return OpenSdFile(out, fixed_path, mode); + R_RETURN(OpenSdFile(out, fixed_path, mode)); } Result OpenAtmosphereSdRomfsFile(FsFile *out, ncm::ProgramId program_id, const char *path, u32 mode) { char fixed_path[ams::fs::EntryNameLengthMax + 1]; FormatAtmosphereRomfsPath(fixed_path, sizeof(fixed_path), program_id, path); - return OpenSdFile(out, fixed_path, mode); + R_RETURN(OpenSdFile(out, fixed_path, mode)); } Result OpenAtmosphereRomfsFile(FsFile *out, ncm::ProgramId program_id, const char *path, u32 mode, FsFileSystem *fs) { char fixed_path[ams::fs::EntryNameLengthMax + 1]; FormatAtmosphereRomfsPath(fixed_path, sizeof(fixed_path), program_id, path); - return fsFsOpenFile(fs, fixed_path, mode, out); + R_RETURN(fsFsOpenFile(fs, fixed_path, mode, out)); } Result CreateSdDirectory(const char *path) { R_TRY(EnsureSdInitialized()); - return fsFsCreateDirectory(std::addressof(g_sd_filesystem), path); + R_RETURN(fsFsCreateDirectory(std::addressof(g_sd_filesystem), path)); } Result CreateAtmosphereSdDirectory(const char *path) { char fixed_path[ams::fs::EntryNameLengthMax + 1]; FormatAtmosphereSdPath(fixed_path, sizeof(fixed_path), path); - return CreateSdDirectory(fixed_path); + R_RETURN(CreateSdDirectory(fixed_path)); } Result OpenSdDirectory(FsDir *out, const char *path, u32 mode) { R_TRY(EnsureSdInitialized()); - return fsFsOpenDirectory(std::addressof(g_sd_filesystem), path, mode, out); + R_RETURN(fsFsOpenDirectory(std::addressof(g_sd_filesystem), path, mode, out)); } Result OpenAtmosphereSdDirectory(FsDir *out, const char *path, u32 mode) { char fixed_path[ams::fs::EntryNameLengthMax + 1]; FormatAtmosphereSdPath(fixed_path, sizeof(fixed_path), path); - return OpenSdDirectory(out, fixed_path, mode); + R_RETURN(OpenSdDirectory(out, fixed_path, mode)); } Result OpenAtmosphereSdDirectory(FsDir *out, ncm::ProgramId program_id, const char *path, u32 mode) { char fixed_path[ams::fs::EntryNameLengthMax + 1]; FormatAtmosphereSdPath(fixed_path, sizeof(fixed_path), program_id, path); - return OpenSdDirectory(out, fixed_path, mode); + R_RETURN(OpenSdDirectory(out, fixed_path, mode)); } Result OpenAtmosphereSdRomfsDirectory(FsDir *out, ncm::ProgramId program_id, const char *path, u32 mode) { char fixed_path[ams::fs::EntryNameLengthMax + 1]; FormatAtmosphereRomfsPath(fixed_path, sizeof(fixed_path), program_id, path); - return OpenSdDirectory(out, fixed_path, mode); + R_RETURN(OpenSdDirectory(out, fixed_path, mode)); } Result OpenAtmosphereRomfsDirectory(FsDir *out, ncm::ProgramId program_id, const char *path, u32 mode, FsFileSystem *fs) { char fixed_path[ams::fs::EntryNameLengthMax + 1]; FormatAtmosphereRomfsPath(fixed_path, sizeof(fixed_path), program_id, path); - return fsFsOpenDirectory(fs, fixed_path, mode, out); + R_RETURN(fsFsOpenDirectory(fs, fixed_path, mode, out)); } void FormatAtmosphereSdPath(char *dst_path, size_t dst_path_size, const char *src_path) { diff --git a/stratosphere/ams_mitm/source/bpc_mitm/bpcmitm_module.cpp b/stratosphere/ams_mitm/source/bpc_mitm/bpcmitm_module.cpp index d06a48578..8776c9b50 100644 --- a/stratosphere/ams_mitm/source/bpc_mitm/bpcmitm_module.cpp +++ b/stratosphere/ams_mitm/source/bpc_mitm/bpcmitm_module.cpp @@ -56,7 +56,7 @@ namespace ams::mitm::bpc { switch (port_index) { case PortIndex_Mitm: - return this->AcceptMitmImpl(server, sf::CreateSharedObjectEmplaced(decltype(fsrv)(fsrv), client_info), fsrv); + R_RETURN(this->AcceptMitmImpl(server, sf::CreateSharedObjectEmplaced(decltype(fsrv)(fsrv), client_info), fsrv)); AMS_UNREACHABLE_DEFAULT_CASE(); } } diff --git a/stratosphere/ams_mitm/source/dns_mitm/dnsmitm_module.cpp b/stratosphere/ams_mitm/source/dns_mitm/dnsmitm_module.cpp index 3e959a47f..004c3a1c4 100644 --- a/stratosphere/ams_mitm/source/dns_mitm/dnsmitm_module.cpp +++ b/stratosphere/ams_mitm/source/dns_mitm/dnsmitm_module.cpp @@ -58,7 +58,7 @@ namespace ams::mitm::socket::resolver { switch (port_index) { case PortIndex_Mitm: - return this->AcceptMitmImpl(server, sf::CreateSharedObjectEmplaced(decltype(fsrv)(fsrv), client_info), fsrv); + R_RETURN(this->AcceptMitmImpl(server, sf::CreateSharedObjectEmplaced(decltype(fsrv)(fsrv), client_info), fsrv)); AMS_UNREACHABLE_DEFAULT_CASE(); } } diff --git a/stratosphere/ams_mitm/source/fs_mitm/fs_mitm_service.cpp b/stratosphere/ams_mitm/source/fs_mitm/fs_mitm_service.cpp index 9c36f9115..116675295 100644 --- a/stratosphere/ams_mitm/source/fs_mitm/fs_mitm_service.cpp +++ b/stratosphere/ams_mitm/source/fs_mitm/fs_mitm_service.cpp @@ -157,17 +157,17 @@ namespace ams::mitm::fs { R_UNLESS(try_program_specific, sm::mitm::ResultShouldForwardToSession()); /* If we're not opening a HBL filesystem, just try to open a generic one. */ - return OpenProgramSpecificWebContentFileSystem(out, program_id, filesystem_type, fwd, path, with_id); + R_RETURN(OpenProgramSpecificWebContentFileSystem(out, program_id, filesystem_type, fwd, path, with_id)); } } Result FsMitmService::OpenFileSystemWithPatch(sf::Out> out, ncm::ProgramId program_id, u32 _filesystem_type) { - return OpenWebContentFileSystem(out, m_client_info.program_id, program_id, static_cast(_filesystem_type), m_forward_service.get(), nullptr, false, m_client_info.override_status.IsProgramSpecific()); + R_RETURN(OpenWebContentFileSystem(out, m_client_info.program_id, program_id, static_cast(_filesystem_type), m_forward_service.get(), nullptr, false, m_client_info.override_status.IsProgramSpecific())); } Result FsMitmService::OpenFileSystemWithId(sf::Out> out, const fssrv::sf::Path &path, ncm::ProgramId program_id, u32 _filesystem_type) { - return OpenWebContentFileSystem(out, m_client_info.program_id, program_id, static_cast(_filesystem_type), m_forward_service.get(), std::addressof(path), true, m_client_info.override_status.IsProgramSpecific()); + R_RETURN(OpenWebContentFileSystem(out, m_client_info.program_id, program_id, static_cast(_filesystem_type), m_forward_service.get(), std::addressof(path), true, m_client_info.override_status.IsProgramSpecific())); } Result FsMitmService::OpenSdCardFileSystem(sf::Out> out) { diff --git a/stratosphere/ams_mitm/source/fs_mitm/fsmitm_boot0storage.cpp b/stratosphere/ams_mitm/source/fs_mitm/fsmitm_boot0storage.cpp index f3fa77d6e..06d91ea55 100644 --- a/stratosphere/ams_mitm/source/fs_mitm/fsmitm_boot0storage.cpp +++ b/stratosphere/ams_mitm/source/fs_mitm/fsmitm_boot0storage.cpp @@ -74,7 +74,7 @@ namespace ams::mitm::fs { /* Check if we have nothing to do. */ R_SUCCEED_IF(size == 0); - return Base::Read(offset, _buffer, size); + R_RETURN(Base::Read(offset, _buffer, size)); } Result Boot0Storage::Write(s64 offset, const void *_buffer, size_t size) { @@ -115,7 +115,7 @@ namespace ams::mitm::fs { /* We want to protect AutoRCM from NS on ipatched units. If we can modify bct pubks or we're not touching any of them, proceed. */ if (this->CanModifyBctPublicKey() || offset >= BctEndOffset || (util::AlignUp(offset, BctSize) >= BctEndOffset && (offset % BctSize) >= BctPubkEnd)) { - return Base::Write(offset, buffer, size); + R_RETURN(Base::Write(offset, buffer, size)); } /* Handle any data written past the end of the pubk region. */ @@ -136,7 +136,7 @@ namespace ams::mitm::fs { } } - return Base::Write(0, g_boot0_bct_buffer, BctEndOffset); + R_RETURN(Base::Write(0, g_boot0_bct_buffer, BctEndOffset)); } CustomPublicKeyBoot0Storage::CustomPublicKeyBoot0Storage(FsStorage &s, const sm::MitmProcessInfo &c, spl::SocType soc) : Base(s), m_client_info(c), m_soc_type(soc) { @@ -174,7 +174,7 @@ namespace ams::mitm::fs { R_SUCCEED_IF(size == 0); /* Perform whatever remains of the read. */ - return Base::Read(offset, buffer, size); + R_RETURN(Base::Read(offset, buffer, size)); } Result CustomPublicKeyBoot0Storage::Write(s64 offset, const void *_buffer, size_t size) { @@ -236,7 +236,7 @@ namespace ams::mitm::fs { R_SUCCEED_IF(size == 0); /* Perform whatever remains of the write. */ - return Base::Write(offset, buffer, size); + R_RETURN(Base::Write(offset, buffer, size)); } bool DetectBoot0CustomPublicKey(::FsStorage &storage) { diff --git a/stratosphere/ams_mitm/source/fs_mitm/fsmitm_boot0storage.hpp b/stratosphere/ams_mitm/source/fs_mitm/fsmitm_boot0storage.hpp index 39daf9aa4..dc85d527a 100644 --- a/stratosphere/ams_mitm/source/fs_mitm/fsmitm_boot0storage.hpp +++ b/stratosphere/ams_mitm/source/fs_mitm/fsmitm_boot0storage.hpp @@ -41,7 +41,7 @@ namespace ams::mitm::fs { /* Fast case. */ if (sector_ofs == 0 && util::IsAligned(size, SectorSize)) { - return Base::Read(offset, buffer, size); + R_RETURN(Base::Read(offset, buffer, size)); } R_TRY(Base::Read(seek, m_sector_buf, SectorSize)); @@ -85,7 +85,7 @@ namespace ams::mitm::fs { /* Fast case. */ if (sector_ofs == 0 && util::IsAligned(size, SectorSize)) { - return Base::Write(offset, buffer, size); + R_RETURN(Base::Write(offset, buffer, size)); } /* Load existing sector data. */ diff --git a/stratosphere/ams_mitm/source/fs_mitm/fsmitm_calibration_binary_storage.cpp b/stratosphere/ams_mitm/source/fs_mitm/fsmitm_calibration_binary_storage.cpp index 3e57bf9fe..ea3294fcc 100644 --- a/stratosphere/ams_mitm/source/fs_mitm/fsmitm_calibration_binary_storage.cpp +++ b/stratosphere/ams_mitm/source/fs_mitm/fsmitm_calibration_binary_storage.cpp @@ -25,6 +25,7 @@ namespace ams::mitm::fs { constinit os::SdkMutex g_cal0_access_mutex; } + Result CalibrationBinaryStorage::Read(s64 offset, void *_buffer, size_t size) { /* Acquire exclusive calibration binary access. */ std::scoped_lock lk(g_cal0_access_mutex); @@ -74,7 +75,7 @@ namespace ams::mitm::fs { R_SUCCEED_IF(size == 0); /* Handle any remaining data. */ - return Base::Read(offset, buffer, size); + R_RETURN(Base::Read(offset, buffer, size)); } Result CalibrationBinaryStorage::Write(s64 offset, const void *_buffer, size_t size) { @@ -129,7 +130,7 @@ namespace ams::mitm::fs { R_SUCCEED_IF(size == 0); /* Handle any remaining data. */ - return Base::Write(offset, buffer, size); + R_RETURN(Base::Write(offset, buffer, size)); } } diff --git a/stratosphere/ams_mitm/source/fs_mitm/fsmitm_layered_romfs_storage.cpp b/stratosphere/ams_mitm/source/fs_mitm/fsmitm_layered_romfs_storage.cpp index 6bd810f1a..de41c800f 100644 --- a/stratosphere/ams_mitm/source/fs_mitm/fsmitm_layered_romfs_storage.cpp +++ b/stratosphere/ams_mitm/source/fs_mitm/fsmitm_layered_romfs_storage.cpp @@ -179,31 +179,31 @@ namespace ams::mitm::fs { virtual Result Read(s64 offset, void *buffer, size_t size) override { - return m_impl->Read(offset, buffer, size); + R_RETURN(m_impl->Read(offset, buffer, size)); } virtual Result GetSize(s64 *out_size) override { - return m_impl->GetSize(out_size); + R_RETURN(m_impl->GetSize(out_size)); } virtual Result Flush() override { - return m_impl->Flush(); + R_RETURN(m_impl->Flush()); } virtual Result OperateRange(void *dst, size_t dst_size, ams::fs::OperationId op_id, s64 offset, s64 size, const void *src, size_t src_size) override { - return m_impl->OperateRange(dst, dst_size, op_id, offset, size, src, src_size); + R_RETURN(m_impl->OperateRange(dst, dst_size, op_id, offset, size, src, src_size)); } virtual Result Write(s64 offset, const void *buffer, size_t size) override { /* TODO: Better result code? */ AMS_UNUSED(offset, buffer, size); - return ams::fs::ResultUnsupportedOperation(); + R_THROW(ams::fs::ResultUnsupportedOperation()) } virtual Result SetSize(s64 size) override { /* TODO: Better result code? */ AMS_UNUSED(size); - return ams::fs::ResultUnsupportedOperation(); + R_THROW(ams::fs::ResultUnsupportedOperation()) } }; diff --git a/stratosphere/ams_mitm/source/fs_mitm/fsmitm_module.cpp b/stratosphere/ams_mitm/source/fs_mitm/fsmitm_module.cpp index ce6433fea..7fca526ab 100644 --- a/stratosphere/ams_mitm/source/fs_mitm/fsmitm_module.cpp +++ b/stratosphere/ams_mitm/source/fs_mitm/fsmitm_module.cpp @@ -53,7 +53,7 @@ namespace ams::mitm::fs { switch (port_index) { case PortIndex_Mitm: - return this->AcceptMitmImpl(server, sf::CreateSharedObjectEmplaced(decltype(fsrv)(fsrv), client_info), fsrv); + R_RETURN(this->AcceptMitmImpl(server, sf::CreateSharedObjectEmplaced(decltype(fsrv)(fsrv), client_info), fsrv)); AMS_UNREACHABLE_DEFAULT_CASE(); } } diff --git a/stratosphere/ams_mitm/source/fs_mitm/fsmitm_readonly_layered_filesystem.hpp b/stratosphere/ams_mitm/source/fs_mitm/fsmitm_readonly_layered_filesystem.hpp index c5113bc4b..f9030c9e1 100644 --- a/stratosphere/ams_mitm/source/fs_mitm/fsmitm_readonly_layered_filesystem.hpp +++ b/stratosphere/ams_mitm/source/fs_mitm/fsmitm_readonly_layered_filesystem.hpp @@ -29,52 +29,52 @@ namespace ams::mitm::fs { private: virtual Result DoCreateFile(const ams::fs::Path &path, s64 size, int flags) override final { AMS_UNUSED(path, size, flags); - return ams::fs::ResultUnsupportedOperation(); + R_THROW(ams::fs::ResultUnsupportedOperation()) } virtual Result DoDeleteFile(const ams::fs::Path &path) override final { AMS_UNUSED(path); - return ams::fs::ResultUnsupportedOperation(); + R_THROW(ams::fs::ResultUnsupportedOperation()) } virtual Result DoCreateDirectory(const ams::fs::Path &path) override final { AMS_UNUSED(path); - return ams::fs::ResultUnsupportedOperation(); + R_THROW(ams::fs::ResultUnsupportedOperation()) } virtual Result DoDeleteDirectory(const ams::fs::Path &path) override final { AMS_UNUSED(path); - return ams::fs::ResultUnsupportedOperation(); + R_THROW(ams::fs::ResultUnsupportedOperation()) } virtual Result DoDeleteDirectoryRecursively(const ams::fs::Path &path) override final { AMS_UNUSED(path); - return ams::fs::ResultUnsupportedOperation(); + R_THROW(ams::fs::ResultUnsupportedOperation()) } virtual Result DoRenameFile(const ams::fs::Path &old_path, const ams::fs::Path &new_path) override final { AMS_UNUSED(old_path, new_path); - return ams::fs::ResultUnsupportedOperation(); + R_THROW(ams::fs::ResultUnsupportedOperation()) } virtual Result DoRenameDirectory(const ams::fs::Path &old_path, const ams::fs::Path &new_path) override final { AMS_UNUSED(old_path, new_path); - return ams::fs::ResultUnsupportedOperation(); + R_THROW(ams::fs::ResultUnsupportedOperation()) } virtual Result DoGetEntryType(ams::fs::DirectoryEntryType *out, const ams::fs::Path &path) override final { R_SUCCEED_IF(R_SUCCEEDED(m_fs_1.GetEntryType(out, path))); - return m_fs_2.GetEntryType(out, path); + R_RETURN(m_fs_2.GetEntryType(out, path)); } virtual Result DoOpenFile(std::unique_ptr *out_file, const ams::fs::Path &path, ams::fs::OpenMode mode) override final { R_SUCCEED_IF(R_SUCCEEDED(m_fs_1.OpenFile(out_file, path, mode))); - return m_fs_2.OpenFile(out_file, path, mode); + R_RETURN(m_fs_2.OpenFile(out_file, path, mode)); } virtual Result DoOpenDirectory(std::unique_ptr *out_dir, const ams::fs::Path &path, ams::fs::OpenDirectoryMode mode) override final { R_SUCCEED_IF(R_SUCCEEDED(m_fs_1.OpenDirectory(out_dir, path, mode))); - return m_fs_2.OpenDirectory(out_dir, path, mode); + R_RETURN(m_fs_2.OpenDirectory(out_dir, path, mode)); } virtual Result DoCommit() override final { @@ -83,22 +83,22 @@ namespace ams::mitm::fs { virtual Result DoGetFreeSpaceSize(s64 *out, const ams::fs::Path &path) { AMS_UNUSED(out, path); - return ams::fs::ResultUnsupportedOperation(); + R_THROW(ams::fs::ResultUnsupportedOperation()) } virtual Result DoGetTotalSpaceSize(s64 *out, const ams::fs::Path &path) { AMS_UNUSED(out, path); - return ams::fs::ResultUnsupportedOperation(); + R_THROW(ams::fs::ResultUnsupportedOperation()) } virtual Result DoCleanDirectoryRecursively(const ams::fs::Path &path) { AMS_UNUSED(path); - return ams::fs::ResultUnsupportedOperation(); + R_THROW(ams::fs::ResultUnsupportedOperation()) } virtual Result DoGetFileTimeStampRaw(ams::fs::FileTimeStampRaw *out, const ams::fs::Path &path) { R_SUCCEED_IF(R_SUCCEEDED(m_fs_1.GetFileTimeStampRaw(out, path))); - return m_fs_2.GetFileTimeStampRaw(out, path); + R_RETURN(m_fs_2.GetFileTimeStampRaw(out, path)); } }; diff --git a/stratosphere/ams_mitm/source/ns_mitm/ns_am_mitm_service.cpp b/stratosphere/ams_mitm/source/ns_mitm/ns_am_mitm_service.cpp index 4c855a7a1..5afb42243 100644 --- a/stratosphere/ams_mitm/source/ns_mitm/ns_am_mitm_service.cpp +++ b/stratosphere/ams_mitm/source/ns_mitm/ns_am_mitm_service.cpp @@ -20,7 +20,7 @@ namespace ams::mitm::ns { Result NsAmMitmService::GetApplicationContentPath(const sf::OutBuffer &out_path, ncm::ProgramId application_id, u8 content_type) { - return nsamGetApplicationContentPathFwd(m_forward_service.get(), out_path.GetPointer(), out_path.GetSize(), static_cast(application_id), static_cast(content_type)); + R_RETURN(nsamGetApplicationContentPathFwd(m_forward_service.get(), out_path.GetPointer(), out_path.GetSize(), static_cast(application_id), static_cast(content_type))); } Result NsAmMitmService::ResolveApplicationContentPath(ncm::ProgramId application_id, u8 content_type) { @@ -31,11 +31,11 @@ namespace ams::mitm::ns { nsamResolveApplicationContentPathFwd(m_forward_service.get(), static_cast(application_id), static_cast(content_type)); R_SUCCEED(); } - return nsamResolveApplicationContentPathFwd(m_forward_service.get(), static_cast(application_id), static_cast(content_type)); + R_RETURN(nsamResolveApplicationContentPathFwd(m_forward_service.get(), static_cast(application_id), static_cast(content_type))); } Result NsAmMitmService::GetRunningApplicationProgramId(sf::Out out, ncm::ProgramId application_id) { - return nsamGetRunningApplicationProgramIdFwd(m_forward_service.get(), reinterpret_cast(out.GetPointer()), static_cast(application_id)); + R_RETURN(nsamGetRunningApplicationProgramIdFwd(m_forward_service.get(), reinterpret_cast(out.GetPointer()), static_cast(application_id))); } } diff --git a/stratosphere/ams_mitm/source/ns_mitm/ns_web_mitm_service.cpp b/stratosphere/ams_mitm/source/ns_mitm/ns_web_mitm_service.cpp index 6e2234e51..1372bf593 100644 --- a/stratosphere/ams_mitm/source/ns_mitm/ns_web_mitm_service.cpp +++ b/stratosphere/ams_mitm/source/ns_mitm/ns_web_mitm_service.cpp @@ -19,7 +19,7 @@ namespace ams::mitm::ns { Result NsDocumentService::GetApplicationContentPath(const sf::OutBuffer &out_path, ncm::ProgramId application_id, u8 content_type) { - return nswebGetApplicationContentPath(m_srv.get(), out_path.GetPointer(), out_path.GetSize(), static_cast(application_id), static_cast(content_type)); + R_RETURN(nswebGetApplicationContentPath(m_srv.get(), out_path.GetPointer(), out_path.GetSize(), static_cast(application_id), static_cast(content_type))); } Result NsDocumentService::ResolveApplicationContentPath(ncm::ProgramId application_id, u8 content_type) { @@ -30,11 +30,11 @@ namespace ams::mitm::ns { nswebResolveApplicationContentPath(m_srv.get(), static_cast(application_id), static_cast(content_type)); R_SUCCEED(); } - return nswebResolveApplicationContentPath(m_srv.get(), static_cast(application_id), static_cast(content_type)); + R_RETURN(nswebResolveApplicationContentPath(m_srv.get(), static_cast(application_id), static_cast(content_type))); } Result NsDocumentService::GetRunningApplicationProgramId(sf::Out out, ncm::ProgramId application_id) { - return nswebGetRunningApplicationProgramId(m_srv.get(), reinterpret_cast(out.GetPointer()), static_cast(application_id)); + R_RETURN(nswebGetRunningApplicationProgramId(m_srv.get(), reinterpret_cast(out.GetPointer()), static_cast(application_id))); } Result NsWebMitmService::GetDocumentInterface(sf::Out> out) { diff --git a/stratosphere/ams_mitm/source/ns_mitm/nsmitm_module.cpp b/stratosphere/ams_mitm/source/ns_mitm/nsmitm_module.cpp index bb48fac93..1148ddad5 100644 --- a/stratosphere/ams_mitm/source/ns_mitm/nsmitm_module.cpp +++ b/stratosphere/ams_mitm/source/ns_mitm/nsmitm_module.cpp @@ -57,9 +57,9 @@ namespace ams::mitm::ns { switch (port_index) { case PortIndex_Mitm: if (hos::GetVersion() < hos::Version_3_0_0) { - return this->AcceptMitmImpl(server, sf::CreateSharedObjectEmplaced(decltype(fsrv)(fsrv), client_info), fsrv); + R_RETURN(this->AcceptMitmImpl(server, sf::CreateSharedObjectEmplaced(decltype(fsrv)(fsrv), client_info), fsrv)); } else { - return this->AcceptMitmImpl(server, sf::CreateSharedObjectEmplaced(decltype(fsrv)(fsrv), client_info), fsrv); + R_RETURN(this->AcceptMitmImpl(server, sf::CreateSharedObjectEmplaced(decltype(fsrv)(fsrv), client_info), fsrv)); } AMS_UNREACHABLE_DEFAULT_CASE(); diff --git a/stratosphere/ams_mitm/source/set_mitm/setmitm_module.cpp b/stratosphere/ams_mitm/source/set_mitm/setmitm_module.cpp index 982b64e89..68579bb40 100644 --- a/stratosphere/ams_mitm/source/set_mitm/setmitm_module.cpp +++ b/stratosphere/ams_mitm/source/set_mitm/setmitm_module.cpp @@ -57,9 +57,9 @@ namespace ams::mitm::settings { switch (port_index) { case PortIndex_SetMitm: - return this->AcceptMitmImpl(server, sf::CreateSharedObjectEmplaced(decltype(fsrv)(fsrv), client_info), fsrv); + R_RETURN(this->AcceptMitmImpl(server, sf::CreateSharedObjectEmplaced(decltype(fsrv)(fsrv), client_info), fsrv)); case PortIndex_SetSysMitm: - return this->AcceptMitmImpl(server, sf::CreateSharedObjectEmplaced(decltype(fsrv)(fsrv), client_info), fsrv); + R_RETURN(this->AcceptMitmImpl(server, sf::CreateSharedObjectEmplaced(decltype(fsrv)(fsrv), client_info), fsrv)); AMS_UNREACHABLE_DEFAULT_CASE(); } } diff --git a/stratosphere/ams_mitm/source/set_mitm/setsys_mitm_service.cpp b/stratosphere/ams_mitm/source/set_mitm/setsys_mitm_service.cpp index fc8f9bbd1..eb504b3c9 100644 --- a/stratosphere/ams_mitm/source/set_mitm/setsys_mitm_service.cpp +++ b/stratosphere/ams_mitm/source/set_mitm/setsys_mitm_service.cpp @@ -99,7 +99,7 @@ namespace ams::mitm::settings { } Result SetSysMitmService::GetFirmwareVersion2(sf::Out out) { - return GetFirmwareVersionImpl(out.GetPointer(), m_client_info); + R_RETURN(GetFirmwareVersionImpl(out.GetPointer(), m_client_info)); } Result SetSysMitmService::GetSettingsItemValueSize(sf::Out out_size, const settings::SettingsName &name, const settings::SettingsItemKey &key) { diff --git a/stratosphere/ams_mitm/source/set_mitm/settings_sd_kvs.cpp b/stratosphere/ams_mitm/source/set_mitm/settings_sd_kvs.cpp index fda9bfce1..1d0d9ce10 100644 --- a/stratosphere/ams_mitm/source/set_mitm/settings_sd_kvs.cpp +++ b/stratosphere/ams_mitm/source/set_mitm/settings_sd_kvs.cpp @@ -273,7 +273,7 @@ namespace ams::settings::fwdbg { Result ParseSettingsItemValue(const char *name, const char *key, const char *value) { R_TRY(ValidateSettingsName(name)); R_TRY(ValidateSettingsItemKey(key)); - return ParseSettingsItemValueImpl(name, key, value); + R_RETURN(ParseSettingsItemValueImpl(name, key, value)); } static int SystemSettingsIniHandler(void *user, const char *name, const char *key, const char *value) { diff --git a/stratosphere/ams_mitm/source/sysupdater/sysupdater_async_impl.cpp b/stratosphere/ams_mitm/source/sysupdater/sysupdater_async_impl.cpp index be1124095..ffe82fd93 100644 --- a/stratosphere/ams_mitm/source/sysupdater/sysupdater_async_impl.cpp +++ b/stratosphere/ams_mitm/source/sysupdater/sysupdater_async_impl.cpp @@ -70,7 +70,7 @@ namespace ams::mitm::sysupdater { } Result AsyncPrepareSdCardUpdateImpl::Execute() { - return m_task->PrepareAndExecute(); + R_RETURN(m_task->PrepareAndExecute()); } void AsyncPrepareSdCardUpdateImpl::CancelImpl() { diff --git a/stratosphere/ams_mitm/source/sysupdater/sysupdater_async_impl.hpp b/stratosphere/ams_mitm/source/sysupdater/sysupdater_async_impl.hpp index 6684177ff..f2b41c5cc 100644 --- a/stratosphere/ams_mitm/source/sysupdater/sysupdater_async_impl.hpp +++ b/stratosphere/ams_mitm/source/sysupdater/sysupdater_async_impl.hpp @@ -29,28 +29,21 @@ namespace ams::mitm::sysupdater { template Result SaveErrorContextIfFailed(T &async, Result result) { - if (R_FAILED(result)) { - async.GetErrorContext(std::addressof(m_error_context)); - return result; - } + ON_RESULT_FAILURE { async.GetErrorContext(std::addressof(m_error_context)); }; - R_SUCCEED(); + R_RETURN(result); } template Result GetAndSaveErrorContext(T &async) { - R_TRY(this->SaveErrorContextIfFailed(async, async.Get())); - R_SUCCEED(); + R_RETURN(this->SaveErrorContextIfFailed(async, async.Get())); } template Result SaveInternalTaskErrorContextIfFailed(T &async, Result result) { - if (R_FAILED(result)) { - async.CreateErrorContext(std::addressof(m_error_context)); - return result; - } + ON_RESULT_FAILURE { async.CreateErrorContext(std::addressof(m_error_context)); }; - R_SUCCEED(); + R_RETURN(result); } const err::ErrorContext &GetErrorContextImpl() { @@ -82,7 +75,7 @@ namespace ams::mitm::sysupdater { virtual ~AsyncResultBase() { /* ... */ } Result Get() { - return ToAsyncResult(this->GetImpl()); + R_RETURN(ToAsyncResult(this->GetImpl())); } private: virtual Result GetImpl() = 0; diff --git a/stratosphere/ams_mitm/source/sysupdater/sysupdater_fs_utils.cpp b/stratosphere/ams_mitm/source/sysupdater/sysupdater_fs_utils.cpp index 27a0478ea..6f098087d 100644 --- a/stratosphere/ams_mitm/source/sysupdater/sysupdater_fs_utils.cpp +++ b/stratosphere/ams_mitm/source/sysupdater/sysupdater_fs_utils.cpp @@ -208,8 +208,8 @@ namespace ams::mitm::sysupdater { /* Open the appropriate interface. */ const auto * const creator_intfs = fssystem::GetFileSystemCreatorInterfaces(); switch (fs_type) { - case fssystem::NcaFsHeader::FsType::PartitionFs: return creator_intfs->partition_fs_creator->Create(out, std::move(storage)); - case fssystem::NcaFsHeader::FsType::RomFs: return creator_intfs->rom_fs_creator->Create(out, std::move(storage)); + case fssystem::NcaFsHeader::FsType::PartitionFs: R_RETURN(creator_intfs->partition_fs_creator->Create(out, std::move(storage))); + case fssystem::NcaFsHeader::FsType::RomFs: R_RETURN(creator_intfs->rom_fs_creator->Create(out, std::move(storage))); default: R_THROW(fs::ResultInvalidNcaFileSystemType()); } @@ -248,7 +248,7 @@ namespace ams::mitm::sysupdater { R_UNLESS(unique_fs != nullptr, fs::ResultAllocationMemoryFailedNew()); /* Register the fs. */ - return ams::fs::fsa::Register(mount_name, std::move(unique_fs)); + R_RETURN(ams::fs::fsa::Register(mount_name, std::move(unique_fs))); } } diff --git a/stratosphere/ams_mitm/source/sysupdater/sysupdater_service.cpp b/stratosphere/ams_mitm/source/sysupdater/sysupdater_service.cpp index 689dba496..034095b6f 100644 --- a/stratosphere/ams_mitm/source/sysupdater/sysupdater_service.cpp +++ b/stratosphere/ams_mitm/source/sysupdater/sysupdater_service.cpp @@ -60,7 +60,7 @@ namespace ams::mitm::sysupdater { const size_t path_len = util::SNPrintf(package_path, sizeof(package_path), "%s%s", package_root_path, entry_path); AMS_ABORT_UNLESS(path_len < ams::fs::EntryNameLengthMax); - return ams::fs::ConvertToFsCommonPath(dst, dst_size, package_path); + R_RETURN(ams::fs::ConvertToFsCommonPath(dst, dst_size, package_path)); } Result LoadContentMeta(ncm::AutoBuffer *out, const char *package_root_path, const fs::DirectoryEntry &entry) { @@ -69,7 +69,7 @@ namespace ams::mitm::sysupdater { char path[ams::fs::EntryNameLengthMax]; R_TRY(ConvertToFsCommonPath(path, sizeof(path), package_root_path, entry.name)); - return ncm::ReadContentMetaPathAlongWithExtendedDataAndDigest(out, path); + R_RETURN(ncm::ReadContentMetaPathAlongWithExtendedDataAndDigest(out, path)); } Result ReadContentMetaPath(ncm::AutoBuffer *out, const char *package_root, const ncm::ContentInfo &content_info) { @@ -84,7 +84,7 @@ namespace ams::mitm::sysupdater { R_TRY(ConvertToFsCommonPath(content_path.str, sizeof(content_path.str), package_root, cnmt_nca_name)); /* Read the content meta path. */ - return ncm::ReadContentMetaPathAlongWithExtendedDataAndDigest(out, content_path.str); + R_RETURN(ncm::ReadContentMetaPathAlongWithExtendedDataAndDigest(out, content_path.str)); } Result GetSystemUpdateUpdateContentInfoFromPackage(ncm::ContentInfo *out, const char *package_root) { @@ -154,7 +154,7 @@ namespace ams::mitm::sysupdater { /* Declare helper for result validation. */ auto ValidateResult = [&](Result result) ALWAYS_INLINE_LAMBDA -> Result { *out_result = result; - return result; + R_RETURN(result); }; /* Iterate over all files to find all content metas. */ @@ -411,11 +411,11 @@ namespace ams::mitm::sysupdater { }; Result SystemUpdateService::SetupUpdate(sf::CopyHandle &&transfer_memory, u64 transfer_memory_size, const ncm::Path &path, bool exfat) { - return this->SetupUpdateImpl(std::move(transfer_memory), transfer_memory_size, path, exfat, GetFirmwareVariationId()); + R_RETURN(this->SetupUpdateImpl(std::move(transfer_memory), transfer_memory_size, path, exfat, GetFirmwareVariationId())); } Result SystemUpdateService::SetupUpdateWithVariation(sf::CopyHandle &&transfer_memory, u64 transfer_memory_size, const ncm::Path &path, bool exfat, ncm::FirmwareVariationId firmware_variation_id) { - return this->SetupUpdateImpl(std::move(transfer_memory), transfer_memory_size, path, exfat, firmware_variation_id); + R_RETURN(this->SetupUpdateImpl(std::move(transfer_memory), transfer_memory_size, path, exfat, firmware_variation_id)); } Result SystemUpdateService::RequestPrepareUpdate(sf::OutCopyHandle out_event_handle, sf::Out> out_async) { diff --git a/stratosphere/boot/source/boot_battery_driver.hpp b/stratosphere/boot/source/boot_battery_driver.hpp index 9a385fc66..00b74794b 100644 --- a/stratosphere/boot/source/boot_battery_driver.hpp +++ b/stratosphere/boot/source/boot_battery_driver.hpp @@ -46,35 +46,35 @@ namespace ams::boot { } Result GetChargePercentage(float *out) { - return powctl::GetBatteryChargePercentage(out, s_battery_session); + R_RETURN(powctl::GetBatteryChargePercentage(out, s_battery_session)); } Result GetAverageVCell(int *out) { - return powctl::GetBatteryAverageVCell(out, s_battery_session); + R_RETURN(powctl::GetBatteryAverageVCell(out, s_battery_session)); } Result GetVoltageFuelGaugePercentage(float *out) { - return powctl::GetBatteryVoltageFuelGaugePercentage(out, s_battery_session); + R_RETURN(powctl::GetBatteryVoltageFuelGaugePercentage(out, s_battery_session)); } Result GetAverageCurrent(int *out) { - return powctl::GetBatteryAverageCurrent(out, s_battery_session); + R_RETURN(powctl::GetBatteryAverageCurrent(out, s_battery_session)); } Result GetCurrent(int *out) { - return powctl::GetBatteryCurrent(out, s_battery_session); + R_RETURN(powctl::GetBatteryCurrent(out, s_battery_session)); } Result GetTemperature(float *out) { - return powctl::GetBatteryTemperature(out, s_battery_session); + R_RETURN(powctl::GetBatteryTemperature(out, s_battery_session)); } Result IsI2cShutdownEnabled(bool *out) { - return powctl::IsBatteryI2cShutdownEnabled(out, s_battery_session); + R_RETURN(powctl::IsBatteryI2cShutdownEnabled(out, s_battery_session)); } Result SetI2cShutdownEnabled(bool en) { - return powctl::SetBatteryI2cShutdownEnabled(s_battery_session, en); + R_RETURN(powctl::SetBatteryI2cShutdownEnabled(s_battery_session, en)); } }; diff --git a/stratosphere/boot/source/boot_charger_driver.hpp b/stratosphere/boot/source/boot_charger_driver.hpp index 4c570fdf1..227578802 100644 --- a/stratosphere/boot/source/boot_charger_driver.hpp +++ b/stratosphere/boot/source/boot_charger_driver.hpp @@ -62,35 +62,35 @@ namespace ams::boot { } Result GetChargeCurrentState(powctl::ChargeCurrentState *out) { - return powctl::GetChargerChargeCurrentState(out, m_charger_session); + R_RETURN(powctl::GetChargerChargeCurrentState(out, m_charger_session)); } Result SetChargeCurrentState(powctl::ChargeCurrentState state) { - return powctl::SetChargerChargeCurrentState(m_charger_session, state); + R_RETURN(powctl::SetChargerChargeCurrentState(m_charger_session, state)); } Result GetInputCurrentLimit(int *out) { - return powctl::GetChargerInputCurrentLimit(out, m_charger_session); + R_RETURN(powctl::GetChargerInputCurrentLimit(out, m_charger_session)); } Result SetChargerConfiguration(powctl::ChargerConfiguration cfg) { - return powctl::SetChargerChargerConfiguration(m_charger_session, cfg); + R_RETURN(powctl::SetChargerChargerConfiguration(m_charger_session, cfg)); } Result GetFastChargeCurrentLimit(int *out) { - return powctl::GetChargerFastChargeCurrentLimit(out, m_charger_session); + R_RETURN(powctl::GetChargerFastChargeCurrentLimit(out, m_charger_session)); } Result SetFastChargeCurrentLimit(int limit) { - return powctl::SetChargerFastChargeCurrentLimit(m_charger_session, limit); + R_RETURN(powctl::SetChargerFastChargeCurrentLimit(m_charger_session, limit)); } Result GetChargeVoltageLimit(int *out) { - return powctl::GetChargerChargeVoltageLimit(out, m_charger_session); + R_RETURN(powctl::GetChargerChargeVoltageLimit(out, m_charger_session)); } Result SetChargeVoltageLimit(int limit) { - return powctl::SetChargerChargeVoltageLimit(m_charger_session, limit); + R_RETURN(powctl::SetChargerChargeVoltageLimit(m_charger_session, limit)); } Result GetChargerStatus(boot::ChargerStatus *out) { @@ -111,19 +111,19 @@ namespace ams::boot { } Result GetBatteryCompensation(int *out) { - return powctl::GetChargerBatteryCompensation(out, m_charger_session); + R_RETURN(powctl::GetChargerBatteryCompensation(out, m_charger_session)); } Result SetBatteryCompensation(int v) { - return powctl::SetChargerBatteryCompensation(m_charger_session, v); + R_RETURN(powctl::SetChargerBatteryCompensation(m_charger_session, v)); } Result GetVoltageClamp(int *out) { - return powctl::GetChargerVoltageClamp(out, m_charger_session); + R_RETURN(powctl::GetChargerVoltageClamp(out, m_charger_session)); } Result SetVoltageClamp(int v) { - return powctl::SetChargerVoltageClamp(m_charger_session, v); + R_RETURN(powctl::SetChargerVoltageClamp(m_charger_session, v)); } }; diff --git a/stratosphere/boot/source/boot_i2c_utils.cpp b/stratosphere/boot/source/boot_i2c_utils.cpp index 21f7e3ee8..1652ccf0a 100644 --- a/stratosphere/boot/source/boot_i2c_utils.cpp +++ b/stratosphere/boot/source/boot_i2c_utils.cpp @@ -49,7 +49,7 @@ namespace ams::boot { R_ABORT_UNLESS(formatter.EnqueueSendCommand(i2c::TransactionOption_StartCondition, cmd, cmd_size)); R_ABORT_UNLESS(formatter.EnqueueReceiveCommand(static_cast(i2c::TransactionOption_StartCondition | i2c::TransactionOption_StopCondition), dst_size)); - return RetryUntilSuccess([&]() { return i2c::driver::ExecuteCommandList(dst, dst_size, session, cmd_list, formatter.GetCurrentLength()); }); + R_RETURN(RetryUntilSuccess([&]() { R_RETURN(i2c::driver::ExecuteCommandList(dst, dst_size, session, cmd_list, formatter.GetCurrentLength())); })); } Result WriteI2cRegister(i2c::driver::I2cSession &session, const u8 *src, size_t src_size, const u8 *cmd, size_t cmd_size) { @@ -62,11 +62,11 @@ namespace ams::boot { std::memcpy(cmd_list + 0, cmd, cmd_size); std::memcpy(cmd_list + cmd_size, src, src_size); - return RetryUntilSuccess([&]() { return i2c::driver::Send(session, cmd_list, src_size + cmd_size, static_cast(i2c::TransactionOption_StartCondition | i2c::TransactionOption_StopCondition)); }); + R_RETURN(RetryUntilSuccess([&]() { R_RETURN(i2c::driver::Send(session, cmd_list, src_size + cmd_size, static_cast(i2c::TransactionOption_StartCondition | i2c::TransactionOption_StopCondition))); })); } Result WriteI2cRegister(i2c::driver::I2cSession &session, const u8 address, const u8 value) { - return WriteI2cRegister(session, std::addressof(value), sizeof(value), &address, sizeof(address)); + R_RETURN(WriteI2cRegister(session, std::addressof(value), sizeof(value), &address, sizeof(address))); } } diff --git a/stratosphere/boot/source/boot_pmic_driver.cpp b/stratosphere/boot/source/boot_pmic_driver.cpp index e87e8c602..893726de7 100644 --- a/stratosphere/boot/source/boot_pmic_driver.cpp +++ b/stratosphere/boot/source/boot_pmic_driver.cpp @@ -36,17 +36,17 @@ namespace ams::boot { Result PmicDriver::GetOnOffIrq(u8 *out) { const u8 addr = 0x0B; - return ReadI2cRegister(m_i2c_session, out, sizeof(*out), std::addressof(addr), sizeof(addr)); + R_RETURN(ReadI2cRegister(m_i2c_session, out, sizeof(*out), std::addressof(addr), sizeof(addr))); } Result PmicDriver::GetPowerStatus(u8 *out) { const u8 addr = 0x15; - return ReadI2cRegister(m_i2c_session, out, sizeof(*out), std::addressof(addr), sizeof(addr)); + R_RETURN(ReadI2cRegister(m_i2c_session, out, sizeof(*out), std::addressof(addr), sizeof(addr))); } Result PmicDriver::GetNvErc(u8 *out) { const u8 addr = 0x0C; - return ReadI2cRegister(m_i2c_session, out, sizeof(*out), std::addressof(addr), sizeof(addr)); + R_RETURN(ReadI2cRegister(m_i2c_session, out, sizeof(*out), std::addressof(addr), sizeof(addr))); } Result PmicDriver::GetPowerButtonPressed(bool *out) { diff --git a/stratosphere/boot/source/boot_rtc_driver.cpp b/stratosphere/boot/source/boot_rtc_driver.cpp index f3e9b9560..2e0dce2de 100644 --- a/stratosphere/boot/source/boot_rtc_driver.cpp +++ b/stratosphere/boot/source/boot_rtc_driver.cpp @@ -23,17 +23,17 @@ namespace ams::boot { const u8 update_val = 0x10; R_TRY(WriteI2cRegister(m_i2c_session, &update_val, sizeof(update_val), &update_addr, sizeof(update_addr))); os::SleepThread(TimeSpan::FromMilliSeconds(16)); - return ReadI2cRegister(m_i2c_session, out, sizeof(*out), &address, sizeof(address)); + R_RETURN(ReadI2cRegister(m_i2c_session, out, sizeof(*out), &address, sizeof(address))); } Result RtcDriver::GetRtcIntr(u8 *out) { const u8 addr = 0x00; - return ReadI2cRegister(m_i2c_session, out, sizeof(*out), &addr, sizeof(addr)); + R_RETURN(ReadI2cRegister(m_i2c_session, out, sizeof(*out), &addr, sizeof(addr))); } Result RtcDriver::GetRtcIntrM(u8 *out) { const u8 addr = 0x01; - return this->ReadRtcRegister(out, addr); + R_RETURN(this->ReadRtcRegister(out, addr)); } } diff --git a/stratosphere/dmnt.gen2/source/dmnt2_breakpoint_manager.cpp b/stratosphere/dmnt.gen2/source/dmnt2_breakpoint_manager.cpp index a79f67b28..f13a59508 100644 --- a/stratosphere/dmnt.gen2/source/dmnt2_breakpoint_manager.cpp +++ b/stratosphere/dmnt.gen2/source/dmnt2_breakpoint_manager.cpp @@ -48,7 +48,7 @@ namespace ams::dmnt { AMS_DMNT2_GDB_LOG_DEBUG("BreakPointManager::SetBreakPoint %p 0x%lx !!! Fail 0x%08x !!!\n", bp, bp->m_address, result.GetValue()); } - return result; + R_RETURN(result); } } diff --git a/stratosphere/dmnt.gen2/source/dmnt2_breakpoint_manager_base.cpp b/stratosphere/dmnt.gen2/source/dmnt2_breakpoint_manager_base.cpp index c5db5cd0b..0819798e3 100644 --- a/stratosphere/dmnt.gen2/source/dmnt2_breakpoint_manager_base.cpp +++ b/stratosphere/dmnt.gen2/source/dmnt2_breakpoint_manager_base.cpp @@ -45,7 +45,7 @@ namespace ams::dmnt { for (size_t i = 0; (bp = static_cast(this->GetBreakPoint(i))) != nullptr; ++i) { if (bp->m_in_use && bp->m_address == address) { AMS_ABORT_UNLESS(bp->m_size == size); - return bp->Clear(m_debug_process); + R_RETURN(bp->Clear(m_debug_process)); } } R_SUCCEED(); diff --git a/stratosphere/dmnt.gen2/source/dmnt2_debug_process.cpp b/stratosphere/dmnt.gen2/source/dmnt2_debug_process.cpp index 42ec735f1..2f88bad0a 100644 --- a/stratosphere/dmnt.gen2/source/dmnt2_debug_process.cpp +++ b/stratosphere/dmnt.gen2/source/dmnt2_debug_process.cpp @@ -281,24 +281,24 @@ namespace ams::dmnt { } Result DebugProcess::GetThreadContext(svc::ThreadContext *out, u64 thread_id, u32 flags) { - return svc::GetDebugThreadContext(out, m_debug_handle, thread_id, flags); + R_RETURN(svc::GetDebugThreadContext(out, m_debug_handle, thread_id, flags)); } Result DebugProcess::SetThreadContext(const svc::ThreadContext *ctx, u64 thread_id, u32 flags) { - return svc::SetDebugThreadContext(m_debug_handle, thread_id, ctx, flags); + R_RETURN(svc::SetDebugThreadContext(m_debug_handle, thread_id, ctx, flags)); } Result DebugProcess::ReadMemory(void *dst, uintptr_t address, size_t size) { - return svc::ReadDebugProcessMemory(reinterpret_cast(dst), m_debug_handle, address, size); + R_RETURN(svc::ReadDebugProcessMemory(reinterpret_cast(dst), m_debug_handle, address, size)); } Result DebugProcess::WriteMemory(const void *src, uintptr_t address, size_t size) { - return svc::WriteDebugProcessMemory(m_debug_handle, reinterpret_cast(src), address, size); + R_RETURN(svc::WriteDebugProcessMemory(m_debug_handle, reinterpret_cast(src), address, size)); } Result DebugProcess::QueryMemory(svc::MemoryInfo *out, uintptr_t address) { svc::PageInfo dummy; - return svc::QueryDebugProcessMemory(out, std::addressof(dummy), m_debug_handle, address); + R_RETURN(svc::QueryDebugProcessMemory(out, std::addressof(dummy), m_debug_handle, address)); } Result DebugProcess::Continue() { @@ -333,7 +333,7 @@ namespace ams::dmnt { Result DebugProcess::Step() { AMS_DMNT2_GDB_LOG_DEBUG("DebugProcess::Step() all\n"); - return this->Step(this->GetLastThreadId()); + R_RETURN(this->Step(this->GetLastThreadId())); } Result DebugProcess::Step(u64 thread_id) { @@ -385,7 +385,7 @@ namespace ams::dmnt { Result DebugProcess::Break() { if (this->GetStatus() == ProcessStatus_Running) { AMS_DMNT2_GDB_LOG_DEBUG("DebugProcess::Break\n"); - return svc::BreakDebugProcess(m_debug_handle); + R_RETURN(svc::BreakDebugProcess(m_debug_handle)); } else { AMS_DMNT2_GDB_LOG_ERROR("DebugProcess::Break called on non-running process!\n"); R_SUCCEED(); @@ -467,7 +467,7 @@ namespace ams::dmnt { } Result DebugProcess::SetBreakPoint(uintptr_t address, size_t size, bool is_step) { - return m_software_breakpoints.SetBreakPoint(address, size, is_step); + R_RETURN(m_software_breakpoints.SetBreakPoint(address, size, is_step)); } Result DebugProcess::ClearBreakPoint(uintptr_t address, size_t size) { @@ -476,7 +476,7 @@ namespace ams::dmnt { } Result DebugProcess::SetHardwareBreakPoint(uintptr_t address, size_t size, bool is_step) { - return m_hardware_breakpoints.SetBreakPoint(address, size, is_step); + R_RETURN(m_hardware_breakpoints.SetBreakPoint(address, size, is_step)); } Result DebugProcess::ClearHardwareBreakPoint(uintptr_t address, size_t size) { @@ -485,15 +485,15 @@ namespace ams::dmnt { } Result DebugProcess::SetWatchPoint(u64 address, u64 size, bool read, bool write) { - return m_hardware_watchpoints.SetWatchPoint(address, size, read, write); + R_RETURN(m_hardware_watchpoints.SetWatchPoint(address, size, read, write)); } Result DebugProcess::ClearWatchPoint(u64 address, u64 size) { - return m_hardware_watchpoints.ClearBreakPoint(address, size); + R_RETURN(m_hardware_watchpoints.ClearBreakPoint(address, size)); } Result DebugProcess::GetWatchPointInfo(u64 address, bool &read, bool &write) { - return m_hardware_watchpoints.GetWatchPointInfo(address, read, write); + R_RETURN(m_hardware_watchpoints.GetWatchPointInfo(address, read, write)); } bool DebugProcess::IsValidWatchPoint(u64 address, u64 size) { diff --git a/stratosphere/dmnt.gen2/source/dmnt2_gdb_server_impl.cpp b/stratosphere/dmnt.gen2/source/dmnt2_gdb_server_impl.cpp index 53247291e..810e2635c 100644 --- a/stratosphere/dmnt.gen2/source/dmnt2_gdb_server_impl.cpp +++ b/stratosphere/dmnt.gen2/source/dmnt2_gdb_server_impl.cpp @@ -957,7 +957,7 @@ namespace ams::dmnt { s32 dummy = -1; svc::Handle handle = m_debug_process.GetHandle(); - return svc::WaitSynchronization(std::addressof(dummy), std::addressof(handle), 1, TimeSpan::FromMilliSeconds(20).GetNanoSeconds()); + R_RETURN(svc::WaitSynchronization(std::addressof(dummy), std::addressof(handle), 1, TimeSpan::FromMilliSeconds(20).GetNanoSeconds())); }(); /* Check if we're killed. */ diff --git a/stratosphere/dmnt.gen2/source/dmnt2_hardware_breakpoint.cpp b/stratosphere/dmnt.gen2/source/dmnt2_hardware_breakpoint.cpp index 3d62436c1..563918825 100644 --- a/stratosphere/dmnt.gen2/source/dmnt2_hardware_breakpoint.cpp +++ b/stratosphere/dmnt.gen2/source/dmnt2_hardware_breakpoint.cpp @@ -99,7 +99,7 @@ namespace ams::dmnt { result = HardwareBreakPointManager::SetExecutionBreakPoint(m_reg, m_ctx, 0); this->Reset(); } - return result; + R_RETURN(result); } Result HardwareBreakPoint::Set(DebugProcess *debug_process, uintptr_t address, size_t size, bool is_step) { @@ -159,7 +159,7 @@ namespace ams::dmnt { AMS_DMNT2_GDB_LOG_ERROR("SetContextBreakPoint FAIL 0x%08x ctx=%d\n", result.GetValue(), ctx); } - return result; + R_RETURN(result); } svc::HardwareBreakPointRegisterName HardwareBreakPointManager::GetWatchPointContextRegister() { @@ -176,7 +176,7 @@ namespace ams::dmnt { AMS_DMNT2_GDB_LOG_ERROR("SetContextBreakPoint FAIL 0x%08x reg=%d, ctx=%d, address=%lx\n", result.GetValue(), reg, ctx, address); } - return result; + R_RETURN(result); } void HardwareBreakPointManager::CountBreakPointRegisters() { diff --git a/stratosphere/dmnt.gen2/source/dmnt2_hardware_watchpoint.cpp b/stratosphere/dmnt.gen2/source/dmnt2_hardware_watchpoint.cpp index 137c0a0c7..00804dfa9 100644 --- a/stratosphere/dmnt.gen2/source/dmnt2_hardware_watchpoint.cpp +++ b/stratosphere/dmnt.gen2/source/dmnt2_hardware_watchpoint.cpp @@ -50,7 +50,7 @@ namespace ams::dmnt { if (R_FAILED(result)) { AMS_DMNT2_GDB_LOG_ERROR("SetDataBreakPoint FAIL 0x%08x, reg=%d, address=0x%lx\n", result.GetValue(), reg, address); } - return result; + R_RETURN(result); } } @@ -101,7 +101,7 @@ namespace ams::dmnt { result = SetDataBreakPoint(m_reg, m_ctx, 0, 0, false, false); this->Reset(); } - return result; + R_RETURN(result); } Result WatchPoint::Set(DebugProcess *debug_process, uintptr_t address, size_t size, bool read, bool write) { @@ -143,7 +143,7 @@ namespace ams::dmnt { R_UNLESS(bp != nullptr, svc::ResultOutOfHandles()); /* Set the watchpoint. */ - return bp->Set(m_debug_process, address, size, read, write); + R_RETURN(bp->Set(m_debug_process, address, size, read, write)); } Result HardwareWatchPointManager::GetWatchPointInfo(u64 address, bool &read, bool &write) { diff --git a/stratosphere/dmnt.gen2/source/dmnt2_software_breakpoint.cpp b/stratosphere/dmnt.gen2/source/dmnt2_software_breakpoint.cpp index d83aa0254..c772d2849 100644 --- a/stratosphere/dmnt.gen2/source/dmnt2_software_breakpoint.cpp +++ b/stratosphere/dmnt.gen2/source/dmnt2_software_breakpoint.cpp @@ -43,7 +43,7 @@ namespace ams::dmnt { AMS_DMNT2_GDB_LOG_ERROR("SoftwareBreakPoint::Clear %p 0x%lx, insn=0x%x, !!! Null Address !!!\n", this, m_address, m_insn); } } - return result; + R_RETURN(result); } Result SoftwareBreakPoint::Set(DebugProcess *debug_process, uintptr_t address, size_t size, bool is_step) { @@ -76,7 +76,7 @@ namespace ams::dmnt { m_in_use = true; } - return result; + R_RETURN(result); } SoftwareBreakPointManager::SoftwareBreakPointManager(DebugProcess *debug_process) : BreakPointManager(debug_process) { diff --git a/stratosphere/dmnt/source/cheat/dmnt_cheat_service.cpp b/stratosphere/dmnt/source/cheat/dmnt_cheat_service.cpp index 5c04f82e3..3327dfa4f 100644 --- a/stratosphere/dmnt/source/cheat/dmnt_cheat_service.cpp +++ b/stratosphere/dmnt/source/cheat/dmnt_cheat_service.cpp @@ -32,7 +32,7 @@ namespace ams::dmnt::cheat { } Result CheatService::GetCheatProcessMetadata(sf::Out out_metadata) { - return dmnt::cheat::impl::GetCheatProcessMetadata(out_metadata.GetPointer()); + R_RETURN(dmnt::cheat::impl::GetCheatProcessMetadata(out_metadata.GetPointer())); } Result CheatService::ForceOpenCheatProcess() { @@ -41,15 +41,15 @@ namespace ams::dmnt::cheat { } Result CheatService::PauseCheatProcess() { - return dmnt::cheat::impl::PauseCheatProcess(); + R_RETURN(dmnt::cheat::impl::PauseCheatProcess()); } Result CheatService::ResumeCheatProcess() { - return dmnt::cheat::impl::ResumeCheatProcess(); + R_RETURN(dmnt::cheat::impl::ResumeCheatProcess()); } Result CheatService::ForceCloseCheatProcess() { - return dmnt::cheat::impl::ForceCloseCheatProcess(); + R_RETURN(dmnt::cheat::impl::ForceCloseCheatProcess()); } /* ========================================================================================= */ @@ -57,26 +57,26 @@ namespace ams::dmnt::cheat { /* ========================================================================================= */ Result CheatService::GetCheatProcessMappingCount(sf::Out out_count) { - return dmnt::cheat::impl::GetCheatProcessMappingCount(out_count.GetPointer()); + R_RETURN(dmnt::cheat::impl::GetCheatProcessMappingCount(out_count.GetPointer())); } Result CheatService::GetCheatProcessMappings(const sf::OutArray &mappings, sf::Out out_count, u64 offset) { R_UNLESS(mappings.GetPointer() != nullptr, dmnt::cheat::ResultCheatNullBuffer()); - return dmnt::cheat::impl::GetCheatProcessMappings(mappings.GetPointer(), mappings.GetSize(), out_count.GetPointer(), offset); + R_RETURN(dmnt::cheat::impl::GetCheatProcessMappings(mappings.GetPointer(), mappings.GetSize(), out_count.GetPointer(), offset)); } Result CheatService::ReadCheatProcessMemory(const sf::OutBuffer &buffer, u64 address, u64 out_size) { R_UNLESS(buffer.GetPointer() != nullptr, dmnt::cheat::ResultCheatNullBuffer()); - return dmnt::cheat::impl::ReadCheatProcessMemory(address, buffer.GetPointer(), std::min(out_size, buffer.GetSize())); + R_RETURN(dmnt::cheat::impl::ReadCheatProcessMemory(address, buffer.GetPointer(), std::min(out_size, buffer.GetSize()))); } Result CheatService::WriteCheatProcessMemory(const sf::InBuffer &buffer, u64 address, u64 in_size) { R_UNLESS(buffer.GetPointer() != nullptr, dmnt::cheat::ResultCheatNullBuffer()); - return dmnt::cheat::impl::WriteCheatProcessMemory(address, buffer.GetPointer(), std::min(in_size, buffer.GetSize())); + R_RETURN(dmnt::cheat::impl::WriteCheatProcessMemory(address, buffer.GetPointer(), std::min(in_size, buffer.GetSize()))); } Result CheatService::QueryCheatProcessMemory(sf::Out mapping, u64 address) { - return dmnt::cheat::impl::QueryCheatProcessMemory(mapping.GetPointer(), address); + R_RETURN(dmnt::cheat::impl::QueryCheatProcessMemory(mapping.GetPointer(), address)); } /* ========================================================================================= */ @@ -84,44 +84,44 @@ namespace ams::dmnt::cheat { /* ========================================================================================= */ Result CheatService::GetCheatCount(sf::Out out_count) { - return dmnt::cheat::impl::GetCheatCount(out_count.GetPointer()); + R_RETURN(dmnt::cheat::impl::GetCheatCount(out_count.GetPointer())); } Result CheatService::GetCheats(const sf::OutArray &cheats, sf::Out out_count, u64 offset) { R_UNLESS(cheats.GetPointer() != nullptr, dmnt::cheat::ResultCheatNullBuffer()); - return dmnt::cheat::impl::GetCheats(cheats.GetPointer(), cheats.GetSize(), out_count.GetPointer(), offset); + R_RETURN(dmnt::cheat::impl::GetCheats(cheats.GetPointer(), cheats.GetSize(), out_count.GetPointer(), offset)); } Result CheatService::GetCheatById(sf::Out cheat, u32 cheat_id) { - return dmnt::cheat::impl::GetCheatById(cheat.GetPointer(), cheat_id); + R_RETURN(dmnt::cheat::impl::GetCheatById(cheat.GetPointer(), cheat_id)); } Result CheatService::ToggleCheat(u32 cheat_id) { - return dmnt::cheat::impl::ToggleCheat(cheat_id); + R_RETURN(dmnt::cheat::impl::ToggleCheat(cheat_id)); } Result CheatService::AddCheat(const CheatDefinition &cheat, sf::Out out_cheat_id, bool enabled) { - return dmnt::cheat::impl::AddCheat(out_cheat_id.GetPointer(), cheat, enabled); + R_RETURN(dmnt::cheat::impl::AddCheat(out_cheat_id.GetPointer(), cheat, enabled)); } Result CheatService::RemoveCheat(u32 cheat_id) { - return dmnt::cheat::impl::RemoveCheat(cheat_id); + R_RETURN(dmnt::cheat::impl::RemoveCheat(cheat_id)); } Result CheatService::ReadStaticRegister(sf::Out out, u8 which) { - return dmnt::cheat::impl::ReadStaticRegister(out.GetPointer(), which); + R_RETURN(dmnt::cheat::impl::ReadStaticRegister(out.GetPointer(), which)); } Result CheatService::WriteStaticRegister(u8 which, u64 value) { - return dmnt::cheat::impl::WriteStaticRegister(which, value); + R_RETURN(dmnt::cheat::impl::WriteStaticRegister(which, value)); } Result CheatService::ResetStaticRegisters() { - return dmnt::cheat::impl::ResetStaticRegisters(); + R_RETURN(dmnt::cheat::impl::ResetStaticRegisters()); } Result CheatService::SetMasterCheat(const CheatDefinition &cheat) { - return dmnt::cheat::impl::SetMasterCheat(cheat); + R_RETURN(dmnt::cheat::impl::SetMasterCheat(cheat)); } /* ========================================================================================= */ @@ -129,16 +129,16 @@ namespace ams::dmnt::cheat { /* ========================================================================================= */ Result CheatService::GetFrozenAddressCount(sf::Out out_count) { - return dmnt::cheat::impl::GetFrozenAddressCount(out_count.GetPointer()); + R_RETURN(dmnt::cheat::impl::GetFrozenAddressCount(out_count.GetPointer())); } Result CheatService::GetFrozenAddresses(const sf::OutArray &addresses, sf::Out out_count, u64 offset) { R_UNLESS(addresses.GetPointer() != nullptr, dmnt::cheat::ResultCheatNullBuffer()); - return dmnt::cheat::impl::GetFrozenAddresses(addresses.GetPointer(), addresses.GetSize(), out_count.GetPointer(), offset); + R_RETURN(dmnt::cheat::impl::GetFrozenAddresses(addresses.GetPointer(), addresses.GetSize(), out_count.GetPointer(), offset)); } Result CheatService::GetFrozenAddress(sf::Out entry, u64 address) { - return dmnt::cheat::impl::GetFrozenAddress(entry.GetPointer(), address); + R_RETURN(dmnt::cheat::impl::GetFrozenAddress(entry.GetPointer(), address)); } Result CheatService::EnableFrozenAddress(sf::Out out_value, u64 address, u64 width) { @@ -146,11 +146,11 @@ namespace ams::dmnt::cheat { R_UNLESS(width > 0, dmnt::cheat::ResultFrozenAddressInvalidWidth()); R_UNLESS(width <= sizeof(u64), dmnt::cheat::ResultFrozenAddressInvalidWidth()); R_UNLESS((width & (width - 1)) == 0, dmnt::cheat::ResultFrozenAddressInvalidWidth()); - return dmnt::cheat::impl::EnableFrozenAddress(out_value.GetPointer(), address, width); + R_RETURN(dmnt::cheat::impl::EnableFrozenAddress(out_value.GetPointer(), address, width)); } Result CheatService::DisableFrozenAddress(u64 address) { - return dmnt::cheat::impl::DisableFrozenAddress(address); + R_RETURN(dmnt::cheat::impl::DisableFrozenAddress(address)); } } diff --git a/stratosphere/dmnt/source/cheat/impl/dmnt_cheat_api.cpp b/stratosphere/dmnt/source/cheat/impl/dmnt_cheat_api.cpp index 4906eed47..c23d1c9c0 100644 --- a/stratosphere/dmnt/source/cheat/impl/dmnt_cheat_api.cpp +++ b/stratosphere/dmnt/source/cheat/impl/dmnt_cheat_api.cpp @@ -301,7 +301,7 @@ namespace ams::dmnt::cheat::impl { } Result ForceOpenCheatProcess() { - return this->AttachToApplicationProcess(false); + R_RETURN(this->AttachToApplicationProcess(false)); } Result ForceCloseCheatProcess() { @@ -310,7 +310,7 @@ namespace ams::dmnt::cheat::impl { } Result ReadCheatProcessMemoryUnsafe(u64 proc_addr, void *out_data, size_t size) { - return svc::ReadDebugProcessMemory(reinterpret_cast(out_data), this->GetCheatProcessHandle(), proc_addr, size); + R_RETURN(svc::ReadDebugProcessMemory(reinterpret_cast(out_data), this->GetCheatProcessHandle(), proc_addr, size)); } Result WriteCheatProcessMemoryUnsafe(u64 proc_addr, const void *data, size_t size) { @@ -340,7 +340,7 @@ namespace ams::dmnt::cheat::impl { Result PauseCheatProcessUnsafe() { m_broken_unsafe = true; m_unsafe_break_event.Clear(); - return svc::BreakDebugProcess(this->GetCheatProcessHandle()); + R_RETURN(svc::BreakDebugProcess(this->GetCheatProcessHandle())); } Result ResumeCheatProcessUnsafe() { @@ -406,7 +406,7 @@ namespace ams::dmnt::cheat::impl { R_TRY(this->EnsureCheatProcess()); - return this->ReadCheatProcessMemoryUnsafe(proc_addr, out_data, size); + R_RETURN(this->ReadCheatProcessMemoryUnsafe(proc_addr, out_data, size)); } Result WriteCheatProcessMemory(u64 proc_addr, const void *data, size_t size) { @@ -414,7 +414,7 @@ namespace ams::dmnt::cheat::impl { R_TRY(this->EnsureCheatProcess()); - return this->WriteCheatProcessMemoryUnsafe(proc_addr, data, size); + R_RETURN(this->WriteCheatProcessMemoryUnsafe(proc_addr, data, size)); } Result QueryCheatProcessMemory(svc::MemoryInfo *mapping, u64 address) { @@ -423,7 +423,7 @@ namespace ams::dmnt::cheat::impl { R_TRY(this->EnsureCheatProcess()); svc::PageInfo page_info; - return svc::QueryDebugProcessMemory(mapping, std::addressof(page_info), this->GetCheatProcessHandle(), address); + R_RETURN(svc::QueryDebugProcessMemory(mapping, std::addressof(page_info), this->GetCheatProcessHandle(), address)); } Result PauseCheatProcess() { @@ -431,7 +431,7 @@ namespace ams::dmnt::cheat::impl { R_TRY(this->EnsureCheatProcess()); - return this->PauseCheatProcessUnsafe(); + R_RETURN(this->PauseCheatProcessUnsafe()); } Result ResumeCheatProcess() { @@ -439,7 +439,7 @@ namespace ams::dmnt::cheat::impl { R_TRY(this->EnsureCheatProcess()); - return this->ResumeCheatProcessUnsafe(); + R_RETURN(this->ResumeCheatProcessUnsafe()); } Result GetCheatCount(u64 *out_count) { @@ -844,7 +844,7 @@ namespace ams::dmnt::cheat::impl { } else if (num_modules == 1 && !on_process_launch) { proc_module = std::addressof(proc_modules[0]); } else { - return dmnt::cheat::ResultCheatNotAttached(); + R_THROW(dmnt::cheat::ResultCheatNotAttached()); } m_cheat_process_metadata.main_nso_extents.base = proc_module->address; @@ -1198,119 +1198,119 @@ namespace ams::dmnt::cheat::impl { } Result GetCheatProcessMetadata(CheatProcessMetadata *out) { - return GetReference(g_cheat_process_manager).GetCheatProcessMetadata(out); + R_RETURN(GetReference(g_cheat_process_manager).GetCheatProcessMetadata(out)); } Result ForceOpenCheatProcess() { - return GetReference(g_cheat_process_manager).ForceOpenCheatProcess(); + R_RETURN(GetReference(g_cheat_process_manager).ForceOpenCheatProcess()); } Result PauseCheatProcess() { - return GetReference(g_cheat_process_manager).PauseCheatProcess(); + R_RETURN(GetReference(g_cheat_process_manager).PauseCheatProcess()); } Result ResumeCheatProcess() { - return GetReference(g_cheat_process_manager).ResumeCheatProcess(); + R_RETURN(GetReference(g_cheat_process_manager).ResumeCheatProcess()); } Result ForceCloseCheatProcess() { - return GetReference(g_cheat_process_manager).ForceCloseCheatProcess(); + R_RETURN(GetReference(g_cheat_process_manager).ForceCloseCheatProcess()); } Result ReadCheatProcessMemoryUnsafe(u64 process_addr, void *out_data, size_t size) { - return GetReference(g_cheat_process_manager).ReadCheatProcessMemoryUnsafe(process_addr, out_data, size); + R_RETURN(GetReference(g_cheat_process_manager).ReadCheatProcessMemoryUnsafe(process_addr, out_data, size)); } Result WriteCheatProcessMemoryUnsafe(u64 process_addr, void *data, size_t size) { - return GetReference(g_cheat_process_manager).WriteCheatProcessMemoryUnsafe(process_addr, data, size); + R_RETURN(GetReference(g_cheat_process_manager).WriteCheatProcessMemoryUnsafe(process_addr, data, size)); } Result PauseCheatProcessUnsafe() { - return GetReference(g_cheat_process_manager).PauseCheatProcessUnsafe(); + R_RETURN(GetReference(g_cheat_process_manager).PauseCheatProcessUnsafe()); } Result ResumeCheatProcessUnsafe() { - return GetReference(g_cheat_process_manager).ResumeCheatProcessUnsafe(); + R_RETURN(GetReference(g_cheat_process_manager).ResumeCheatProcessUnsafe()); } Result GetCheatProcessMappingCount(u64 *out_count) { - return GetReference(g_cheat_process_manager).GetCheatProcessMappingCount(out_count); + R_RETURN(GetReference(g_cheat_process_manager).GetCheatProcessMappingCount(out_count)); } Result GetCheatProcessMappings(svc::MemoryInfo *mappings, size_t max_count, u64 *out_count, u64 offset) { - return GetReference(g_cheat_process_manager).GetCheatProcessMappings(mappings, max_count, out_count, offset); + R_RETURN(GetReference(g_cheat_process_manager).GetCheatProcessMappings(mappings, max_count, out_count, offset)); } Result ReadCheatProcessMemory(u64 proc_addr, void *out_data, size_t size) { - return GetReference(g_cheat_process_manager).ReadCheatProcessMemory(proc_addr, out_data, size); + R_RETURN(GetReference(g_cheat_process_manager).ReadCheatProcessMemory(proc_addr, out_data, size)); } Result WriteCheatProcessMemory(u64 proc_addr, const void *data, size_t size) { - return GetReference(g_cheat_process_manager).WriteCheatProcessMemory(proc_addr, data, size); + R_RETURN(GetReference(g_cheat_process_manager).WriteCheatProcessMemory(proc_addr, data, size)); } Result QueryCheatProcessMemory(svc::MemoryInfo *mapping, u64 address) { - return GetReference(g_cheat_process_manager).QueryCheatProcessMemory(mapping, address); + R_RETURN(GetReference(g_cheat_process_manager).QueryCheatProcessMemory(mapping, address)); } Result GetCheatCount(u64 *out_count) { - return GetReference(g_cheat_process_manager).GetCheatCount(out_count); + R_RETURN(GetReference(g_cheat_process_manager).GetCheatCount(out_count)); } Result GetCheats(CheatEntry *cheats, size_t max_count, u64 *out_count, u64 offset) { - return GetReference(g_cheat_process_manager).GetCheats(cheats, max_count, out_count, offset); + R_RETURN(GetReference(g_cheat_process_manager).GetCheats(cheats, max_count, out_count, offset)); } Result GetCheatById(CheatEntry *out_cheat, u32 cheat_id) { - return GetReference(g_cheat_process_manager).GetCheatById(out_cheat, cheat_id); + R_RETURN(GetReference(g_cheat_process_manager).GetCheatById(out_cheat, cheat_id)); } Result ToggleCheat(u32 cheat_id) { - return GetReference(g_cheat_process_manager).ToggleCheat(cheat_id); + R_RETURN(GetReference(g_cheat_process_manager).ToggleCheat(cheat_id)); } Result AddCheat(u32 *out_id, const CheatDefinition &def, bool enabled) { - return GetReference(g_cheat_process_manager).AddCheat(out_id, def, enabled); + R_RETURN(GetReference(g_cheat_process_manager).AddCheat(out_id, def, enabled)); } Result RemoveCheat(u32 cheat_id) { - return GetReference(g_cheat_process_manager).RemoveCheat(cheat_id); + R_RETURN(GetReference(g_cheat_process_manager).RemoveCheat(cheat_id)); } Result SetMasterCheat(const CheatDefinition &def) { - return GetReference(g_cheat_process_manager).SetMasterCheat(def); + R_RETURN(GetReference(g_cheat_process_manager).SetMasterCheat(def)); } Result ReadStaticRegister(u64 *out, size_t which) { - return GetReference(g_cheat_process_manager).ReadStaticRegister(out, which); + R_RETURN(GetReference(g_cheat_process_manager).ReadStaticRegister(out, which)); } Result WriteStaticRegister(size_t which, u64 value) { - return GetReference(g_cheat_process_manager).WriteStaticRegister(which, value); + R_RETURN(GetReference(g_cheat_process_manager).WriteStaticRegister(which, value)); } Result ResetStaticRegisters() { - return GetReference(g_cheat_process_manager).ResetStaticRegisters(); + R_RETURN(GetReference(g_cheat_process_manager).ResetStaticRegisters()); } Result GetFrozenAddressCount(u64 *out_count) { - return GetReference(g_cheat_process_manager).GetFrozenAddressCount(out_count); + R_RETURN(GetReference(g_cheat_process_manager).GetFrozenAddressCount(out_count)); } Result GetFrozenAddresses(FrozenAddressEntry *frz_addrs, size_t max_count, u64 *out_count, u64 offset) { - return GetReference(g_cheat_process_manager).GetFrozenAddresses(frz_addrs, max_count, out_count, offset); + R_RETURN(GetReference(g_cheat_process_manager).GetFrozenAddresses(frz_addrs, max_count, out_count, offset)); } Result GetFrozenAddress(FrozenAddressEntry *frz_addr, u64 address) { - return GetReference(g_cheat_process_manager).GetFrozenAddress(frz_addr, address); + R_RETURN(GetReference(g_cheat_process_manager).GetFrozenAddress(frz_addr, address)); } Result EnableFrozenAddress(u64 *out_value, u64 address, u64 width) { - return GetReference(g_cheat_process_manager).EnableFrozenAddress(out_value, address, width); + R_RETURN(GetReference(g_cheat_process_manager).EnableFrozenAddress(out_value, address, width)); } Result DisableFrozenAddress(u64 address) { - return GetReference(g_cheat_process_manager).DisableFrozenAddress(address); + R_RETURN(GetReference(g_cheat_process_manager).DisableFrozenAddress(address)); } } diff --git a/stratosphere/dmnt/source/cheat/impl/dmnt_cheat_debug_events_manager.cpp b/stratosphere/dmnt/source/cheat/impl/dmnt_cheat_debug_events_manager.cpp index 7c71891f2..fc65620c6 100644 --- a/stratosphere/dmnt/source/cheat/impl/dmnt_cheat_debug_events_manager.cpp +++ b/stratosphere/dmnt/source/cheat/impl/dmnt_cheat_debug_events_manager.cpp @@ -84,9 +84,9 @@ namespace ams::dmnt::cheat::impl { Result ContinueDebugEvent(os::NativeHandle debug_handle) { if (hos::GetVersion() >= hos::Version_3_0_0) { - return svc::ContinueDebugEvent(debug_handle, svc::ContinueFlag_ExceptionHandled | svc::ContinueFlag_ContinueAll, nullptr, 0); + R_RETURN(svc::ContinueDebugEvent(debug_handle, svc::ContinueFlag_ExceptionHandled | svc::ContinueFlag_ContinueAll, nullptr, 0)); } else { - return svc::LegacyContinueDebugEvent(debug_handle, svc::ContinueFlag_ExceptionHandled | svc::ContinueFlag_ContinueAll, 0); + R_RETURN(svc::LegacyContinueDebugEvent(debug_handle, svc::ContinueFlag_ExceptionHandled | svc::ContinueFlag_ContinueAll, 0)); } } @@ -138,7 +138,7 @@ namespace ams::dmnt::cheat::impl { /* Send handle to correct core, wait for continue to finish. */ this->SendHandle(target_core, cheat_dbg_hnd); - return this->GetContinueResult(target_core); + R_RETURN(this->GetContinueResult(target_core)); } }; @@ -152,7 +152,7 @@ namespace ams::dmnt::cheat::impl { } Result ContinueCheatProcess(os::NativeHandle cheat_dbg_hnd) { - return GetReference(g_events_manager).ContinueCheatProcess(cheat_dbg_hnd); + R_RETURN(GetReference(g_events_manager).ContinueCheatProcess(cheat_dbg_hnd)); } } diff --git a/stratosphere/fatal/source/fatal_task_clock.cpp b/stratosphere/fatal/source/fatal_task_clock.cpp index 350ef0703..f15e5f6f5 100644 --- a/stratosphere/fatal/source/fatal_task_clock.cpp +++ b/stratosphere/fatal/source/fatal_task_clock.cpp @@ -70,7 +70,7 @@ namespace ams::fatal::srv { } Result AdjustClockTask::Run() { - return AdjustClock(); + R_RETURN(AdjustClock()); } } diff --git a/stratosphere/fatal/source/fatal_task_screen.cpp b/stratosphere/fatal/source/fatal_task_screen.cpp index 9ccaa8bd1..0aa3634ae 100644 --- a/stratosphere/fatal/source/fatal_task_screen.cpp +++ b/stratosphere/fatal/source/fatal_task_screen.cpp @@ -495,7 +495,7 @@ namespace ams::fatal::srv { /* Don't show the fatal error screen until we've verified the battery is okay. */ m_context->battery_event->Wait(); - return ShowFatal(); + R_RETURN(ShowFatal()); } void BacklightControlTask::TurnOnBacklight() { diff --git a/stratosphere/loader/source/ldr_loader_service.cpp b/stratosphere/loader/source/ldr_loader_service.cpp index e4ca20612..61c849799 100644 --- a/stratosphere/loader/source/ldr_loader_service.cpp +++ b/stratosphere/loader/source/ldr_loader_service.cpp @@ -44,7 +44,7 @@ namespace ams::ldr { path[sizeof(path) - 1] = '\x00'; /* Create the process. */ - return ldr::CreateProcess(out, pin_id, loc, override_status, path, g_argument_store.Get(loc.program_id), flags, resource_limit); + R_RETURN(ldr::CreateProcess(out, pin_id, loc, override_status, path, g_argument_store.Get(loc.program_id), flags, resource_limit)); } Result LoaderService::GetProgramInfo(ProgramInfo *out, cfg::OverrideStatus *out_status, const ncm::ProgramLocation &loc) { @@ -81,29 +81,29 @@ namespace ams::ldr { Result LoaderService::PinProgram(PinId *out, const ncm::ProgramLocation &loc, const cfg::OverrideStatus &status) { *out = {}; - return ldr::PinProgram(out, loc, status); + R_RETURN(ldr::PinProgram(out, loc, status)); } Result LoaderService::UnpinProgram(PinId id) { - return ldr::UnpinProgram(id); + R_RETURN(ldr::UnpinProgram(id)); } Result LoaderService::SetProgramArgument(ncm::ProgramId program_id, const void *argument, size_t size) { - return g_argument_store.Set(program_id, argument, size); + R_RETURN(g_argument_store.Set(program_id, argument, size)); } Result LoaderService::FlushArguments() { - return g_argument_store.Flush(); + R_RETURN(g_argument_store.Flush()); } Result LoaderService::GetProcessModuleInfo(u32 *out_count, ModuleInfo *out, size_t max_out_count, os::ProcessId process_id) { *out_count = 0; std::memset(out, 0, max_out_count * sizeof(*out)); - return ldr::GetProcessModuleInfo(out_count, out, max_out_count, process_id); + R_RETURN(ldr::GetProcessModuleInfo(out_count, out, max_out_count, process_id)); } Result LoaderService::RegisterExternalCode(os::NativeHandle *out, ncm::ProgramId program_id) { - return fssystem::CreateExternalCode(out, program_id); + R_RETURN(fssystem::CreateExternalCode(out, program_id)); } void LoaderService::UnregisterExternalCode(ncm::ProgramId program_id) { diff --git a/stratosphere/loader/source/ldr_loader_service.hpp b/stratosphere/loader/source/ldr_loader_service.hpp index c7516d839..bad74cd80 100644 --- a/stratosphere/loader/source/ldr_loader_service.hpp +++ b/stratosphere/loader/source/ldr_loader_service.hpp @@ -22,29 +22,30 @@ namespace ams::ldr { public: /* Official commands. */ Result CreateProcess(sf::OutMoveHandle proc_h, PinId id, u32 flags, sf::CopyHandle &&reslimit_h) { + /* Create a handle to set the output to when done. */ os::NativeHandle handle = os::InvalidNativeHandle; - const auto result = this->CreateProcess(std::addressof(handle), id, flags, reslimit_h.GetOsHandle()); - proc_h.SetValue(handle, true); - return result; + ON_SCOPE_EXIT { proc_h.SetValue(handle, true); }; + + R_RETURN(this->CreateProcess(std::addressof(handle), id, flags, reslimit_h.GetOsHandle())); } Result GetProgramInfo(sf::Out out_program_info, const ncm::ProgramLocation &loc) { - return this->GetProgramInfo(out_program_info.GetPointer(), nullptr, loc); + R_RETURN(this->GetProgramInfo(out_program_info.GetPointer(), nullptr, loc)); } Result PinProgram(sf::Out out_id, const ncm::ProgramLocation &loc) { - return this->PinProgram(out_id.GetPointer(), loc, cfg::OverrideStatus{}); + R_RETURN(this->PinProgram(out_id.GetPointer(), loc, cfg::OverrideStatus{})); } Result UnpinProgram(PinId id); Result SetProgramArgumentDeprecated(ncm::ProgramId program_id, const sf::InPointerBuffer &args, u32 args_size) { AMS_UNUSED(args_size); - return this->SetProgramArgument(program_id, args.GetPointer(), std::min(args_size, args.GetSize())); + R_RETURN(this->SetProgramArgument(program_id, args.GetPointer(), std::min(args_size, args.GetSize()))); } Result SetProgramArgument(ncm::ProgramId program_id, const sf::InPointerBuffer &args) { - return this->SetProgramArgument(program_id, args.GetPointer(), args.GetSize()); + R_RETURN(this->SetProgramArgument(program_id, args.GetPointer(), args.GetSize())); } Result FlushArguments(); @@ -52,17 +53,18 @@ namespace ams::ldr { Result GetProcessModuleInfo(sf::Out count, const sf::OutPointerArray &out, os::ProcessId process_id) { R_UNLESS(out.GetSize() <= std::numeric_limits::max(), ldr::ResultInvalidSize()); - return this->GetProcessModuleInfo(count.GetPointer(), out.GetPointer(), out.GetSize(), process_id); + R_RETURN(this->GetProcessModuleInfo(count.GetPointer(), out.GetPointer(), out.GetSize(), process_id)); } Result SetEnabledProgramVerification(bool enabled); /* Atmosphere commands. */ Result AtmosphereRegisterExternalCode(sf::OutMoveHandle out, ncm::ProgramId program_id) { + /* Create a handle to set the output to when done. */ os::NativeHandle handle = os::InvalidNativeHandle; - const auto result = this->RegisterExternalCode(std::addressof(handle), program_id); - out.SetValue(handle, true); - return result; + ON_SCOPE_EXIT { out.SetValue(handle, true); }; + + R_RETURN(this->RegisterExternalCode(std::addressof(handle), program_id)); } void AtmosphereUnregisterExternalCode(ncm::ProgramId program_id) { @@ -74,11 +76,11 @@ namespace ams::ldr { } Result AtmosphereGetProgramInfo(sf::Out out_program_info, sf::Out out_status, const ncm::ProgramLocation &loc) { - return this->GetProgramInfo(out_program_info.GetPointer(), out_status.GetPointer(), loc); + R_RETURN(this->GetProgramInfo(out_program_info.GetPointer(), out_status.GetPointer(), loc)); } Result AtmospherePinProgram(sf::Out out_id, const ncm::ProgramLocation &loc, const cfg::OverrideStatus &override_status) { - return this->PinProgram(out_id.GetPointer(), loc, override_status); + R_RETURN(this->PinProgram(out_id.GetPointer(), loc, override_status)); } private: Result CreateProcess(os::NativeHandle *out, PinId pin_id, u32 flags, os::NativeHandle resource_limit); diff --git a/stratosphere/loader/source/ldr_meta.cpp b/stratosphere/loader/source/ldr_meta.cpp index 35e922b05..587962002 100644 --- a/stratosphere/loader/source/ldr_meta.cpp +++ b/stratosphere/loader/source/ldr_meta.cpp @@ -275,7 +275,7 @@ namespace ams::ldr { Result LoadMetaFromCache(Meta *out_meta, const ncm::ProgramLocation &loc, const cfg::OverrideStatus &status) { if (g_cached_program_id != loc.program_id || g_cached_override_status != status) { - return LoadMeta(out_meta, loc, status); + R_RETURN(LoadMeta(out_meta, loc, status)); } *out_meta = g_meta_cache.meta; R_SUCCEED(); diff --git a/stratosphere/ncm/source/ncm_main.cpp b/stratosphere/ncm/source/ncm_main.cpp index 412733e3c..e1fe85c59 100644 --- a/stratosphere/ncm/source/ncm_main.cpp +++ b/stratosphere/ncm/source/ncm_main.cpp @@ -76,7 +76,7 @@ namespace ams { explicit ContentManagerServerManager(sf::SharedPointer manager) : m_manager(manager) { /* ... */ } ams::Result Initialize() { - return this->RegisterObjectForServer(m_manager, ContentManagerServiceName, ContentManagerManagerSessions); + R_RETURN(this->RegisterObjectForServer(m_manager, ContentManagerServiceName, ContentManagerManagerSessions)); } ams::Result StartThreads() { @@ -120,7 +120,7 @@ namespace ams { LocationResolverServerManager(sf::SharedPointer manager) : m_manager(manager) { /* ... */ } ams::Result Initialize() { - return this->RegisterObjectForServer(m_manager, LocationResolverServiceName, LocationResolverManagerSessions); + R_RETURN(this->RegisterObjectForServer(m_manager, LocationResolverServiceName, LocationResolverManagerSessions)); } ams::Result StartThreads() { diff --git a/stratosphere/ro/source/impl/ro_service_impl.cpp b/stratosphere/ro/source/impl/ro_service_impl.cpp index 85c21f593..054412ca3 100644 --- a/stratosphere/ro/source/impl/ro_service_impl.cpp +++ b/stratosphere/ro/source/impl/ro_service_impl.cpp @@ -526,7 +526,7 @@ namespace ams::ro::impl { context->SetNrrInfoInUse(nrr_info, false); std::memset(nrr_info, 0, sizeof(*nrr_info)); } - return UnmapNrr(context->GetProcessHandle(), nrr_backup.mapped_header, nrr_backup.nrr_heap_address, nrr_backup.nrr_heap_size, nrr_backup.mapped_code_address); + R_RETURN(UnmapNrr(context->GetProcessHandle(), nrr_backup.mapped_header, nrr_backup.nrr_heap_address, nrr_backup.nrr_heap_size, nrr_backup.mapped_code_address)); } Result MapManualLoadModuleMemory(u64 *out_address, size_t context_id, u64 nro_address, u64 nro_size, u64 bss_address, u64 bss_size) { @@ -594,7 +594,7 @@ namespace ams::ro::impl { context->SetNroInfoInUse(nro_info, false); std::memset(nro_info, 0, sizeof(*nro_info)); } - return UnmapNro(context->GetProcessHandle(), nro_backup.base_address, nro_backup.nro_heap_address, nro_backup.bss_heap_address, nro_backup.bss_heap_size, nro_backup.code_size, nro_backup.rw_size); + R_RETURN(UnmapNro(context->GetProcessHandle(), nro_backup.base_address, nro_backup.nro_heap_address, nro_backup.bss_heap_address, nro_backup.bss_heap_size, nro_backup.code_size, nro_backup.rw_size)); } /* Debug service implementations. */ diff --git a/stratosphere/ro/source/ro_debug_monitor_service.cpp b/stratosphere/ro/source/ro_debug_monitor_service.cpp index a3ff79abf..af4a25da8 100644 --- a/stratosphere/ro/source/ro_debug_monitor_service.cpp +++ b/stratosphere/ro/source/ro_debug_monitor_service.cpp @@ -21,7 +21,7 @@ namespace ams::ro { Result DebugMonitorService::GetProcessModuleInfo(sf::Out out_count, const sf::OutArray &out_infos, os::ProcessId process_id) { R_UNLESS(out_infos.GetSize() <= std::numeric_limits::max(), ro::ResultInvalidSize()); - return impl::GetProcessModuleInfo(out_count.GetPointer(), out_infos.GetPointer(), out_infos.GetSize(), process_id); + R_RETURN(impl::GetProcessModuleInfo(out_count.GetPointer(), out_infos.GetPointer(), out_infos.GetSize(), process_id)); } } diff --git a/stratosphere/ro/source/ro_main.cpp b/stratosphere/ro/source/ro_main.cpp index c4a9ea41a..25b38a6ff 100644 --- a/stratosphere/ro/source/ro_main.cpp +++ b/stratosphere/ro/source/ro_main.cpp @@ -62,11 +62,11 @@ namespace ams { ams::Result ServerManager::OnNeedsToAccept(int port_index, Server *server) { switch (port_index) { case PortIndex_DebugMonitor: - return this->AcceptImpl(server, ObjectFactory::CreateSharedEmplaced(std::addressof(g_server_allocator))); + R_RETURN(this->AcceptImpl(server, ObjectFactory::CreateSharedEmplaced(std::addressof(g_server_allocator)))); case PortIndex_User: - return this->AcceptImpl(server, ObjectFactory::CreateSharedEmplaced(std::addressof(g_server_allocator), ro::NrrKind_User)); + R_RETURN(this->AcceptImpl(server, ObjectFactory::CreateSharedEmplaced(std::addressof(g_server_allocator), ro::NrrKind_User))); case PortIndex_JitPlugin: - return this->AcceptImpl(server, ObjectFactory::CreateSharedEmplaced(std::addressof(g_server_allocator), ro::NrrKind_JitPlugin)); + R_RETURN(this->AcceptImpl(server, ObjectFactory::CreateSharedEmplaced(std::addressof(g_server_allocator), ro::NrrKind_JitPlugin))); AMS_UNREACHABLE_DEFAULT_CASE(); } } diff --git a/stratosphere/ro/source/ro_ro_service.cpp b/stratosphere/ro/source/ro_ro_service.cpp index e7d6aa546..ec309fb63 100644 --- a/stratosphere/ro/source/ro_ro_service.cpp +++ b/stratosphere/ro/source/ro_ro_service.cpp @@ -37,27 +37,27 @@ namespace ams::ro { Result RoService::MapManualLoadModuleMemory(sf::Out load_address, const sf::ClientProcessId &client_pid, u64 nro_address, u64 nro_size, u64 bss_address, u64 bss_size) { R_TRY(impl::ValidateProcess(m_context_id, client_pid.GetValue())); - return impl::MapManualLoadModuleMemory(load_address.GetPointer(), m_context_id, nro_address, nro_size, bss_address, bss_size); + R_RETURN(impl::MapManualLoadModuleMemory(load_address.GetPointer(), m_context_id, nro_address, nro_size, bss_address, bss_size)); } Result RoService::UnmapManualLoadModuleMemory(const sf::ClientProcessId &client_pid, u64 nro_address) { R_TRY(impl::ValidateProcess(m_context_id, client_pid.GetValue())); - return impl::UnmapManualLoadModuleMemory(m_context_id, nro_address); + R_RETURN(impl::UnmapManualLoadModuleMemory(m_context_id, nro_address)); } Result RoService::RegisterModuleInfo(const sf::ClientProcessId &client_pid, u64 nrr_address, u64 nrr_size) { R_TRY(impl::ValidateProcess(m_context_id, client_pid.GetValue())); - return impl::RegisterModuleInfo(m_context_id, os::InvalidNativeHandle, nrr_address, nrr_size, NrrKind_User, true); + R_RETURN(impl::RegisterModuleInfo(m_context_id, os::InvalidNativeHandle, nrr_address, nrr_size, NrrKind_User, true)); } Result RoService::UnregisterModuleInfo(const sf::ClientProcessId &client_pid, u64 nrr_address) { R_TRY(impl::ValidateProcess(m_context_id, client_pid.GetValue())); - return impl::UnregisterModuleInfo(m_context_id, nrr_address); + R_RETURN(impl::UnregisterModuleInfo(m_context_id, nrr_address)); } Result RoService::RegisterProcessHandle(const sf::ClientProcessId &client_pid, sf::CopyHandle &&process_h) { /* Register the process. */ - return impl::RegisterProcess(std::addressof(m_context_id), std::move(process_h), client_pid.GetValue()); + R_RETURN(impl::RegisterProcess(std::addressof(m_context_id), std::move(process_h), client_pid.GetValue())); } Result RoService::RegisterProcessModuleInfo(const sf::ClientProcessId &client_pid, u64 nrr_address, u64 nrr_size, sf::CopyHandle &&process_h) { @@ -65,7 +65,7 @@ namespace ams::ro { R_TRY(impl::ValidateProcess(m_context_id, client_pid.GetValue())); /* Register the module. */ - return impl::RegisterModuleInfo(m_context_id, process_h.GetOsHandle(), nrr_address, nrr_size, m_nrr_kind, m_nrr_kind == NrrKind_JitPlugin); + R_RETURN(impl::RegisterModuleInfo(m_context_id, process_h.GetOsHandle(), nrr_address, nrr_size, m_nrr_kind, m_nrr_kind == NrrKind_JitPlugin)); } } diff --git a/stratosphere/spl/source/spl_crypto_service.hpp b/stratosphere/spl/source/spl_crypto_service.hpp index e38b0aec0..462f9adbd 100644 --- a/stratosphere/spl/source/spl_crypto_service.hpp +++ b/stratosphere/spl/source/spl_crypto_service.hpp @@ -30,35 +30,35 @@ namespace ams::spl { public: /* Actual commands. */ Result GenerateAesKek(sf::Out out_access_key, KeySource key_source, u32 generation, u32 option) { - return m_manager.GenerateAesKek(out_access_key.GetPointer(), key_source, generation, option); + R_RETURN(m_manager.GenerateAesKek(out_access_key.GetPointer(), key_source, generation, option)); } Result LoadAesKey(s32 keyslot, AccessKey access_key, KeySource key_source) { - return m_manager.LoadAesKey(keyslot, this, access_key, key_source); + R_RETURN(m_manager.LoadAesKey(keyslot, this, access_key, key_source)); } Result GenerateAesKey(sf::Out out_key, AccessKey access_key, KeySource key_source) { - return m_manager.GenerateAesKey(out_key.GetPointer(), access_key, key_source); + R_RETURN(m_manager.GenerateAesKey(out_key.GetPointer(), access_key, key_source)); } Result DecryptAesKey(sf::Out out_key, KeySource key_source, u32 generation, u32 option) { - return m_manager.DecryptAesKey(out_key.GetPointer(), key_source, generation, option); + R_RETURN(m_manager.DecryptAesKey(out_key.GetPointer(), key_source, generation, option)); } Result ComputeCtr(const sf::OutNonSecureBuffer &out_buf, s32 keyslot, const sf::InNonSecureBuffer &in_buf, IvCtr iv_ctr) { - return m_manager.ComputeCtr(out_buf.GetPointer(), out_buf.GetSize(), keyslot, this, in_buf.GetPointer(), in_buf.GetSize(), iv_ctr); + R_RETURN(m_manager.ComputeCtr(out_buf.GetPointer(), out_buf.GetSize(), keyslot, this, in_buf.GetPointer(), in_buf.GetSize(), iv_ctr)); } Result ComputeCmac(sf::Out out_cmac, s32 keyslot, const sf::InPointerBuffer &in_buf) { - return m_manager.ComputeCmac(out_cmac.GetPointer(), keyslot, this, in_buf.GetPointer(), in_buf.GetSize()); + R_RETURN(m_manager.ComputeCmac(out_cmac.GetPointer(), keyslot, this, in_buf.GetPointer(), in_buf.GetSize())); } Result AllocateAesKeySlot(sf::Out out_keyslot) { - return m_manager.AllocateAesKeySlot(out_keyslot.GetPointer(), this); + R_RETURN(m_manager.AllocateAesKeySlot(out_keyslot.GetPointer(), this)); } Result DeallocateAesKeySlot(s32 keyslot) { - return m_manager.DeallocateAesKeySlot(keyslot, this); + R_RETURN(m_manager.DeallocateAesKeySlot(keyslot, this)); } Result GetAesKeySlotAvailableEvent(sf::OutCopyHandle out_hnd) { diff --git a/stratosphere/spl/source/spl_deprecated_service.hpp b/stratosphere/spl/source/spl_deprecated_service.hpp index 099e8f7de..1f638ee39 100644 --- a/stratosphere/spl/source/spl_deprecated_service.hpp +++ b/stratosphere/spl/source/spl_deprecated_service.hpp @@ -32,99 +32,99 @@ namespace ams::spl { public: /* Actual commands. */ Result GetConfig(sf::Out out, u32 which) { - return m_manager.GetConfig(out.GetPointer(), static_cast(which)); + R_RETURN(m_manager.GetConfig(out.GetPointer(), static_cast(which))); } Result ModularExponentiate(const sf::OutPointerBuffer &out, const sf::InPointerBuffer &base, const sf::InPointerBuffer &exp, const sf::InPointerBuffer &mod) { - return m_manager.ModularExponentiate(out.GetPointer(), out.GetSize(), base.GetPointer(), base.GetSize(), exp.GetPointer(), exp.GetSize(), mod.GetPointer(), mod.GetSize()); + R_RETURN(m_manager.ModularExponentiate(out.GetPointer(), out.GetSize(), base.GetPointer(), base.GetSize(), exp.GetPointer(), exp.GetSize(), mod.GetPointer(), mod.GetSize())); } Result GenerateAesKek(sf::Out out_access_key, KeySource key_source, u32 generation, u32 option) { - return m_manager.GenerateAesKek(out_access_key.GetPointer(), key_source, generation, option); + R_RETURN(m_manager.GenerateAesKek(out_access_key.GetPointer(), key_source, generation, option)); } Result LoadAesKey(s32 keyslot, AccessKey access_key, KeySource key_source) { - return m_manager.LoadAesKey(keyslot, this, access_key, key_source); + R_RETURN(m_manager.LoadAesKey(keyslot, this, access_key, key_source)); } Result GenerateAesKey(sf::Out out_key, AccessKey access_key, KeySource key_source) { - return m_manager.GenerateAesKey(out_key.GetPointer(), access_key, key_source); + R_RETURN(m_manager.GenerateAesKey(out_key.GetPointer(), access_key, key_source)); } Result SetConfig(u32 which, u64 value) { - return m_manager.SetConfig(static_cast(which), value); + R_RETURN(m_manager.SetConfig(static_cast(which), value)); } Result GenerateRandomBytes(const sf::OutPointerBuffer &out) { - return m_manager.GenerateRandomBytes(out.GetPointer(), out.GetSize()); + R_RETURN(m_manager.GenerateRandomBytes(out.GetPointer(), out.GetSize())); } Result DecryptAndStoreGcKey(const sf::InPointerBuffer &src, AccessKey access_key, KeySource key_source, u32 option) { - return m_manager.DecryptAndStoreGcKey(src.GetPointer(), src.GetSize(), access_key, key_source, option); + R_RETURN(m_manager.DecryptAndStoreGcKey(src.GetPointer(), src.GetSize(), access_key, key_source, option)); } Result DecryptGcMessage(sf::Out out_size, const sf::OutPointerBuffer &out, const sf::InPointerBuffer &base, const sf::InPointerBuffer &mod, const sf::InPointerBuffer &label_digest) { - return m_manager.DecryptGcMessage(out_size.GetPointer(), out.GetPointer(), out.GetSize(), base.GetPointer(), base.GetSize(), mod.GetPointer(), mod.GetSize(), label_digest.GetPointer(), label_digest.GetSize()); + R_RETURN(m_manager.DecryptGcMessage(out_size.GetPointer(), out.GetPointer(), out.GetSize(), base.GetPointer(), base.GetSize(), mod.GetPointer(), mod.GetSize(), label_digest.GetPointer(), label_digest.GetSize())); } Result IsDevelopment(sf::Out is_dev) { - return m_manager.IsDevelopment(is_dev.GetPointer()); + R_RETURN(m_manager.IsDevelopment(is_dev.GetPointer())); } Result GenerateSpecificAesKey(sf::Out out_key, KeySource key_source, u32 generation, u32 which) { - return m_manager.GenerateSpecificAesKey(out_key.GetPointer(), key_source, generation, which); + R_RETURN(m_manager.GenerateSpecificAesKey(out_key.GetPointer(), key_source, generation, which)); } Result DecryptDeviceUniqueData(const sf::OutPointerBuffer &dst, const sf::InPointerBuffer &src, AccessKey access_key, KeySource key_source, u32 option) { - return m_manager.DecryptDeviceUniqueData(dst.GetPointer(), dst.GetSize(), src.GetPointer(), src.GetSize(), access_key, key_source, option); + R_RETURN(m_manager.DecryptDeviceUniqueData(dst.GetPointer(), dst.GetSize(), src.GetPointer(), src.GetSize(), access_key, key_source, option)); } Result DecryptAesKey(sf::Out out_key, KeySource key_source, u32 generation, u32 option) { - return m_manager.DecryptAesKey(out_key.GetPointer(), key_source, generation, option); + R_RETURN(m_manager.DecryptAesKey(out_key.GetPointer(), key_source, generation, option)); } Result ComputeCtrDeprecated(const sf::OutBuffer &out_buf, s32 keyslot, const sf::InBuffer &in_buf, IvCtr iv_ctr) { - return m_manager.ComputeCtr(out_buf.GetPointer(), out_buf.GetSize(), keyslot, this, in_buf.GetPointer(), in_buf.GetSize(), iv_ctr); + R_RETURN(m_manager.ComputeCtr(out_buf.GetPointer(), out_buf.GetSize(), keyslot, this, in_buf.GetPointer(), in_buf.GetSize(), iv_ctr)); } Result ComputeCtr(const sf::OutNonSecureBuffer &out_buf, s32 keyslot, const sf::InNonSecureBuffer &in_buf, IvCtr iv_ctr) { - return m_manager.ComputeCtr(out_buf.GetPointer(), out_buf.GetSize(), keyslot, this, in_buf.GetPointer(), in_buf.GetSize(), iv_ctr); + R_RETURN(m_manager.ComputeCtr(out_buf.GetPointer(), out_buf.GetSize(), keyslot, this, in_buf.GetPointer(), in_buf.GetSize(), iv_ctr)); } Result ComputeCmac(sf::Out out_cmac, s32 keyslot, const sf::InPointerBuffer &in_buf) { - return m_manager.ComputeCmac(out_cmac.GetPointer(), keyslot, this, in_buf.GetPointer(), in_buf.GetSize()); + R_RETURN(m_manager.ComputeCmac(out_cmac.GetPointer(), keyslot, this, in_buf.GetPointer(), in_buf.GetSize())); } Result LoadEsDeviceKey(const sf::InPointerBuffer &src, AccessKey access_key, KeySource key_source, u32 option) { - return m_manager.LoadEsDeviceKey(src.GetPointer(), src.GetSize(), access_key, key_source, option); + R_RETURN(m_manager.LoadEsDeviceKey(src.GetPointer(), src.GetSize(), access_key, key_source, option)); } Result PrepareEsTitleKeyDeprecated(sf::Out out_access_key, const sf::InPointerBuffer &base, const sf::InPointerBuffer &mod, const sf::InPointerBuffer &label_digest) { - return m_manager.PrepareEsTitleKey(out_access_key.GetPointer(), base.GetPointer(), base.GetSize(), mod.GetPointer(), mod.GetSize(), label_digest.GetPointer(), label_digest.GetSize(), 0); + R_RETURN(m_manager.PrepareEsTitleKey(out_access_key.GetPointer(), base.GetPointer(), base.GetSize(), mod.GetPointer(), mod.GetSize(), label_digest.GetPointer(), label_digest.GetSize(), 0)); } Result PrepareEsTitleKey(sf::Out out_access_key, const sf::InPointerBuffer &base, const sf::InPointerBuffer &mod, const sf::InPointerBuffer &label_digest, u32 generation) { - return m_manager.PrepareEsTitleKey(out_access_key.GetPointer(), base.GetPointer(), base.GetSize(), mod.GetPointer(), mod.GetSize(), label_digest.GetPointer(), label_digest.GetSize(), generation); + R_RETURN(m_manager.PrepareEsTitleKey(out_access_key.GetPointer(), base.GetPointer(), base.GetSize(), mod.GetPointer(), mod.GetSize(), label_digest.GetPointer(), label_digest.GetSize(), generation)); } Result LoadPreparedAesKey(s32 keyslot, AccessKey access_key) { - return m_manager.LoadPreparedAesKey(keyslot, this, access_key); + R_RETURN(m_manager.LoadPreparedAesKey(keyslot, this, access_key)); } Result PrepareCommonEsTitleKeyDeprecated(sf::Out out_access_key, KeySource key_source) { - return m_manager.PrepareCommonEsTitleKey(out_access_key.GetPointer(), key_source, 0); + R_RETURN(m_manager.PrepareCommonEsTitleKey(out_access_key.GetPointer(), key_source, 0)); } Result PrepareCommonEsTitleKey(sf::Out out_access_key, KeySource key_source, u32 generation) { - return m_manager.PrepareCommonEsTitleKey(out_access_key.GetPointer(), key_source, generation); + R_RETURN(m_manager.PrepareCommonEsTitleKey(out_access_key.GetPointer(), key_source, generation)); } Result AllocateAesKeySlot(sf::Out out_keyslot) { - return m_manager.AllocateAesKeySlot(out_keyslot.GetPointer(), this); + R_RETURN(m_manager.AllocateAesKeySlot(out_keyslot.GetPointer(), this)); } Result DeallocateAesKeySlot(s32 keyslot) { - return m_manager.DeallocateAesKeySlot(keyslot, this); + R_RETURN(m_manager.DeallocateAesKeySlot(keyslot, this)); } Result GetAesKeySlotAvailableEvent(sf::OutCopyHandle out_hnd) { @@ -133,11 +133,11 @@ namespace ams::spl { } Result SetBootReason(BootReasonValue boot_reason) { - return m_manager.SetBootReason(boot_reason); + R_RETURN(m_manager.SetBootReason(boot_reason)); } Result GetBootReason(sf::Out out) { - return m_manager.GetBootReason(out.GetPointer()); + R_RETURN(m_manager.GetBootReason(out.GetPointer())); } }; static_assert(spl::impl::IsIDeprecatedGeneralInterface); diff --git a/stratosphere/spl/source/spl_device_unique_data_service.hpp b/stratosphere/spl/source/spl_device_unique_data_service.hpp index ae907bddf..53ba6bd51 100644 --- a/stratosphere/spl/source/spl_device_unique_data_service.hpp +++ b/stratosphere/spl/source/spl_device_unique_data_service.hpp @@ -25,11 +25,11 @@ namespace ams::spl { public: /* Actual commands. */ Result DecryptDeviceUniqueDataDeprecated(const sf::OutPointerBuffer &dst, const sf::InPointerBuffer &src, AccessKey access_key, KeySource key_source, u32 option) { - return m_manager.DecryptDeviceUniqueData(dst.GetPointer(), dst.GetSize(), src.GetPointer(), src.GetSize(), access_key, key_source, option); + R_RETURN(m_manager.DecryptDeviceUniqueData(dst.GetPointer(), dst.GetSize(), src.GetPointer(), src.GetSize(), access_key, key_source, option)); } Result DecryptDeviceUniqueData(const sf::OutPointerBuffer &dst, const sf::InPointerBuffer &src, AccessKey access_key, KeySource key_source) { - return m_manager.DecryptDeviceUniqueData(dst.GetPointer(), dst.GetSize(), src.GetPointer(), src.GetSize(), access_key, key_source, static_cast(smc::DeviceUniqueDataMode::DecryptDeviceUniqueData)); + R_RETURN(m_manager.DecryptDeviceUniqueData(dst.GetPointer(), dst.GetSize(), src.GetPointer(), src.GetSize(), access_key, key_source, static_cast(smc::DeviceUniqueDataMode::DecryptDeviceUniqueData))); } }; static_assert(spl::impl::IsIDeviceUniqueDataInterface); diff --git a/stratosphere/spl/source/spl_es_service.hpp b/stratosphere/spl/source/spl_es_service.hpp index 2f8fc05f7..a4cba97f6 100644 --- a/stratosphere/spl/source/spl_es_service.hpp +++ b/stratosphere/spl/source/spl_es_service.hpp @@ -25,35 +25,35 @@ namespace ams::spl { public: /* Actual commands. */ Result LoadEsDeviceKeyDeprecated(const sf::InPointerBuffer &src, AccessKey access_key, KeySource key_source, u32 option) { - return m_manager.LoadEsDeviceKey(src.GetPointer(), src.GetSize(), access_key, key_source, option); + R_RETURN(m_manager.LoadEsDeviceKey(src.GetPointer(), src.GetSize(), access_key, key_source, option)); } Result LoadEsDeviceKey(const sf::InPointerBuffer &src, AccessKey access_key, KeySource key_source) { - return m_manager.LoadEsDeviceKey(src.GetPointer(), src.GetSize(), access_key, key_source, static_cast(smc::DeviceUniqueDataMode::DecryptAndStoreEsDeviceKey)); + R_RETURN(m_manager.LoadEsDeviceKey(src.GetPointer(), src.GetSize(), access_key, key_source, static_cast(smc::DeviceUniqueDataMode::DecryptAndStoreEsDeviceKey))); } Result PrepareEsTitleKey(sf::Out out_access_key, const sf::InPointerBuffer &base, const sf::InPointerBuffer &mod, const sf::InPointerBuffer &label_digest, u32 generation) { - return m_manager.PrepareEsTitleKey(out_access_key.GetPointer(), base.GetPointer(), base.GetSize(), mod.GetPointer(), mod.GetSize(), label_digest.GetPointer(), label_digest.GetSize(), generation); + R_RETURN(m_manager.PrepareEsTitleKey(out_access_key.GetPointer(), base.GetPointer(), base.GetSize(), mod.GetPointer(), mod.GetSize(), label_digest.GetPointer(), label_digest.GetSize(), generation)); } Result PrepareCommonEsTitleKey(sf::Out out_access_key, KeySource key_source, u32 generation) { - return m_manager.PrepareCommonEsTitleKey(out_access_key.GetPointer(), key_source, generation); + R_RETURN(m_manager.PrepareCommonEsTitleKey(out_access_key.GetPointer(), key_source, generation)); } Result DecryptAndStoreDrmDeviceCertKey(const sf::InPointerBuffer &src, AccessKey access_key, KeySource key_source) { - return m_manager.DecryptAndStoreDrmDeviceCertKey(src.GetPointer(), src.GetSize(), access_key, key_source); + R_RETURN(m_manager.DecryptAndStoreDrmDeviceCertKey(src.GetPointer(), src.GetSize(), access_key, key_source)); } Result ModularExponentiateWithDrmDeviceCertKey(const sf::OutPointerBuffer &out, const sf::InPointerBuffer &base, const sf::InPointerBuffer &mod) { - return m_manager.ModularExponentiateWithDrmDeviceCertKey(out.GetPointer(), out.GetSize(), base.GetPointer(), base.GetSize(), mod.GetPointer(), mod.GetSize()); + R_RETURN(m_manager.ModularExponentiateWithDrmDeviceCertKey(out.GetPointer(), out.GetSize(), base.GetPointer(), base.GetSize(), mod.GetPointer(), mod.GetSize())); } Result PrepareEsArchiveKey(sf::Out out_access_key, const sf::InPointerBuffer &base, const sf::InPointerBuffer &mod, const sf::InPointerBuffer &label_digest, u32 generation) { - return m_manager.PrepareEsArchiveKey(out_access_key.GetPointer(), base.GetPointer(), base.GetSize(), mod.GetPointer(), mod.GetSize(), label_digest.GetPointer(), label_digest.GetSize(), generation); + R_RETURN(m_manager.PrepareEsArchiveKey(out_access_key.GetPointer(), base.GetPointer(), base.GetSize(), mod.GetPointer(), mod.GetSize(), label_digest.GetPointer(), label_digest.GetSize(), generation)); } Result LoadPreparedAesKey(s32 keyslot, AccessKey access_key) { - return m_manager.LoadPreparedAesKey(keyslot, this, access_key); + R_RETURN(m_manager.LoadPreparedAesKey(keyslot, this, access_key)); } }; static_assert(spl::impl::IsIEsInterface); diff --git a/stratosphere/spl/source/spl_fs_service.hpp b/stratosphere/spl/source/spl_fs_service.hpp index c0ef7c4d3..c7f00125f 100644 --- a/stratosphere/spl/source/spl_fs_service.hpp +++ b/stratosphere/spl/source/spl_fs_service.hpp @@ -25,27 +25,27 @@ namespace ams::spl { public: /* Actual commands. */ Result DecryptAndStoreGcKeyDeprecated(const sf::InPointerBuffer &src, AccessKey access_key, KeySource key_source, u32 option) { - return m_manager.DecryptAndStoreGcKey(src.GetPointer(), src.GetSize(), access_key, key_source, option); + R_RETURN(m_manager.DecryptAndStoreGcKey(src.GetPointer(), src.GetSize(), access_key, key_source, option)); } Result DecryptAndStoreGcKey(const sf::InPointerBuffer &src, AccessKey access_key, KeySource key_source) { - return m_manager.DecryptAndStoreGcKey(src.GetPointer(), src.GetSize(), access_key, key_source, static_cast(smc::DeviceUniqueDataMode::DecryptAndStoreGcKey)); + R_RETURN(m_manager.DecryptAndStoreGcKey(src.GetPointer(), src.GetSize(), access_key, key_source, static_cast(smc::DeviceUniqueDataMode::DecryptAndStoreGcKey))); } Result DecryptGcMessage(sf::Out out_size, const sf::OutPointerBuffer &out, const sf::InPointerBuffer &base, const sf::InPointerBuffer &mod, const sf::InPointerBuffer &label_digest) { - return m_manager.DecryptGcMessage(out_size.GetPointer(), out.GetPointer(), out.GetSize(), base.GetPointer(), base.GetSize(), mod.GetPointer(), mod.GetSize(), label_digest.GetPointer(), label_digest.GetSize()); + R_RETURN(m_manager.DecryptGcMessage(out_size.GetPointer(), out.GetPointer(), out.GetSize(), base.GetPointer(), base.GetSize(), mod.GetPointer(), mod.GetSize(), label_digest.GetPointer(), label_digest.GetSize())); } Result GenerateSpecificAesKey(sf::Out out_key, KeySource key_source, u32 generation, u32 which) { - return m_manager.GenerateSpecificAesKey(out_key.GetPointer(), key_source, generation, which); + R_RETURN(m_manager.GenerateSpecificAesKey(out_key.GetPointer(), key_source, generation, which)); } Result LoadPreparedAesKey(s32 keyslot, AccessKey access_key) { - return m_manager.LoadPreparedAesKey(keyslot, this, access_key); + R_RETURN(m_manager.LoadPreparedAesKey(keyslot, this, access_key)); } Result GetPackage2Hash(const sf::OutPointerBuffer &dst) { - return m_manager.GetPackage2Hash(dst.GetPointer(), dst.GetSize()); + R_RETURN(m_manager.GetPackage2Hash(dst.GetPointer(), dst.GetSize())); } }; static_assert(spl::impl::IsIFsInterface); diff --git a/stratosphere/spl/source/spl_general_service.hpp b/stratosphere/spl/source/spl_general_service.hpp index 0c29e18ad..184569d17 100644 --- a/stratosphere/spl/source/spl_general_service.hpp +++ b/stratosphere/spl/source/spl_general_service.hpp @@ -27,31 +27,31 @@ namespace ams::spl { public: /* Actual commands. */ Result GetConfig(sf::Out out, u32 key) { - return m_manager.GetConfig(out.GetPointer(), static_cast(key)); + R_RETURN(m_manager.GetConfig(out.GetPointer(), static_cast(key))); } Result ModularExponentiate(const sf::OutPointerBuffer &out, const sf::InPointerBuffer &base, const sf::InPointerBuffer &exp, const sf::InPointerBuffer &mod) { - return m_manager.ModularExponentiate(out.GetPointer(), out.GetSize(), base.GetPointer(), base.GetSize(), exp.GetPointer(), exp.GetSize(), mod.GetPointer(), mod.GetSize()); + R_RETURN(m_manager.ModularExponentiate(out.GetPointer(), out.GetSize(), base.GetPointer(), base.GetSize(), exp.GetPointer(), exp.GetSize(), mod.GetPointer(), mod.GetSize())); } Result SetConfig(u32 key, u64 value) { - return m_manager.SetConfig(static_cast(key), value); + R_RETURN(m_manager.SetConfig(static_cast(key), value)); } Result GenerateRandomBytes(const sf::OutPointerBuffer &out) { - return m_manager.GenerateRandomBytes(out.GetPointer(), out.GetSize()); + R_RETURN(m_manager.GenerateRandomBytes(out.GetPointer(), out.GetSize())); } Result IsDevelopment(sf::Out is_dev) { - return m_manager.IsDevelopment(is_dev.GetPointer()); + R_RETURN(m_manager.IsDevelopment(is_dev.GetPointer())); } Result SetBootReason(BootReasonValue boot_reason) { - return m_manager.SetBootReason(boot_reason); + R_RETURN(m_manager.SetBootReason(boot_reason)); } Result GetBootReason(sf::Out out) { - return m_manager.GetBootReason(out.GetPointer()); + R_RETURN(m_manager.GetBootReason(out.GetPointer())); } }; static_assert(spl::impl::IsIGeneralInterface); diff --git a/stratosphere/spl/source/spl_main.cpp b/stratosphere/spl/source/spl_main.cpp index 2ff3f1d56..f77519458 100644 --- a/stratosphere/spl/source/spl_main.cpp +++ b/stratosphere/spl/source/spl_main.cpp @@ -108,22 +108,22 @@ namespace ams { switch (port_index) { case PortIndex_General: if (g_use_new_server) { - return this->AcceptImpl(server, m_general_service_object.GetShared()); + R_RETURN(this->AcceptImpl(server, m_general_service_object.GetShared())); } else { - return this->AcceptImpl(server, ObjectFactory::CreateSharedEmplaced(m_allocator, m_secure_monitor_manager)); + R_RETURN(this->AcceptImpl(server, ObjectFactory::CreateSharedEmplaced(m_allocator, m_secure_monitor_manager))); } case PortIndex_Random: - return this->AcceptImpl(server, m_random_service_object.GetShared()); + R_RETURN(this->AcceptImpl(server, m_random_service_object.GetShared())); case PortIndex_Crypto: - return this->AcceptImpl(server, ObjectFactory::CreateSharedEmplaced(m_allocator, m_secure_monitor_manager)); + R_RETURN(this->AcceptImpl(server, ObjectFactory::CreateSharedEmplaced(m_allocator, m_secure_monitor_manager))); case PortIndex_Fs: - return this->AcceptImpl(server, ObjectFactory::CreateSharedEmplaced(m_allocator, m_secure_monitor_manager)); + R_RETURN(this->AcceptImpl(server, ObjectFactory::CreateSharedEmplaced(m_allocator, m_secure_monitor_manager))); case PortIndex_Ssl: - return this->AcceptImpl(server, ObjectFactory::CreateSharedEmplaced(m_allocator, m_secure_monitor_manager)); + R_RETURN(this->AcceptImpl(server, ObjectFactory::CreateSharedEmplaced(m_allocator, m_secure_monitor_manager))); case PortIndex_Es: - return this->AcceptImpl(server, ObjectFactory::CreateSharedEmplaced(m_allocator, m_secure_monitor_manager)); + R_RETURN(this->AcceptImpl(server, ObjectFactory::CreateSharedEmplaced(m_allocator, m_secure_monitor_manager))); case PortIndex_Manu: - return this->AcceptImpl(server, ObjectFactory::CreateSharedEmplaced(m_allocator, m_secure_monitor_manager)); + R_RETURN(this->AcceptImpl(server, ObjectFactory::CreateSharedEmplaced(m_allocator, m_secure_monitor_manager))); AMS_UNREACHABLE_DEFAULT_CASE(); } } diff --git a/stratosphere/spl/source/spl_manu_service.hpp b/stratosphere/spl/source/spl_manu_service.hpp index b1284b990..bc0459f53 100644 --- a/stratosphere/spl/source/spl_manu_service.hpp +++ b/stratosphere/spl/source/spl_manu_service.hpp @@ -25,7 +25,7 @@ namespace ams::spl { public: /* Actual commands. */ Result ReencryptDeviceUniqueData(const sf::OutPointerBuffer &out, const sf::InPointerBuffer &src, AccessKey access_key_dec, KeySource source_dec, AccessKey access_key_enc, KeySource source_enc, u32 option) { - return m_manager.ReencryptDeviceUniqueData(out.GetPointer(), out.GetSize(), src.GetPointer(), src.GetSize(), access_key_dec, source_dec, access_key_enc, source_enc, option); + R_RETURN(m_manager.ReencryptDeviceUniqueData(out.GetPointer(), out.GetSize(), src.GetPointer(), src.GetSize(), access_key_dec, source_dec, access_key_enc, source_enc, option)); } }; static_assert(spl::impl::IsIManuInterface); diff --git a/stratosphere/spl/source/spl_random_service.hpp b/stratosphere/spl/source/spl_random_service.hpp index bd2111c68..89c32f1fc 100644 --- a/stratosphere/spl/source/spl_random_service.hpp +++ b/stratosphere/spl/source/spl_random_service.hpp @@ -27,7 +27,7 @@ namespace ams::spl { public: /* Actual commands. */ Result GenerateRandomBytes(const sf::OutBuffer &out) { - return m_manager.GenerateRandomBytes(out.GetPointer(), out.GetSize()); + R_RETURN(m_manager.GenerateRandomBytes(out.GetPointer(), out.GetSize())); } }; static_assert(spl::impl::IsIRandomInterface); diff --git a/stratosphere/spl/source/spl_secure_monitor_manager.cpp b/stratosphere/spl/source/spl_secure_monitor_manager.cpp index 2e0e1779b..e5b899169 100644 --- a/stratosphere/spl/source/spl_secure_monitor_manager.cpp +++ b/stratosphere/spl/source/spl_secure_monitor_manager.cpp @@ -23,111 +23,111 @@ namespace ams::spl { } Result SecureMonitorManager::ModularExponentiate(void *out, size_t out_size, const void *base, size_t base_size, const void *exp, size_t exp_size, const void *mod, size_t mod_size) { - return impl::ModularExponentiate(out, out_size, base, base_size, exp, exp_size, mod, mod_size); + R_RETURN(impl::ModularExponentiate(out, out_size, base, base_size, exp, exp_size, mod, mod_size)); } Result SecureMonitorManager::GenerateAesKek(AccessKey *out_access_key, const KeySource &key_source, u32 generation, u32 option) { - return impl::GenerateAesKek(out_access_key, key_source, generation, option); + R_RETURN(impl::GenerateAesKek(out_access_key, key_source, generation, option)); } Result SecureMonitorManager::LoadAesKey(s32 keyslot, const void *owner, const AccessKey &access_key, const KeySource &key_source) { R_TRY(this->TestAesKeySlot(nullptr, keyslot, owner)); - return impl::LoadAesKey(keyslot, access_key, key_source); + R_RETURN(impl::LoadAesKey(keyslot, access_key, key_source)); } Result SecureMonitorManager::GenerateAesKey(AesKey *out_key, const AccessKey &access_key, const KeySource &key_source) { - return impl::GenerateAesKey(out_key, access_key, key_source); + R_RETURN(impl::GenerateAesKey(out_key, access_key, key_source)); } Result SecureMonitorManager::DecryptDeviceUniqueData(void *dst, size_t dst_size, const void *src, size_t src_size, const AccessKey &access_key, const KeySource &key_source, u32 option) { - return impl::DecryptDeviceUniqueData(dst, dst_size, src, src_size, access_key, key_source, option); + R_RETURN(impl::DecryptDeviceUniqueData(dst, dst_size, src, src_size, access_key, key_source, option)); } Result SecureMonitorManager::ReencryptDeviceUniqueData(void *dst, size_t dst_size, const void *src, size_t src_size, const AccessKey &access_key_dec, const KeySource &source_dec, const AccessKey &access_key_enc, const KeySource &source_enc, u32 option) { - return impl::ReencryptDeviceUniqueData(dst, dst_size, src, src_size, access_key_dec, source_dec, access_key_enc, source_enc, option); + R_RETURN(impl::ReencryptDeviceUniqueData(dst, dst_size, src, src_size, access_key_dec, source_dec, access_key_enc, source_enc, option)); } Result SecureMonitorManager::GetConfig(u64 *out, spl::ConfigItem key) { - return impl::GetConfig(out, key); + R_RETURN(impl::GetConfig(out, key)); } Result SecureMonitorManager::SetConfig(spl::ConfigItem key, u64 value) { - return impl::SetConfig(key, value); + R_RETURN(impl::SetConfig(key, value)); } Result SecureMonitorManager::GetPackage2Hash(void *dst, const size_t size) { - return impl::GetPackage2Hash(dst, size); + R_RETURN(impl::GetPackage2Hash(dst, size)); } Result SecureMonitorManager::GenerateRandomBytes(void *out, size_t size) { - return impl::GenerateRandomBytes(out, size); + R_RETURN(impl::GenerateRandomBytes(out, size)); } Result SecureMonitorManager::DecryptAndStoreGcKey(const void *src, size_t src_size, const AccessKey &access_key, const KeySource &key_source, u32 option) { - return impl::DecryptAndStoreGcKey(src, src_size, access_key, key_source, option); + R_RETURN(impl::DecryptAndStoreGcKey(src, src_size, access_key, key_source, option)); } Result SecureMonitorManager::DecryptGcMessage(u32 *out_size, void *dst, size_t dst_size, const void *base, size_t base_size, const void *mod, size_t mod_size, const void *label_digest, size_t label_digest_size) { - return impl::DecryptGcMessage(out_size, dst, dst_size, base, base_size, mod, mod_size, label_digest, label_digest_size); + R_RETURN(impl::DecryptGcMessage(out_size, dst, dst_size, base, base_size, mod, mod_size, label_digest, label_digest_size)); } Result SecureMonitorManager::DecryptAndStoreSslClientCertKey(const void *src, size_t src_size, const AccessKey &access_key, const KeySource &key_source) { - return impl::DecryptAndStoreSslClientCertKey(src, src_size, access_key, key_source); + R_RETURN(impl::DecryptAndStoreSslClientCertKey(src, src_size, access_key, key_source)); } Result SecureMonitorManager::ModularExponentiateWithSslClientCertKey(void *out, size_t out_size, const void *base, size_t base_size, const void *mod, size_t mod_size) { - return impl::ModularExponentiateWithSslClientCertKey(out, out_size, base, base_size, mod, mod_size); + R_RETURN(impl::ModularExponentiateWithSslClientCertKey(out, out_size, base, base_size, mod, mod_size)); } Result SecureMonitorManager::DecryptAndStoreDrmDeviceCertKey(const void *src, size_t src_size, const AccessKey &access_key, const KeySource &key_source) { - return impl::DecryptAndStoreDrmDeviceCertKey(src, src_size, access_key, key_source); + R_RETURN(impl::DecryptAndStoreDrmDeviceCertKey(src, src_size, access_key, key_source)); } Result SecureMonitorManager::ModularExponentiateWithDrmDeviceCertKey(void *out, size_t out_size, const void *base, size_t base_size, const void *mod, size_t mod_size) { - return impl::ModularExponentiateWithDrmDeviceCertKey(out, out_size, base, base_size, mod, mod_size); + R_RETURN(impl::ModularExponentiateWithDrmDeviceCertKey(out, out_size, base, base_size, mod, mod_size)); } Result SecureMonitorManager::IsDevelopment(bool *out) { - return impl::IsDevelopment(out); + R_RETURN(impl::IsDevelopment(out)); } Result SecureMonitorManager::GenerateSpecificAesKey(AesKey *out_key, const KeySource &key_source, u32 generation, u32 which) { - return impl::GenerateSpecificAesKey(out_key, key_source, generation, which); + R_RETURN(impl::GenerateSpecificAesKey(out_key, key_source, generation, which)); } Result SecureMonitorManager::DecryptAesKey(AesKey *out_key, const KeySource &key_source, u32 generation, u32 option) { - return impl::DecryptAesKey(out_key, key_source, generation, option); + R_RETURN(impl::DecryptAesKey(out_key, key_source, generation, option)); } Result SecureMonitorManager::ComputeCtr(void *dst, size_t dst_size, s32 keyslot, const void *owner, const void *src, size_t src_size, const IvCtr &iv_ctr) { R_TRY(this->TestAesKeySlot(nullptr, keyslot, owner)); - return impl::ComputeCtr(dst, dst_size, keyslot, src, src_size, iv_ctr); + R_RETURN(impl::ComputeCtr(dst, dst_size, keyslot, src, src_size, iv_ctr)); } Result SecureMonitorManager::ComputeCmac(Cmac *out_cmac, s32 keyslot, const void *owner, const void *data, size_t size) { R_TRY(this->TestAesKeySlot(nullptr, keyslot, owner)); - return impl::ComputeCmac(out_cmac, keyslot, data, size); + R_RETURN(impl::ComputeCmac(out_cmac, keyslot, data, size)); } Result SecureMonitorManager::LoadEsDeviceKey(const void *src, size_t src_size, const AccessKey &access_key, const KeySource &key_source, u32 option) { - return impl::LoadEsDeviceKey(src, src_size, access_key, key_source, option); + R_RETURN(impl::LoadEsDeviceKey(src, src_size, access_key, key_source, option)); } Result SecureMonitorManager::PrepareEsTitleKey(AccessKey *out_access_key, const void *base, size_t base_size, const void *mod, size_t mod_size, const void *label_digest, size_t label_digest_size, u32 generation) { - return impl::PrepareEsTitleKey(out_access_key, base, base_size, mod, mod_size, label_digest, label_digest_size, generation); + R_RETURN(impl::PrepareEsTitleKey(out_access_key, base, base_size, mod, mod_size, label_digest, label_digest_size, generation)); } Result SecureMonitorManager::PrepareEsArchiveKey(AccessKey *out_access_key, const void *base, size_t base_size, const void *mod, size_t mod_size, const void *label_digest, size_t label_digest_size, u32 generation) { - return impl::PrepareEsArchiveKey(out_access_key, base, base_size, mod, mod_size, label_digest, label_digest_size, generation); + R_RETURN(impl::PrepareEsArchiveKey(out_access_key, base, base_size, mod, mod_size, label_digest, label_digest_size, generation)); } Result SecureMonitorManager::PrepareCommonEsTitleKey(AccessKey *out_access_key, const KeySource &key_source, u32 generation) { - return impl::PrepareCommonEsTitleKey(out_access_key, key_source, generation); + R_RETURN(impl::PrepareCommonEsTitleKey(out_access_key, key_source, generation)); } Result SecureMonitorManager::LoadPreparedAesKey(s32 keyslot, const void *owner, const AccessKey &access_key) { R_TRY(this->TestAesKeySlot(nullptr, keyslot, owner)); - return impl::LoadPreparedAesKey(keyslot, access_key); + R_RETURN(impl::LoadPreparedAesKey(keyslot, access_key)); } Result SecureMonitorManager::AllocateAesKeySlot(s32 *out_keyslot, const void *owner) { @@ -153,7 +153,7 @@ namespace ams::spl { R_TRY(this->TestAesKeySlot(std::addressof(index), keyslot, owner)); m_aes_keyslot_owners[index] = nullptr; - return impl::DeallocateAesKeySlot(keyslot); + R_RETURN(impl::DeallocateAesKeySlot(keyslot)); } void SecureMonitorManager::DeallocateAesKeySlots(const void *owner) { @@ -166,11 +166,11 @@ namespace ams::spl { } Result SecureMonitorManager::SetBootReason(BootReasonValue boot_reason) { - return impl::SetBootReason(boot_reason); + R_RETURN(impl::SetBootReason(boot_reason)); } Result SecureMonitorManager::GetBootReason(BootReasonValue *out) { - return impl::GetBootReason(out); + R_RETURN(impl::GetBootReason(out)); } os::SystemEvent *SecureMonitorManager::GetAesKeySlotAvailableEvent() { diff --git a/stratosphere/spl/source/spl_ssl_service.hpp b/stratosphere/spl/source/spl_ssl_service.hpp index 650db5c79..9e979e462 100644 --- a/stratosphere/spl/source/spl_ssl_service.hpp +++ b/stratosphere/spl/source/spl_ssl_service.hpp @@ -25,11 +25,11 @@ namespace ams::spl { public: /* Actual commands. */ Result DecryptAndStoreSslClientCertKey(const sf::InPointerBuffer &src, AccessKey access_key, KeySource key_source) { - return m_manager.DecryptAndStoreSslClientCertKey(src.GetPointer(), src.GetSize(), access_key, key_source); + R_RETURN(m_manager.DecryptAndStoreSslClientCertKey(src.GetPointer(), src.GetSize(), access_key, key_source)); } Result ModularExponentiateWithSslClientCertKey(const sf::OutPointerBuffer &out, const sf::InPointerBuffer &base, const sf::InPointerBuffer &mod) { - return m_manager.ModularExponentiateWithSslClientCertKey(out.GetPointer(), out.GetSize(), base.GetPointer(), base.GetSize(), mod.GetPointer(), mod.GetSize()); + R_RETURN(m_manager.ModularExponentiateWithSslClientCertKey(out.GetPointer(), out.GetSize(), base.GetPointer(), base.GetSize(), mod.GetPointer(), mod.GetSize())); } }; static_assert(spl::impl::IsISslInterface);