1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 16:18:12 +00:00

Kernel: Make Process::start_tracing_from API OOM safe

Modify the API so it's possible to propagate error on OOM failure.
NonnullOwnPtr<T> is not appropriate for the ThreadTracer::create() API,
so switch to OwnPtr<T>, use adopt_own_if_nonnull() to handle creation.
This commit is contained in:
Brian Gianforcaro 2021-05-12 21:44:07 -07:00 committed by Andreas Kling
parent dba261f79b
commit 956314f0a1
4 changed files with 12 additions and 6 deletions

View file

@ -6,8 +6,8 @@
#pragma once
#include <AK/NonnullOwnPtr.h>
#include <AK/Optional.h>
#include <AK/OwnPtr.h>
#include <Kernel/UnixTypes.h>
#include <LibC/sys/arch/i386/regs.h>
@ -15,7 +15,7 @@ namespace Kernel {
class ThreadTracer {
public:
static NonnullOwnPtr<ThreadTracer> create(ProcessID tracer) { return make<ThreadTracer>(tracer); }
static OwnPtr<ThreadTracer> create(ProcessID tracer) { return adopt_own_if_nonnull(new ThreadTracer(tracer)); }
ProcessID tracer_pid() const { return m_tracer_pid; }
bool has_pending_signal(u32 signal) const { return m_pending_signals & (1 << (signal - 1)); }