summaryrefslogtreecommitdiff
path: root/Kernel/Net
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-09-05 14:01:09 +0200
committerAndreas Kling <kling@serenityos.org>2021-09-05 14:08:12 +0200
commit81d3f823f7cbd1e1c97b0624323c6d376d94b7d8 (patch)
treef9e08f8b3d369cbbd252b4ed9f59cb9d4bd0510d /Kernel/Net
parenta5e71debef312817ea34e4df32c7d45096d9cef9 (diff)
downloadserenity-81d3f823f7cbd1e1c97b0624323c6d376d94b7d8.zip
Kernel: Use TRY() in LocalSocket
Diffstat (limited to 'Kernel/Net')
-rw-r--r--Kernel/Net/LocalSocket.cpp17
1 files changed, 4 insertions, 13 deletions
diff --git a/Kernel/Net/LocalSocket.cpp b/Kernel/Net/LocalSocket.cpp
index e8da313f0f..7421385262 100644
--- a/Kernel/Net/LocalSocket.cpp
+++ b/Kernel/Net/LocalSocket.cpp
@@ -50,15 +50,8 @@ KResultOr<NonnullRefPtr<LocalSocket>> LocalSocket::try_create(int type)
KResultOr<SocketPair> LocalSocket::try_create_connected_pair(int type)
{
- auto socket_or_error = LocalSocket::try_create(type);
- if (socket_or_error.is_error())
- return socket_or_error.error();
-
- auto socket = socket_or_error.release_value();
-
- auto description1_result = FileDescription::try_create(*socket);
- if (description1_result.is_error())
- return description1_result.error();
+ auto socket = TRY(LocalSocket::try_create(type));
+ auto description1 = TRY(FileDescription::try_create(*socket));
if (auto result = socket->try_set_path("[socketpair]"sv); result.is_error())
return result;
@@ -68,11 +61,9 @@ KResultOr<SocketPair> LocalSocket::try_create_connected_pair(int type)
socket->set_connect_side_role(Role::Connected);
socket->set_role(Role::Accepted);
- auto description2_result = FileDescription::try_create(*socket);
- if (description2_result.is_error())
- return description2_result.error();
+ auto description2 = TRY(FileDescription::try_create(*socket));
- return SocketPair { description1_result.release_value(), description2_result.release_value() };
+ return SocketPair { move(description1), move(description2) };
}
LocalSocket::LocalSocket(int type, NonnullOwnPtr<DoubleBuffer> client_buffer, NonnullOwnPtr<DoubleBuffer> server_buffer)