diff options
-rw-r--r-- | Kernel/Arch/i386/ProcessorInfo.cpp | 2 | ||||
-rw-r--r-- | Kernel/FileSystem/ProcFS.cpp | 4 | ||||
-rw-r--r-- | Kernel/KBufferBuilder.cpp | 20 | ||||
-rw-r--r-- | Kernel/KBufferBuilder.h | 4 | ||||
-rw-r--r-- | Kernel/Net/IPv4Socket.cpp | 4 | ||||
-rw-r--r-- | Kernel/Net/LocalSocket.cpp | 4 | ||||
-rw-r--r-- | Kernel/Syscalls/thread.cpp | 4 | ||||
-rw-r--r-- | Kernel/Thread.cpp | 4 |
8 files changed, 12 insertions, 34 deletions
diff --git a/Kernel/Arch/i386/ProcessorInfo.cpp b/Kernel/Arch/i386/ProcessorInfo.cpp index 273389424d..2c101c3eb1 100644 --- a/Kernel/Arch/i386/ProcessorInfo.cpp +++ b/Kernel/Arch/i386/ProcessorInfo.cpp @@ -39,7 +39,7 @@ ProcessorInfo::ProcessorInfo(Processor& processor) CPUID cpuid(0); StringBuilder builder; auto emit_u32 = [&](u32 value) { - builder.appendf("%c%c%c%c", + builder.appendff("{:c}{:c}{:c}{:c}", value & 0xff, (value >> 8) & 0xff, (value >> 16) & 0xff, diff --git a/Kernel/FileSystem/ProcFS.cpp b/Kernel/FileSystem/ProcFS.cpp index 52bddb2901..0762ecf52c 100644 --- a/Kernel/FileSystem/ProcFS.cpp +++ b/Kernel/FileSystem/ProcFS.cpp @@ -445,7 +445,7 @@ static bool procfs$devices(InodeIdentifier, KBufferBuilder& builder) static bool procfs$uptime(InodeIdentifier, KBufferBuilder& builder) { - builder.appendf("%llu\n", TimeManagement::the().uptime_ms() / 1000); + builder.appendff("{}\n", TimeManagement::the().uptime_ms() / 1000); return true; } @@ -659,7 +659,7 @@ static bool procfs$pid_root(InodeIdentifier identifier, KBufferBuilder& builder) static bool procfs$self(InodeIdentifier, KBufferBuilder& builder) { - builder.appendf("%d", Process::current()->pid().value()); + builder.appendff("{}", Process::current()->pid().value()); return true; } diff --git a/Kernel/KBufferBuilder.cpp b/Kernel/KBufferBuilder.cpp index a5ec9b7c0d..07f467fc3c 100644 --- a/Kernel/KBufferBuilder.cpp +++ b/Kernel/KBufferBuilder.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org> + * Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org> * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -24,10 +24,8 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include <AK/PrintfImplementation.h> #include <AK/StdLibExtras.h> #include <Kernel/KBufferBuilder.h> -#include <stdarg.h> namespace Kernel { @@ -113,22 +111,6 @@ void KBufferBuilder::append(char ch) m_size += 1; } -void KBufferBuilder::appendvf(const char* fmt, va_list ap) -{ - printf_internal([this](char*&, char ch) { - append(ch); - }, - nullptr, fmt, ap); -} - -void KBufferBuilder::appendf(const char* fmt, ...) -{ - va_list ap; - va_start(ap, fmt); - appendvf(fmt, ap); - va_end(ap); -} - void KBufferBuilder::append_escaped_for_json(const StringView& string) { for (auto ch : string) { diff --git a/Kernel/KBufferBuilder.h b/Kernel/KBufferBuilder.h index 21e9eb6a56..cc4986ffa0 100644 --- a/Kernel/KBufferBuilder.h +++ b/Kernel/KBufferBuilder.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org> + * Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org> * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -44,8 +44,6 @@ public: void append(const StringView&); void append(char); void append(const char*, int); - void appendf(const char*, ...); - void appendvf(const char*, va_list); void append_escaped_for_json(const StringView&); void append_bytes(ReadonlyBytes); diff --git a/Kernel/Net/IPv4Socket.cpp b/Kernel/Net/IPv4Socket.cpp index 33b08a7a8b..29a7ba918a 100644 --- a/Kernel/Net/IPv4Socket.cpp +++ b/Kernel/Net/IPv4Socket.cpp @@ -433,9 +433,9 @@ String IPv4Socket::absolute_path(const FileDescription&) const StringBuilder builder; builder.append("socket:"); - builder.appendf("%s:%d", m_local_address.to_string().characters(), m_local_port); + builder.appendff("{}:{}", m_local_address.to_string(), m_local_port); if (m_role == Role::Accepted || m_role == Role::Connected) - builder.appendf(" / %s:%d", m_peer_address.to_string().characters(), m_peer_port); + builder.appendff(" / {}:{}", m_peer_address.to_string(), m_peer_port); switch (m_role) { case Role::Listener: diff --git a/Kernel/Net/LocalSocket.cpp b/Kernel/Net/LocalSocket.cpp index 3e2d68c975..642bc62156 100644 --- a/Kernel/Net/LocalSocket.cpp +++ b/Kernel/Net/LocalSocket.cpp @@ -349,10 +349,10 @@ String LocalSocket::absolute_path(const FileDescription& description) const builder.append(" (listening)"); break; case Role::Accepted: - builder.appendf(" (accepted from pid %d)", origin_pid()); + builder.appendff(" (accepted from pid {})", origin_pid()); break; case Role::Connected: - builder.appendf(" (connected to pid %d)", acceptor_pid()); + builder.appendff(" (connected to pid {})", acceptor_pid()); break; case Role::Connecting: builder.append(" (connecting)"); diff --git a/Kernel/Syscalls/thread.cpp b/Kernel/Syscalls/thread.cpp index ff8d4b0ae3..b5896c2796 100644 --- a/Kernel/Syscalls/thread.cpp +++ b/Kernel/Syscalls/thread.cpp @@ -70,9 +70,7 @@ int Process::sys$create_thread(void* (*entry)(void*), Userspace<const Syscall::S // So give it a unique name until the user calls $set_thread_name on it // length + 4 to give space for our extra junk at the end StringBuilder builder(m_name.length() + 4); - builder.append(m_name); - builder.appendf("[%d]", thread->tid().value()); - thread->set_name(builder.to_string()); + thread->set_name(String::formatted("{} [{}]", m_name, thread->tid().value())); if (!is_thread_joinable) thread->detach(); diff --git a/Kernel/Thread.cpp b/Kernel/Thread.cpp index 2dc0c7d924..29246915b4 100644 --- a/Kernel/Thread.cpp +++ b/Kernel/Thread.cpp @@ -968,9 +968,9 @@ static bool symbolicate(const RecognizedSymbol& symbol, const Process& process, } unsigned offset = symbol.address - symbol.symbol->address; if (symbol.symbol->address == g_highest_kernel_symbol_address && offset > 4096) { - builder.appendf("%p\n", (void*)(mask_kernel_addresses ? 0xdeadc0de : symbol.address)); + builder.appendff("{:p}\n", (void*)(mask_kernel_addresses ? 0xdeadc0de : symbol.address)); } else { - builder.appendf("%p %s +%u\n", (void*)(mask_kernel_addresses ? 0xdeadc0de : symbol.address), demangle(symbol.symbol->name).characters(), offset); + builder.appendff("{:p} {} +{}\n", (void*)(mask_kernel_addresses ? 0xdeadc0de : symbol.address), demangle(symbol.symbol->name), offset); } return true; } |