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

@ -31,15 +31,15 @@
namespace Kernel {
int Process::sys$anon_create(size_t size, int options)
KResultOr<int> Process::sys$anon_create(size_t size, int options)
{
REQUIRE_PROMISE(stdio);
if (!size)
return -EINVAL;
return EINVAL;
if (size % PAGE_SIZE)
return -EINVAL;
return EINVAL;
int new_fd = alloc_fd();
if (new_fd < 0)
@ -47,7 +47,7 @@ int Process::sys$anon_create(size_t size, int options)
auto vmobject = AnonymousVMObject::create_with_size(size, AllocationStrategy::Reserve);
if (!vmobject)
return -ENOMEM;
return ENOMEM;
auto anon_file = AnonymousFile::create(vmobject.release_nonnull());
auto description_or_error = FileDescription::create(*anon_file);