From e9f21a123611c1d3dcd26cb407d7eefcf165a770 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=9F=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=BE=D0=B2=20=5BArtyom=20Pavlov=5D?= Date: Wed, 9 Oct 2024 18:30:34 +0300 Subject: [PATCH] fix netbsd --- src/netbsd.rs | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/src/netbsd.rs b/src/netbsd.rs index 2842617b..2449b057 100644 --- a/src/netbsd.rs +++ b/src/netbsd.rs @@ -20,25 +20,17 @@ unsafe extern "C" fn polyfill_using_kern_arand( debug_assert_eq!(flags, 0); static MIB: [libc::c_int; 2] = [libc::CTL_KERN, libc::KERN_ARND]; + const MIB_LEN: libc::c_uint = MIB.len() as libc::c_uint; // NetBSD will only return up to 256 bytes at a time, and // older NetBSD kernels will fail on longer buffers. let mut len = cmp::min(buflen, 256); - let ret = unsafe { - libc::sysctl( - MIB.as_ptr(), - MIB.len() as libc::c_uint, - buf, - &mut len, - ptr::null(), - 0, - ) - }; + let ret = unsafe { libc::sysctl(MIB.as_ptr(), MIB_LEN, buf, &mut len, ptr::null(), 0) }; if ret == -1 { -1 } else { - len as libc::ssize_t + libc::ssize_t::try_from(len).expect("len is bounded by 256") } }