mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 23:50:19 +00:00
Kernel: Use TRY() in sys$getrandom()
This commit is contained in:
parent
a8516681b7
commit
f2512071f2
Notes:
sideshowbarker
2024-07-18 04:38:16 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/f2512071f28
1 changed files with 3 additions and 6 deletions
|
@ -23,14 +23,11 @@ KResultOr<FlatPtr> Process::sys$getrandom(Userspace<void*> buffer, size_t buffer
|
|||
auto data_buffer = UserOrKernelBuffer::for_user_buffer(buffer, buffer_size);
|
||||
if (!data_buffer.has_value())
|
||||
return EFAULT;
|
||||
auto result = data_buffer.value().write_buffered<1024>(buffer_size, [&](Bytes bytes) {
|
||||
|
||||
return TRY(data_buffer.value().write_buffered<1024>(buffer_size, [&](Bytes bytes) {
|
||||
get_good_random_bytes(bytes);
|
||||
return bytes.size();
|
||||
});
|
||||
if (result.is_error())
|
||||
return result.error();
|
||||
else
|
||||
return result.release_value();
|
||||
}));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue