BAN: Mark RefPtr and WeakPtr operator bool() as explicit
This commit is contained in:
parent
dafd2fecf7
commit
511fc870a1
|
@ -128,7 +128,7 @@ namespace BAN
|
||||||
bool operator!=(RefPtr other) const { return m_pointer != other.m_pointer; }
|
bool operator!=(RefPtr other) const { return m_pointer != other.m_pointer; }
|
||||||
|
|
||||||
bool empty() const { return m_pointer == nullptr; }
|
bool empty() const { return m_pointer == nullptr; }
|
||||||
operator bool() const { return m_pointer; }
|
explicit operator bool() const { return m_pointer; }
|
||||||
|
|
||||||
void clear()
|
void clear()
|
||||||
{
|
{
|
||||||
|
|
|
@ -91,7 +91,7 @@ namespace BAN
|
||||||
|
|
||||||
bool valid() const { return m_link && m_link->valid(); }
|
bool valid() const { return m_link && m_link->valid(); }
|
||||||
|
|
||||||
operator bool() const { return valid(); }
|
explicit operator bool() const { return valid(); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
WeakPtr(const RefPtr<WeakLink<T>>& link)
|
WeakPtr(const RefPtr<WeakLink<T>>& link)
|
||||||
|
|
|
@ -95,8 +95,7 @@ namespace Kernel
|
||||||
|
|
||||||
BAN::ErrorOr<int> OpenFileDescriptorSet::socket(int domain, int type, int protocol)
|
BAN::ErrorOr<int> OpenFileDescriptorSet::socket(int domain, int type, int protocol)
|
||||||
{
|
{
|
||||||
if (protocol != 0)
|
bool valid_protocol = true;
|
||||||
return BAN::Error::from_errno(EPROTONOSUPPORT);
|
|
||||||
|
|
||||||
SocketDomain sock_domain;
|
SocketDomain sock_domain;
|
||||||
switch (domain)
|
switch (domain)
|
||||||
|
@ -109,6 +108,7 @@ namespace Kernel
|
||||||
break;
|
break;
|
||||||
case AF_UNIX:
|
case AF_UNIX:
|
||||||
sock_domain = SocketDomain::UNIX;
|
sock_domain = SocketDomain::UNIX;
|
||||||
|
valid_protocol = false;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return BAN::Error::from_errno(EPROTOTYPE);
|
return BAN::Error::from_errno(EPROTOTYPE);
|
||||||
|
@ -119,17 +119,25 @@ namespace Kernel
|
||||||
{
|
{
|
||||||
case SOCK_STREAM:
|
case SOCK_STREAM:
|
||||||
sock_type = SocketType::STREAM;
|
sock_type = SocketType::STREAM;
|
||||||
|
if (protocol != IPPROTO_TCP)
|
||||||
|
valid_protocol = false;
|
||||||
break;
|
break;
|
||||||
case SOCK_DGRAM:
|
case SOCK_DGRAM:
|
||||||
sock_type = SocketType::DGRAM;
|
sock_type = SocketType::DGRAM;
|
||||||
|
if (protocol != IPPROTO_UDP)
|
||||||
|
valid_protocol = false;
|
||||||
break;
|
break;
|
||||||
case SOCK_SEQPACKET:
|
case SOCK_SEQPACKET:
|
||||||
sock_type = SocketType::SEQPACKET;
|
sock_type = SocketType::SEQPACKET;
|
||||||
|
valid_protocol = false;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return BAN::Error::from_errno(EPROTOTYPE);
|
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()));
|
auto socket = TRY(NetworkManager::get().create_socket(sock_domain, sock_type, 0777, m_credentials.euid(), m_credentials.egid()));
|
||||||
|
|
||||||
int fd = TRY(get_free_fd());
|
int fd = TRY(get_free_fd());
|
||||||
|
|
|
@ -361,7 +361,7 @@ namespace Kernel
|
||||||
|
|
||||||
bool TTY::is_initialized()
|
bool TTY::is_initialized()
|
||||||
{
|
{
|
||||||
return s_tty;
|
return !!s_tty;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue