mirror of
https://github.com/NotAShelf/microfetch.git
synced 2026-04-18 23:49:53 +00:00
system: use std::env::var_os over libc helpers
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: I2747d4b065095314a1d454a204a251c96a6a6964
This commit is contained in:
parent
17cd7530d6
commit
99e033c415
2 changed files with 27 additions and 25 deletions
|
|
@ -101,12 +101,15 @@ fn print_system_info(
|
|||
|
||||
let len = cursor.position() as usize;
|
||||
// Direct syscall to avoid stdout buffering allocation
|
||||
let written = unsafe { libc::write(libc::STDOUT_FILENO, buf.as_ptr().cast(), len) };
|
||||
let written = unsafe { syscall::sys_write(1, buf.as_ptr(), len) };
|
||||
if written < 0 {
|
||||
return Err(io::Error::last_os_error().into());
|
||||
}
|
||||
if written as usize != len {
|
||||
return Err(io::Error::new(io::ErrorKind::WriteZero, "partial write to stdout").into());
|
||||
return Err(
|
||||
io::Error::new(io::ErrorKind::WriteZero, "partial write to stdout")
|
||||
.into(),
|
||||
);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue