ams: globally prefer R_RETURN to return for ams::Result

This commit is contained in:
Michael Scire
2022-03-26 14:48:33 -07:00
parent dd78ede99f
commit bbf22b4c60
325 changed files with 1955 additions and 1993 deletions

View File

@@ -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<sf::SharedPointer<ams::fssrv::sf::IFileSystem>> out, ncm::ProgramId program_id, u32 _filesystem_type) {
return OpenWebContentFileSystem(out, m_client_info.program_id, program_id, static_cast<FsFileSystemType>(_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<FsFileSystemType>(_filesystem_type), m_forward_service.get(), nullptr, false, m_client_info.override_status.IsProgramSpecific()));
}
Result FsMitmService::OpenFileSystemWithId(sf::Out<sf::SharedPointer<ams::fssrv::sf::IFileSystem>> 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<FsFileSystemType>(_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<FsFileSystemType>(_filesystem_type), m_forward_service.get(), std::addressof(path), true, m_client_info.override_status.IsProgramSpecific()));
}
Result FsMitmService::OpenSdCardFileSystem(sf::Out<sf::SharedPointer<ams::fssrv::sf::IFileSystem>> out) {

View File

@@ -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) {

View File

@@ -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. */

View File

@@ -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));
}
}

View File

@@ -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())
}
};

View File

@@ -53,7 +53,7 @@ namespace ams::mitm::fs {
switch (port_index) {
case PortIndex_Mitm:
return this->AcceptMitmImpl(server, sf::CreateSharedObjectEmplaced<IFsMitmInterface, FsMitmService>(decltype(fsrv)(fsrv), client_info), fsrv);
R_RETURN(this->AcceptMitmImpl(server, sf::CreateSharedObjectEmplaced<IFsMitmInterface, FsMitmService>(decltype(fsrv)(fsrv), client_info), fsrv));
AMS_UNREACHABLE_DEFAULT_CASE();
}
}

View File

@@ -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<ams::fs::fsa::IFile> *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<ams::fs::fsa::IDirectory> *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));
}
};