diff options
author | Andreas Kling <kling@serenityos.org> | 2021-09-06 20:30:18 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-09-06 20:30:18 +0200 |
commit | 0d44cdb7a21bdc845aef3363a92e61d280d3758d (patch) | |
tree | 88ab2b208594c537f09db2e1a424d6c5176101db | |
parent | 1101994fadaf0d2f7a5ed20a8b5a1dfbf47890ae (diff) | |
download | serenity-0d44cdb7a21bdc845aef3363a92e61d280d3758d.zip |
Kernel: Wrap two VirtualFileSystem directory traversals in TRY()
-rw-r--r-- | Kernel/FileSystem/VirtualFileSystem.cpp | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/Kernel/FileSystem/VirtualFileSystem.cpp b/Kernel/FileSystem/VirtualFileSystem.cpp index a0a9756633..0135af8c3b 100644 --- a/Kernel/FileSystem/VirtualFileSystem.cpp +++ b/Kernel/FileSystem/VirtualFileSystem.cpp @@ -462,12 +462,10 @@ KResult VirtualFileSystem::rename(StringView old_path, StringView new_path, Cust if (old_inode.index() != new_inode.index() && old_inode.is_directory() && new_inode.is_directory()) { size_t child_count = 0; - auto traversal_result = new_inode.traverse_as_directory([&child_count](auto&) { + TRY(new_inode.traverse_as_directory([&child_count](auto&) { ++child_count; return child_count <= 2; - }); - if (traversal_result.is_error()) - return traversal_result; + })); if (child_count > 2) return ENOTEMPTY; } @@ -707,12 +705,10 @@ KResult VirtualFileSystem::rmdir(StringView path, Custody& base) } size_t child_count = 0; - auto traversal_result = inode.traverse_as_directory([&child_count](auto&) { + TRY(inode.traverse_as_directory([&child_count](auto&) { ++child_count; return true; - }); - if (traversal_result.is_error()) - return traversal_result; + })); if (child_count != 2) return ENOTEMPTY; |