diff options
Diffstat (limited to 'src/core')
| -rw-r--r-- | src/core/file_sys/romfs_factory.cpp | 10 | ||||
| -rw-r--r-- | src/core/file_sys/savedata_factory.cpp | 4 | ||||
| -rw-r--r-- | src/core/file_sys/sdmc_factory.cpp | 2 | ||||
| -rw-r--r-- | src/core/hle/kernel/k_page_table.cpp | 4 | ||||
| -rw-r--r-- | src/core/hle/result.h | 210 | ||||
| -rw-r--r-- | src/core/hle/service/filesystem/filesystem.cpp | 21 | ||||
| -rw-r--r-- | src/core/hle/service/glue/glue_manager.cpp | 4 | ||||
| -rw-r--r-- | src/core/hle/service/ldr/ldr.cpp | 4 | ||||
| -rw-r--r-- | src/core/hle/service/mii/mii_manager.cpp | 4 | ||||
| -rw-r--r-- | src/core/hle/service/ns/ns.cpp | 4 | ||||
| -rw-r--r-- | src/core/hle/service/sm/sm.cpp | 4 | ||||
| -rw-r--r-- | src/core/hle/service/spl/spl_module.cpp | 26 | ||||
| -rw-r--r-- | src/core/hle/service/vi/vi.cpp | 10 |
13 files changed, 115 insertions, 192 deletions
diff --git a/src/core/file_sys/romfs_factory.cpp b/src/core/file_sys/romfs_factory.cpp index 638c6cea8..3d9ce863b 100644 --- a/src/core/file_sys/romfs_factory.cpp +++ b/src/core/file_sys/romfs_factory.cpp | |||
| @@ -39,13 +39,12 @@ void RomFSFactory::SetPackedUpdate(VirtualFile update_raw_file) { | |||
| 39 | 39 | ||
| 40 | ResultVal<VirtualFile> RomFSFactory::OpenCurrentProcess(u64 current_process_title_id) const { | 40 | ResultVal<VirtualFile> RomFSFactory::OpenCurrentProcess(u64 current_process_title_id) const { |
| 41 | if (!updatable) { | 41 | if (!updatable) { |
| 42 | return MakeResult<VirtualFile>(file); | 42 | return file; |
| 43 | } | 43 | } |
| 44 | 44 | ||
| 45 | const PatchManager patch_manager{current_process_title_id, filesystem_controller, | 45 | const PatchManager patch_manager{current_process_title_id, filesystem_controller, |
| 46 | content_provider}; | 46 | content_provider}; |
| 47 | return MakeResult<VirtualFile>( | 47 | return patch_manager.PatchRomFS(file, ivfc_offset, ContentRecordType::Program, update_raw); |
| 48 | patch_manager.PatchRomFS(file, ivfc_offset, ContentRecordType::Program, update_raw)); | ||
| 49 | } | 48 | } |
| 50 | 49 | ||
| 51 | ResultVal<VirtualFile> RomFSFactory::OpenPatchedRomFS(u64 title_id, ContentRecordType type) const { | 50 | ResultVal<VirtualFile> RomFSFactory::OpenPatchedRomFS(u64 title_id, ContentRecordType type) const { |
| @@ -58,8 +57,7 @@ ResultVal<VirtualFile> RomFSFactory::OpenPatchedRomFS(u64 title_id, ContentRecor | |||
| 58 | 57 | ||
| 59 | const PatchManager patch_manager{title_id, filesystem_controller, content_provider}; | 58 | const PatchManager patch_manager{title_id, filesystem_controller, content_provider}; |
| 60 | 59 | ||
| 61 | return MakeResult<VirtualFile>( | 60 | return patch_manager.PatchRomFS(nca->GetRomFS(), nca->GetBaseIVFCOffset(), type); |
| 62 | patch_manager.PatchRomFS(nca->GetRomFS(), nca->GetBaseIVFCOffset(), type)); | ||
| 63 | } | 61 | } |
| 64 | 62 | ||
| 65 | ResultVal<VirtualFile> RomFSFactory::OpenPatchedRomFSWithProgramIndex( | 63 | ResultVal<VirtualFile> RomFSFactory::OpenPatchedRomFSWithProgramIndex( |
| @@ -83,7 +81,7 @@ ResultVal<VirtualFile> RomFSFactory::Open(u64 title_id, StorageId storage, | |||
| 83 | return ResultUnknown; | 81 | return ResultUnknown; |
| 84 | } | 82 | } |
| 85 | 83 | ||
| 86 | return MakeResult<VirtualFile>(romfs); | 84 | return romfs; |
| 87 | } | 85 | } |
| 88 | 86 | ||
| 89 | std::shared_ptr<NCA> RomFSFactory::GetEntry(u64 title_id, StorageId storage, | 87 | std::shared_ptr<NCA> RomFSFactory::GetEntry(u64 title_id, StorageId storage, |
diff --git a/src/core/file_sys/savedata_factory.cpp b/src/core/file_sys/savedata_factory.cpp index b5254dd75..0c8ec4ba2 100644 --- a/src/core/file_sys/savedata_factory.cpp +++ b/src/core/file_sys/savedata_factory.cpp | |||
| @@ -94,7 +94,7 @@ ResultVal<VirtualDir> SaveDataFactory::Create(SaveDataSpaceId space, | |||
| 94 | return ResultUnknown; | 94 | return ResultUnknown; |
| 95 | } | 95 | } |
| 96 | 96 | ||
| 97 | return MakeResult<VirtualDir>(std::move(out)); | 97 | return out; |
| 98 | } | 98 | } |
| 99 | 99 | ||
| 100 | ResultVal<VirtualDir> SaveDataFactory::Open(SaveDataSpaceId space, | 100 | ResultVal<VirtualDir> SaveDataFactory::Open(SaveDataSpaceId space, |
| @@ -115,7 +115,7 @@ ResultVal<VirtualDir> SaveDataFactory::Open(SaveDataSpaceId space, | |||
| 115 | return ResultUnknown; | 115 | return ResultUnknown; |
| 116 | } | 116 | } |
| 117 | 117 | ||
| 118 | return MakeResult<VirtualDir>(std::move(out)); | 118 | return out; |
| 119 | } | 119 | } |
| 120 | 120 | ||
| 121 | VirtualDir SaveDataFactory::GetSaveDataSpaceDirectory(SaveDataSpaceId space) const { | 121 | VirtualDir SaveDataFactory::GetSaveDataSpaceDirectory(SaveDataSpaceId space) const { |
diff --git a/src/core/file_sys/sdmc_factory.cpp b/src/core/file_sys/sdmc_factory.cpp index e5c72cd4d..c0e13e56f 100644 --- a/src/core/file_sys/sdmc_factory.cpp +++ b/src/core/file_sys/sdmc_factory.cpp | |||
| @@ -25,7 +25,7 @@ SDMCFactory::SDMCFactory(VirtualDir sd_dir_, VirtualDir sd_mod_dir_) | |||
| 25 | SDMCFactory::~SDMCFactory() = default; | 25 | SDMCFactory::~SDMCFactory() = default; |
| 26 | 26 | ||
| 27 | ResultVal<VirtualDir> SDMCFactory::Open() const { | 27 | ResultVal<VirtualDir> SDMCFactory::Open() const { |
| 28 | return MakeResult<VirtualDir>(sd_dir); | 28 | return sd_dir; |
| 29 | } | 29 | } |
| 30 | 30 | ||
| 31 | VirtualDir SDMCFactory::GetSDMCModificationLoadRoot(u64 title_id) const { | 31 | VirtualDir SDMCFactory::GetSDMCModificationLoadRoot(u64 title_id) const { |
diff --git a/src/core/hle/kernel/k_page_table.cpp b/src/core/hle/kernel/k_page_table.cpp index 5e0b620c2..526b87241 100644 --- a/src/core/hle/kernel/k_page_table.cpp +++ b/src/core/hle/kernel/k_page_table.cpp | |||
| @@ -859,7 +859,7 @@ ResultVal<VAddr> KPageTable::SetHeapSize(std::size_t size) { | |||
| 859 | current_heap_addr = heap_region_start + size; | 859 | current_heap_addr = heap_region_start + size; |
| 860 | } | 860 | } |
| 861 | 861 | ||
| 862 | return MakeResult<VAddr>(heap_region_start); | 862 | return heap_region_start; |
| 863 | } | 863 | } |
| 864 | 864 | ||
| 865 | ResultVal<VAddr> KPageTable::AllocateAndMapMemory(std::size_t needed_num_pages, std::size_t align, | 865 | ResultVal<VAddr> KPageTable::AllocateAndMapMemory(std::size_t needed_num_pages, std::size_t align, |
| @@ -893,7 +893,7 @@ ResultVal<VAddr> KPageTable::AllocateAndMapMemory(std::size_t needed_num_pages, | |||
| 893 | 893 | ||
| 894 | block_manager->Update(addr, needed_num_pages, state, perm); | 894 | block_manager->Update(addr, needed_num_pages, state, perm); |
| 895 | 895 | ||
| 896 | return MakeResult<VAddr>(addr); | 896 | return addr; |
| 897 | } | 897 | } |
| 898 | 898 | ||
| 899 | ResultCode KPageTable::LockForDeviceAddressSpace(VAddr addr, std::size_t size) { | 899 | ResultCode KPageTable::LockForDeviceAddressSpace(VAddr addr, std::size_t size) { |
diff --git a/src/core/hle/result.h b/src/core/hle/result.h index 2c6b24848..3807b9aa8 100644 --- a/src/core/hle/result.h +++ b/src/core/hle/result.h | |||
| @@ -4,11 +4,10 @@ | |||
| 4 | 4 | ||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include <new> | ||
| 8 | #include <utility> | ||
| 9 | #include "common/assert.h" | 7 | #include "common/assert.h" |
| 10 | #include "common/bit_field.h" | 8 | #include "common/bit_field.h" |
| 11 | #include "common/common_types.h" | 9 | #include "common/common_types.h" |
| 10 | #include "common/expected.h" | ||
| 12 | 11 | ||
| 13 | // All the constants in this file come from http://switchbrew.org/index.php?title=Error_codes | 12 | // All the constants in this file come from http://switchbrew.org/index.php?title=Error_codes |
| 14 | 13 | ||
| @@ -155,203 +154,130 @@ constexpr ResultCode ResultSuccess(0); | |||
| 155 | constexpr ResultCode ResultUnknown(UINT32_MAX); | 154 | constexpr ResultCode ResultUnknown(UINT32_MAX); |
| 156 | 155 | ||
| 157 | /** | 156 | /** |
| 158 | * This is an optional value type. It holds a `ResultCode` and, if that code is a success code, | 157 | * This is an optional value type. It holds a `ResultCode` and, if that code is ResultSuccess, it |
| 159 | * also holds a result of type `T`. If the code is an error code then trying to access the inner | 158 | * also holds a result of type `T`. If the code is an error code (not ResultSuccess), then trying |
| 160 | * value fails, thus ensuring that the ResultCode of functions is always checked properly before | 159 | * to access the inner value with operator* is undefined behavior and will assert with Unwrap(). |
| 161 | * their return value is used. It is similar in concept to the `std::optional` type | 160 | * Users of this class must be cognizant to check the status of the ResultVal with operator bool(), |
| 162 | * (http://en.cppreference.com/w/cpp/experimental/optional) originally proposed for inclusion in | 161 | * Code(), Succeeded() or Failed() prior to accessing the inner value. |
| 163 | * C++14, or the `Result` type in Rust (http://doc.rust-lang.org/std/result/index.html). | ||
| 164 | * | 162 | * |
| 165 | * An example of how it could be used: | 163 | * An example of how it could be used: |
| 166 | * \code | 164 | * \code |
| 167 | * ResultVal<int> Frobnicate(float strength) { | 165 | * ResultVal<int> Frobnicate(float strength) { |
| 168 | * if (strength < 0.f || strength > 1.0f) { | 166 | * if (strength < 0.f || strength > 1.0f) { |
| 169 | * // Can't frobnicate too weakly or too strongly | 167 | * // Can't frobnicate too weakly or too strongly |
| 170 | * return ResultCode(ErrorDescription::OutOfRange, ErrorModule::Common, | 168 | * return ResultCode{ErrorModule::Common, 1}; |
| 171 | * ErrorSummary::InvalidArgument, ErrorLevel::Permanent); | ||
| 172 | * } else { | 169 | * } else { |
| 173 | * // Frobnicated! Give caller a cookie | 170 | * // Frobnicated! Give caller a cookie |
| 174 | * return MakeResult<int>(42); | 171 | * return 42; |
| 175 | * } | 172 | * } |
| 176 | * } | 173 | * } |
| 177 | * \endcode | 174 | * \endcode |
| 178 | * | 175 | * |
| 179 | * \code | 176 | * \code |
| 180 | * ResultVal<int> frob_result = Frobnicate(0.75f); | 177 | * auto frob_result = Frobnicate(0.75f); |
| 181 | * if (frob_result) { | 178 | * if (frob_result) { |
| 182 | * // Frobbed ok | 179 | * // Frobbed ok |
| 183 | * printf("My cookie is %d\n", *frob_result); | 180 | * printf("My cookie is %d\n", *frob_result); |
| 184 | * } else { | 181 | * } else { |
| 185 | * printf("Guess I overdid it. :( Error code: %ux\n", frob_result.code().hex); | 182 | * printf("Guess I overdid it. :( Error code: %ux\n", frob_result.Code().raw); |
| 186 | * } | 183 | * } |
| 187 | * \endcode | 184 | * \endcode |
| 188 | */ | 185 | */ |
| 189 | template <typename T> | 186 | template <typename T> |
| 190 | class ResultVal { | 187 | class ResultVal { |
| 191 | public: | 188 | public: |
| 192 | /// Constructs an empty `ResultVal` with the given error code. The code must not be a success | 189 | constexpr ResultVal() : expected{} {} |
| 193 | /// code. | 190 | |
| 194 | ResultVal(ResultCode error_code = ResultUnknown) : result_code(error_code) { | 191 | constexpr ResultVal(ResultCode code) : expected{Common::Unexpected(code)} {} |
| 195 | ASSERT(error_code.IsError()); | 192 | |
| 196 | } | 193 | template <typename U> |
| 194 | constexpr ResultVal(U&& val) : expected{std::forward<U>(val)} {} | ||
| 197 | 195 | ||
| 198 | /** | ||
| 199 | * Similar to the non-member function `MakeResult`, with the exception that you can manually | ||
| 200 | * specify the success code. `success_code` must not be an error code. | ||
| 201 | */ | ||
| 202 | template <typename... Args> | 196 | template <typename... Args> |
| 203 | [[nodiscard]] static ResultVal WithCode(ResultCode success_code, Args&&... args) { | 197 | constexpr ResultVal(Args&&... args) : expected{std::in_place, std::forward<Args>(args)...} {} |
| 204 | ResultVal<T> result; | ||
| 205 | result.emplace(success_code, std::forward<Args>(args)...); | ||
| 206 | return result; | ||
| 207 | } | ||
| 208 | 198 | ||
| 209 | ResultVal(const ResultVal& o) noexcept : result_code(o.result_code) { | 199 | ~ResultVal() = default; |
| 210 | if (!o.empty()) { | ||
| 211 | new (&object) T(o.object); | ||
| 212 | } | ||
| 213 | } | ||
| 214 | 200 | ||
| 215 | ResultVal(ResultVal&& o) noexcept : result_code(o.result_code) { | 201 | constexpr ResultVal(const ResultVal&) = default; |
| 216 | if (!o.empty()) { | 202 | constexpr ResultVal(ResultVal&&) = default; |
| 217 | new (&object) T(std::move(o.object)); | ||
| 218 | } | ||
| 219 | } | ||
| 220 | 203 | ||
| 221 | ~ResultVal() { | 204 | ResultVal& operator=(const ResultVal&) = default; |
| 222 | if (!empty()) { | 205 | ResultVal& operator=(ResultVal&&) = default; |
| 223 | object.~T(); | ||
| 224 | } | ||
| 225 | } | ||
| 226 | 206 | ||
| 227 | ResultVal& operator=(const ResultVal& o) noexcept { | 207 | [[nodiscard]] constexpr explicit operator bool() const noexcept { |
| 228 | if (this == &o) { | 208 | return expected.has_value(); |
| 229 | return *this; | ||
| 230 | } | ||
| 231 | if (!empty()) { | ||
| 232 | if (!o.empty()) { | ||
| 233 | object = o.object; | ||
| 234 | } else { | ||
| 235 | object.~T(); | ||
| 236 | } | ||
| 237 | } else { | ||
| 238 | if (!o.empty()) { | ||
| 239 | new (&object) T(o.object); | ||
| 240 | } | ||
| 241 | } | ||
| 242 | result_code = o.result_code; | ||
| 243 | |||
| 244 | return *this; | ||
| 245 | } | 209 | } |
| 246 | 210 | ||
| 247 | ResultVal& operator=(ResultVal&& o) noexcept { | 211 | [[nodiscard]] constexpr ResultCode Code() const { |
| 248 | if (this == &o) { | 212 | return expected.has_value() ? ResultSuccess : expected.error(); |
| 249 | return *this; | ||
| 250 | } | ||
| 251 | if (!empty()) { | ||
| 252 | if (!o.empty()) { | ||
| 253 | object = std::move(o.object); | ||
| 254 | } else { | ||
| 255 | object.~T(); | ||
| 256 | } | ||
| 257 | } else { | ||
| 258 | if (!o.empty()) { | ||
| 259 | new (&object) T(std::move(o.object)); | ||
| 260 | } | ||
| 261 | } | ||
| 262 | result_code = o.result_code; | ||
| 263 | |||
| 264 | return *this; | ||
| 265 | } | 213 | } |
| 266 | 214 | ||
| 267 | /** | 215 | [[nodiscard]] constexpr bool Succeeded() const { |
| 268 | * Replaces the current result with a new constructed result value in-place. The code must not | 216 | return expected.has_value(); |
| 269 | * be an error code. | ||
| 270 | */ | ||
| 271 | template <typename... Args> | ||
| 272 | void emplace(ResultCode success_code, Args&&... args) { | ||
| 273 | ASSERT(success_code.IsSuccess()); | ||
| 274 | if (!empty()) { | ||
| 275 | object.~T(); | ||
| 276 | } | ||
| 277 | new (&object) T(std::forward<Args>(args)...); | ||
| 278 | result_code = success_code; | ||
| 279 | } | 217 | } |
| 280 | 218 | ||
| 281 | /// Returns true if the `ResultVal` contains an error code and no value. | 219 | [[nodiscard]] constexpr bool Failed() const { |
| 282 | [[nodiscard]] bool empty() const { | 220 | return !expected.has_value(); |
| 283 | return result_code.IsError(); | ||
| 284 | } | 221 | } |
| 285 | 222 | ||
| 286 | /// Returns true if the `ResultVal` contains a return value. | 223 | [[nodiscard]] constexpr T* operator->() { |
| 287 | [[nodiscard]] bool Succeeded() const { | 224 | return std::addressof(expected.value()); |
| 288 | return result_code.IsSuccess(); | ||
| 289 | } | 225 | } |
| 290 | /// Returns true if the `ResultVal` contains an error code and no value. | 226 | |
| 291 | [[nodiscard]] bool Failed() const { | 227 | [[nodiscard]] constexpr const T* operator->() const { |
| 292 | return empty(); | 228 | return std::addressof(expected.value()); |
| 293 | } | 229 | } |
| 294 | 230 | ||
| 295 | [[nodiscard]] ResultCode Code() const { | 231 | [[nodiscard]] constexpr T& operator*() & { |
| 296 | return result_code; | 232 | return *expected; |
| 297 | } | 233 | } |
| 298 | 234 | ||
| 299 | [[nodiscard]] const T& operator*() const { | 235 | [[nodiscard]] constexpr const T& operator*() const& { |
| 300 | return object; | 236 | return *expected; |
| 301 | } | 237 | } |
| 302 | [[nodiscard]] T& operator*() { | 238 | |
| 303 | return object; | 239 | [[nodiscard]] constexpr T&& operator*() && { |
| 240 | return *expected; | ||
| 304 | } | 241 | } |
| 305 | [[nodiscard]] const T* operator->() const { | 242 | |
| 306 | return &object; | 243 | [[nodiscard]] constexpr const T&& operator*() const&& { |
| 244 | return *expected; | ||
| 307 | } | 245 | } |
| 308 | [[nodiscard]] T* operator->() { | 246 | |
| 309 | return &object; | 247 | [[nodiscard]] constexpr T& Unwrap() & { |
| 248 | ASSERT_MSG(Succeeded(), "Tried to Unwrap empty ResultVal"); | ||
| 249 | return expected.value(); | ||
| 310 | } | 250 | } |
| 311 | 251 | ||
| 312 | /// Returns the value contained in this `ResultVal`, or the supplied default if it is missing. | 252 | [[nodiscard]] constexpr const T& Unwrap() const& { |
| 313 | template <typename U> | 253 | ASSERT_MSG(Succeeded(), "Tried to Unwrap empty ResultVal"); |
| 314 | [[nodiscard]] T ValueOr(U&& value) const { | 254 | return expected.value(); |
| 315 | return !empty() ? object : std::move(value); | ||
| 316 | } | 255 | } |
| 317 | 256 | ||
| 318 | /// Asserts that the result succeeded and returns a reference to it. | 257 | [[nodiscard]] constexpr T&& Unwrap() && { |
| 319 | [[nodiscard]] T& Unwrap() & { | ||
| 320 | ASSERT_MSG(Succeeded(), "Tried to Unwrap empty ResultVal"); | 258 | ASSERT_MSG(Succeeded(), "Tried to Unwrap empty ResultVal"); |
| 321 | return **this; | 259 | return std::move(expected.value()); |
| 322 | } | 260 | } |
| 323 | 261 | ||
| 324 | [[nodiscard]] T&& Unwrap() && { | 262 | [[nodiscard]] constexpr const T&& Unwrap() const&& { |
| 325 | ASSERT_MSG(Succeeded(), "Tried to Unwrap empty ResultVal"); | 263 | ASSERT_MSG(Succeeded(), "Tried to Unwrap empty ResultVal"); |
| 326 | return std::move(**this); | 264 | return std::move(expected.value()); |
| 327 | } | 265 | } |
| 328 | 266 | ||
| 329 | private: | 267 | template <typename U> |
| 330 | // A union is used to allocate the storage for the value, while allowing us to construct and | 268 | [[nodiscard]] constexpr T ValueOr(U&& v) const& { |
| 331 | // destruct it at will. | 269 | return expected.value_or(v); |
| 332 | union { | 270 | } |
| 333 | T object; | ||
| 334 | }; | ||
| 335 | ResultCode result_code; | ||
| 336 | }; | ||
| 337 | 271 | ||
| 338 | /** | 272 | template <typename U> |
| 339 | * This function is a helper used to construct `ResultVal`s. It receives the arguments to construct | 273 | [[nodiscard]] constexpr T ValueOr(U&& v) && { |
| 340 | * `T` with and creates a success `ResultVal` contained the constructed value. | 274 | return expected.value_or(v); |
| 341 | */ | 275 | } |
| 342 | template <typename T, typename... Args> | ||
| 343 | [[nodiscard]] ResultVal<T> MakeResult(Args&&... args) { | ||
| 344 | return ResultVal<T>::WithCode(ResultSuccess, std::forward<Args>(args)...); | ||
| 345 | } | ||
| 346 | 276 | ||
| 347 | /** | 277 | private: |
| 348 | * Deducible overload of MakeResult, allowing the template parameter to be ommited if you're just | 278 | // TODO: Replace this with std::expected once it is standardized in the STL. |
| 349 | * copy or move constructing. | 279 | Common::Expected<T, ResultCode> expected; |
| 350 | */ | 280 | }; |
| 351 | template <typename Arg> | ||
| 352 | [[nodiscard]] ResultVal<std::remove_cvref_t<Arg>> MakeResult(Arg&& arg) { | ||
| 353 | return ResultVal<std::remove_cvref_t<Arg>>::WithCode(ResultSuccess, std::forward<Arg>(arg)); | ||
| 354 | } | ||
| 355 | 281 | ||
| 356 | /** | 282 | /** |
| 357 | * Check for the success of `source` (which must evaluate to a ResultVal). If it succeeds, unwraps | 283 | * Check for the success of `source` (which must evaluate to a ResultVal). If it succeeds, unwraps |
diff --git a/src/core/hle/service/filesystem/filesystem.cpp b/src/core/hle/service/filesystem/filesystem.cpp index f8f9e32f7..42e468ce2 100644 --- a/src/core/hle/service/filesystem/filesystem.cpp +++ b/src/core/hle/service/filesystem/filesystem.cpp | |||
| @@ -226,11 +226,10 @@ ResultVal<FileSys::VirtualFile> VfsDirectoryServiceWrapper::OpenFile(const std:: | |||
| 226 | } | 226 | } |
| 227 | 227 | ||
| 228 | if (mode == FileSys::Mode::Append) { | 228 | if (mode == FileSys::Mode::Append) { |
| 229 | return MakeResult<FileSys::VirtualFile>( | 229 | return std::make_shared<FileSys::OffsetVfsFile>(file, 0, file->GetSize()); |
| 230 | std::make_shared<FileSys::OffsetVfsFile>(file, 0, file->GetSize())); | ||
| 231 | } | 230 | } |
| 232 | 231 | ||
| 233 | return MakeResult<FileSys::VirtualFile>(file); | 232 | return file; |
| 234 | } | 233 | } |
| 235 | 234 | ||
| 236 | ResultVal<FileSys::VirtualDir> VfsDirectoryServiceWrapper::OpenDirectory(const std::string& path_) { | 235 | ResultVal<FileSys::VirtualDir> VfsDirectoryServiceWrapper::OpenDirectory(const std::string& path_) { |
| @@ -240,7 +239,7 @@ ResultVal<FileSys::VirtualDir> VfsDirectoryServiceWrapper::OpenDirectory(const s | |||
| 240 | // TODO(DarkLordZach): Find a better error code for this | 239 | // TODO(DarkLordZach): Find a better error code for this |
| 241 | return FileSys::ERROR_PATH_NOT_FOUND; | 240 | return FileSys::ERROR_PATH_NOT_FOUND; |
| 242 | } | 241 | } |
| 243 | return MakeResult(dir); | 242 | return dir; |
| 244 | } | 243 | } |
| 245 | 244 | ||
| 246 | ResultVal<FileSys::EntryType> VfsDirectoryServiceWrapper::GetEntryType( | 245 | ResultVal<FileSys::EntryType> VfsDirectoryServiceWrapper::GetEntryType( |
| @@ -252,12 +251,12 @@ ResultVal<FileSys::EntryType> VfsDirectoryServiceWrapper::GetEntryType( | |||
| 252 | auto filename = Common::FS::GetFilename(path); | 251 | auto filename = Common::FS::GetFilename(path); |
| 253 | // TODO(Subv): Some games use the '/' path, find out what this means. | 252 | // TODO(Subv): Some games use the '/' path, find out what this means. |
| 254 | if (filename.empty()) | 253 | if (filename.empty()) |
| 255 | return MakeResult(FileSys::EntryType::Directory); | 254 | return FileSys::EntryType::Directory; |
| 256 | 255 | ||
| 257 | if (dir->GetFile(filename) != nullptr) | 256 | if (dir->GetFile(filename) != nullptr) |
| 258 | return MakeResult(FileSys::EntryType::File); | 257 | return FileSys::EntryType::File; |
| 259 | if (dir->GetSubdirectory(filename) != nullptr) | 258 | if (dir->GetSubdirectory(filename) != nullptr) |
| 260 | return MakeResult(FileSys::EntryType::Directory); | 259 | return FileSys::EntryType::Directory; |
| 261 | return FileSys::ERROR_PATH_NOT_FOUND; | 260 | return FileSys::ERROR_PATH_NOT_FOUND; |
| 262 | } | 261 | } |
| 263 | 262 | ||
| @@ -270,7 +269,7 @@ ResultVal<FileSys::FileTimeStampRaw> VfsDirectoryServiceWrapper::GetFileTimeStam | |||
| 270 | if (GetEntryType(path).Failed()) { | 269 | if (GetEntryType(path).Failed()) { |
| 271 | return FileSys::ERROR_PATH_NOT_FOUND; | 270 | return FileSys::ERROR_PATH_NOT_FOUND; |
| 272 | } | 271 | } |
| 273 | return MakeResult(dir->GetFileTimeStamp(Common::FS::GetFilename(path))); | 272 | return dir->GetFileTimeStamp(Common::FS::GetFilename(path)); |
| 274 | } | 273 | } |
| 275 | 274 | ||
| 276 | FileSystemController::FileSystemController(Core::System& system_) : system{system_} {} | 275 | FileSystemController::FileSystemController(Core::System& system_) : system{system_} {} |
| @@ -395,7 +394,7 @@ ResultVal<FileSys::VirtualDir> FileSystemController::OpenSaveDataSpace( | |||
| 395 | return FileSys::ERROR_ENTITY_NOT_FOUND; | 394 | return FileSys::ERROR_ENTITY_NOT_FOUND; |
| 396 | } | 395 | } |
| 397 | 396 | ||
| 398 | return MakeResult(save_data_factory->GetSaveDataSpaceDirectory(space)); | 397 | return save_data_factory->GetSaveDataSpaceDirectory(space); |
| 399 | } | 398 | } |
| 400 | 399 | ||
| 401 | ResultVal<FileSys::VirtualDir> FileSystemController::OpenSDMC() const { | 400 | ResultVal<FileSys::VirtualDir> FileSystemController::OpenSDMC() const { |
| @@ -421,7 +420,7 @@ ResultVal<FileSys::VirtualDir> FileSystemController::OpenBISPartition( | |||
| 421 | return FileSys::ERROR_INVALID_ARGUMENT; | 420 | return FileSys::ERROR_INVALID_ARGUMENT; |
| 422 | } | 421 | } |
| 423 | 422 | ||
| 424 | return MakeResult<FileSys::VirtualDir>(std::move(part)); | 423 | return part; |
| 425 | } | 424 | } |
| 426 | 425 | ||
| 427 | ResultVal<FileSys::VirtualFile> FileSystemController::OpenBISPartitionStorage( | 426 | ResultVal<FileSys::VirtualFile> FileSystemController::OpenBISPartitionStorage( |
| @@ -437,7 +436,7 @@ ResultVal<FileSys::VirtualFile> FileSystemController::OpenBISPartitionStorage( | |||
| 437 | return FileSys::ERROR_INVALID_ARGUMENT; | 436 | return FileSys::ERROR_INVALID_ARGUMENT; |
| 438 | } | 437 | } |
| 439 | 438 | ||
| 440 | return MakeResult<FileSys::VirtualFile>(std::move(part)); | 439 | return part; |
| 441 | } | 440 | } |
| 442 | 441 | ||
| 443 | u64 FileSystemController::GetFreeSpaceSize(FileSys::StorageId id) const { | 442 | u64 FileSystemController::GetFreeSpaceSize(FileSys::StorageId id) const { |
diff --git a/src/core/hle/service/glue/glue_manager.cpp b/src/core/hle/service/glue/glue_manager.cpp index aa9d48c0c..48e133b48 100644 --- a/src/core/hle/service/glue/glue_manager.cpp +++ b/src/core/hle/service/glue/glue_manager.cpp | |||
| @@ -26,7 +26,7 @@ ResultVal<ApplicationLaunchProperty> ARPManager::GetLaunchProperty(u64 title_id) | |||
| 26 | return ERR_NOT_REGISTERED; | 26 | return ERR_NOT_REGISTERED; |
| 27 | } | 27 | } |
| 28 | 28 | ||
| 29 | return MakeResult<ApplicationLaunchProperty>(iter->second.launch); | 29 | return iter->second.launch; |
| 30 | } | 30 | } |
| 31 | 31 | ||
| 32 | ResultVal<std::vector<u8>> ARPManager::GetControlProperty(u64 title_id) const { | 32 | ResultVal<std::vector<u8>> ARPManager::GetControlProperty(u64 title_id) const { |
| @@ -39,7 +39,7 @@ ResultVal<std::vector<u8>> ARPManager::GetControlProperty(u64 title_id) const { | |||
| 39 | return ERR_NOT_REGISTERED; | 39 | return ERR_NOT_REGISTERED; |
| 40 | } | 40 | } |
| 41 | 41 | ||
| 42 | return MakeResult<std::vector<u8>>(iter->second.control); | 42 | return iter->second.control; |
| 43 | } | 43 | } |
| 44 | 44 | ||
| 45 | ResultCode ARPManager::Register(u64 title_id, ApplicationLaunchProperty launch, | 45 | ResultCode ARPManager::Register(u64 title_id, ApplicationLaunchProperty launch, |
diff --git a/src/core/hle/service/ldr/ldr.cpp b/src/core/hle/service/ldr/ldr.cpp index 24b7e4435..e4b97c1f6 100644 --- a/src/core/hle/service/ldr/ldr.cpp +++ b/src/core/hle/service/ldr/ldr.cpp | |||
| @@ -335,7 +335,7 @@ public: | |||
| 335 | CASCADE_CODE(result); | 335 | CASCADE_CODE(result); |
| 336 | 336 | ||
| 337 | if (ValidateRegionForMap(page_table, addr, size)) { | 337 | if (ValidateRegionForMap(page_table, addr, size)) { |
| 338 | return MakeResult<VAddr>(addr); | 338 | return addr; |
| 339 | } | 339 | } |
| 340 | } | 340 | } |
| 341 | 341 | ||
| @@ -371,7 +371,7 @@ public: | |||
| 371 | } | 371 | } |
| 372 | 372 | ||
| 373 | if (ValidateRegionForMap(page_table, addr, size)) { | 373 | if (ValidateRegionForMap(page_table, addr, size)) { |
| 374 | return MakeResult<VAddr>(addr); | 374 | return addr; |
| 375 | } | 375 | } |
| 376 | } | 376 | } |
| 377 | 377 | ||
diff --git a/src/core/hle/service/mii/mii_manager.cpp b/src/core/hle/service/mii/mii_manager.cpp index 4fef2aea4..ca4ed35bb 100644 --- a/src/core/hle/service/mii/mii_manager.cpp +++ b/src/core/hle/service/mii/mii_manager.cpp | |||
| @@ -443,14 +443,14 @@ ResultVal<std::vector<MiiInfoElement>> MiiManager::GetDefault(SourceFlag source_ | |||
| 443 | std::vector<MiiInfoElement> result; | 443 | std::vector<MiiInfoElement> result; |
| 444 | 444 | ||
| 445 | if ((source_flag & SourceFlag::Default) == SourceFlag::None) { | 445 | if ((source_flag & SourceFlag::Default) == SourceFlag::None) { |
| 446 | return MakeResult(std::move(result)); | 446 | return result; |
| 447 | } | 447 | } |
| 448 | 448 | ||
| 449 | for (std::size_t index = BaseMiiCount; index < DefaultMiiCount; index++) { | 449 | for (std::size_t index = BaseMiiCount; index < DefaultMiiCount; index++) { |
| 450 | result.emplace_back(BuildDefault(index), Source::Default); | 450 | result.emplace_back(BuildDefault(index), Source::Default); |
| 451 | } | 451 | } |
| 452 | 452 | ||
| 453 | return MakeResult(std::move(result)); | 453 | return result; |
| 454 | } | 454 | } |
| 455 | 455 | ||
| 456 | ResultCode MiiManager::GetIndex([[maybe_unused]] const MiiInfo& info, u32& index) { | 456 | ResultCode MiiManager::GetIndex([[maybe_unused]] const MiiInfo& info, u32& index) { |
diff --git a/src/core/hle/service/ns/ns.cpp b/src/core/hle/service/ns/ns.cpp index 931b48f72..64ffc8572 100644 --- a/src/core/hle/service/ns/ns.cpp +++ b/src/core/hle/service/ns/ns.cpp | |||
| @@ -414,7 +414,7 @@ ResultVal<u8> IApplicationManagerInterface::GetApplicationDesiredLanguage( | |||
| 414 | for (const auto lang : *priority_list) { | 414 | for (const auto lang : *priority_list) { |
| 415 | const auto supported_flag = GetSupportedLanguageFlag(lang); | 415 | const auto supported_flag = GetSupportedLanguageFlag(lang); |
| 416 | if (supported_languages == 0 || (supported_languages & supported_flag) == supported_flag) { | 416 | if (supported_languages == 0 || (supported_languages & supported_flag) == supported_flag) { |
| 417 | return MakeResult(static_cast<u8>(lang)); | 417 | return static_cast<u8>(lang); |
| 418 | } | 418 | } |
| 419 | } | 419 | } |
| 420 | 420 | ||
| @@ -448,7 +448,7 @@ ResultVal<u64> IApplicationManagerInterface::ConvertApplicationLanguageToLanguag | |||
| 448 | return ERR_APPLICATION_LANGUAGE_NOT_FOUND; | 448 | return ERR_APPLICATION_LANGUAGE_NOT_FOUND; |
| 449 | } | 449 | } |
| 450 | 450 | ||
| 451 | return MakeResult(static_cast<u64>(*language_code)); | 451 | return static_cast<u64>(*language_code); |
| 452 | } | 452 | } |
| 453 | 453 | ||
| 454 | IApplicationVersionInterface::IApplicationVersionInterface(Core::System& system_) | 454 | IApplicationVersionInterface::IApplicationVersionInterface(Core::System& system_) |
diff --git a/src/core/hle/service/sm/sm.cpp b/src/core/hle/service/sm/sm.cpp index ae4dc4a75..41abb146c 100644 --- a/src/core/hle/service/sm/sm.cpp +++ b/src/core/hle/service/sm/sm.cpp | |||
| @@ -87,7 +87,7 @@ ResultVal<Kernel::KPort*> ServiceManager::GetServicePort(const std::string& name | |||
| 87 | auto handler = it->second; | 87 | auto handler = it->second; |
| 88 | port->GetServerPort().SetSessionHandler(std::move(handler)); | 88 | port->GetServerPort().SetSessionHandler(std::move(handler)); |
| 89 | 89 | ||
| 90 | return MakeResult(port); | 90 | return port; |
| 91 | } | 91 | } |
| 92 | 92 | ||
| 93 | /** | 93 | /** |
| @@ -165,7 +165,7 @@ ResultVal<Kernel::KClientSession*> SM::GetServiceImpl(Kernel::HLERequestContext& | |||
| 165 | 165 | ||
| 166 | LOG_DEBUG(Service_SM, "called service={} -> session={}", name, session->GetId()); | 166 | LOG_DEBUG(Service_SM, "called service={} -> session={}", name, session->GetId()); |
| 167 | 167 | ||
| 168 | return MakeResult(session); | 168 | return session; |
| 169 | } | 169 | } |
| 170 | 170 | ||
| 171 | void SM::RegisterService(Kernel::HLERequestContext& ctx) { | 171 | void SM::RegisterService(Kernel::HLERequestContext& ctx) { |
diff --git a/src/core/hle/service/spl/spl_module.cpp b/src/core/hle/service/spl/spl_module.cpp index ed4c06260..10f7d1461 100644 --- a/src/core/hle/service/spl/spl_module.cpp +++ b/src/core/hle/service/spl/spl_module.cpp | |||
| @@ -120,40 +120,40 @@ ResultVal<u64> Module::Interface::GetConfigImpl(ConfigItem config_item) const { | |||
| 120 | return ResultSecureMonitorNotImplemented; | 120 | return ResultSecureMonitorNotImplemented; |
| 121 | case ConfigItem::ExosphereApiVersion: | 121 | case ConfigItem::ExosphereApiVersion: |
| 122 | // Get information about the current exosphere version. | 122 | // Get information about the current exosphere version. |
| 123 | return MakeResult((u64{HLE::ApiVersion::ATMOSPHERE_RELEASE_VERSION_MAJOR} << 56) | | 123 | return (u64{HLE::ApiVersion::ATMOSPHERE_RELEASE_VERSION_MAJOR} << 56) | |
| 124 | (u64{HLE::ApiVersion::ATMOSPHERE_RELEASE_VERSION_MINOR} << 48) | | 124 | (u64{HLE::ApiVersion::ATMOSPHERE_RELEASE_VERSION_MINOR} << 48) | |
| 125 | (u64{HLE::ApiVersion::ATMOSPHERE_RELEASE_VERSION_MICRO} << 40) | | 125 | (u64{HLE::ApiVersion::ATMOSPHERE_RELEASE_VERSION_MICRO} << 40) | |
| 126 | (static_cast<u64>(HLE::ApiVersion::GetTargetFirmware()))); | 126 | (static_cast<u64>(HLE::ApiVersion::GetTargetFirmware())); |
| 127 | case ConfigItem::ExosphereNeedsReboot: | 127 | case ConfigItem::ExosphereNeedsReboot: |
| 128 | // We are executing, so we aren't in the process of rebooting. | 128 | // We are executing, so we aren't in the process of rebooting. |
| 129 | return MakeResult(u64{0}); | 129 | return u64{0}; |
| 130 | case ConfigItem::ExosphereNeedsShutdown: | 130 | case ConfigItem::ExosphereNeedsShutdown: |
| 131 | // We are executing, so we aren't in the process of shutting down. | 131 | // We are executing, so we aren't in the process of shutting down. |
| 132 | return MakeResult(u64{0}); | 132 | return u64{0}; |
| 133 | case ConfigItem::ExosphereGitCommitHash: | 133 | case ConfigItem::ExosphereGitCommitHash: |
| 134 | // Get information about the current exosphere git commit hash. | 134 | // Get information about the current exosphere git commit hash. |
| 135 | return MakeResult(u64{0}); | 135 | return u64{0}; |
| 136 | case ConfigItem::ExosphereHasRcmBugPatch: | 136 | case ConfigItem::ExosphereHasRcmBugPatch: |
| 137 | // Get information about whether this unit has the RCM bug patched. | 137 | // Get information about whether this unit has the RCM bug patched. |
| 138 | return MakeResult(u64{0}); | 138 | return u64{0}; |
| 139 | case ConfigItem::ExosphereBlankProdInfo: | 139 | case ConfigItem::ExosphereBlankProdInfo: |
| 140 | // Get whether this unit should simulate a "blanked" PRODINFO. | 140 | // Get whether this unit should simulate a "blanked" PRODINFO. |
| 141 | return MakeResult(u64{0}); | 141 | return u64{0}; |
| 142 | case ConfigItem::ExosphereAllowCalWrites: | 142 | case ConfigItem::ExosphereAllowCalWrites: |
| 143 | // Get whether this unit should allow writing to the calibration partition. | 143 | // Get whether this unit should allow writing to the calibration partition. |
| 144 | return MakeResult(u64{0}); | 144 | return u64{0}; |
| 145 | case ConfigItem::ExosphereEmummcType: | 145 | case ConfigItem::ExosphereEmummcType: |
| 146 | // Get what kind of emummc this unit has active. | 146 | // Get what kind of emummc this unit has active. |
| 147 | return MakeResult(u64{0}); | 147 | return u64{0}; |
| 148 | case ConfigItem::ExospherePayloadAddress: | 148 | case ConfigItem::ExospherePayloadAddress: |
| 149 | // Gets the physical address of the reboot payload buffer, if one exists. | 149 | // Gets the physical address of the reboot payload buffer, if one exists. |
| 150 | return ResultSecureMonitorNotInitialized; | 150 | return ResultSecureMonitorNotInitialized; |
| 151 | case ConfigItem::ExosphereLogConfiguration: | 151 | case ConfigItem::ExosphereLogConfiguration: |
| 152 | // Get the log configuration. | 152 | // Get the log configuration. |
| 153 | return MakeResult(u64{0}); | 153 | return u64{0}; |
| 154 | case ConfigItem::ExosphereForceEnableUsb30: | 154 | case ConfigItem::ExosphereForceEnableUsb30: |
| 155 | // Get whether usb 3.0 should be force-enabled. | 155 | // Get whether usb 3.0 should be force-enabled. |
| 156 | return MakeResult(u64{0}); | 156 | return u64{0}; |
| 157 | default: | 157 | default: |
| 158 | return ResultSecureMonitorInvalidArgument; | 158 | return ResultSecureMonitorInvalidArgument; |
| 159 | } | 159 | } |
diff --git a/src/core/hle/service/vi/vi.cpp b/src/core/hle/service/vi/vi.cpp index 439e7e472..760b528b9 100644 --- a/src/core/hle/service/vi/vi.cpp +++ b/src/core/hle/service/vi/vi.cpp | |||
| @@ -1284,15 +1284,15 @@ private: | |||
| 1284 | static ResultVal<ConvertedScaleMode> ConvertScalingModeImpl(NintendoScaleMode mode) { | 1284 | static ResultVal<ConvertedScaleMode> ConvertScalingModeImpl(NintendoScaleMode mode) { |
| 1285 | switch (mode) { | 1285 | switch (mode) { |
| 1286 | case NintendoScaleMode::None: | 1286 | case NintendoScaleMode::None: |
| 1287 | return MakeResult(ConvertedScaleMode::None); | 1287 | return ConvertedScaleMode::None; |
| 1288 | case NintendoScaleMode::Freeze: | 1288 | case NintendoScaleMode::Freeze: |
| 1289 | return MakeResult(ConvertedScaleMode::Freeze); | 1289 | return ConvertedScaleMode::Freeze; |
| 1290 | case NintendoScaleMode::ScaleToWindow: | 1290 | case NintendoScaleMode::ScaleToWindow: |
| 1291 | return MakeResult(ConvertedScaleMode::ScaleToWindow); | 1291 | return ConvertedScaleMode::ScaleToWindow; |
| 1292 | case NintendoScaleMode::ScaleAndCrop: | 1292 | case NintendoScaleMode::ScaleAndCrop: |
| 1293 | return MakeResult(ConvertedScaleMode::ScaleAndCrop); | 1293 | return ConvertedScaleMode::ScaleAndCrop; |
| 1294 | case NintendoScaleMode::PreserveAspectRatio: | 1294 | case NintendoScaleMode::PreserveAspectRatio: |
| 1295 | return MakeResult(ConvertedScaleMode::PreserveAspectRatio); | 1295 | return ConvertedScaleMode::PreserveAspectRatio; |
| 1296 | default: | 1296 | default: |
| 1297 | LOG_ERROR(Service_VI, "Invalid scaling mode specified, mode={}", mode); | 1297 | LOG_ERROR(Service_VI, "Invalid scaling mode specified, mode={}", mode); |
| 1298 | return ERR_OPERATION_FAILED; | 1298 | return ERR_OPERATION_FAILED; |