mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 14:38:11 +00:00
Kernel: Modify TimeManagement::current_time(..) API so it can't fail. (#6869)
The fact that current_time can "fail" makes its use a bit awkward. All callers in the Kernel are trusted besides syscalls, so assert that they never get there, and make sure all current callers perform validation of the clock_id with TimeManagement::is_valid_clock_id(). I have fuzzed this change locally for a bit to make sure I didn't miss any obvious regression.
This commit is contained in:
parent
64b4e3f34b
commit
11306d7121
6 changed files with 14 additions and 13 deletions
|
@ -44,7 +44,7 @@ Time Timer::now(bool is_firing) const
|
|||
break;
|
||||
}
|
||||
}
|
||||
return TimeManagement::the().current_time(clock_id).value();
|
||||
return TimeManagement::the().current_time(clock_id);
|
||||
}
|
||||
|
||||
TimerQueue& TimerQueue::the()
|
||||
|
@ -59,7 +59,7 @@ UNMAP_AFTER_INIT TimerQueue::TimerQueue()
|
|||
|
||||
RefPtr<Timer> TimerQueue::add_timer_without_id(clockid_t clock_id, const Time& deadline, Function<void()>&& callback)
|
||||
{
|
||||
if (deadline <= TimeManagement::the().current_time(clock_id).value())
|
||||
if (deadline <= TimeManagement::the().current_time(clock_id))
|
||||
return {};
|
||||
|
||||
// Because timer handlers can execute on any processor and there is
|
||||
|
@ -117,7 +117,7 @@ void TimerQueue::add_timer_locked(NonnullRefPtr<Timer> timer)
|
|||
|
||||
TimerId TimerQueue::add_timer(clockid_t clock_id, const Time& deadline, Function<void()>&& callback)
|
||||
{
|
||||
auto expires = TimeManagement::the().current_time(clock_id).value();
|
||||
auto expires = TimeManagement::the().current_time(clock_id);
|
||||
expires = expires + deadline;
|
||||
return add_timer(adopt_ref(*new Timer(clock_id, expires, move(callback))));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue