mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 20:27:45 +00:00
Kernel: Replace KResult and KResultOr<T> with Error and ErrorOr<T>
We now use AK::Error and AK::ErrorOr<T> in both kernel and userspace! This was a slightly tedious refactoring that took a long time, so it's not unlikely that some bugs crept in. Nevertheless, it does pass basic functionality testing, and it's just real nice to finally see the same pattern in all contexts. :^)
This commit is contained in:
parent
7ee10c6926
commit
79fa9765ca
262 changed files with 2415 additions and 2600 deletions
|
@ -11,7 +11,7 @@
|
|||
|
||||
namespace Kernel {
|
||||
|
||||
KResultOr<FlatPtr> Process::sys$writev(int fd, Userspace<const struct iovec*> iov, int iov_count)
|
||||
ErrorOr<FlatPtr> Process::sys$writev(int fd, Userspace<const struct iovec*> iov, int iov_count)
|
||||
{
|
||||
VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this)
|
||||
REQUIRE_PROMISE(stdio);
|
||||
|
@ -45,7 +45,7 @@ KResultOr<FlatPtr> Process::sys$writev(int fd, Userspace<const struct iovec*> io
|
|||
auto result = do_write(*description, buffer.value(), vec.iov_len);
|
||||
if (result.is_error()) {
|
||||
if (nwritten == 0)
|
||||
return result.error();
|
||||
return result.release_error();
|
||||
return nwritten;
|
||||
}
|
||||
nwritten += result.value();
|
||||
|
@ -54,7 +54,7 @@ KResultOr<FlatPtr> Process::sys$writev(int fd, Userspace<const struct iovec*> io
|
|||
return nwritten;
|
||||
}
|
||||
|
||||
KResultOr<FlatPtr> Process::do_write(OpenFileDescription& description, const UserOrKernelBuffer& data, size_t data_size)
|
||||
ErrorOr<FlatPtr> Process::do_write(OpenFileDescription& description, const UserOrKernelBuffer& data, size_t data_size)
|
||||
{
|
||||
size_t total_nwritten = 0;
|
||||
|
||||
|
@ -81,9 +81,9 @@ KResultOr<FlatPtr> Process::do_write(OpenFileDescription& description, const Use
|
|||
if (nwritten_or_error.is_error()) {
|
||||
if (total_nwritten > 0)
|
||||
return total_nwritten;
|
||||
if (nwritten_or_error.error() == EAGAIN)
|
||||
if (nwritten_or_error.error().code() == EAGAIN)
|
||||
continue;
|
||||
return nwritten_or_error.error();
|
||||
return nwritten_or_error.release_error();
|
||||
}
|
||||
VERIFY(nwritten_or_error.value() > 0);
|
||||
total_nwritten += nwritten_or_error.value();
|
||||
|
@ -91,7 +91,7 @@ KResultOr<FlatPtr> Process::do_write(OpenFileDescription& description, const Use
|
|||
return total_nwritten;
|
||||
}
|
||||
|
||||
KResultOr<FlatPtr> Process::sys$write(int fd, Userspace<const u8*> data, size_t size)
|
||||
ErrorOr<FlatPtr> Process::sys$write(int fd, Userspace<const u8*> data, size_t size)
|
||||
{
|
||||
VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this)
|
||||
REQUIRE_PROMISE(stdio);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue