mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-27 06:48:49 +00:00
Kernel: Make UserOrKernelBuffer::for_user_buffer() return ErrorOr<T>
This simplifies EFAULT propagation with TRY(). :^)
This commit is contained in:
parent
b820ae2828
commit
f2c3a41a8f
Notes:
sideshowbarker
2024-07-18 00:53:53 +09:00
Author: https://github.com/awesomekling
Commit: f2c3a41a8f
7 changed files with 27 additions and 47 deletions
|
@ -182,16 +182,14 @@ ErrorOr<void> Coredump::write_regions()
|
|||
auto* page = region->physical_page(i);
|
||||
|
||||
uint8_t zero_buffer[PAGE_SIZE] = {};
|
||||
Optional<UserOrKernelBuffer> src_buffer;
|
||||
|
||||
if (page) {
|
||||
src_buffer = UserOrKernelBuffer::for_user_buffer(reinterpret_cast<uint8_t*>((region->vaddr().as_ptr() + (i * PAGE_SIZE))), PAGE_SIZE);
|
||||
} else {
|
||||
auto src_buffer = [&]() -> ErrorOr<UserOrKernelBuffer> {
|
||||
if (page)
|
||||
return UserOrKernelBuffer::for_user_buffer(reinterpret_cast<uint8_t*>((region->vaddr().as_ptr() + (i * PAGE_SIZE))), PAGE_SIZE);
|
||||
// If the current page is not backed by a physical page, we zero it in the coredump file.
|
||||
// TODO: Do we want to include the contents of pages that have not been faulted-in in the coredump?
|
||||
// (A page may not be backed by a physical page because it has never been faulted in when the process ran).
|
||||
src_buffer = UserOrKernelBuffer::for_kernel_buffer(zero_buffer);
|
||||
}
|
||||
return UserOrKernelBuffer::for_kernel_buffer(zero_buffer);
|
||||
}();
|
||||
TRY(m_description->write(src_buffer.value(), PAGE_SIZE));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue