Kernel: Convert all *Builder::appendf() => appendff()

This commit is contained in:
Andreas Kling 2021-02-09 16:08:43 +01:00
parent 764af6cdec
commit 1f277f0bd9
8 changed files with 12 additions and 34 deletions

View file

@ -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,

View file

@ -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;
}

View file

@ -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) {

View file

@ -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);

View file

@ -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:

View file

@ -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)");

View file

@ -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();

View file

@ -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;
}