Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kmc-solid: Handle errors returned by SOLID_FS_ReadDir #103005

Merged
merged 1 commit into from
Oct 24, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions library/std/src/sys/solid/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,15 +175,19 @@ impl Iterator for ReadDir {
type Item = io::Result<DirEntry>;

fn next(&mut self) -> Option<io::Result<DirEntry>> {
unsafe {
let mut out_dirent = MaybeUninit::uninit();
error::SolidError::err_if_negative(abi::SOLID_FS_ReadDir(
let entry = unsafe {
let mut out_entry = MaybeUninit::uninit();
match error::SolidError::err_if_negative(abi::SOLID_FS_ReadDir(
self.inner.dirp,
out_dirent.as_mut_ptr(),
))
.ok()?;
Some(Ok(DirEntry { entry: out_dirent.assume_init(), inner: Arc::clone(&self.inner) }))
}
out_entry.as_mut_ptr(),
)) {
Ok(_) => out_entry.assume_init(),
Err(e) if e.as_raw() == abi::SOLID_ERR_NOTFOUND => return None,
Err(e) => return Some(Err(e.as_io_error())),
}
};

(entry.d_name[0] != 0).then(|| Ok(DirEntry { entry, inner: Arc::clone(&self.inner) }))
}
}

Expand Down