Quellcode durchsuchen

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

Andreas Kling vor 3 Jahren
Ursprung
Commit
e3b063581e
1 geänderte Dateien mit 1 neuen und 3 gelöschten Zeilen
  1. 1 3
      Kernel/Syscalls/alarm.cpp

+ 1 - 3
Kernel/Syscalls/alarm.cpp

@@ -30,9 +30,7 @@ KResultOr<FlatPtr> Process::sys$alarm(unsigned seconds)
         auto deadline = TimeManagement::the().current_time(CLOCK_REALTIME_COARSE);
         auto deadline = TimeManagement::the().current_time(CLOCK_REALTIME_COARSE);
         deadline = deadline + Time::from_seconds(seconds);
         deadline = deadline + Time::from_seconds(seconds);
         if (!m_alarm_timer) {
         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]() {
         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);
             [[maybe_unused]] auto rc = send_signal(SIGALRM, nullptr);