1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 17:58:12 +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

@ -27,8 +27,7 @@ ErrorOr<FlatPtr> Process::sys$clock_gettime(clockid_t clock_id, Userspace<timesp
VERIFY_NO_PROCESS_BIG_LOCK(this);
TRY(require_promise(Pledge::stdio));
if (!TimeManagement::is_valid_clock_id(clock_id))
return EINVAL;
TRY(TimeManagement::validate_clock_id(clock_id));
auto ts = TimeManagement::the().current_time(clock_id).to_timespec();
TRY(copy_to_user(user_ts, &ts));
@ -75,8 +74,7 @@ ErrorOr<FlatPtr> Process::sys$clock_nanosleep(Userspace<const Syscall::SC_clock_
return EINVAL;
}
if (!TimeManagement::is_valid_clock_id(params.clock_id))
return EINVAL;
TRY(TimeManagement::validate_clock_id(params.clock_id));
bool was_interrupted;
if (is_absolute) {