1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 11:58:12 +00:00

Kernel: Use KResultOr<size_t> for the DoubleBuffer class

This commit is contained in:
Gunnar Beutner 2021-06-16 15:33:14 +02:00 committed by Andreas Kling
parent 1c3346e3ce
commit ca3cae81eb
4 changed files with 31 additions and 31 deletions

View file

@ -293,10 +293,10 @@ KResultOr<size_t> LocalSocket::sendto(FileDescription& description, const UserOr
auto* socket_buffer = send_buffer_for(description);
if (!socket_buffer)
return EINVAL;
ssize_t nwritten = socket_buffer->write(data, data_size);
if (nwritten > 0)
Thread::current()->did_unix_socket_write(nwritten);
return nwritten;
auto nwritten_or_error = socket_buffer->write(data, data_size);
if (!nwritten_or_error.is_error() && nwritten_or_error.value() > 0)
Thread::current()->did_unix_socket_write(nwritten_or_error.value());
return nwritten_or_error;
}
DoubleBuffer* LocalSocket::receive_buffer_for(FileDescription& description)
@ -338,10 +338,10 @@ KResultOr<size_t> LocalSocket::recvfrom(FileDescription& description, UserOrKern
if (!has_attached_peer(description) && socket_buffer->is_empty())
return 0;
VERIFY(!socket_buffer->is_empty());
auto nread = socket_buffer->read(buffer, buffer_size);
if (nread > 0)
Thread::current()->did_unix_socket_read(nread);
return nread;
auto nread_or_error = socket_buffer->read(buffer, buffer_size);
if (!nread_or_error.is_error() && nread_or_error.value() > 0)
Thread::current()->did_unix_socket_read(nread_or_error.value());
return nread_or_error;
}
StringView LocalSocket::socket_path() const