diff options
author | Andreas Kling <kling@serenityos.org> | 2021-09-06 20:28:40 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-09-06 20:28:40 +0200 |
commit | 1101994fadaf0d2f7a5ed20a8b5a1dfbf47890ae (patch) | |
tree | ebc754aae68f6e223da6e559fb8cda6bc4a727a5 /Kernel/FileSystem/ISO9660FileSystem.cpp | |
parent | a2bf8244fe140e39006e0022d55027aaf95225de (diff) | |
download | serenity-1101994fadaf0d2f7a5ed20a8b5a1dfbf47890ae.zip |
Kernel: Wrap ISO9660FS directory traversal in TRY()
Diffstat (limited to 'Kernel/FileSystem/ISO9660FileSystem.cpp')
-rw-r--r-- | Kernel/FileSystem/ISO9660FileSystem.cpp | 23 |
1 files changed, 5 insertions, 18 deletions
diff --git a/Kernel/FileSystem/ISO9660FileSystem.cpp b/Kernel/FileSystem/ISO9660FileSystem.cpp index 650c18e3c8..4024fa139c 100644 --- a/Kernel/FileSystem/ISO9660FileSystem.cpp +++ b/Kernel/FileSystem/ISO9660FileSystem.cpp @@ -305,7 +305,7 @@ KResult ISO9660FS::calculate_inode_count() const size_t inode_count = 1; - auto traversal_result = visit_directory_record(m_primary_volume->root_directory_record_header, [&](ISO::DirectoryRecordHeader const* header) { + TRY(visit_directory_record(m_primary_volume->root_directory_record_header, [&](ISO::DirectoryRecordHeader const* header) { if (header == nullptr) { return RecursionDecision::Continue; } @@ -324,12 +324,7 @@ KResult ISO9660FS::calculate_inode_count() const } return RecursionDecision::Continue; - }); - - if (traversal_result.is_error()) { - dbgln_if(ISO9660_DEBUG, "Failed to traverse for caching inode count!"); - return traversal_result; - } + })); m_cached_inode_count = inode_count; return KSuccess; @@ -473,7 +468,7 @@ KResult ISO9660Inode::traverse_as_directory(Function<bool(FileSystem::DirectoryE { Array<u8, max_file_identifier_length> file_identifier_buffer; - auto traversal_result = fs().visit_directory_record(m_record, [&](ISO::DirectoryRecordHeader const* record) { + return fs().visit_directory_record(m_record, [&](ISO::DirectoryRecordHeader const* record) { StringView filename = get_normalized_filename(*record, file_identifier_buffer); dbgln_if(ISO9660_VERY_DEBUG, "traverse_as_directory(): Found {}", filename); @@ -486,11 +481,6 @@ KResult ISO9660Inode::traverse_as_directory(Function<bool(FileSystem::DirectoryE return RecursionDecision::Continue; }); - - if (traversal_result.is_error()) - return traversal_result; - - return KSuccess; } KResultOr<NonnullRefPtr<Inode>> ISO9660Inode::lookup(StringView name) @@ -498,7 +488,7 @@ KResultOr<NonnullRefPtr<Inode>> ISO9660Inode::lookup(StringView name) RefPtr<Inode> inode; Array<u8, max_file_identifier_length> file_identifier_buffer; - auto traversal_result = fs().visit_directory_record(m_record, [&](ISO::DirectoryRecordHeader const* record) { + TRY(fs().visit_directory_record(m_record, [&](ISO::DirectoryRecordHeader const* record) { StringView filename = get_normalized_filename(*record, file_identifier_buffer); if (filename == name) { @@ -516,10 +506,7 @@ KResultOr<NonnullRefPtr<Inode>> ISO9660Inode::lookup(StringView name) } return RecursionDecision::Continue; - }); - - if (traversal_result.is_error()) - return traversal_result; + })); if (!inode) return ENOENT; |