From 1101994fadaf0d2f7a5ed20a8b5a1dfbf47890ae Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Mon, 6 Sep 2021 20:28:40 +0200 Subject: Kernel: Wrap ISO9660FS directory traversal in TRY() --- Kernel/FileSystem/ISO9660FileSystem.cpp | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) (limited to 'Kernel/FileSystem/ISO9660FileSystem.cpp') 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 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> ISO9660Inode::lookup(StringView name) @@ -498,7 +488,7 @@ KResultOr> ISO9660Inode::lookup(StringView name) RefPtr inode; Array 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> ISO9660Inode::lookup(StringView name) } return RecursionDecision::Continue; - }); - - if (traversal_result.is_error()) - return traversal_result; + })); if (!inode) return ENOENT; -- cgit v1.2.3