Skip to content

Commit f7ce988

Browse files
committed
Allow cmsg_space! to be used in unit tests
1 parent fde9ebc commit f7ce988

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/sys/socket/mod.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -415,13 +415,11 @@ impl Ipv6MembershipRequest {
415415
macro_rules! cmsg_space {
416416
( $( $x:ty ),* ) => {
417417
{
418-
use nix::sys::socket::{c_uint, CMSG_SPACE};
419-
use std::mem;
420418
let mut space = 0;
421419
$(
422420
// CMSG_SPACE is always safe
423421
space += unsafe {
424-
CMSG_SPACE(mem::size_of::<$x>() as c_uint)
422+
$crate::sys::socket::CMSG_SPACE(::std::mem::size_of::<$x>() as $crate::sys::socket::c_uint)
425423
} as usize;
426424
)*
427425
Vec::<u8>::with_capacity(space)
@@ -1789,3 +1787,11 @@ pub fn shutdown(df: RawFd, how: Shutdown) -> Result<()> {
17891787
Errno::result(shutdown(df, how)).map(drop)
17901788
}
17911789
}
1790+
1791+
#[cfg(test)]
1792+
mod tests {
1793+
#[test]
1794+
fn can_use_cmsg_space() {
1795+
let _ = cmsg_space!(u8);
1796+
}
1797+
}

0 commit comments

Comments
 (0)