1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 06:37:35 +00:00

Kernel: Convert a bunch of String::format() => String::formatted()

This commit is contained in:
Andreas Kling 2021-01-11 22:07:01 +01:00
parent 0ae9ae48fa
commit 7c4ddecacb
14 changed files with 22 additions and 33 deletions

View file

@ -394,8 +394,8 @@ String DevFSDeviceInode::determine_name() const
case 4:
if (m_attached_device->minor() >= 64)
return String::format("ttyS%d", m_attached_device->minor() - 64);
return String::format("tty%d", m_attached_device->minor());
return String::formatted("ttyS{}", m_attached_device->minor() - 64);
return String::formatted("tty{}", m_attached_device->minor());
default:
ASSERT_NOT_REACHED();
@ -403,7 +403,7 @@ String DevFSDeviceInode::determine_name() const
} else {
switch (m_attached_device->major()) {
case 29:
return String::format("fb%d", m_attached_device->minor());
return String::formatted("fb{}", m_attached_device->minor());
case 3: {
size_t drive_index = (u8)'a' + m_attached_device->minor();
char drive_letter = (u8)drive_index;
@ -414,7 +414,7 @@ String DevFSDeviceInode::determine_name() const
// FIXME: Try to not hardcode a maximum of 16 partitions per drive!
size_t drive_index = (u8)'a' + (m_attached_device->minor() / 16);
char drive_letter = (u8)drive_index;
return String::format("hd%c%d", drive_letter, m_attached_device->minor() + 1);
return String::formatted("hd{:c}{}", drive_letter, m_attached_device->minor() + 1);
}
}

View file

@ -62,7 +62,7 @@ public:
return m_fsid != other.m_fsid || m_index != other.m_index;
}
String to_string() const { return String::format("%u:%u", m_fsid, m_index); }
String to_string() const { return String::formatted("{}:{}", m_fsid, m_index); }
private:
u32 m_fsid { 0 };

View file

@ -90,7 +90,7 @@ KResultOr<size_t> InodeWatcher::write(FileDescription&, size_t, const UserOrKern
String InodeWatcher::absolute_path(const FileDescription&) const
{
if (auto inode = m_inode.strong_ref())
return String::format("InodeWatcher:%s", inode->identifier().to_string().characters());
return String::formatted("InodeWatcher:{}", inode->identifier().to_string());
return "InodeWatcher:(gone)";
}

View file

@ -130,9 +130,6 @@ enum ProcFileType {
static inline ProcessID to_pid(const InodeIdentifier& identifier)
{
#ifdef PROCFS_DEBUG
dbg() << "to_pid, index=" << String::format("%08x", identifier.index()) << " -> " << (identifier.index() >> 16);
#endif
return identifier.index() >> 16u;
}
@ -800,9 +797,9 @@ static bool procfs$memstat(InodeIdentifier, KBufferBuilder& builder)
json.add("kmalloc_call_count", stats.kmalloc_call_count);
json.add("kfree_call_count", stats.kfree_call_count);
slab_alloc_stats([&json](size_t slab_size, size_t num_allocated, size_t num_free) {
auto prefix = String::format("slab_%zu", slab_size);
json.add(String::format("%s_num_allocated", prefix.characters()), num_allocated);
json.add(String::format("%s_num_free", prefix.characters()), num_free);
auto prefix = String::formatted("slab_{}", slab_size);
json.add(String::formatted("{}_num_allocated", prefix), num_allocated);
json.add(String::formatted("{}_num_free", prefix), num_free);
});
json.finish();
return true;
@ -1264,10 +1261,6 @@ InodeMetadata ProcFSInode::metadata() const
metadata.mode &= ~077;
}
}
#ifdef PROCFS_DEBUG
dbg() << "Returning mode " << String::format("%o", metadata.mode);
#endif
return metadata;
}