mirror of
https://github.com/NotAShelf/microfetch.git
synced 2026-04-12 12:57:41 +00:00
various: fix clippy lints
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: Icbd2ba104c66907208cb37adf0c3915a6a6a6964
This commit is contained in:
parent
a798c5d3e8
commit
0c294d348b
2 changed files with 7 additions and 5 deletions
|
|
@ -99,12 +99,14 @@ fn print_system_info(
|
|||
{blue} ▟█▘ ▜█▖ {cyan}▝█▛ {cyan} {blue}Colors{reset} {colors}\n\n"
|
||||
)?;
|
||||
|
||||
let len = cursor.position() as usize;
|
||||
let len =
|
||||
usize::try_from(cursor.position()).expect("cursor position fits usize");
|
||||
// Direct syscall to avoid stdout buffering allocation
|
||||
let written = unsafe { syscall::sys_write(1, buf.as_ptr(), len) };
|
||||
if written < 0 {
|
||||
return Err(io::Error::last_os_error().into());
|
||||
}
|
||||
#[allow(clippy::cast_sign_loss)] // non-negative verified by the guard above
|
||||
if written as usize != len {
|
||||
return Err(
|
||||
io::Error::new(io::ErrorKind::WriteZero, "partial write to stdout")
|
||||
|
|
|
|||
|
|
@ -157,12 +157,12 @@ pub fn get_memory_usage() -> Result<String, io::Error> {
|
|||
}
|
||||
|
||||
#[allow(clippy::cast_precision_loss)]
|
||||
let total_memory_gb = total_memory_kb as f64 / 1024.0 / 1024.0;
|
||||
let total_gb = total_memory_kb as f64 / 1024.0 / 1024.0;
|
||||
#[allow(clippy::cast_precision_loss)]
|
||||
let available_memory_gb = available_memory_kb as f64 / 1024.0 / 1024.0;
|
||||
let used_memory_gb = total_memory_gb - available_memory_gb;
|
||||
let available_gb = available_memory_kb as f64 / 1024.0 / 1024.0;
|
||||
let used_memory_gb = total_gb - available_gb;
|
||||
|
||||
Ok((used_memory_gb, total_memory_gb))
|
||||
Ok((used_memory_gb, total_gb))
|
||||
}
|
||||
|
||||
let (used_memory, total_memory) = parse_memory_info()?;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue