Guard debugging messages with the `debug-assertions` flag
@@ -644,7 +644,9 @@ impl FileSystem {
/// A rust-style base implementation for `fd_write`. It directly calls `fd_pwrite` with the
/// current `offset` of Fd `fd` and then calls `fd_seek`.
pub(crate) fn fd_write(&mut self, fd: Fd, buf: &[u8]) -> FileSystemResult<Size> {
- // Redirect writes to fd(0) and fd(1) to the host's stdout and stderr respectively
+ #[cfg(debug_assertions)]
+ {
+ // Redirect writes to stdout and stderr to the host's stdout and stderr respectively
if fd.0 == 0 || fd.0 == 1 {
let s = std::str::from_utf8(&buf).expect("Found invalid UTF-8");
print!("{}", s);
@@ -654,6 +656,7 @@ impl FileSystem {
eprint!("{}", s);
return Ok(buf.len() as u32)
}
+ }
self.check_right(&fd, Rights::FD_WRITE)?;
let offset = self.fd_table.get(&fd).ok_or(ErrNo::BadF)?.offset;
