mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-28 19:59:17 +00:00
Kernel: Change Inode::{read/write}_bytes interface to KResultOr<ssize_t>
The error handling in all these cases was still using the old style negative values to indicate errors. We have a nicer solution for this now with KResultOr<T>. This change switches the interface and then all implementers to use the new style.
This commit is contained in:
parent
de9b454f89
commit
234c6ae32d
Notes:
sideshowbarker
2024-07-18 18:47:22 +09:00
Author: https://github.com/bgianfo
Commit: 234c6ae32d
Pull-request: https://github.com/SerenityOS/serenity/pull/6802
Reviewed-by: https://github.com/awesomekling
18 changed files with 88 additions and 82 deletions
|
@ -60,9 +60,10 @@ KResultOr<NonnullOwnPtr<KBuffer>> Inode::read_entire(FileDescription* descriptio
|
|||
off_t offset = 0;
|
||||
for (;;) {
|
||||
auto buf = UserOrKernelBuffer::for_kernel_buffer(buffer);
|
||||
nread = read_bytes(offset, sizeof(buffer), buf, description);
|
||||
if (nread < 0)
|
||||
return KResult((ErrnoCode)-nread);
|
||||
auto result = read_bytes(offset, sizeof(buffer), buf, description);
|
||||
if (result.is_error())
|
||||
return result.error();
|
||||
nread = result.value();
|
||||
VERIFY(nread <= (ssize_t)sizeof(buffer));
|
||||
if (nread <= 0)
|
||||
break;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue