1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-14 07:44:59 +00:00

Kernel: Make KBuffer::try_create_with_size() return KResultOr

This allows us to use TRY() in a lot of new places.
This commit is contained in:
Andreas Kling 2021-09-07 15:15:08 +02:00
parent c69035c630
commit 899cee8185
10 changed files with 31 additions and 72 deletions

View file

@ -150,11 +150,8 @@ TCPSocket::~TCPSocket()
KResultOr<NonnullRefPtr<TCPSocket>> TCPSocket::try_create(int protocol, NonnullOwnPtr<DoubleBuffer> receive_buffer)
{
// Note: Scratch buffer is only used for SOCK_STREAM sockets.
auto scratch_buffer = KBuffer::try_create_with_size(65536);
if (!scratch_buffer)
return ENOMEM;
return adopt_nonnull_ref_or_enomem(new (nothrow) TCPSocket(protocol, move(receive_buffer), scratch_buffer.release_nonnull()));
auto scratch_buffer = TRY(KBuffer::try_create_with_size(65536));
return adopt_nonnull_ref_or_enomem(new (nothrow) TCPSocket(protocol, move(receive_buffer), move(scratch_buffer)));
}
KResultOr<size_t> TCPSocket::protocol_receive(ReadonlyBytes raw_ipv4_packet, UserOrKernelBuffer& buffer, size_t buffer_size, [[maybe_unused]] int flags)