mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 08:08:12 +00:00
Kernel: Make UserOrKernelBuffer R/W helpers return KResultOr<size_t>
This makes error propagation less cumbersome (and also exposed some places where we were not doing it.)
This commit is contained in:
parent
25a45e639a
commit
e46343bf9a
15 changed files with 64 additions and 85 deletions
|
@ -23,7 +23,7 @@ KResultOr<int> Process::sys$dbgputch(u8 ch)
|
|||
return 0;
|
||||
}
|
||||
|
||||
KResultOr<int> Process::sys$dbgputstr(Userspace<const u8*> characters, int length)
|
||||
KResultOr<size_t> Process::sys$dbgputstr(Userspace<const u8*> characters, int length)
|
||||
{
|
||||
if (length <= 0)
|
||||
return 0;
|
||||
|
@ -31,14 +31,11 @@ KResultOr<int> Process::sys$dbgputstr(Userspace<const u8*> characters, int lengt
|
|||
auto buffer = UserOrKernelBuffer::for_user_buffer(characters, length);
|
||||
if (!buffer.has_value())
|
||||
return EFAULT;
|
||||
ssize_t nread = buffer.value().read_buffered<1024>(length, [&](const u8* buffer, size_t buffer_size) {
|
||||
return buffer.value().read_buffered<1024>(length, [&](u8 const* buffer, size_t buffer_size) {
|
||||
for (size_t i = 0; i < buffer_size; ++i)
|
||||
IO::out8(0xe9, buffer[i]);
|
||||
return (ssize_t)buffer_size;
|
||||
return buffer_size;
|
||||
});
|
||||
if (nread < 0)
|
||||
return (int)nread;
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue