Kernel: Fix TmpFS directory entry enumeration early return

This commit is contained in:
Bananymous 2023-11-06 21:06:10 +02:00
parent 181d139c7d
commit e33b3bcdff
1 changed files with 4 additions and 2 deletions

View File

@ -394,7 +394,8 @@ namespace Kernel
template<TmpFuncs::for_each_entry_callback F> template<TmpFuncs::for_each_entry_callback F>
void TmpDirectoryInode::for_each_entry(F callback) void TmpDirectoryInode::for_each_entry(F callback)
{ {
for (size_t data_block_index = 0; data_block_index * blksize() < (size_t)size(); data_block_index++) bool done = false;
for (size_t data_block_index = 0; !done && data_block_index * blksize() < (size_t)size(); data_block_index++)
{ {
const size_t block_index = this->block_index(data_block_index).value(); const size_t block_index = this->block_index(data_block_index).value();
const size_t byte_count = BAN::Math::min<size_t>(size() - data_block_index * blksize(), blksize()); const size_t byte_count = BAN::Math::min<size_t>(size() - data_block_index * blksize(), blksize());
@ -403,12 +404,13 @@ namespace Kernel
bytespan = bytespan.slice(0, byte_count); bytespan = bytespan.slice(0, byte_count);
while (bytespan.size() > 0) while (bytespan.size() > 0)
{ {
const auto& entry = bytespan.as<TmpDirectoryEntry>(); auto& entry = bytespan.as<TmpDirectoryEntry>();
switch (callback(entry)) switch (callback(entry))
{ {
case BAN::Iteration::Continue: case BAN::Iteration::Continue:
break; break;
case BAN::Iteration::Break: case BAN::Iteration::Break:
done = true;
return; return;
default: default:
ASSERT_NOT_REACHED(); ASSERT_NOT_REACHED();