diff options
author | Andreas Kling <kling@serenityos.org> | 2021-09-05 16:11:42 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-09-05 16:25:40 +0200 |
commit | aa4d5817afcf7f8455396c01435331ed6d9637d4 (patch) | |
tree | 2bf9480b620e01782a0f96284e9bb41176db6600 /Kernel | |
parent | b2950c67ea6509e39ed78a82f4e10df53bca66b6 (diff) | |
download | serenity-aa4d5817afcf7f8455396c01435331ed6d9637d4.zip |
Kernel: Use TRY() in sys$ptrace()
Diffstat (limited to 'Kernel')
-rw-r--r-- | Kernel/Syscalls/ptrace.cpp | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/Kernel/Syscalls/ptrace.cpp b/Kernel/Syscalls/ptrace.cpp index d7be01114e..8a671378bd 100644 --- a/Kernel/Syscalls/ptrace.cpp +++ b/Kernel/Syscalls/ptrace.cpp @@ -52,9 +52,7 @@ static KResultOr<u32> handle_ptrace(const Kernel::Syscall::SC_ptrace_params& par if (peer_process.tracer()) { return EBUSY; } - auto result = peer_process.start_tracing_from(caller.pid()); - if (result.is_error()) - return result.error(); + TRY(peer_process.start_tracing_from(caller.pid())); SpinlockLocker lock(peer->get_lock()); if (peer->state() != Thread::State::Stopped) { peer->send_signal(SIGSTOP, &caller); @@ -123,10 +121,8 @@ static KResultOr<u32> handle_ptrace(const Kernel::Syscall::SC_ptrace_params& par return EFAULT; if (!Memory::is_user_address(VirtualAddress { peek_params.address })) return EFAULT; - auto result = peer->process().peek_user_data(Userspace<const u32*> { (FlatPtr)peek_params.address }); - if (result.is_error()) - return result.error(); - if (!copy_to_user(peek_params.out_data, &result.value())) + auto data = TRY(peer->process().peek_user_data(Userspace<const u32*> { (FlatPtr)peek_params.address })); + if (!copy_to_user(peek_params.out_data, &data)) return EFAULT; break; } @@ -140,10 +136,8 @@ static KResultOr<u32> handle_ptrace(const Kernel::Syscall::SC_ptrace_params& par Kernel::Syscall::SC_ptrace_peek_params peek_params {}; if (!copy_from_user(&peek_params, reinterpret_cast<Kernel::Syscall::SC_ptrace_peek_params*>(params.addr))) return EFAULT; - auto result = peer->peek_debug_register(reinterpret_cast<uintptr_t>(peek_params.address)); - if (result.is_error()) - return result.error(); - if (!copy_to_user(peek_params.out_data, &result.value())) + auto data = TRY(peer->peek_debug_register(reinterpret_cast<uintptr_t>(peek_params.address))); + if (!copy_to_user(peek_params.out_data, &data)) return EFAULT; break; } |