From 19d3f8cab77a95b284e30f142521c6b483221324 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Wed, 20 Jan 2021 23:11:17 +0100 Subject: Kernel+LibC: Turn errno codes into a strongly typed enum ..and allow implicit creation of KResult and KResultOr from ErrnoCode. This means that kernel functions that return those types can finally do "return EINVAL;" and it will just work. There's a handful of functions that still deal with signed integers that should be converted to return KResults. --- Kernel/FileSystem/DevFS.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'Kernel/FileSystem/DevFS.cpp') diff --git a/Kernel/FileSystem/DevFS.cpp b/Kernel/FileSystem/DevFS.cpp index 123f5e45c8..149a73edb1 100644 --- a/Kernel/FileSystem/DevFS.cpp +++ b/Kernel/FileSystem/DevFS.cpp @@ -124,17 +124,17 @@ ssize_t DevFSInode::write_bytes(off_t, ssize_t, const UserOrKernelBuffer&, FileD KResultOr> DevFSInode::create_child(const String&, mode_t, dev_t, uid_t, gid_t) { - return KResult(-EROFS); + return EROFS; } KResult DevFSInode::add_child(Inode&, const StringView&, mode_t) { - return KResult(-EROFS); + return EROFS; } KResult DevFSInode::remove_child(const StringView&) { - return KResult(-EROFS); + return EROFS; } KResultOr DevFSInode::directory_entry_count() const @@ -144,17 +144,17 @@ KResultOr DevFSInode::directory_entry_count() const KResult DevFSInode::chmod(mode_t) { - return KResult(-EPERM); + return EPERM; } KResult DevFSInode::chown(uid_t, gid_t) { - return KResult(-EPERM); + return EPERM; } KResult DevFSInode::truncate(u64) { - return KResult(-EPERM); + return EPERM; } String DevFSLinkInode::name() const @@ -221,7 +221,7 @@ InodeMetadata DevFSDirectoryInode::metadata() const KResult DevFSDirectoryInode::traverse_as_directory(Function) const { LOCKER(m_lock); - return KResult(-EINVAL); + return EINVAL; } RefPtr DevFSDirectoryInode::lookup(StringView) { @@ -288,10 +288,10 @@ KResultOr> DevFSRootDirectoryInode::create_child(const Stri if (metadata.is_directory()) { for (auto& folder : m_subfolders) { if (folder.name() == name) - return KResult(-EEXIST); + return EEXIST; } if (name != "pts") - return KResult(-EROFS); + return EROFS; auto new_directory_inode = adopt(*new DevFSPtsDirectoryInode(m_parent_fs)); m_subfolders.append(new_directory_inode); m_parent_fs.m_nodes.append(new_directory_inode); @@ -300,7 +300,7 @@ KResultOr> DevFSRootDirectoryInode::create_child(const Stri if (metadata.is_symlink()) { for (auto& link : m_links) { if (link.name() == name) - return KResult(-EEXIST); + return EEXIST; } dbgln("DevFS: Success on create new symlink"); auto new_link_inode = adopt(*new DevFSLinkInode(m_parent_fs, name)); @@ -308,7 +308,7 @@ KResultOr> DevFSRootDirectoryInode::create_child(const Stri m_parent_fs.m_nodes.append(new_link_inode); return new_link_inode; } - return KResult(-EROFS); + return EROFS; } DevFSRootDirectoryInode::~DevFSRootDirectoryInode() -- cgit v1.2.3