1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-18 21:35:06 +00:00

Kernel: Make UserOrKernelBuffer return KResult from read/write/memset

This allows us to simplify a whole bunch of call sites with TRY(). :^)
This commit is contained in:
Andreas Kling 2021-09-07 12:09:52 +02:00
parent 7bf8844499
commit b481132418
29 changed files with 85 additions and 118 deletions

View file

@ -489,8 +489,7 @@ KResultOr<size_t> ProcFSProcessPropertyInode::read_bytes(off_t offset, size_t co
if (!data_buffer)
return KResult(EFAULT);
ssize_t nread = min(static_cast<off_t>(data_buffer->size() - offset), static_cast<off_t>(count));
if (!buffer.write(data_buffer->data() + offset, nread))
return KResult(EFAULT);
TRY(buffer.write(data_buffer->data() + offset, nread));
return nread;
}
if (!description->data()) {
@ -507,8 +506,7 @@ KResultOr<size_t> ProcFSProcessPropertyInode::read_bytes(off_t offset, size_t co
return 0;
ssize_t nread = min(static_cast<off_t>(data_buffer->size() - offset), static_cast<off_t>(count));
if (!buffer.write(data_buffer->data() + offset, nread))
return KResult(EFAULT);
TRY(buffer.write(data_buffer->data() + offset, nread));
return nread;
}