BAN: Mark RefPtr and WeakPtr operator bool() as explicit

This commit is contained in:
Bananymous 2024-06-17 20:19:36 +03:00
parent dafd2fecf7
commit 511fc870a1
4 changed files with 13 additions and 5 deletions

View File

@ -128,7 +128,7 @@ namespace BAN
bool operator!=(RefPtr other) const { return m_pointer != other.m_pointer; }
bool empty() const { return m_pointer == nullptr; }
operator bool() const { return m_pointer; }
explicit operator bool() const { return m_pointer; }
void clear()
{

View File

@ -91,7 +91,7 @@ namespace BAN
bool valid() const { return m_link && m_link->valid(); }
operator bool() const { return valid(); }
explicit operator bool() const { return valid(); }
private:
WeakPtr(const RefPtr<WeakLink<T>>& link)

View File

@ -95,8 +95,7 @@ namespace Kernel
BAN::ErrorOr<int> OpenFileDescriptorSet::socket(int domain, int type, int protocol)
{
if (protocol != 0)
return BAN::Error::from_errno(EPROTONOSUPPORT);
bool valid_protocol = true;
SocketDomain sock_domain;
switch (domain)
@ -109,6 +108,7 @@ namespace Kernel
break;
case AF_UNIX:
sock_domain = SocketDomain::UNIX;
valid_protocol = false;
break;
default:
return BAN::Error::from_errno(EPROTOTYPE);
@ -119,17 +119,25 @@ namespace Kernel
{
case SOCK_STREAM:
sock_type = SocketType::STREAM;
if (protocol != IPPROTO_TCP)
valid_protocol = false;
break;
case SOCK_DGRAM:
sock_type = SocketType::DGRAM;
if (protocol != IPPROTO_UDP)
valid_protocol = false;
break;
case SOCK_SEQPACKET:
sock_type = SocketType::SEQPACKET;
valid_protocol = false;
break;
default:
return BAN::Error::from_errno(EPROTOTYPE);
}
if (protocol && !valid_protocol)
return BAN::Error::from_errno(EPROTONOSUPPORT);
auto socket = TRY(NetworkManager::get().create_socket(sock_domain, sock_type, 0777, m_credentials.euid(), m_credentials.egid()));
int fd = TRY(get_free_fd());

View File

@ -361,7 +361,7 @@ namespace Kernel
bool TTY::is_initialized()
{
return s_tty;
return !!s_tty;
}
}