1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-02 23:12:08 +00:00

Kernel: Use TRY() when validating clock_id in TimeManagement

Gets rid of a bit of code duplication, and makes the API more consistent
with the style we are moving towards.
This commit is contained in:
Brian Gianforcaro 2022-02-21 13:53:43 -08:00 committed by Brian Gianforcaro
parent e167cafa70
commit d05fa14e52
3 changed files with 6 additions and 8 deletions

View file

@ -37,7 +37,7 @@ TimeManagement& TimeManagement::the()
return *s_the;
}
bool TimeManagement::is_valid_clock_id(clockid_t clock_id)
ErrorOr<void> TimeManagement::validate_clock_id(clockid_t clock_id)
{
switch (clock_id) {
case CLOCK_MONOTONIC:
@ -45,9 +45,9 @@ bool TimeManagement::is_valid_clock_id(clockid_t clock_id)
case CLOCK_MONOTONIC_RAW:
case CLOCK_REALTIME:
case CLOCK_REALTIME_COARSE:
return true;
return {};
default:
return false;
return EINVAL;
};
}