mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 17:27:35 +00:00
Kernel: Use KResultOr<size_t> throughout the TTY subsystem
Previously the VirtualConsole::on_tty_write() method would return an incorrect value when an error had occurred. This prompted me to update the TTY subsystem to use KResultOr<size_t> everywhere.
This commit is contained in:
parent
a49a15cabf
commit
1c3346e3ce
9 changed files with 29 additions and 29 deletions
|
@ -133,12 +133,13 @@ public:
|
|||
auto to_copy = min(sizeof(buffer), len - nread);
|
||||
if (!read(buffer, nread, to_copy))
|
||||
return EFAULT;
|
||||
ssize_t copied = f(buffer, to_copy);
|
||||
if (copied < 0)
|
||||
return copied;
|
||||
VERIFY((size_t)copied <= to_copy);
|
||||
nread += (size_t)copied;
|
||||
if ((size_t)copied < to_copy)
|
||||
KResultOr<size_t> copied_or_error = f(buffer, to_copy);
|
||||
if (copied_or_error.is_error())
|
||||
return copied_or_error.error();
|
||||
auto copied = copied_or_error.value();
|
||||
VERIFY(copied <= to_copy);
|
||||
nread += copied;
|
||||
if (copied < to_copy)
|
||||
break;
|
||||
}
|
||||
return nread;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue