summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-12-25 17:05:05 +0100
committerAndreas Kling <kling@serenityos.org>2020-12-25 17:05:05 +0100
commited5c26d698f586d0d5036b29cd88f6b91314314c (patch)
tree7f9045dea04ad0f04f25e19eeda0c23cf7b05ad5
parentcb2c8f71f44f8c628f57e6ac3cadca57642c7682 (diff)
downloadserenity-ed5c26d698f586d0d5036b29cd88f6b91314314c.zip
AK: Remove custom %w format string specifier
This was a non-standard specifier alias for %04x. This patch replaces all uses of it with new-style formatting functions instead.
-rw-r--r--AK/PrintfImplementation.h5
-rw-r--r--Kernel/Net/NetworkTask.cpp44
-rw-r--r--Kernel/PCI/Definitions.h2
-rw-r--r--Kernel/Scheduler.cpp8
-rw-r--r--Kernel/Syscalls/fork.cpp2
-rw-r--r--Kernel/Thread.cpp2
-rw-r--r--Kernel/VM/MemoryManager.cpp2
7 files changed, 45 insertions, 20 deletions
diff --git a/AK/PrintfImplementation.h b/AK/PrintfImplementation.h
index fa87ddc06f..0fd229bd1f 100644
--- a/AK/PrintfImplementation.h
+++ b/AK/PrintfImplementation.h
@@ -386,10 +386,6 @@ struct PrintfImpl {
m_putch(m_bufptr, '%');
return 1;
}
- ALWAYS_INLINE int format_w(const ModifierState& state, ArgumentListRefT ap) const
- {
- return print_hex(m_putch, m_bufptr, NextArgument<int>()(ap), false, state.alternate_form, false, true, 4);
- }
ALWAYS_INLINE int format_c(const ModifierState& state, ArgumentListRefT ap) const
{
char c = NextArgument<int>()(ap);
@@ -511,7 +507,6 @@ ALWAYS_INLINE int printf_internal(PutChFunc putch, char* buffer, const char*& fm
PRINTF_IMPL_DELEGATE_TO_IMPL(q);
PRINTF_IMPL_DELEGATE_TO_IMPL(s);
PRINTF_IMPL_DELEGATE_TO_IMPL(u);
- PRINTF_IMPL_DELEGATE_TO_IMPL(w);
PRINTF_IMPL_DELEGATE_TO_IMPL(x);
default:
ret += impl.format_unrecognized(*p, fmt, state, ap);
diff --git a/Kernel/Net/NetworkTask.cpp b/Kernel/Net/NetworkTask.cpp
index fee823fd78..9241474cf1 100644
--- a/Kernel/Net/NetworkTask.cpp
+++ b/Kernel/Net/NetworkTask.cpp
@@ -123,7 +123,7 @@ void NetworkTask_main(void*)
}
auto& eth = *(const EthernetFrameHeader*)buffer;
#ifdef ETHERNET_DEBUG
- klog() << "NetworkTask: From " << eth.source().to_string().characters() << " to " << eth.destination().to_string().characters() << ", ether_type=" << String::format("%w", eth.ether_type()) << ", packet_length=" << packet_size;
+ dbgln("NetworkTask: From {} to {}, ether_type={:#04x}, packet_size={}", eth.source().to_string(), eth.destination().to_string(), eth.ether_type(), packet_size);
#endif
#ifdef ETHERNET_VERY_DEBUG
@@ -171,16 +171,21 @@ void handle_arp(const EthernetFrameHeader& eth, size_t frame_size)
}
auto& packet = *static_cast<const ARPPacket*>(eth.payload());
if (packet.hardware_type() != 1 || packet.hardware_address_length() != sizeof(MACAddress)) {
- klog() << "handle_arp: Hardware type not ethernet (" << String::format("%w", packet.hardware_type()) << ", len=" << packet.hardware_address_length() << ")";
+ dbgln("handle_arp: Hardware type not ethernet ({:#04x}, len={})", packet.hardware_type(), packet.hardware_address_length());
return;
}
if (packet.protocol_type() != EtherType::IPv4 || packet.protocol_address_length() != sizeof(IPv4Address)) {
- klog() << "handle_arp: Protocol type not IPv4 (" << String::format("%w", packet.hardware_type()) << ", len=" << packet.protocol_address_length() << ")";
+ dbgln("handle_arp: Protocol type not IPv4 ({:#04x}, len={})", packet.protocol_type(), packet.protocol_address_length());
return;
}
#ifdef ARP_DEBUG
- klog() << "handle_arp: operation=" << String::format("%w", packet.operation()) << ", sender=" << packet.sender_hardware_address().to_string().characters() << "/" << packet.sender_protocol_address().to_string().characters() << ", target=" << packet.target_hardware_address().to_string().characters() << "/" << packet.target_protocol_address().to_string().characters();
+ dbgln("handle_arp: operation={:#04x}, sender={}/{}, target={}/{}",
+ packet.operation(),
+ packet.sender_hardware_address().to_string(),
+ packet.sender_protocol_address().to_string(),
+ packet.target_hardware_address().to_string(),
+ packet.target_protocol_address().to_string());
#endif
if (!packet.sender_hardware_address().is_zero() && !packet.sender_protocol_address().is_zero()) {
@@ -341,7 +346,20 @@ void handle_tcp(const IPv4Packet& ipv4_packet, const timeval& packet_timestamp)
size_t payload_size = ipv4_packet.payload_size() - tcp_packet.header_size();
#ifdef TCP_DEBUG
- klog() << "handle_tcp: source=" << ipv4_packet.source().to_string().characters() << ":" << tcp_packet.source_port() << ", destination=" << ipv4_packet.destination().to_string().characters() << ":" << tcp_packet.destination_port() << " seq_no=" << tcp_packet.sequence_number() << ", ack_no=" << tcp_packet.ack_number() << ", flags=" << String::format("%w", tcp_packet.flags()) << " (" << (tcp_packet.has_syn() ? "SYN " : "") << (tcp_packet.has_ack() ? "ACK " : "") << (tcp_packet.has_fin() ? "FIN " : "") << (tcp_packet.has_rst() ? "RST " : "") << "), window_size=" << tcp_packet.window_size() << ", payload_size=" << payload_size;
+ dbgln("handle_tcp: source={}:{}, destination={}:{}, seq_no={}, ack_no={}, flags={:#04x} ({}{}{}{}), window_size={}, payload_size={}",
+ ipv4_packet.source().to_string(),
+ tcp_packet.source_port(),
+ ipv4_packet.destination().to_string(),
+ tcp_packet.destination_port(),
+ tcp_packet.sequence_number(),
+ tcp_packet.ack_number(),
+ tcp_packet.flags(),
+ tcp_packet.has_syn() ? "SYN " : "",
+ tcp_packet.has_ack() ? "ACK " : "",
+ tcp_packet.has_fin() ? "FIN " : "",
+ tcp_packet.has_rst() ? "RST " : "",
+ tcp_packet.window_size(),
+ payload_size);
#endif
auto adapter = NetworkAdapter::from_ipv4_address(ipv4_packet.destination());
@@ -358,8 +376,20 @@ void handle_tcp(const IPv4Packet& ipv4_packet, const timeval& packet_timestamp)
auto socket = TCPSocket::from_tuple(tuple);
if (!socket) {
- klog() << "handle_tcp: No TCP socket for tuple " << tuple.to_string().characters();
- klog() << "handle_tcp: source=" << ipv4_packet.source().to_string().characters() << ":" << tcp_packet.source_port() << ", destination=" << ipv4_packet.destination().to_string().characters() << ":" << tcp_packet.destination_port() << " seq_no=" << tcp_packet.sequence_number() << ", ack_no=" << tcp_packet.ack_number() << ", flags=" << String::format("%w", tcp_packet.flags()) << " (" << (tcp_packet.has_syn() ? "SYN " : "") << (tcp_packet.has_ack() ? "ACK " : "") << (tcp_packet.has_fin() ? "FIN " : "") << (tcp_packet.has_rst() ? "RST " : "") << "), window_size=" << tcp_packet.window_size() << ", payload_size=" << payload_size;
+ dbgln("handle_tcp: No TCP socket for tuple {}", tuple.to_string());
+ dbgln("handle_tcp: source={}:{}, destination={}:{}, seq_no={}, ack_no={}, flags={:#04x} ({}{}{}{}), window_size={}, payload_size={}",
+ ipv4_packet.source().to_string(), tcp_packet.source_port(),
+ ipv4_packet.destination().to_string(),
+ tcp_packet.destination_port(),
+ tcp_packet.sequence_number(),
+ tcp_packet.ack_number(),
+ tcp_packet.flags(),
+ tcp_packet.has_syn() ? "SYN " : "",
+ tcp_packet.has_ack() ? "ACK " : "",
+ tcp_packet.has_fin() ? "FIN " : "",
+ tcp_packet.has_rst() ? "RST " : "",
+ tcp_packet.window_size(),
+ payload_size);
return;
}
diff --git a/Kernel/PCI/Definitions.h b/Kernel/PCI/Definitions.h
index 944b41f40c..49a9b43825 100644
--- a/Kernel/PCI/Definitions.h
+++ b/Kernel/PCI/Definitions.h
@@ -87,7 +87,7 @@ struct ID {
};
inline const LogStream& operator<<(const LogStream& stream, const ID value)
{
- return stream << "(" << String::format("%w", value.vendor_id) << ":" << String::format("%w", value.device_id) << ")";
+ return stream << String::formatted("({:04x}:{:04x})", value.vendor_id, value.device_id);
}
struct Address {
public:
diff --git a/Kernel/Scheduler.cpp b/Kernel/Scheduler.cpp
index e5b0aa8adc..f5dc03e6f5 100644
--- a/Kernel/Scheduler.cpp
+++ b/Kernel/Scheduler.cpp
@@ -141,15 +141,15 @@ bool Scheduler::pick_next()
dbg() << "Scheduler[" << Processor::current().id() << "]: Non-runnables:";
Scheduler::for_each_nonrunnable([&](Thread& thread) -> IterationDecision {
if (thread.state() == Thread::Dying)
- dbg() << " " << String::format("%-12s", thread.state_string()) << " " << thread << " @ " << String::format("%w", thread.tss().cs) << ":" << String::format("%x", thread.tss().eip) << " Finalizable: " << thread.is_finalizable();
+ dbg() << " " << String::format("%-12s", thread.state_string()) << " " << thread << " @ " << String::formatted("{:04x}:{:08x}", thread.tss().cs, thread.tss().eip) << " Finalizable: " << thread.is_finalizable();
else
- dbg() << " " << String::format("%-12s", thread.state_string()) << " " << thread << " @ " << String::format("%w", thread.tss().cs) << ":" << String::format("%x", thread.tss().eip);
+ dbg() << " " << String::format("%-12s", thread.state_string()) << " " << thread << " @ " << String::formatted("{:04x}:{:08x}", thread.tss().cs, thread.tss().eip);
return IterationDecision::Continue;
});
dbg() << "Scheduler[" << Processor::current().id() << "]: Runnables:";
Scheduler::for_each_runnable([](Thread& thread) -> IterationDecision {
- dbg() << " " << String::format("%3u", thread.effective_priority()) << "/" << String::format("%2u", thread.priority()) << " " << String::format("%-12s", thread.state_string()) << " " << thread << " @ " << String::format("%w", thread.tss().cs) << ":" << String::format("%x", thread.tss().eip);
+ dbg() << " " << String::format("%3u", thread.effective_priority()) << "/" << String::format("%2u", thread.priority()) << " " << String::format("%-12s", thread.state_string()) << " " << thread << " @ " << String::formatted("{:04x}:{:08x}", thread.tss().cs, thread.tss().eip);
return IterationDecision::Continue;
});
#endif
@@ -331,7 +331,7 @@ bool Scheduler::context_switch(Thread* thread)
from_thread->set_state(Thread::Runnable);
#ifdef LOG_EVERY_CONTEXT_SWITCH
- dbg() << "Scheduler[" << Processor::current().id() << "]: " << *from_thread << " -> " << *thread << " [" << thread->priority() << "] " << String::format("%w", thread->tss().cs) << ":" << String::format("%x", thread->tss().eip);
+ dbgln("Scheduler[{}]: {} -> {} [prio={}] {:04x}:{:08x}", Processor::current().id(), from_thread->tid().value(), thread->tid().value(), thread->priority(), thread->tss().cs, thread->tss().eip);
#endif
}
diff --git a/Kernel/Syscalls/fork.cpp b/Kernel/Syscalls/fork.cpp
index 7d32a2e3c7..cb215a42b2 100644
--- a/Kernel/Syscalls/fork.cpp
+++ b/Kernel/Syscalls/fork.cpp
@@ -77,7 +77,7 @@ pid_t Process::sys$fork(RegisterState& regs)
child_tss.ss = regs.userspace_ss;
#ifdef FORK_DEBUG
- dbg() << "fork: child will begin executing at " << String::format("%w", child_tss.cs) << ":" << String::format("%x", child_tss.eip) << " with stack " << String::format("%w", child_tss.ss) << ":" << String::format("%x", child_tss.esp) << ", kstack " << String::format("%w", child_tss.ss0) << ":" << String::format("%x", child_tss.esp0);
+ dbgln("fork: child will begin executing at {:04x}:{:08x} with stack {:04x}:{:08x}, kstack {:04x}:{:08x}", child_tss.cs, child_tss.eip, child_tss.ss, child_tss.esp, child_tss.ss0, child_tss.esp0);
#endif
SharedBuffer::share_all_shared_buffers(*this, *child);
diff --git a/Kernel/Thread.cpp b/Kernel/Thread.cpp
index ba8475a833..e1b1bd5e5a 100644
--- a/Kernel/Thread.cpp
+++ b/Kernel/Thread.cpp
@@ -830,7 +830,7 @@ DispatchSignalResult Thread::dispatch_signal(u8 signal)
regs.eip = g_return_to_ring3_from_signal_trampoline.get();
#ifdef SIGNAL_DEBUG
- klog() << "signal: Okay, " << *this << " {" << state_string() << "} has been primed with signal handler " << String::format("%w", m_tss.cs) << ":" << String::format("%x", m_tss.eip) << " to deliver " << signal;
+ dbgln("signal: Thread in state '{}' has been primed with signal handler {:04x}:{:08x} to deliver {}", state_string(), m_tss.cs, m_tss.eip, signal);
#endif
return DispatchSignalResult::Continue;
}
diff --git a/Kernel/VM/MemoryManager.cpp b/Kernel/VM/MemoryManager.cpp
index 28e975577e..b2f3dcd30f 100644
--- a/Kernel/VM/MemoryManager.cpp
+++ b/Kernel/VM/MemoryManager.cpp
@@ -374,7 +374,7 @@ PageFaultResponse MemoryManager::handle_page_fault(const PageFault& fault)
return PageFaultResponse::ShouldCrash;
}
#ifdef PAGE_FAULT_DEBUG
- dbg() << "MM: CPU[" << Processor::current().id() << "] handle_page_fault(" << String::format("%w", fault.code()) << ") at " << fault.vaddr();
+ dbgln("MM: CPU[{}] handle_page_fault({:#04x}) at {}", Processor::current().id(), fault.code(), fault.vaddr());
#endif
auto* region = find_region_from_vaddr(fault.vaddr());
if (!region) {