1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 02:47:35 +00:00

Kernel: Remove the KString::try_create(String::formatted(...)) pattern

We can now directly create formatted KStrings with KString::formatted.

:^)
This commit is contained in:
Daniel Bertalan 2021-12-28 09:38:41 +01:00 committed by Brian Gianforcaro
parent 7d6058415e
commit 52beeebe70
11 changed files with 18 additions and 35 deletions

View file

@ -18,8 +18,7 @@ namespace Kernel {
ErrorOr<NonnullRefPtr<MasterPTY>> MasterPTY::try_create(unsigned int index)
{
// FIXME: Don't make a temporary String here
auto pts_name = TRY(KString::try_create(String::formatted("/dev/pts/{}", index)));
auto pts_name = TRY(KString::formatted("/dev/pts/{}", index));
auto tty_name = TRY(pts_name->try_clone());
auto buffer = TRY(DoubleBuffer::try_create());
@ -133,8 +132,7 @@ ErrorOr<void> MasterPTY::ioctl(OpenFileDescription& description, unsigned reques
ErrorOr<NonnullOwnPtr<KString>> MasterPTY::pseudo_path(const OpenFileDescription&) const
{
// FIXME: Replace this and others of this pattern by KString::formatted()
return KString::try_create(String::formatted("ptm:{}", m_pts_name));
return KString::formatted("ptm:{}", m_pts_name);
}
}

View file

@ -103,10 +103,7 @@ void VirtualConsole::set_graphical(bool graphical)
UNMAP_AFTER_INIT NonnullRefPtr<VirtualConsole> VirtualConsole::create(size_t index)
{
// FIXME: Don't make a temporary String here
auto pts_name_or_error = KString::try_create(String::formatted("/dev/tty/{}", index));
VERIFY(!pts_name_or_error.is_error());
auto pts_name = pts_name_or_error.release_value();
auto pts_name = MUST(KString::formatted("/dev/tty/{}", index));
auto virtual_console_or_error = DeviceManagement::try_create_device<VirtualConsole>(index, move(pts_name));
// FIXME: Find a way to propagate errors