mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 13:37:45 +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
18 changed files with 88 additions and 82 deletions
|
@ -540,13 +540,14 @@ PageFaultResponse Region::handle_inode_fault(size_t page_index_in_region, Scoped
|
|||
// Reading the page may block, so release the MM lock temporarily
|
||||
mm_lock.unlock();
|
||||
auto buffer = UserOrKernelBuffer::for_kernel_buffer(page_buffer);
|
||||
auto nread = inode.read_bytes(page_index_in_vmobject * PAGE_SIZE, PAGE_SIZE, buffer, nullptr);
|
||||
auto result = inode.read_bytes(page_index_in_vmobject * PAGE_SIZE, PAGE_SIZE, buffer, nullptr);
|
||||
mm_lock.lock();
|
||||
|
||||
if (nread < 0) {
|
||||
dmesgln("MM: handle_inode_fault had error ({}) while reading!", nread);
|
||||
if (result.is_error()) {
|
||||
dmesgln("MM: handle_inode_fault had error ({}) while reading!", result.error());
|
||||
return PageFaultResponse::ShouldCrash;
|
||||
}
|
||||
auto nread = result.value();
|
||||
if (nread < PAGE_SIZE) {
|
||||
// If we read less than a page, zero out the rest to avoid leaking uninitialized data.
|
||||
memset(page_buffer + nread, 0, PAGE_SIZE - nread);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue