Skip to content

Commit 7f4c3fe

Browse files
authored
Fix no-std builds for MacOS and BSDs (#647)
* Fix no-std builds for MacOS and BSDs * Fix unused mut warning and tighten unsafe block
1 parent f78803c commit 7f4c3fe

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

src/net/send_recv/msg.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -168,14 +168,12 @@ impl<'buf, 'slice, 'fd> SendAncillaryBuffer<'buf, 'slice, 'fd> {
168168
self.length = new_length;
169169

170170
// Get the last header in the buffer.
171-
let mut last_header = leap!(messages::Messages::new(buffer).last());
171+
let last_header = leap!(messages::Messages::new(buffer).last());
172172

173173
// Set the header fields.
174-
unsafe {
175-
last_header.cmsg_len = c::CMSG_LEN(source_len) as _;
176-
last_header.cmsg_level = cmsg_level;
177-
last_header.cmsg_type = cmsg_type;
178-
}
174+
last_header.cmsg_len = unsafe { c::CMSG_LEN(source_len) } as _;
175+
last_header.cmsg_level = cmsg_level;
176+
last_header.cmsg_type = cmsg_type;
179177

180178
// Get the pointer to the payload and copy the data.
181179
unsafe {

src/process/procctl.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
66
#![allow(unsafe_code)]
77

8+
use alloc::vec::Vec;
89
use core::mem::MaybeUninit;
910
use core::ptr;
1011

@@ -329,7 +330,7 @@ pub fn get_reaper_pids(process: ProcSelector) -> io::Result<Vec<PidInfo>> {
329330
// Sadly no better way to guarantee that we get all the results than to
330331
// allocate ~8MB of memory..
331332
const PID_MAX: usize = 99999;
332-
let mut pids: Vec<procctl_reaper_pidinfo> = vec![Default::default(); PID_MAX];
333+
let mut pids: Vec<procctl_reaper_pidinfo> = alloc::vec![Default::default(); PID_MAX];
333334
let mut pinfo = procctl_reaper_pids {
334335
rp_count: PID_MAX as _,
335336
rp_pad0: [0; 15],

src/process/wait.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ pub enum WaitId<'a> {
256256
/// Eat the lifetime for non-Linux platforms.
257257
#[doc(hidden)]
258258
#[cfg(not(target_os = "linux"))]
259-
__EatLifetime(std::marker::PhantomData<&'a ()>),
259+
__EatLifetime(core::marker::PhantomData<&'a ()>),
260260
// TODO(notgull): Once this crate has the concept of PGIDs, add a WaitId::Pgid
261261
}
262262

0 commit comments

Comments
 (0)