From e3b063581edd0f3a6811fb8d052cdc02d1dcda9a Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Mon, 6 Sep 2021 12:02:59 +0200 Subject: Kernel: Use TRY() in sys$alarm() --- Kernel/Syscalls/alarm.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'Kernel') diff --git a/Kernel/Syscalls/alarm.cpp b/Kernel/Syscalls/alarm.cpp index d6847c1fbd..3ffb2d8f53 100644 --- a/Kernel/Syscalls/alarm.cpp +++ b/Kernel/Syscalls/alarm.cpp @@ -30,9 +30,7 @@ KResultOr Process::sys$alarm(unsigned seconds) auto deadline = TimeManagement::the().current_time(CLOCK_REALTIME_COARSE); deadline = deadline + Time::from_seconds(seconds); if (!m_alarm_timer) { - m_alarm_timer = adopt_ref_if_nonnull(new (nothrow) Timer()); - if (!m_alarm_timer) - return ENOMEM; + m_alarm_timer = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) Timer)); } auto timer_was_added = TimerQueue::the().add_timer_without_id(*m_alarm_timer, CLOCK_REALTIME_COARSE, deadline, [this]() { [[maybe_unused]] auto rc = send_signal(SIGALRM, nullptr); -- cgit v1.2.3