mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 22:57:44 +00:00
Everywhere: Rename ASSERT => VERIFY
(...and ASSERT_NOT_REACHED => VERIFY_NOT_REACHED) Since all of these checks are done in release builds as well, let's rename them to VERIFY to prevent confusion, as everyone is used to assertions being compiled out in release. We can introduce a new ASSERT macro that is specifically for debug checks, but I'm doing this wholesale conversion first since we've accumulated thousands of these already, and it's not immediately obvious which ones are suitable for ASSERT.
This commit is contained in:
parent
b33a6a443e
commit
5d180d1f99
725 changed files with 3448 additions and 3448 deletions
|
@ -308,7 +308,7 @@ UNMAP_AFTER_INIT void E1000NetworkAdapter::read_mac_address()
|
|||
mac[5] = tmp >> 8;
|
||||
set_mac_address(mac);
|
||||
} else {
|
||||
ASSERT_NOT_REACHED();
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -323,7 +323,7 @@ UNMAP_AFTER_INIT void E1000NetworkAdapter::initialize_rx_descriptors()
|
|||
for (size_t i = 0; i < number_of_rx_descriptors; ++i) {
|
||||
auto& descriptor = rx_descriptors[i];
|
||||
auto region = MM.allocate_contiguous_kernel_region(8192, "E1000 RX buffer", Region::Access::Read | Region::Access::Write);
|
||||
ASSERT(region);
|
||||
VERIFY(region);
|
||||
m_rx_buffers_regions.append(region.release_nonnull());
|
||||
descriptor.addr = m_rx_buffers_regions[i].physical_page(0)->paddr().get();
|
||||
descriptor.status = 0;
|
||||
|
@ -344,7 +344,7 @@ UNMAP_AFTER_INIT void E1000NetworkAdapter::initialize_tx_descriptors()
|
|||
for (size_t i = 0; i < number_of_tx_descriptors; ++i) {
|
||||
auto& descriptor = tx_descriptors[i];
|
||||
auto region = MM.allocate_contiguous_kernel_region(8192, "E1000 TX buffer", Region::Access::Read | Region::Access::Write);
|
||||
ASSERT(region);
|
||||
VERIFY(region);
|
||||
m_tx_buffers_regions.append(region.release_nonnull());
|
||||
descriptor.addr = m_tx_buffers_regions[i].physical_page(0)->paddr().get();
|
||||
descriptor.cmd = 0;
|
||||
|
@ -426,7 +426,7 @@ void E1000NetworkAdapter::send_raw(ReadonlyBytes payload)
|
|||
#endif
|
||||
auto* tx_descriptors = (e1000_tx_desc*)m_tx_descriptors_region->vaddr().as_ptr();
|
||||
auto& descriptor = tx_descriptors[tx_current];
|
||||
ASSERT(payload.size() <= 8192);
|
||||
VERIFY(payload.size() <= 8192);
|
||||
auto* vptr = (void*)m_tx_buffers_regions[tx_current].vaddr().as_ptr();
|
||||
memcpy(vptr, payload.data(), payload.size());
|
||||
descriptor.length = payload.size();
|
||||
|
@ -464,7 +464,7 @@ void E1000NetworkAdapter::receive()
|
|||
break;
|
||||
auto* buffer = m_rx_buffers_regions[rx_current].vaddr().as_ptr();
|
||||
u16 length = rx_descriptors[rx_current].length;
|
||||
ASSERT(length <= 8192);
|
||||
VERIFY(length <= 8192);
|
||||
#if E1000_DEBUG
|
||||
klog() << "E1000: Received 1 packet @ " << buffer << " (" << length << ") bytes!";
|
||||
#endif
|
||||
|
|
|
@ -105,7 +105,7 @@ public:
|
|||
|
||||
NetworkOrdered<u16> compute_checksum() const
|
||||
{
|
||||
ASSERT(!m_checksum);
|
||||
VERIFY(!m_checksum);
|
||||
return internet_checksum(this, sizeof(IPv4Packet));
|
||||
}
|
||||
|
||||
|
|
|
@ -97,7 +97,7 @@ void IPv4Socket::get_peer_address(sockaddr* address, socklen_t* address_size)
|
|||
|
||||
KResult IPv4Socket::bind(Userspace<const sockaddr*> user_address, socklen_t address_size)
|
||||
{
|
||||
ASSERT(setup_state() == SetupState::Unstarted);
|
||||
VERIFY(setup_state() == SetupState::Unstarted);
|
||||
if (address_size != sizeof(sockaddr_in))
|
||||
return EINVAL;
|
||||
|
||||
|
@ -260,7 +260,7 @@ KResultOr<size_t> IPv4Socket::receive_byte_buffered(FileDescription& description
|
|||
}
|
||||
}
|
||||
|
||||
ASSERT(!m_receive_buffer.is_empty());
|
||||
VERIFY(!m_receive_buffer.is_empty());
|
||||
int nreceived = m_receive_buffer.read(buffer, buffer_length);
|
||||
if (nreceived > 0)
|
||||
Thread::current()->did_ipv4_socket_read((size_t)nreceived);
|
||||
|
@ -311,8 +311,8 @@ KResultOr<size_t> IPv4Socket::receive_packet_buffered(FileDescription& descripti
|
|||
// Unblocked due to timeout.
|
||||
return EAGAIN;
|
||||
}
|
||||
ASSERT(m_can_read);
|
||||
ASSERT(!m_receive_queue.is_empty());
|
||||
VERIFY(m_can_read);
|
||||
VERIFY(!m_receive_queue.is_empty());
|
||||
packet = m_receive_queue.take_first();
|
||||
set_can_read(!m_receive_queue.is_empty());
|
||||
|
||||
|
@ -321,7 +321,7 @@ KResultOr<size_t> IPv4Socket::receive_packet_buffered(FileDescription& descripti
|
|||
packet.data.value().size(),
|
||||
m_receive_queue.size());
|
||||
}
|
||||
ASSERT(packet.data.has_value());
|
||||
VERIFY(packet.data.has_value());
|
||||
|
||||
packet_timestamp = packet.timestamp;
|
||||
|
||||
|
@ -337,7 +337,7 @@ KResultOr<size_t> IPv4Socket::receive_packet_buffered(FileDescription& descripti
|
|||
return EFAULT;
|
||||
|
||||
socklen_t out_length = sizeof(sockaddr_in);
|
||||
ASSERT(addr_length);
|
||||
VERIFY(addr_length);
|
||||
if (!copy_to_user(addr_length, &out_length))
|
||||
return EFAULT;
|
||||
}
|
||||
|
@ -390,7 +390,7 @@ bool IPv4Socket::did_receive(const IPv4Address& source_address, u16 source_port,
|
|||
size_t space_in_receive_buffer = m_receive_buffer.space_for_writing();
|
||||
if (packet_size > space_in_receive_buffer) {
|
||||
dbgln("IPv4Socket({}): did_receive refusing packet since buffer is full.", this);
|
||||
ASSERT(m_can_read);
|
||||
VERIFY(m_can_read);
|
||||
return false;
|
||||
}
|
||||
auto scratch_buffer = UserOrKernelBuffer::for_kernel_buffer(m_scratch_buffer.value().data());
|
||||
|
@ -451,7 +451,7 @@ String IPv4Socket::absolute_path(const FileDescription&) const
|
|||
builder.append(" (connecting)");
|
||||
break;
|
||||
default:
|
||||
ASSERT_NOT_REACHED();
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
return builder.to_string();
|
||||
|
|
|
@ -97,7 +97,7 @@ void LocalSocket::get_peer_address(sockaddr* address, socklen_t* address_size)
|
|||
|
||||
KResult LocalSocket::bind(Userspace<const sockaddr*> user_address, socklen_t address_size)
|
||||
{
|
||||
ASSERT(setup_state() == SetupState::Unstarted);
|
||||
VERIFY(setup_state() == SetupState::Unstarted);
|
||||
if (address_size != sizeof(sockaddr_un))
|
||||
return EINVAL;
|
||||
|
||||
|
@ -123,7 +123,7 @@ KResult LocalSocket::bind(Userspace<const sockaddr*> user_address, socklen_t add
|
|||
|
||||
auto file = move(result.value());
|
||||
|
||||
ASSERT(file->inode());
|
||||
VERIFY(file->inode());
|
||||
if (!file->inode()->bind_socket(*this))
|
||||
return EADDRINUSE;
|
||||
|
||||
|
@ -136,7 +136,7 @@ KResult LocalSocket::bind(Userspace<const sockaddr*> user_address, socklen_t add
|
|||
|
||||
KResult LocalSocket::connect(FileDescription& description, Userspace<const sockaddr*> address, socklen_t address_size, ShouldBlock)
|
||||
{
|
||||
ASSERT(!m_bound);
|
||||
VERIFY(!m_bound);
|
||||
if (address_size != sizeof(sockaddr_un))
|
||||
return EINVAL;
|
||||
u16 sa_family_copy;
|
||||
|
@ -162,14 +162,14 @@ KResult LocalSocket::connect(FileDescription& description, Userspace<const socka
|
|||
|
||||
m_file = move(description_or_error.value());
|
||||
|
||||
ASSERT(m_file->inode());
|
||||
VERIFY(m_file->inode());
|
||||
if (!m_file->inode()->socket())
|
||||
return ECONNREFUSED;
|
||||
|
||||
m_address.sun_family = sa_family_copy;
|
||||
memcpy(m_address.sun_path, safe_address, sizeof(m_address.sun_path));
|
||||
|
||||
ASSERT(m_connect_side_fd == &description);
|
||||
VERIFY(m_connect_side_fd == &description);
|
||||
set_connect_side_role(Role::Connecting);
|
||||
|
||||
auto peer = m_file->inode()->socket();
|
||||
|
@ -217,12 +217,12 @@ KResult LocalSocket::listen(size_t backlog)
|
|||
|
||||
KResult LocalSocket::attach(FileDescription& description)
|
||||
{
|
||||
ASSERT(!m_accept_side_fd_open);
|
||||
VERIFY(!m_accept_side_fd_open);
|
||||
if (m_connect_side_role == Role::None) {
|
||||
ASSERT(m_connect_side_fd == nullptr);
|
||||
VERIFY(m_connect_side_fd == nullptr);
|
||||
m_connect_side_fd = &description;
|
||||
} else {
|
||||
ASSERT(m_connect_side_fd != &description);
|
||||
VERIFY(m_connect_side_fd != &description);
|
||||
m_accept_side_fd_open = true;
|
||||
}
|
||||
|
||||
|
@ -235,7 +235,7 @@ void LocalSocket::detach(FileDescription& description)
|
|||
if (m_connect_side_fd == &description) {
|
||||
m_connect_side_fd = nullptr;
|
||||
} else {
|
||||
ASSERT(m_accept_side_fd_open);
|
||||
VERIFY(m_accept_side_fd_open);
|
||||
m_accept_side_fd_open = false;
|
||||
}
|
||||
|
||||
|
@ -261,7 +261,7 @@ bool LocalSocket::has_attached_peer(const FileDescription& description) const
|
|||
return m_connect_side_fd != nullptr;
|
||||
if (role == Role::Connected)
|
||||
return m_accept_side_fd_open;
|
||||
ASSERT_NOT_REACHED();
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
bool LocalSocket::can_write(const FileDescription& description, size_t) const
|
||||
|
@ -325,7 +325,7 @@ KResultOr<size_t> LocalSocket::recvfrom(FileDescription& description, UserOrKern
|
|||
}
|
||||
if (!has_attached_peer(description) && socket_buffer->is_empty())
|
||||
return 0;
|
||||
ASSERT(!socket_buffer->is_empty());
|
||||
VERIFY(!socket_buffer->is_empty());
|
||||
auto nread = socket_buffer->read(buffer, buffer_size);
|
||||
if (nread > 0)
|
||||
Thread::current()->did_unix_socket_read(nread);
|
||||
|
@ -438,7 +438,7 @@ NonnullRefPtrVector<FileDescription>& LocalSocket::recvfd_queue_for(const FileDe
|
|||
return m_fds_for_client;
|
||||
if (role == Role::Accepted)
|
||||
return m_fds_for_server;
|
||||
ASSERT_NOT_REACHED();
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
NonnullRefPtrVector<FileDescription>& LocalSocket::sendfd_queue_for(const FileDescription& description)
|
||||
|
@ -448,7 +448,7 @@ NonnullRefPtrVector<FileDescription>& LocalSocket::sendfd_queue_for(const FileDe
|
|||
return m_fds_for_server;
|
||||
if (role == Role::Accepted)
|
||||
return m_fds_for_client;
|
||||
ASSERT_NOT_REACHED();
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
KResult LocalSocket::sendfd(const FileDescription& socket_description, FileDescription& passing_description)
|
||||
|
|
|
@ -208,7 +208,7 @@ size_t NetworkAdapter::dequeue_packet(u8* buffer, size_t buffer_size, timeval& p
|
|||
packet_timestamp = packet_with_timestamp.timestamp;
|
||||
auto packet = move(packet_with_timestamp.packet);
|
||||
size_t packet_size = packet.size();
|
||||
ASSERT(packet_size <= buffer_size);
|
||||
VERIFY(packet_size <= buffer_size);
|
||||
memcpy(buffer, packet.data(), packet_size);
|
||||
if (m_unused_packet_buffers_count < 100) {
|
||||
m_unused_packet_buffers.append(packet);
|
||||
|
|
|
@ -314,8 +314,8 @@ void handle_udp(const IPv4Packet& ipv4_packet, const timeval& packet_timestamp)
|
|||
return;
|
||||
}
|
||||
|
||||
ASSERT(socket->type() == SOCK_DGRAM);
|
||||
ASSERT(socket->local_port() == udp_packet.destination_port());
|
||||
VERIFY(socket->type() == SOCK_DGRAM);
|
||||
VERIFY(socket->local_port() == udp_packet.destination_port());
|
||||
socket->did_receive(ipv4_packet.source(), udp_packet.source_port(), KBuffer::copy(&ipv4_packet, sizeof(IPv4Packet) + ipv4_packet.payload_size()), packet_timestamp);
|
||||
}
|
||||
|
||||
|
@ -391,8 +391,8 @@ void handle_tcp(const IPv4Packet& ipv4_packet, const timeval& packet_timestamp)
|
|||
|
||||
LOCKER(socket->lock());
|
||||
|
||||
ASSERT(socket->type() == SOCK_STREAM);
|
||||
ASSERT(socket->local_port() == tcp_packet.destination_port());
|
||||
VERIFY(socket->type() == SOCK_STREAM);
|
||||
VERIFY(socket->local_port() == tcp_packet.destination_port());
|
||||
|
||||
#if TCP_DEBUG
|
||||
klog() << "handle_tcp: got socket; state=" << socket->tuple().to_string().characters() << " " << TCPSocket::to_string(socket->state());
|
||||
|
|
|
@ -77,7 +77,7 @@ public:
|
|||
void unblock(const IPv4Address& ip_addr, const MACAddress& addr)
|
||||
{
|
||||
BlockCondition::unblock([&](auto& b, void*, bool&) {
|
||||
ASSERT(b.blocker_type() == Thread::Blocker::Type::Routing);
|
||||
VERIFY(b.blocker_type() == Thread::Blocker::Type::Routing);
|
||||
auto& blocker = static_cast<ARPTableBlocker&>(b);
|
||||
return blocker.unblock(false, ip_addr, addr);
|
||||
});
|
||||
|
@ -86,7 +86,7 @@ public:
|
|||
protected:
|
||||
virtual bool should_add_blocker(Thread::Blocker& b, void*) override
|
||||
{
|
||||
ASSERT(b.blocker_type() == Thread::Blocker::Type::Routing);
|
||||
VERIFY(b.blocker_type() == Thread::Blocker::Type::Routing);
|
||||
auto& blocker = static_cast<ARPTableBlocker&>(b);
|
||||
auto val = s_arp_table->resource().get(blocker.ip_addr());
|
||||
if (!val.has_value())
|
||||
|
@ -107,7 +107,7 @@ ARPTableBlocker::ARPTableBlocker(IPv4Address ip_addr, Optional<MACAddress>& addr
|
|||
|
||||
void ARPTableBlocker::not_blocking(bool timeout_in_past)
|
||||
{
|
||||
ASSERT(timeout_in_past || !m_should_block);
|
||||
VERIFY(timeout_in_past || !m_should_block);
|
||||
auto addr = s_arp_table->resource().get(ip_addr());
|
||||
|
||||
ScopedSpinLock lock(m_lock);
|
||||
|
|
|
@ -76,7 +76,7 @@ RefPtr<Socket> Socket::accept()
|
|||
return nullptr;
|
||||
dbgln_if(SOCKET_DEBUG, "Socket({}) de-queueing connection", this);
|
||||
auto client = m_pending.take_first();
|
||||
ASSERT(!client->is_connected());
|
||||
VERIFY(!client->is_connected());
|
||||
auto& process = *Process::current();
|
||||
client->m_acceptor = { process.pid().value(), process.uid(), process.gid() };
|
||||
client->m_connected = true;
|
||||
|
@ -101,7 +101,7 @@ KResult Socket::setsockopt(int level, int option, Userspace<const void*> user_va
|
|||
{
|
||||
if (level != SOL_SOCKET)
|
||||
return ENOPROTOOPT;
|
||||
ASSERT(level == SOL_SOCKET);
|
||||
VERIFY(level == SOL_SOCKET);
|
||||
switch (option) {
|
||||
case SO_SNDTIMEO:
|
||||
if (user_value_size != sizeof(timeval))
|
||||
|
|
|
@ -132,13 +132,13 @@ RefPtr<TCPSocket> TCPSocket::create_client(const IPv4Address& new_local_address,
|
|||
|
||||
void TCPSocket::release_to_originator()
|
||||
{
|
||||
ASSERT(!!m_originator);
|
||||
VERIFY(!!m_originator);
|
||||
m_originator.strong_ref()->release_for_accept(this);
|
||||
}
|
||||
|
||||
void TCPSocket::release_for_accept(RefPtr<TCPSocket> socket)
|
||||
{
|
||||
ASSERT(m_pending_release_for_accept.contains(socket->tuple()));
|
||||
VERIFY(m_pending_release_for_accept.contains(socket->tuple()));
|
||||
m_pending_release_for_accept.remove(socket->tuple());
|
||||
// FIXME: Should we observe this error somehow?
|
||||
[[maybe_unused]] auto rc = queue_connection_from(*socket);
|
||||
|
@ -170,7 +170,7 @@ KResultOr<size_t> TCPSocket::protocol_receive(ReadonlyBytes raw_ipv4_packet, Use
|
|||
#if TCP_SOCKET_DEBUG
|
||||
klog() << "payload_size " << payload_size << ", will it fit in " << buffer_size << "?";
|
||||
#endif
|
||||
ASSERT(buffer_size >= payload_size);
|
||||
VERIFY(buffer_size >= payload_size);
|
||||
if (!buffer.write(tcp_packet.payload(), payload_size))
|
||||
return EFAULT;
|
||||
return payload_size;
|
||||
|
@ -189,7 +189,7 @@ KResult TCPSocket::send_tcp_packet(u16 flags, const UserOrKernelBuffer* payload,
|
|||
const size_t buffer_size = sizeof(TCPPacket) + payload_size;
|
||||
auto buffer = ByteBuffer::create_zeroed(buffer_size);
|
||||
auto& tcp_packet = *(TCPPacket*)(buffer.data());
|
||||
ASSERT(local_port());
|
||||
VERIFY(local_port());
|
||||
tcp_packet.set_source_port(local_port());
|
||||
tcp_packet.set_destination_port(peer_port());
|
||||
tcp_packet.set_window_size(1024);
|
||||
|
@ -219,7 +219,7 @@ KResult TCPSocket::send_tcp_packet(u16 flags, const UserOrKernelBuffer* payload,
|
|||
}
|
||||
|
||||
auto routing_decision = route_to(peer_address(), local_address(), bound_interface());
|
||||
ASSERT(!routing_decision.is_zero());
|
||||
VERIFY(!routing_decision.is_zero());
|
||||
|
||||
auto packet_buffer = UserOrKernelBuffer::for_kernel_buffer(buffer.data());
|
||||
auto result = routing_decision.adapter->send_ipv4(
|
||||
|
@ -236,7 +236,7 @@ KResult TCPSocket::send_tcp_packet(u16 flags, const UserOrKernelBuffer* payload,
|
|||
void TCPSocket::send_outgoing_packets()
|
||||
{
|
||||
auto routing_decision = route_to(peer_address(), local_address(), bound_interface());
|
||||
ASSERT(!routing_decision.is_zero());
|
||||
VERIFY(!routing_decision.is_zero());
|
||||
|
||||
auto now = kgettimeofday();
|
||||
|
||||
|
@ -321,7 +321,7 @@ NetworkOrdered<u16> TCPSocket::compute_tcp_checksum(const IPv4Address& source, c
|
|||
if (checksum > 0xffff)
|
||||
checksum = (checksum >> 16) + (checksum & 0xffff);
|
||||
}
|
||||
ASSERT(packet.data_offset() * 4 == sizeof(TCPPacket));
|
||||
VERIFY(packet.data_offset() * 4 == sizeof(TCPPacket));
|
||||
w = (const NetworkOrdered<u16>*)packet.payload();
|
||||
for (size_t i = 0; i < payload_size / sizeof(u16); ++i) {
|
||||
checksum += w[i];
|
||||
|
@ -391,7 +391,7 @@ KResult TCPSocket::protocol_connect(FileDescription& description, ShouldBlock sh
|
|||
if (Thread::current()->block<Thread::ConnectBlocker>({}, description, unblock_flags).was_interrupted())
|
||||
return EINTR;
|
||||
locker.lock();
|
||||
ASSERT(setup_state() == SetupState::Completed);
|
||||
VERIFY(setup_state() == SetupState::Completed);
|
||||
if (has_error()) { // TODO: check unblock_flags
|
||||
m_role = Role::None;
|
||||
return ECONNREFUSED;
|
||||
|
|
|
@ -58,7 +58,7 @@ SocketHandle<UDPSocket> UDPSocket::from_port(u16 port)
|
|||
if (it == sockets_by_port().resource().end())
|
||||
return {};
|
||||
socket = (*it).value;
|
||||
ASSERT(socket);
|
||||
VERIFY(socket);
|
||||
}
|
||||
return { *socket };
|
||||
}
|
||||
|
@ -83,8 +83,8 @@ KResultOr<size_t> UDPSocket::protocol_receive(ReadonlyBytes raw_ipv4_packet, Use
|
|||
{
|
||||
auto& ipv4_packet = *(const IPv4Packet*)(raw_ipv4_packet.data());
|
||||
auto& udp_packet = *static_cast<const UDPPacket*>(ipv4_packet.payload());
|
||||
ASSERT(udp_packet.length() >= sizeof(UDPPacket)); // FIXME: This should be rejected earlier.
|
||||
ASSERT(buffer_size >= (udp_packet.length() - sizeof(UDPPacket)));
|
||||
VERIFY(udp_packet.length() >= sizeof(UDPPacket)); // FIXME: This should be rejected earlier.
|
||||
VERIFY(buffer_size >= (udp_packet.length() - sizeof(UDPPacket)));
|
||||
if (!buffer.write(udp_packet.payload(), udp_packet.length() - sizeof(UDPPacket)))
|
||||
return EFAULT;
|
||||
return udp_packet.length() - sizeof(UDPPacket);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue