mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2025-05-18 00:54:23 -04:00
ams: globally prefer R_RETURN to return for ams::Result
This commit is contained in:
parent
dd78ede99f
commit
bbf22b4c60
325 changed files with 1955 additions and 1993 deletions
|
@ -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<void *>(access_key));
|
||||
R_RETURN(splCryptoGenerateAesKek(key_source, generation, option, static_cast<void *>(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<u32>(slot));
|
||||
R_RETURN(splCryptoLoadAesKey(std::addressof(access_key), key_source, static_cast<u32>(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<u32>(generation), option, dst);
|
||||
R_RETURN(splFsGenerateSpecificAesKey(key_source, static_cast<u32>(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<s32>(slot), iv);
|
||||
R_RETURN(splCryptoCryptAesCtr(src, dst, src_size, static_cast<s32>(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<u32>(generation), option, dst);
|
||||
});
|
||||
R_RETURN(WaitAvailableKeySlotAndExecute([&]() -> Result {
|
||||
R_RETURN(splCryptoDecryptAesKey(key_source, static_cast<u32>(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<u32>(slot));
|
||||
R_RETURN(splFsLoadTitlekey(std::addressof(access_key), static_cast<u32>(slot)));
|
||||
} else {
|
||||
/* TODO: libnx binding not available. */
|
||||
/* return splEsLoadTitlekey(std::addressof(access_key), static_cast<u32>(slot)); */
|
||||
/* R_RETURN(splEsLoadTitlekey(std::addressof(access_key), static_cast<u32>(slot))); */
|
||||
AMS_ABORT_UNLESS(false);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue