diff options
author | Andreas Kling <kling@serenityos.org> | 2021-09-07 14:55:44 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-09-07 14:55:44 +0200 |
commit | 3c44e381d46ffa7ecece92463d592212383411e3 (patch) | |
tree | 20ca55ed11b41f4ae76dd5669361a8ab74bf0056 /Kernel/Net/Socket.cpp | |
parent | cd5d483bbd48e37203c2871dab7bb76884465b08 (diff) | |
download | serenity-3c44e381d46ffa7ecece92463d592212383411e3.zip |
Kernel: Use TRY() some more in Socket
Diffstat (limited to 'Kernel/Net/Socket.cpp')
-rw-r--r-- | Kernel/Net/Socket.cpp | 14 |
1 files changed, 4 insertions, 10 deletions
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<NonnullRefPtr<Socket>> 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<const void*> user_va if (user_value_size != IFNAMSIZ) return EINVAL; auto user_string = static_ptr_cast<const char*>(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; |