bolts: fix freebsd clippy warnings (#1442)

This commit is contained in:
David CARLIER 2023-08-23 00:32:34 +01:00 committed by GitHub
parent 0b43711dc9
commit 389c7c6554
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 5 deletions

View File

@ -662,8 +662,7 @@ mod freebsd {
#[allow(trivial_numeric_casts)] #[allow(trivial_numeric_casts)]
pub fn get_core_ids() -> Result<Vec<CoreId>, Error> { pub fn get_core_ids() -> Result<Vec<CoreId>, Error> {
Ok((0..(usize::from(available_parallelism()?))) Ok((0..(usize::from(available_parallelism()?)))
.into_iter() .map(CoreId)
.map(|n| CoreId(n))
.collect::<Vec<_>>()) .collect::<Vec<_>>())
} }

View File

@ -631,6 +631,7 @@ fn write_minibsod<W: Write>(writer: &mut BufWriter<W>) -> Result<(), std::io::Er
} }
#[cfg(any(target_os = "freebsd", target_os = "netbsd"))] #[cfg(any(target_os = "freebsd", target_os = "netbsd"))]
#[allow(clippy::cast_ptr_alignment)]
fn write_minibsod<W: Write>(writer: &mut BufWriter<W>) -> Result<(), std::io::Error> { fn write_minibsod<W: Write>(writer: &mut BufWriter<W>) -> Result<(), std::io::Error> {
let mut s: usize = 0; let mut s: usize = 0;
#[cfg(target_os = "freebsd")] #[cfg(target_os = "freebsd")]
@ -667,7 +668,10 @@ fn write_minibsod<W: Write>(writer: &mut BufWriter<W>) -> Result<(), std::io::Er
while start < end { while start < end {
let entry = start as *mut u8 as *mut libc::kinfo_vmentry; let entry = start as *mut u8 as *mut libc::kinfo_vmentry;
#[cfg(target_os = "freebsd")] #[cfg(target_os = "freebsd")]
let sz = (*entry).kve_structsize as usize; let sz: usize = (*entry)
.kve_structsize
.try_into()
.expect("invalid kve_structsize value");
#[cfg(target_os = "netbsd")] #[cfg(target_os = "netbsd")]
let sz = std::mem::size_of::<libc::kinfo_vmentry>(); let sz = std::mem::size_of::<libc::kinfo_vmentry>();
if sz == 0 { if sz == 0 {
@ -680,9 +684,9 @@ fn write_minibsod<W: Write>(writer: &mut BufWriter<W>) -> Result<(), std::io::Er
(*entry).kve_end, (*entry).kve_end,
(*entry).kve_path (*entry).kve_path
); );
writer.write(&i.into_bytes())?; writer.write_all(&i.into_bytes())?;
start = start + sz; start += sz;
} }
} }
} else { } else {