Kernel: Use TRY() in sys$alarm()

This commit is contained in:
Andreas Kling 2021-09-06 12:02:59 +02:00
parent b083b165a7
commit e3b063581e
Notes: sideshowbarker 2024-07-18 04:37:21 +09:00

View file

@ -30,9 +30,7 @@ KResultOr<FlatPtr> 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);