From 6c2f0316d97d22bae876cdc14f750d416d83e61a Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Wed, 17 Feb 2021 16:37:11 +0100 Subject: [PATCH] Kernel: Convert snprintf() => String::formatted()/number() --- Kernel/FileSystem/ProcFS.cpp | 12 +++--------- Kernel/TTY/SlavePTY.cpp | 2 +- Kernel/TTY/SlavePTY.h | 2 +- 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/Kernel/FileSystem/ProcFS.cpp b/Kernel/FileSystem/ProcFS.cpp index ec07b6a4fa0..e98154094b2 100644 --- a/Kernel/FileSystem/ProcFS.cpp +++ b/Kernel/FileSystem/ProcFS.cpp @@ -1260,9 +1260,7 @@ KResult ProcFSInode::traverse_as_directory(Functionfile_description(i); if (!description) continue; - char name[16]; - size_t name_length = (size_t)snprintf(name, sizeof(name), "%d", i); - callback({ { name, name_length }, to_identifier_with_fd(fsid(), pid, i), 0 }); + callback({ String::number(i), to_identifier_with_fd(fsid(), pid, i), 0 }); } } break; @@ -1318,9 +1314,7 @@ KResult ProcFSInode::traverse_as_directory(Functionfor_each_thread([&](Thread& thread) -> IterationDecision { int tid = thread.tid().value(); - char name[16]; - size_t name_length = (size_t)snprintf(name, sizeof(name), "%d", tid); - callback({ { name, name_length }, to_identifier_with_stack(fsid(), tid), 0 }); + callback({ String::number(tid), to_identifier_with_stack(fsid(), tid), 0 }); return IterationDecision::Continue; }); } break; diff --git a/Kernel/TTY/SlavePTY.cpp b/Kernel/TTY/SlavePTY.cpp index 5cc09eaa9a6..cb5c707d31e 100644 --- a/Kernel/TTY/SlavePTY.cpp +++ b/Kernel/TTY/SlavePTY.cpp @@ -37,7 +37,7 @@ SlavePTY::SlavePTY(MasterPTY& master, unsigned index) , m_master(master) , m_index(index) { - snprintf(m_tty_name, sizeof(m_tty_name), "/dev/pts/%u", m_index); + m_tty_name = String::formatted("/dev/pts/{}", m_index); auto process = Process::current(); set_uid(process->uid()); set_gid(process->gid()); diff --git a/Kernel/TTY/SlavePTY.h b/Kernel/TTY/SlavePTY.h index fc9c46311fb..4fd889ed9b8 100644 --- a/Kernel/TTY/SlavePTY.h +++ b/Kernel/TTY/SlavePTY.h @@ -66,7 +66,7 @@ private: RefPtr m_master; time_t m_time_of_last_write { 0 }; unsigned m_index { 0 }; - char m_tty_name[32]; + String m_tty_name; }; }