1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-20 13:55:08 +00:00

Kernel: Make copy_time_from_user() helpers use KResultOr<Time>

...and use TRY() for smooth error propagation everywhere.
This commit is contained in:
Andreas Kling 2021-09-06 22:22:14 +02:00
parent ef94c73a01
commit e6929835d2
6 changed files with 29 additions and 54 deletions

View file

@ -90,22 +90,12 @@ KResult Socket::setsockopt(int level, int option, Userspace<const void*> user_va
case SO_SNDTIMEO:
if (user_value_size != sizeof(timeval))
return EINVAL;
{
auto timeout = copy_time_from_user(static_ptr_cast<const timeval*>(user_value));
if (!timeout.has_value())
return EFAULT;
m_send_timeout = timeout.value();
}
m_send_timeout = TRY(copy_time_from_user(static_ptr_cast<timeval const*>(user_value)));
return KSuccess;
case SO_RCVTIMEO:
if (user_value_size != sizeof(timeval))
return EINVAL;
{
auto timeout = copy_time_from_user(static_ptr_cast<const timeval*>(user_value));
if (!timeout.has_value())
return EFAULT;
m_receive_timeout = timeout.value();
}
m_receive_timeout = TRY(copy_time_from_user(static_ptr_cast<timeval const*>(user_value)));
return KSuccess;
case SO_BINDTODEVICE: {
if (user_value_size != IFNAMSIZ)