various: fix clippy lints

Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: Icbd2ba104c66907208cb37adf0c3915a6a6a6964
This commit is contained in:
raf 2026-03-25 17:08:06 +03:00
commit 0c294d348b
Signed by: NotAShelf
GPG key ID: 29D95B64378DB4BF
2 changed files with 7 additions and 5 deletions

View file

@ -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")

View file

@ -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()?;