Skip to content

Commit 47b99eb

Browse files
committed
fix: clippy
1 parent 03dd81e commit 47b99eb

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

crates/libs/kill_tree/src/macos.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,18 +47,25 @@ pub(crate) async fn get_process_info(process_id: ProcessId) -> Option<ProcessInf
4747

4848
#[instrument]
4949
pub(crate) async fn get_process_infos() -> common::Result<ProcessInfos> {
50-
let buffer_size =
50+
let buffer_size_sign =
5151
unsafe { libproc::proc_listpids(libproc::PROC_ALL_PIDS, 0_u32, ptr::null_mut(), 0) };
52-
if buffer_size <= 0 {
52+
if buffer_size_sign <= 0 {
5353
return Err(io::Error::last_os_error().into());
5454
}
55-
let mut buffer = vec![0; buffer_size as usize];
55+
let buffer_size = match usize::try_from(buffer_size_sign) {
56+
Ok(x) => x,
57+
Err(e) => {
58+
debug!(error = ?e, "failed to convert buffer size");
59+
return Err(e.into());
60+
}
61+
};
62+
let mut buffer = vec![0; buffer_size];
5663
let result = unsafe {
5764
libproc::proc_listpids(
5865
libproc::PROC_ALL_PIDS,
5966
0_u32,
6067
buffer.as_mut_ptr().cast(),
61-
buffer_size,
68+
buffer_size_sign,
6269
)
6370
};
6471
if result <= 0 {

0 commit comments

Comments
 (0)