summaryrefslogtreecommitdiff
path: root/Kernel/Time/TimeManagement.cpp
diff options
context:
space:
mode:
authorBrian Gianforcaro <bgianf@serenityos.org>2021-05-05 16:51:06 +0000
committerGitHub <noreply@github.com>2021-05-05 18:51:06 +0200
commit11306d7121f414695c46ef9d6a46125c2cc5db9b (patch)
tree00990bbbf5e6ac0453a0493d43e0a6a44cfdf042 /Kernel/Time/TimeManagement.cpp
parent64b4e3f34b16c6aee35fd399874a3dc1dbeecb87 (diff)
downloadserenity-11306d7121f414695c46ef9d6a46125c2cc5db9b.zip
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.
Diffstat (limited to 'Kernel/Time/TimeManagement.cpp')
-rw-r--r--Kernel/Time/TimeManagement.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/Kernel/Time/TimeManagement.cpp b/Kernel/Time/TimeManagement.cpp
index 3305eeb636..153b02bf21 100644
--- a/Kernel/Time/TimeManagement.cpp
+++ b/Kernel/Time/TimeManagement.cpp
@@ -44,7 +44,7 @@ bool TimeManagement::is_valid_clock_id(clockid_t clock_id)
};
}
-KResultOr<Time> TimeManagement::current_time(clockid_t clock_id) const
+Time TimeManagement::current_time(clockid_t clock_id) const
{
switch (clock_id) {
case CLOCK_MONOTONIC:
@@ -58,7 +58,8 @@ KResultOr<Time> TimeManagement::current_time(clockid_t clock_id) const
case CLOCK_REALTIME_COARSE:
return epoch_time(TimePrecision::Coarse);
default:
- return KResult(EINVAL);
+ // Syscall entrypoint is missing a is_valid_clock_id(..) check?
+ VERIFY_NOT_REACHED();
}
}