summaryrefslogtreecommitdiff
path: root/Kernel
diff options
context:
space:
mode:
authorLenny Maiorani <lenny@colorado.edu>2020-12-20 16:09:48 -0700
committerGitHub <noreply@github.com>2020-12-21 00:09:48 +0100
commit765936ebaedfaa3a339d99a9865b555ddd7c23e2 (patch)
treee092294ec99ca5b3ba9c92139f847dcd9a8a20bc /Kernel
parent4421d98e30763424055eefe729c9cab28abdf19d (diff)
downloadserenity-765936ebaedfaa3a339d99a9865b555ddd7c23e2.zip
Everywhere: Switch from (void) to [[maybe_unused]] (#4473)
Problem: - `(void)` simply casts the expression to void. This is understood to indicate that it is ignored, but this is really a compiler trick to get the compiler to not generate a warning. Solution: - Use the `[[maybe_unused]]` attribute to indicate the value is unused. Note: - Functions taking a `(void)` argument list have also been changed to `()` because this is not needed and shows up in the same grep command.
Diffstat (limited to 'Kernel')
-rw-r--r--Kernel/Arch/i386/CPU.cpp21
-rw-r--r--Kernel/Assertions.h2
-rw-r--r--Kernel/CoreDump.cpp12
-rw-r--r--Kernel/FileSystem/BlockBasedFileSystem.cpp4
-rw-r--r--Kernel/FileSystem/FileDescription.cpp2
-rw-r--r--Kernel/FileSystem/Plan9FileSystem.cpp6
-rw-r--r--Kernel/FileSystem/ProcFS.cpp3
-rw-r--r--Kernel/Interrupts/APIC.cpp2
-rw-r--r--Kernel/Net/E1000NetworkAdapter.cpp2
-rw-r--r--Kernel/Net/IPv4Socket.cpp5
-rw-r--r--Kernel/Net/NetworkTask.cpp37
-rw-r--r--Kernel/Net/RTL8139NetworkAdapter.cpp2
-rw-r--r--Kernel/Net/TCPSocket.cpp9
-rw-r--r--Kernel/Net/UDPSocket.cpp3
-rw-r--r--Kernel/Process.cpp8
-rw-r--r--Kernel/Scheduler.cpp3
-rw-r--r--Kernel/Syscalls/alarm.cpp2
-rw-r--r--Kernel/Syscalls/execve.cpp2
-rw-r--r--Kernel/TTY/TTY.cpp8
-rw-r--r--Kernel/Thread.cpp4
-rw-r--r--Kernel/Time/APICTimer.cpp9
-rw-r--r--Kernel/VM/InodeVMObject.cpp4
22 files changed, 69 insertions, 81 deletions
diff --git a/Kernel/Arch/i386/CPU.cpp b/Kernel/Arch/i386/CPU.cpp
index 0df5f639b7..b863ab2597 100644
--- a/Kernel/Arch/i386/CPU.cpp
+++ b/Kernel/Arch/i386/CPU.cpp
@@ -64,9 +64,9 @@ static GenericInterruptHandler* s_interrupt_handler[GENERIC_INTERRUPT_HANDLERS_C
extern "C" void enter_thread_context(Thread* from_thread, Thread* to_thread);
extern "C" void context_first_init(Thread* from_thread, Thread* to_thread, TrapFrame* trap);
extern "C" u32 do_init_context(Thread* thread, u32 flags);
-extern "C" void exit_kernel_thread(void);
-extern "C" void pre_init_finished(void);
-extern "C" void post_init_finished(void);
+extern "C" void exit_kernel_thread();
+extern "C" void pre_init_finished();
+extern "C" void post_init_finished();
extern "C" void handle_interrupt(TrapFrame*);
#define EH_ENTRY(ec, title) \
@@ -1490,13 +1490,10 @@ void Processor::switch_context(Thread*& from_thread, Thread*& to_thread)
#endif
}
-extern "C" void context_first_init(Thread* from_thread, Thread* to_thread, TrapFrame* trap)
+extern "C" void context_first_init([[maybe_unused]] Thread* from_thread, [[maybe_unused]] Thread* to_thread, [[maybe_unused]] TrapFrame* trap)
{
ASSERT(!are_interrupts_enabled());
ASSERT(is_kernel_mode());
- (void)from_thread;
- (void)to_thread;
- (void)trap;
#ifdef CONTEXT_SWITCH_DEBUG
dbg() << "switch_context <-- from " << VirtualAddress(from_thread) << " " << *from_thread << " to " << VirtualAddress(to_thread) << " " << *to_thread << " (context_first_init)";
@@ -1513,7 +1510,7 @@ extern "C" void context_first_init(Thread* from_thread, Thread* to_thread, TrapF
Scheduler::leave_on_first_switch(trap->regs->eflags);
}
-extern "C" void thread_context_first_enter(void);
+extern "C" void thread_context_first_enter();
asm(
// enter_thread_context returns to here first time a thread is executing
".globl thread_context_first_enter \n"
@@ -1529,7 +1526,7 @@ asm(
" jmp common_trap_exit \n"
);
-void exit_kernel_thread(void)
+void exit_kernel_thread()
{
Thread::current()->exit();
}
@@ -1674,7 +1671,7 @@ void Processor::assume_context(Thread& thread, u32 flags)
ASSERT_NOT_REACHED();
}
-extern "C" void pre_init_finished(void)
+extern "C" void pre_init_finished()
{
ASSERT(g_scheduler_lock.own_lock());
@@ -1687,7 +1684,7 @@ extern "C" void pre_init_finished(void)
Scheduler::leave_on_first_switch(prev_flags);
}
-extern "C" void post_init_finished(void)
+extern "C" void post_init_finished()
{
// We need to re-acquire the scheduler lock before a context switch
// transfers control into the idle loop, which needs the lock held
@@ -1731,7 +1728,7 @@ void Processor::initialize_context_switching(Thread& initial_thread)
[from_to_thread] "b" (&initial_thread),
[cpu] "c" (id())
);
-
+
ASSERT_NOT_REACHED();
}
diff --git a/Kernel/Assertions.h b/Kernel/Assertions.h
index 5a82abd29c..6a0c6b70e1 100644
--- a/Kernel/Assertions.h
+++ b/Kernel/Assertions.h
@@ -31,7 +31,7 @@
#ifdef DEBUG
[[noreturn]] void __assertion_failed(const char* msg, const char* file, unsigned line, const char* func);
-# define ASSERT(expr) (static_cast<bool>(expr) ? (void)0 : __assertion_failed(# expr, __FILE__, __LINE__, __PRETTY_FUNCTION__))
+# define ASSERT(expr) (static_cast<bool>(expr) ? void(0) : __assertion_failed(# expr, __FILE__, __LINE__, __PRETTY_FUNCTION__))
# define ASSERT_NOT_REACHED() ASSERT(false)
#else
# define ASSERT(expr)
diff --git a/Kernel/CoreDump.cpp b/Kernel/CoreDump.cpp
index d75cd993f6..9d8e39637a 100644
--- a/Kernel/CoreDump.cpp
+++ b/Kernel/CoreDump.cpp
@@ -116,7 +116,7 @@ void CoreDump::write_elf_header()
elf_file_header.e_shnum = 0;
elf_file_header.e_shstrndx = SHN_UNDEF;
- (void)m_fd->write(UserOrKernelBuffer::for_kernel_buffer(reinterpret_cast<uint8_t*>(&elf_file_header)), sizeof(Elf32_Ehdr));
+ [[maybe_unused]] auto rc = m_fd->write(UserOrKernelBuffer::for_kernel_buffer(reinterpret_cast<uint8_t*>(&elf_file_header)), sizeof(Elf32_Ehdr));
}
void CoreDump::write_program_headers(size_t notes_size)
@@ -142,7 +142,7 @@ void CoreDump::write_program_headers(size_t notes_size)
offset += phdr.p_filesz;
- (void)m_fd->write(UserOrKernelBuffer::for_kernel_buffer(reinterpret_cast<uint8_t*>(&phdr)), sizeof(Elf32_Phdr));
+ [[maybe_unused]] auto rc = m_fd->write(UserOrKernelBuffer::for_kernel_buffer(reinterpret_cast<uint8_t*>(&phdr)), sizeof(Elf32_Phdr));
}
Elf32_Phdr notes_pheader {};
@@ -155,7 +155,7 @@ void CoreDump::write_program_headers(size_t notes_size)
notes_pheader.p_align = 0;
notes_pheader.p_flags = 0;
- (void)m_fd->write(UserOrKernelBuffer::for_kernel_buffer(reinterpret_cast<uint8_t*>(&notes_pheader)), sizeof(Elf32_Phdr));
+ [[maybe_unused]] auto rc = m_fd->write(UserOrKernelBuffer::for_kernel_buffer(reinterpret_cast<uint8_t*>(&notes_pheader)), sizeof(Elf32_Phdr));
}
void CoreDump::write_regions()
@@ -182,14 +182,14 @@ void CoreDump::write_regions()
// (A page may not be backed by a physical page because it has never been faulted in when the process ran).
src_buffer = UserOrKernelBuffer::for_kernel_buffer(zero_buffer);
}
- (void)m_fd->write(src_buffer.value(), PAGE_SIZE);
+ [[maybe_unused]] auto rc = m_fd->write(src_buffer.value(), PAGE_SIZE);
}
}
}
void CoreDump::write_notes_segment(ByteBuffer& notes_segment)
{
- (void)m_fd->write(UserOrKernelBuffer::for_kernel_buffer(notes_segment.data()), notes_segment.size());
+ [[maybe_unused]] auto rc = m_fd->write(UserOrKernelBuffer::for_kernel_buffer(notes_segment.data()), notes_segment.size());
}
ByteBuffer CoreDump::create_notes_threads_data() const
@@ -264,7 +264,7 @@ void CoreDump::write()
write_regions();
write_notes_segment(notes_segment);
- (void)m_fd->chmod(0400); // Make coredump file readable
+ [[maybe_unused]] auto rc = m_fd->chmod(0400); // Make coredump file readable
}
}
diff --git a/Kernel/FileSystem/BlockBasedFileSystem.cpp b/Kernel/FileSystem/BlockBasedFileSystem.cpp
index ee09e56be2..103b28d5fc 100644
--- a/Kernel/FileSystem/BlockBasedFileSystem.cpp
+++ b/Kernel/FileSystem/BlockBasedFileSystem.cpp
@@ -290,7 +290,7 @@ void BlockBasedFS::flush_specific_block_if_needed(unsigned index)
file_description().seek(base_offset, SEEK_SET);
// FIXME: Should this error path be surfaced somehow?
auto entry_data_buffer = UserOrKernelBuffer::for_kernel_buffer(entry.data);
- (void)file_description().write(entry_data_buffer, block_size());
+ [[maybe_unused]] auto rc = file_description().write(entry_data_buffer, block_size());
cleaned_entries.append(&entry);
}
});
@@ -311,7 +311,7 @@ void BlockBasedFS::flush_writes_impl()
file_description().seek(base_offset, SEEK_SET);
// FIXME: Should this error path be surfaced somehow?
auto entry_data_buffer = UserOrKernelBuffer::for_kernel_buffer(entry.data);
- (void)file_description().write(entry_data_buffer, block_size());
+ [[maybe_unused]] auto rc = file_description().write(entry_data_buffer, block_size());
++count;
});
cache().mark_all_clean();
diff --git a/Kernel/FileSystem/FileDescription.cpp b/Kernel/FileSystem/FileDescription.cpp
index 02958ed401..c4ec739f6a 100644
--- a/Kernel/FileSystem/FileDescription.cpp
+++ b/Kernel/FileSystem/FileDescription.cpp
@@ -71,7 +71,7 @@ FileDescription::~FileDescription()
if (is_fifo())
static_cast<FIFO*>(m_file.ptr())->detach(m_fifo_direction);
// FIXME: Should this error path be observed somehow?
- (void)m_file->close();
+ [[maybe_unused]] auto rc = m_file->close();
m_inode = nullptr;
}
diff --git a/Kernel/FileSystem/Plan9FileSystem.cpp b/Kernel/FileSystem/Plan9FileSystem.cpp
index b3ac7d137a..6e868c037d 100644
--- a/Kernel/FileSystem/Plan9FileSystem.cpp
+++ b/Kernel/FileSystem/Plan9FileSystem.cpp
@@ -710,7 +710,7 @@ Plan9FSInode::~Plan9FSInode()
Plan9FS::Message clunk_request { fs(), Plan9FS::Message::Type::Tclunk };
clunk_request << fid();
// FIXME: Should we observe this error somehow?
- (void)fs().post_message_and_explicitly_ignore_reply(clunk_request);
+ [[maybe_unused]] auto rc = fs().post_message_and_explicitly_ignore_reply(clunk_request);
}
KResult Plan9FSInode::ensure_open_for_mode(int mode)
@@ -909,7 +909,7 @@ KResult Plan9FSInode::traverse_as_directory(Function<bool(const FS::DirectoryEnt
Plan9FS::Message close_message { fs(), Plan9FS::Message::Type::Tclunk };
close_message << clone_fid;
// FIXME: Should we observe this error?
- (void)fs().post_message_and_explicitly_ignore_reply(close_message);
+ [[maybe_unused]] auto rc = fs().post_message_and_explicitly_ignore_reply(close_message);
return result;
}
}
@@ -942,7 +942,7 @@ KResult Plan9FSInode::traverse_as_directory(Function<bool(const FS::DirectoryEnt
Plan9FS::Message close_message { fs(), Plan9FS::Message::Type::Tclunk };
close_message << clone_fid;
// FIXME: Should we observe this error?
- (void)fs().post_message_and_explicitly_ignore_reply(close_message);
+ [[maybe_unused]] auto rc = fs().post_message_and_explicitly_ignore_reply(close_message);
return result;
} else {
// TODO
diff --git a/Kernel/FileSystem/ProcFS.cpp b/Kernel/FileSystem/ProcFS.cpp
index 9ea60115d2..8c41de2106 100644
--- a/Kernel/FileSystem/ProcFS.cpp
+++ b/Kernel/FileSystem/ProcFS.cpp
@@ -1647,9 +1647,8 @@ KResult ProcFSInode::add_child(Inode&, const StringView&, mode_t)
return KResult(-EPERM);
}
-KResult ProcFSInode::remove_child(const StringView& name)
+KResult ProcFSInode::remove_child([[maybe_unused]] const StringView& name)
{
- (void)name;
return KResult(-EPERM);
}
diff --git a/Kernel/Interrupts/APIC.cpp b/Kernel/Interrupts/APIC.cpp
index 22709f2956..103fd1db8a 100644
--- a/Kernel/Interrupts/APIC.cpp
+++ b/Kernel/Interrupts/APIC.cpp
@@ -210,7 +210,7 @@ void APIC::write_icr(const ICRReg& icr)
#define APIC_LVT_TRIGGER_LEVEL (1 << 14)
#define APIC_LVT(iv, dm) (((iv)&0xff) | (((dm)&0x7) << 8))
-extern "C" void apic_ap_start(void);
+extern "C" void apic_ap_start();
extern "C" u16 apic_ap_start_size;
extern "C" u32 ap_cpu_init_stacks;
extern "C" u32 ap_cpu_init_processor_info_array;
diff --git a/Kernel/Net/E1000NetworkAdapter.cpp b/Kernel/Net/E1000NetworkAdapter.cpp
index 399b56bcdb..c045b1bcad 100644
--- a/Kernel/Net/E1000NetworkAdapter.cpp
+++ b/Kernel/Net/E1000NetworkAdapter.cpp
@@ -150,7 +150,7 @@ void E1000NetworkAdapter::detect()
if (id != qemu_bochs_vbox_id)
return;
u8 irq = PCI::get_interrupt_line(address);
- (void)adopt(*new E1000NetworkAdapter(address, irq)).leak_ref();
+ [[maybe_unused]] auto& unused = adopt(*new E1000NetworkAdapter(address, irq)).leak_ref();
});
}
diff --git a/Kernel/Net/IPv4Socket.cpp b/Kernel/Net/IPv4Socket.cpp
index 3377162b25..aaf5bfd828 100644
--- a/Kernel/Net/IPv4Socket.cpp
+++ b/Kernel/Net/IPv4Socket.cpp
@@ -203,11 +203,10 @@ int IPv4Socket::allocate_local_port_if_needed()
return port;
}
-KResultOr<size_t> IPv4Socket::sendto(FileDescription&, const UserOrKernelBuffer& data, size_t data_length, int flags, Userspace<const sockaddr*> addr, socklen_t addr_length)
+KResultOr<size_t> IPv4Socket::sendto(FileDescription&, const UserOrKernelBuffer& data, size_t data_length, [[maybe_unused]] int flags, Userspace<const sockaddr*> addr, socklen_t addr_length)
{
LOCKER(lock());
- (void)flags;
if (addr && addr_length != sizeof(sockaddr_in))
return KResult(-EINVAL);
@@ -621,7 +620,7 @@ int IPv4Socket::ioctl(FileDescription&, unsigned request, FlatPtr arg)
KResult IPv4Socket::close()
{
- (void)shutdown(SHUT_RDWR);
+ [[maybe_unused]] auto rc = shutdown(SHUT_RDWR);
return KSuccess;
}
diff --git a/Kernel/Net/NetworkTask.cpp b/Kernel/Net/NetworkTask.cpp
index 9af09039f9..bf1dc0fd92 100644
--- a/Kernel/Net/NetworkTask.cpp
+++ b/Kernel/Net/NetworkTask.cpp
@@ -374,6 +374,7 @@ void handle_tcp(const IPv4Packet& ipv4_packet, const timeval& packet_timestamp)
socket->receive_tcp_packet(tcp_packet, ipv4_packet.payload_size());
+ [[maybe_unused]] int unused_rc {};
switch (socket->state()) {
case TCPSocket::State::Closed:
klog() << "handle_tcp: unexpected flags in Closed state";
@@ -381,7 +382,7 @@ void handle_tcp(const IPv4Packet& ipv4_packet, const timeval& packet_timestamp)
return;
case TCPSocket::State::TimeWait:
klog() << "handle_tcp: unexpected flags in TimeWait state";
- (void)socket->send_tcp_packet(TCPFlags::RST);
+ unused_rc = socket->send_tcp_packet(TCPFlags::RST);
socket->set_state(TCPSocket::State::Closed);
return;
case TCPSocket::State::Listen:
@@ -403,46 +404,46 @@ void handle_tcp(const IPv4Packet& ipv4_packet, const timeval& packet_timestamp)
#endif
client->set_sequence_number(1000);
client->set_ack_number(tcp_packet.sequence_number() + payload_size + 1);
- (void)client->send_tcp_packet(TCPFlags::SYN | TCPFlags::ACK);
+ [[maybe_unused]] auto rc2 = client->send_tcp_packet(TCPFlags::SYN | TCPFlags::ACK);
client->set_state(TCPSocket::State::SynReceived);
return;
}
default:
klog() << "handle_tcp: unexpected flags in Listen state";
- // (void)socket->send_tcp_packet(TCPFlags::RST);
+ // socket->send_tcp_packet(TCPFlags::RST);
return;
}
case TCPSocket::State::SynSent:
switch (tcp_packet.flags()) {
case TCPFlags::SYN:
socket->set_ack_number(tcp_packet.sequence_number() + payload_size + 1);
- (void)socket->send_tcp_packet(TCPFlags::ACK);
+ unused_rc = socket->send_tcp_packet(TCPFlags::ACK);
socket->set_state(TCPSocket::State::SynReceived);
return;
case TCPFlags::ACK | TCPFlags::SYN:
socket->set_ack_number(tcp_packet.sequence_number() + payload_size + 1);
- (void)socket->send_tcp_packet(TCPFlags::ACK);
+ unused_rc = socket->send_tcp_packet(TCPFlags::ACK);
socket->set_state(TCPSocket::State::Established);
socket->set_setup_state(Socket::SetupState::Completed);
socket->set_connected(true);
return;
case TCPFlags::ACK | TCPFlags::FIN:
socket->set_ack_number(tcp_packet.sequence_number() + payload_size + 1);
- (void)socket->send_tcp_packet(TCPFlags::ACK);
+ unused_rc = socket->send_tcp_packet(TCPFlags::ACK);
socket->set_state(TCPSocket::State::Closed);
socket->set_error(TCPSocket::Error::FINDuringConnect);
socket->set_setup_state(Socket::SetupState::Completed);
return;
case TCPFlags::ACK | TCPFlags::RST:
socket->set_ack_number(tcp_packet.sequence_number() + payload_size);
- (void)socket->send_tcp_packet(TCPFlags::ACK);
+ unused_rc = socket->send_tcp_packet(TCPFlags::ACK);
socket->set_state(TCPSocket::State::Closed);
socket->set_error(TCPSocket::Error::RSTDuringConnect);
socket->set_setup_state(Socket::SetupState::Completed);
return;
default:
klog() << "handle_tcp: unexpected flags in SynSent state";
- (void)socket->send_tcp_packet(TCPFlags::RST);
+ unused_rc = socket->send_tcp_packet(TCPFlags::RST);
socket->set_state(TCPSocket::State::Closed);
socket->set_error(TCPSocket::Error::UnexpectedFlagsDuringConnect);
socket->set_setup_state(Socket::SetupState::Completed);
@@ -457,7 +458,7 @@ void handle_tcp(const IPv4Packet& ipv4_packet, const timeval& packet_timestamp)
case TCPSocket::Direction::Incoming:
if (!socket->has_originator()) {
klog() << "handle_tcp: connection doesn't have an originating socket; maybe it went away?";
- (void)socket->send_tcp_packet(TCPFlags::RST);
+ unused_rc = socket->send_tcp_packet(TCPFlags::RST);
socket->set_state(TCPSocket::State::Closed);
return;
}
@@ -473,7 +474,7 @@ void handle_tcp(const IPv4Packet& ipv4_packet, const timeval& packet_timestamp)
return;
default:
klog() << "handle_tcp: got ACK in SynReceived state but direction is invalid (" << TCPSocket::to_string(socket->direction()) << ")";
- (void)socket->send_tcp_packet(TCPFlags::RST);
+ unused_rc = socket->send_tcp_packet(TCPFlags::RST);
socket->set_state(TCPSocket::State::Closed);
return;
}
@@ -481,7 +482,7 @@ void handle_tcp(const IPv4Packet& ipv4_packet, const timeval& packet_timestamp)
return;
default:
klog() << "handle_tcp: unexpected flags in SynReceived state";
- (void)socket->send_tcp_packet(TCPFlags::RST);
+ unused_rc = socket->send_tcp_packet(TCPFlags::RST);
socket->set_state(TCPSocket::State::Closed);
return;
}
@@ -489,7 +490,7 @@ void handle_tcp(const IPv4Packet& ipv4_packet, const timeval& packet_timestamp)
switch (tcp_packet.flags()) {
default:
klog() << "handle_tcp: unexpected flags in CloseWait state";
- (void)socket->send_tcp_packet(TCPFlags::RST);
+ unused_rc = socket->send_tcp_packet(TCPFlags::RST);
socket->set_state(TCPSocket::State::Closed);
return;
}
@@ -501,7 +502,7 @@ void handle_tcp(const IPv4Packet& ipv4_packet, const timeval& packet_timestamp)
return;
default:
klog() << "handle_tcp: unexpected flags in LastAck state";
- (void)socket->send_tcp_packet(TCPFlags::RST);
+ unused_rc = socket->send_tcp_packet(TCPFlags::RST);
socket->set_state(TCPSocket::State::Closed);
return;
}
@@ -517,7 +518,7 @@ void handle_tcp(const IPv4Packet& ipv4_packet, const timeval& packet_timestamp)
return;
default:
klog() << "handle_tcp: unexpected flags in FinWait1 state";
- (void)socket->send_tcp_packet(TCPFlags::RST);
+ unused_rc = socket->send_tcp_packet(TCPFlags::RST);
socket->set_state(TCPSocket::State::Closed);
return;
}
@@ -532,7 +533,7 @@ void handle_tcp(const IPv4Packet& ipv4_packet, const timeval& packet_timestamp)
return;
default:
klog() << "handle_tcp: unexpected flags in FinWait2 state";
- (void)socket->send_tcp_packet(TCPFlags::RST);
+ unused_rc = socket->send_tcp_packet(TCPFlags::RST);
socket->set_state(TCPSocket::State::Closed);
return;
}
@@ -544,7 +545,7 @@ void handle_tcp(const IPv4Packet& ipv4_packet, const timeval& packet_timestamp)
return;
default:
klog() << "handle_tcp: unexpected flags in Closing state";
- (void)socket->send_tcp_packet(TCPFlags::RST);
+ unused_rc = socket->send_tcp_packet(TCPFlags::RST);
socket->set_state(TCPSocket::State::Closed);
return;
}
@@ -554,7 +555,7 @@ void handle_tcp(const IPv4Packet& ipv4_packet, const timeval& packet_timestamp)
socket->did_receive(ipv4_packet.source(), tcp_packet.source_port(), KBuffer::copy(&ipv4_packet, sizeof(IPv4Packet) + ipv4_packet.payload_size()), packet_timestamp);
socket->set_ack_number(tcp_packet.sequence_number() + payload_size + 1);
- (void)socket->send_tcp_packet(TCPFlags::ACK);
+ unused_rc = socket->send_tcp_packet(TCPFlags::ACK);
socket->set_state(TCPSocket::State::CloseWait);
socket->set_connected(false);
return;
@@ -568,7 +569,7 @@ void handle_tcp(const IPv4Packet& ipv4_packet, const timeval& packet_timestamp)
if (payload_size) {
if (socket->did_receive(ipv4_packet.source(), tcp_packet.source_port(), KBuffer::copy(&ipv4_packet, sizeof(IPv4Packet) + ipv4_packet.payload_size()), packet_timestamp))
- (void)socket->send_tcp_packet(TCPFlags::ACK);
+ unused_rc = socket->send_tcp_packet(TCPFlags::ACK);
}
}
}
diff --git a/Kernel/Net/RTL8139NetworkAdapter.cpp b/Kernel/Net/RTL8139NetworkAdapter.cpp
index f0faa21cd8..86cfa77640 100644
--- a/Kernel/Net/RTL8139NetworkAdapter.cpp
+++ b/Kernel/Net/RTL8139NetworkAdapter.cpp
@@ -135,7 +135,7 @@ void RTL8139NetworkAdapter::detect()
if (id != rtl8139_id)
return;
u8 irq = PCI::get_interrupt_line(address);
- (void)adopt(*new RTL8139NetworkAdapter(address, irq)).leak_ref();
+ [[maybe_unused]] auto& unused = adopt(*new RTL8139NetworkAdapter(address, irq)).leak_ref();
});
}
diff --git a/Kernel/Net/TCPSocket.cpp b/Kernel/Net/TCPSocket.cpp
index 745272a594..ebcce2e2a7 100644
--- a/Kernel/Net/TCPSocket.cpp
+++ b/Kernel/Net/TCPSocket.cpp
@@ -144,7 +144,7 @@ void TCPSocket::release_for_accept(RefPtr<TCPSocket> socket)
ASSERT(m_pending_release_for_accept.contains(socket->tuple()));
m_pending_release_for_accept.remove(socket->tuple());
// FIXME: Should we observe this error somehow?
- (void)queue_connection_from(*socket);
+ [[maybe_unused]] auto rc = queue_connection_from(*socket);
}
TCPSocket::TCPSocket(int protocol)
@@ -167,9 +167,8 @@ NonnullRefPtr<TCPSocket> TCPSocket::create(int protocol)
return adopt(*new TCPSocket(protocol));
}
-KResultOr<size_t> TCPSocket::protocol_receive(ReadonlyBytes raw_ipv4_packet, UserOrKernelBuffer& buffer, size_t buffer_size, int flags)
+KResultOr<size_t> TCPSocket::protocol_receive(ReadonlyBytes raw_ipv4_packet, UserOrKernelBuffer& buffer, size_t buffer_size, [[maybe_unused]] int flags)
{
- (void)flags;
auto& ipv4_packet = *reinterpret_cast<const IPv4Packet*>(raw_ipv4_packet.data());
auto& tcp_packet = *static_cast<const TCPPacket*>(ipv4_packet.payload());
size_t payload_size = raw_ipv4_packet.size() - sizeof(IPv4Packet) - tcp_packet.header_size();
@@ -464,7 +463,7 @@ void TCPSocket::shut_down_for_writing()
#ifdef TCP_SOCKET_DEBUG
dbg() << " Sending FIN/ACK from Established and moving into FinWait1";
#endif
- (void)send_tcp_packet(TCPFlags::FIN | TCPFlags::ACK);
+ [[maybe_unused]] auto rc = send_tcp_packet(TCPFlags::FIN | TCPFlags::ACK);
set_state(State::FinWait1);
} else {
dbg() << " Shutting down TCPSocket for writing but not moving to FinWait1 since state is " << to_string(state());
@@ -479,7 +478,7 @@ KResult TCPSocket::close()
#ifdef TCP_SOCKET_DEBUG
dbg() << " Sending FIN from CloseWait and moving into LastAck";
#endif
- (void)send_tcp_packet(TCPFlags::FIN | TCPFlags::ACK);
+ [[maybe_unused]] auto rc = send_tcp_packet(TCPFlags::FIN | TCPFlags::ACK);
set_state(State::LastAck);
}
diff --git a/Kernel/Net/UDPSocket.cpp b/Kernel/Net/UDPSocket.cpp
index 0ee41ab36d..01242faa2b 100644
--- a/Kernel/Net/UDPSocket.cpp
+++ b/Kernel/Net/UDPSocket.cpp
@@ -79,9 +79,8 @@ NonnullRefPtr<UDPSocket> UDPSocket::create(int protocol)
return adopt(*new UDPSocket(protocol));
}
-KResultOr<size_t> UDPSocket::protocol_receive(ReadonlyBytes raw_ipv4_packet, UserOrKernelBuffer& buffer, size_t buffer_size, int flags)
+KResultOr<size_t> UDPSocket::protocol_receive(ReadonlyBytes raw_ipv4_packet, UserOrKernelBuffer& buffer, size_t buffer_size, [[maybe_unused]] int flags)
{
- (void)flags;
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.
diff --git a/Kernel/Process.cpp b/Kernel/Process.cpp
index a26ac3151c..7657c0fc66 100644
--- a/Kernel/Process.cpp
+++ b/Kernel/Process.cpp
@@ -401,8 +401,8 @@ void Process::dump_regions()
}
// Make sure the compiler doesn't "optimize away" this function:
-extern void signal_trampoline_dummy(void);
-void signal_trampoline_dummy(void)
+extern void signal_trampoline_dummy();
+void signal_trampoline_dummy()
{
// The trampoline preserves the current eax, pushes the signal code and
// then calls the signal handler. We do this because, when interrupting a
@@ -426,8 +426,8 @@ void signal_trampoline_dummy(void)
".att_syntax" ::"i"(Syscall::SC_sigreturn));
}
-extern "C" void asm_signal_trampoline(void);
-extern "C" void asm_signal_trampoline_end(void);
+extern "C" void asm_signal_trampoline();
+extern "C" void asm_signal_trampoline_end();
void create_signal_trampolines()
{
diff --git a/Kernel/Scheduler.cpp b/Kernel/Scheduler.cpp
index c790daf718..41395e311c 100644
--- a/Kernel/Scheduler.cpp
+++ b/Kernel/Scheduler.cpp
@@ -253,14 +253,13 @@ bool Scheduler::yield()
return true;
}
-bool Scheduler::donate_to_and_switch(Thread* beneficiary, const char* reason)
+bool Scheduler::donate_to_and_switch(Thread* beneficiary, [[maybe_unused]] const char* reason)
{
ASSERT(g_scheduler_lock.own_lock());
auto& proc = Processor::current();
ASSERT(proc.in_critical() == 1);
- (void)reason;
unsigned ticks_left = Thread::current()->ticks_left();
if (!beneficiary || beneficiary->state() != Thread::Runnable || ticks_left <= 1)
return Scheduler::yield();
diff --git a/Kernel/Syscalls/alarm.cpp b/Kernel/Syscalls/alarm.cpp
index 79413eca44..f740fd0c47 100644
--- a/Kernel/Syscalls/alarm.cpp
+++ b/Kernel/Syscalls/alarm.cpp
@@ -49,7 +49,7 @@ unsigned Process::sys$alarm(unsigned seconds)
auto deadline = TimeManagement::the().current_time(CLOCK_REALTIME).value();
timespec_add(deadline, { seconds, 0 }, deadline);
m_alarm_timer = TimerQueue::the().add_timer_without_id(CLOCK_REALTIME, deadline, [this]() {
- (void)send_signal(SIGALRM, nullptr);
+ [[maybe_unused]] auto rc = send_signal(SIGALRM, nullptr);
});
}
return previous_alarm_remaining;
diff --git a/Kernel/Syscalls/execve.cpp b/Kernel/Syscalls/execve.cpp
index 581e283e0e..7b4a387b2b 100644
--- a/Kernel/Syscalls/execve.cpp
+++ b/Kernel/Syscalls/execve.cpp
@@ -371,7 +371,7 @@ int Process::do_exec(NonnullRefPtr<FileDescription> main_program_description, Ve
new_main_thread->set_state(Thread::State::Runnable);
}
u32 lock_count_to_restore;
- (void)big_lock().force_unlock_if_locked(lock_count_to_restore);
+ [[maybe_unused]] auto rc = big_lock().force_unlock_if_locked(lock_count_to_restore);
ASSERT_INTERRUPTS_DISABLED();
ASSERT(Processor::current().in_critical());
return 0;
diff --git a/Kernel/TTY/TTY.cpp b/Kernel/TTY/TTY.cpp
index 49a1d89f85..10da12450e 100644
--- a/Kernel/TTY/TTY.cpp
+++ b/Kernel/TTY/TTY.cpp
@@ -57,7 +57,7 @@ KResultOr<size_t> TTY::read(FileDescription&, size_t, UserOrKernelBuffer& buffer
{
if (Process::current()->pgid() != pgid()) {
// FIXME: Should we propagate this error path somehow?
- (void)Process::current()->send_signal(SIGTTIN, nullptr);
+ [[maybe_unused]] auto rc = Process::current()->send_signal(SIGTTIN, nullptr);
return KResult(-EINTR);
}
@@ -104,7 +104,7 @@ KResultOr<size_t> TTY::read(FileDescription&, size_t, UserOrKernelBuffer& buffer
KResultOr<size_t> TTY::write(FileDescription&, size_t, const UserOrKernelBuffer& buffer, size_t size)
{
if (Process::current()->pgid() != pgid()) {
- (void)Process::current()->send_signal(SIGTTOU, nullptr);
+ [[maybe_unused]] auto rc = Process::current()->send_signal(SIGTTOU, nullptr);
return KResult(-EINTR);
}
@@ -172,7 +172,7 @@ void TTY::emit(u8 ch, bool do_evaluate_block_conditions)
dbg() << tty_name() << ": VSUSP pressed!";
generate_signal(SIGTSTP);
if (auto original_process_parent = m_original_process_parent.strong_ref())
- (void)original_process_parent->send_signal(SIGCHLD, nullptr);
+ [[maybe_unused]] auto rc = original_process_parent->send_signal(SIGCHLD, nullptr);
// TODO: Else send it to the session leader maybe?
return;
}
@@ -288,7 +288,7 @@ void TTY::generate_signal(int signal)
Process::for_each_in_pgrp(pgid(), [&](auto& process) {
dbg() << tty_name() << ": Send signal " << signal << " to " << process;
// FIXME: Should this error be propagated somehow?
- (void)process.send_signal(signal, nullptr);
+ [[maybe_unused]] auto rc = process.send_signal(signal, nullptr);
return IterationDecision::Continue;
});
}
diff --git a/Kernel/Thread.cpp b/Kernel/Thread.cpp
index 18482823de..a863780586 100644
--- a/Kernel/Thread.cpp
+++ b/Kernel/Thread.cpp
@@ -213,7 +213,7 @@ void Thread::die_if_needed()
return;
u32 unlock_count;
- (void)unlock_process_if_locked(unlock_count);
+ [[maybe_unused]] auto rc = unlock_process_if_locked(unlock_count);
ScopedCritical critical;
set_should_die();
@@ -240,7 +240,7 @@ void Thread::exit(void* exit_value)
m_join_condition.thread_did_exit(exit_value);
set_should_die();
u32 unlock_count;
- (void)unlock_process_if_locked(unlock_count);
+ [[maybe_unused]] auto rc = unlock_process_if_locked(unlock_count);
die_if_needed();
}
diff --git a/Kernel/Time/APICTimer.cpp b/Kernel/Time/APICTimer.cpp
index 7f91f4a06b..2b0a80e24f 100644
--- a/Kernel/Time/APICTimer.cpp
+++ b/Kernel/Time/APICTimer.cpp
@@ -165,21 +165,18 @@ void APICTimer::reset_to_default_ticks_per_second()
{
}
-bool APICTimer::try_to_set_frequency(size_t frequency)
+bool APICTimer::try_to_set_frequency([[maybe_unused]] size_t frequency)
{
- (void)frequency;
return true;
}
-bool APICTimer::is_capable_of_frequency(size_t frequency) const
+bool APICTimer::is_capable_of_frequency([[maybe_unused]] size_t frequency) const
{
- (void)frequency;
return false;
}
-size_t APICTimer::calculate_nearest_possible_frequency(size_t frequency) const
+size_t APICTimer::calculate_nearest_possible_frequency([[maybe_unused]] size_t frequency) const
{
- (void)frequency;
return 0;
}
diff --git a/Kernel/VM/InodeVMObject.cpp b/Kernel/VM/InodeVMObject.cpp
index c63417fab0..970dec24a9 100644
--- a/Kernel/VM/InodeVMObject.cpp
+++ b/Kernel/VM/InodeVMObject.cpp
@@ -89,10 +89,8 @@ void InodeVMObject::inode_size_changed(Badge<Inode>, size_t old_size, size_t new
});
}
-void InodeVMObject::inode_contents_changed(Badge<Inode>, off_t offset, ssize_t size, const UserOrKernelBuffer& data)
+void InodeVMObject::inode_contents_changed(Badge<Inode>, off_t offset, [[maybe_unused]] ssize_t size, [[maybe_unused]] const UserOrKernelBuffer& data)
{
- (void)size;
- (void)data;
InterruptDisabler disabler;
ASSERT(offset >= 0);