1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 13:48:12 +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:
Andreas Kling 2021-03-01 13:49:16 +01:00
parent 9af1e1a3bf
commit ac71775de5
70 changed files with 747 additions and 742 deletions

View file

@ -29,16 +29,16 @@
namespace Kernel {
int Process::sys$dup2(int old_fd, int new_fd)
KResultOr<int> Process::sys$dup2(int old_fd, int new_fd)
{
REQUIRE_PROMISE(stdio);
auto description = file_description(old_fd);
if (!description)
return -EBADF;
return EBADF;
if (old_fd == new_fd)
return 0;
if (new_fd < 0 || new_fd >= m_max_open_file_descriptors)
return -EINVAL;
return EINVAL;
m_fds[new_fd].set(*description);
return new_fd;
}