mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 09:48:11 +00:00
AK: Make Vector::try_* functions return ErrorOr<void>
Instead of signalling allocation failure with a bool return value (false), we now use ErrorOr<void> and return ENOMEM as appropriate. This allows us to use TRY() and MUST() with Vector. :^)
This commit is contained in:
parent
cd49f30bea
commit
88b6428c25
16 changed files with 98 additions and 152 deletions
|
@ -168,8 +168,7 @@ ErrorOr<FlatPtr> Process::sys$sendmsg(int sockfd, Userspace<const struct msghdr*
|
|||
if (msg.msg_iovlen != 1)
|
||||
return ENOTSUP; // FIXME: Support this :)
|
||||
Vector<iovec, 1> iovs;
|
||||
if (!iovs.try_resize(msg.msg_iovlen))
|
||||
return ENOMEM;
|
||||
TRY(iovs.try_resize(msg.msg_iovlen));
|
||||
TRY(copy_n_from_user(iovs.data(), msg.msg_iov, msg.msg_iovlen));
|
||||
if (iovs[0].iov_len > NumericLimits<ssize_t>::max())
|
||||
return EINVAL;
|
||||
|
@ -201,8 +200,7 @@ ErrorOr<FlatPtr> Process::sys$recvmsg(int sockfd, Userspace<struct msghdr*> user
|
|||
if (msg.msg_iovlen != 1)
|
||||
return ENOTSUP; // FIXME: Support this :)
|
||||
Vector<iovec, 1> iovs;
|
||||
if (!iovs.try_resize(msg.msg_iovlen))
|
||||
return ENOMEM;
|
||||
TRY(iovs.try_resize(msg.msg_iovlen));
|
||||
TRY(copy_n_from_user(iovs.data(), msg.msg_iov, msg.msg_iovlen));
|
||||
|
||||
Userspace<sockaddr*> user_addr((FlatPtr)msg.msg_name);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue