From 3c44e381d46ffa7ecece92463d592212383411e3 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Tue, 7 Sep 2021 14:55:44 +0200 Subject: Kernel: Use TRY() some more in Socket --- Kernel/Net/Socket.cpp | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'Kernel/Net/Socket.cpp') diff --git a/Kernel/Net/Socket.cpp b/Kernel/Net/Socket.cpp index 89124d7ebb..89f7300713 100644 --- a/Kernel/Net/Socket.cpp +++ b/Kernel/Net/Socket.cpp @@ -20,12 +20,8 @@ namespace Kernel { KResultOr> Socket::create(int domain, int type, int protocol) { switch (domain) { - case AF_LOCAL: { - auto socket_or_error = LocalSocket::try_create(type & SOCK_TYPE_MASK); - if (socket_or_error.is_error()) - return socket_or_error.error(); - return socket_or_error.release_value(); - } + case AF_LOCAL: + return TRY(LocalSocket::try_create(type & SOCK_TYPE_MASK)); case AF_INET: return IPv4Socket::create(type & SOCK_TYPE_MASK, protocol); default: @@ -101,10 +97,8 @@ KResult Socket::setsockopt(int level, int option, Userspace user_va if (user_value_size != IFNAMSIZ) return EINVAL; auto user_string = static_ptr_cast(user_value); - auto ifname_or_error = try_copy_kstring_from_user(user_string, user_value_size); - if (ifname_or_error.is_error()) - return ifname_or_error.error(); - auto device = NetworkingManagement::the().lookup_by_name(ifname_or_error.value()->view()); + auto ifname = TRY(try_copy_kstring_from_user(user_string, user_value_size)); + auto device = NetworkingManagement::the().lookup_by_name(ifname->view()); if (!device) return ENODEV; m_bound_interface = device; -- cgit v1.2.3