Simplify file descriptor clamping
@@ -293,10 +293,10 @@ impl FileSystem {
/// Pick a new fd randomly.
fn new_fd(&self) -> FileSystemResult<Fd> {
loop {
- let new_fd: Fd = self.random_u32()?.into();
+ let new_fd = self.random_u32()?;
// Set upper limit to 2**31 - 1 (WASI requirement)
- let new_fd = Fd(new_fd.0 >> 1);
+ let new_fd = (new_fd >> 1).into();
if !self.fd_table.contains_key(&new_fd) {
return Ok(new_fd);
