1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 04:48:14 +00:00

Kernel: Make KString factories return KResultOr + use TRY() everywhere

There are a number of places that don't have an error propagation path
right now, so I've added FIXME's about that.
This commit is contained in:
Andreas Kling 2021-09-06 19:24:54 +02:00
parent 69b9b2888c
commit 56a2594de7
21 changed files with 100 additions and 122 deletions

View file

@ -21,11 +21,10 @@ DevFS::DevFS()
void DevFS::notify_new_device(Device& device)
{
auto name = KString::try_create(device.device_name());
VERIFY(name);
// FIXME: Handle KString allocation failure.
auto name = KString::try_create(device.device_name()).release_value();
MutexLocker locker(m_lock);
auto new_device_inode = adopt_ref(*new DevFSDeviceInode(*this, device, name.release_nonnull()));
auto new_device_inode = adopt_ref(*new DevFSDeviceInode(*this, device, move(name)));
m_nodes.append(new_device_inode);
m_root_inode->m_devices.append(new_device_inode);
}
@ -276,10 +275,8 @@ KResultOr<NonnullRefPtr<Inode>> DevFSRootDirectoryInode::create_child(StringView
if (link.name() == name)
return EEXIST;
}
auto name_kstring = KString::try_create(name);
if (!name_kstring)
return ENOMEM;
auto new_link_inode = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) DevFSLinkInode(fs(), name_kstring.release_nonnull())));
auto name_kstring = TRY(KString::try_create(name));
auto new_link_inode = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) DevFSLinkInode(fs(), move(name_kstring))));
if (!m_links.try_ensure_capacity(m_links.size() + 1))
return ENOMEM;
if (!fs().m_nodes.try_ensure_capacity(fs().m_nodes.size() + 1))