From 6bcde0dcf44c30a532ba42730e97ced3781f9f6e Mon Sep 17 00:00:00 2001 From: Sam Atkins Date: Fri, 17 Mar 2023 16:04:19 +0000 Subject: [PATCH] LibCore: Don't record false DirIterator errors `readdir()` returns null if there is an error, OR if we reached the end. We don't need to create an Error if there wasn't one. --- Userland/Libraries/LibCore/DirIterator.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Userland/Libraries/LibCore/DirIterator.cpp b/Userland/Libraries/LibCore/DirIterator.cpp index c9a09d9e80e..0eefc9311eb 100644 --- a/Userland/Libraries/LibCore/DirIterator.cpp +++ b/Userland/Libraries/LibCore/DirIterator.cpp @@ -48,7 +48,10 @@ bool DirIterator::advance_next() errno = 0; auto* de = readdir(m_dir); if (!de) { - m_error = Error::from_errno(errno); + if (errno != 0) { + m_error = Error::from_errno(errno); + dbgln("DirIteration error: {}", m_error.value()); + } m_next.clear(); return false; }