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

Kernel: Stop allowing implicit conversion from KResult to int

This patch removes KResult::operator int() and deals with the fallout.
This forces a lot of code to be more explicit in its handling of errors,
greatly improving readability.
This commit is contained in:
Andreas Kling 2021-08-14 15:15:11 +02:00
parent d30d776ca4
commit 7676edfb9b
14 changed files with 51 additions and 52 deletions

View file

@ -137,7 +137,7 @@ KResult IPv4Socket::listen(size_t backlog)
{
MutexLocker locker(lock());
auto result = allocate_local_port_if_needed();
if (result.error_or_port.is_error() && result.error_or_port.error() != -ENOPROTOOPT)
if (result.error_or_port.is_error() && result.error_or_port.error() != ENOPROTOOPT)
return result.error_or_port.error();
set_backlog(backlog);
@ -231,7 +231,7 @@ KResultOr<size_t> IPv4Socket::sendto(FileDescription&, const UserOrKernelBuffer&
if (m_local_address.to_u32() == 0)
m_local_address = routing_decision.adapter->ipv4_address();
if (auto result = allocate_local_port_if_needed(); result.error_or_port.is_error() && result.error_or_port.error() != -ENOPROTOOPT)
if (auto result = allocate_local_port_if_needed(); result.error_or_port.is_error() && result.error_or_port.error() != ENOPROTOOPT)
return result.error_or_port.error();
dbgln_if(IPV4_SOCKET_DEBUG, "sendto: destination={}:{}", m_peer_address, m_peer_port);