diff options
author | Andreas Kling <kling@serenityos.org> | 2021-09-05 15:13:20 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-09-05 15:13:20 +0200 |
commit | 83fed5b2de58e7ad9dc2da1f15dd5cf0e052cadd (patch) | |
tree | 1c6d3d99d74f40387e78b9dc2e7a8318a6a58877 /Kernel/Syscalls/execve.cpp | |
parent | 0cf65cf7ec5513dc972f51e2bdc95ca7f983064b (diff) | |
download | serenity-83fed5b2de58e7ad9dc2da1f15dd5cf0e052cadd.zip |
Kernel: Tidy up Memory::AddressSpace construction
- Return KResultOr<T> in places
- Propagate errors
- Use TRY()
Diffstat (limited to 'Kernel/Syscalls/execve.cpp')
-rw-r--r-- | Kernel/Syscalls/execve.cpp | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/Kernel/Syscalls/execve.cpp b/Kernel/Syscalls/execve.cpp index 0f1ed35b8e..afbf187725 100644 --- a/Kernel/Syscalls/execve.cpp +++ b/Kernel/Syscalls/execve.cpp @@ -453,9 +453,7 @@ static KResultOr<LoadResult> load_elf_object(NonnullOwnPtr<Memory::AddressSpace> KResultOr<LoadResult> Process::load(NonnullRefPtr<FileDescription> main_program_description, RefPtr<FileDescription> interpreter_description, const ElfW(Ehdr) & main_program_header) { - auto new_space = Memory::AddressSpace::try_create(nullptr); - if (!new_space) - return ENOMEM; + auto new_space = TRY(Memory::AddressSpace::try_create(nullptr)); ScopeGuard space_guard([&]() { Memory::MemoryManager::enter_process_paging_scope(*this); @@ -467,7 +465,7 @@ KResultOr<LoadResult> Process::load(NonnullRefPtr<FileDescription> main_program_ } if (interpreter_description.is_null()) { - auto result = load_elf_object(new_space.release_nonnull(), main_program_description, load_offset.value(), ShouldAllocateTls::Yes, ShouldAllowSyscalls::No); + auto result = load_elf_object(move(new_space), main_program_description, load_offset.value(), ShouldAllocateTls::Yes, ShouldAllowSyscalls::No); if (result.is_error()) return result.error(); @@ -478,7 +476,7 @@ KResultOr<LoadResult> Process::load(NonnullRefPtr<FileDescription> main_program_ return result; } - auto interpreter_load_result = load_elf_object(new_space.release_nonnull(), *interpreter_description, load_offset.value(), ShouldAllocateTls::No, ShouldAllowSyscalls::Yes); + auto interpreter_load_result = load_elf_object(move(new_space), *interpreter_description, load_offset.value(), ShouldAllocateTls::No, ShouldAllowSyscalls::Yes); if (interpreter_load_result.is_error()) return interpreter_load_result.error(); |