diff options
author | Andreas Kling <kling@serenityos.org> | 2021-01-20 23:11:17 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-01-20 23:20:02 +0100 |
commit | 19d3f8cab77a95b284e30f142521c6b483221324 (patch) | |
tree | 8df3f585e91113215b52d10a9a0032c9998dc1b5 /Kernel/FileSystem/TmpFS.cpp | |
parent | e279b45aed5509efc537fc8c831f40733d7b1028 (diff) | |
download | serenity-19d3f8cab77a95b284e30f142521c6b483221324.zip |
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.
Diffstat (limited to 'Kernel/FileSystem/TmpFS.cpp')
-rw-r--r-- | Kernel/FileSystem/TmpFS.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/Kernel/FileSystem/TmpFS.cpp b/Kernel/FileSystem/TmpFS.cpp index 207c18f657..ac8cef0605 100644 --- a/Kernel/FileSystem/TmpFS.cpp +++ b/Kernel/FileSystem/TmpFS.cpp @@ -134,7 +134,7 @@ KResult TmpFSInode::traverse_as_directory(Function<bool(const FS::DirectoryEntry LOCKER(m_lock, Lock::Mode::Shared); if (!is_directory()) - return KResult(-ENOTDIR); + return ENOTDIR; callback({ ".", identifier(), 0 }); callback({ "..", m_parent, 0 }); @@ -278,7 +278,7 @@ KResultOr<NonnullRefPtr<Inode>> TmpFSInode::create_child(const String& name, mod // TODO: Support creating devices on TmpFS. if (dev != 0) - return KResult(-ENOTSUP); + return ENOTSUP; struct timeval now; kgettimeofday(now); @@ -305,7 +305,7 @@ KResult TmpFSInode::add_child(Inode& child, const StringView& name, mode_t) ASSERT(child.fsid() == fsid()); if (name.length() > NAME_MAX) - return KResult(-ENAMETOOLONG); + return ENAMETOOLONG; m_children.set(name, { name, static_cast<TmpFSInode&>(child) }); did_add_child(child.identifier()); @@ -322,7 +322,7 @@ KResult TmpFSInode::remove_child(const StringView& name) auto it = m_children.find(name); if (it == m_children.end()) - return KResult(-ENOENT); + return ENOENT; auto child_id = it->value.inode->identifier(); m_children.remove(it); did_remove_child(child_id); @@ -339,7 +339,7 @@ KResult TmpFSInode::truncate(u64 size) else if (!m_content) { m_content = KBuffer::try_create_with_size(size); if (!m_content) - return KResult(-ENOMEM); + return ENOMEM; } else if (static_cast<size_t>(size) < m_content->capacity()) { size_t prev_size = m_metadata.size; m_content->set_size(size); @@ -349,7 +349,7 @@ KResult TmpFSInode::truncate(u64 size) size_t prev_size = m_metadata.size; auto tmp = KBuffer::try_create_with_size(size); if (!tmp) - return KResult(-ENOMEM); + return ENOMEM; memcpy(tmp->data(), m_content->data(), prev_size); m_content = move(tmp); } |