mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 14:47:44 +00:00
Kernel: Make all syscall functions return KResultOr<T>
This makes it a lot easier to return errors since we no longer have to worry about negating EFOO errors and can just return them flat.
This commit is contained in:
parent
9af1e1a3bf
commit
ac71775de5
70 changed files with 747 additions and 742 deletions
|
@ -30,39 +30,39 @@
|
|||
|
||||
namespace Kernel {
|
||||
|
||||
int Process::sys$sendfd(int sockfd, int fd)
|
||||
KResultOr<int> Process::sys$sendfd(int sockfd, int fd)
|
||||
{
|
||||
REQUIRE_PROMISE(sendfd);
|
||||
auto socket_description = file_description(sockfd);
|
||||
if (!socket_description)
|
||||
return -EBADF;
|
||||
return EBADF;
|
||||
if (!socket_description->is_socket())
|
||||
return -ENOTSOCK;
|
||||
return ENOTSOCK;
|
||||
auto& socket = *socket_description->socket();
|
||||
if (!socket.is_local())
|
||||
return -EAFNOSUPPORT;
|
||||
return EAFNOSUPPORT;
|
||||
if (!socket.is_connected())
|
||||
return -ENOTCONN;
|
||||
return ENOTCONN;
|
||||
|
||||
auto passing_descriptor = file_description(fd);
|
||||
if (!passing_descriptor)
|
||||
return -EBADF;
|
||||
return EBADF;
|
||||
|
||||
auto& local_socket = static_cast<LocalSocket&>(socket);
|
||||
return local_socket.sendfd(*socket_description, *passing_descriptor);
|
||||
}
|
||||
|
||||
int Process::sys$recvfd(int sockfd, int options)
|
||||
KResultOr<int> Process::sys$recvfd(int sockfd, int options)
|
||||
{
|
||||
REQUIRE_PROMISE(recvfd);
|
||||
auto socket_description = file_description(sockfd);
|
||||
if (!socket_description)
|
||||
return -EBADF;
|
||||
return EBADF;
|
||||
if (!socket_description->is_socket())
|
||||
return -ENOTSOCK;
|
||||
return ENOTSOCK;
|
||||
auto& socket = *socket_description->socket();
|
||||
if (!socket.is_local())
|
||||
return -EAFNOSUPPORT;
|
||||
return EAFNOSUPPORT;
|
||||
|
||||
int new_fd = alloc_fd();
|
||||
if (new_fd < 0)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue