@@ -46,7 +46,7 @@ use std::{io, slice};
46
46
47
47
#[ cfg( not( target_vendor = "apple" ) ) ]
48
48
use libc:: ssize_t;
49
- use libc:: { c_void , in6_addr, in_addr} ;
49
+ use libc:: { in6_addr, in_addr} ;
50
50
51
51
#[ cfg( not( target_os = "redox" ) ) ]
52
52
use crate :: RecvFlags ;
@@ -458,8 +458,7 @@ pub(crate) fn unix_sockaddr(path: &Path) -> io::Result<SockAddr> {
458
458
// SAFETY: a `sockaddr_storage` of all zeros is valid.
459
459
let mut storage = unsafe { mem:: zeroed :: < sockaddr_storage > ( ) } ;
460
460
let len = {
461
- let storage: & mut libc:: sockaddr_un =
462
- unsafe { & mut * ( & mut storage as * mut sockaddr_storage ) . cast ( ) } ;
461
+ let storage = unsafe { & mut * ptr:: addr_of_mut!( storage) . cast :: < libc:: sockaddr_un > ( ) } ;
463
462
464
463
let bytes = path. as_os_str ( ) . as_bytes ( ) ;
465
464
let too_long = match bytes. first ( ) {
@@ -483,13 +482,13 @@ pub(crate) fn unix_sockaddr(path: &Path) -> io::Result<SockAddr> {
483
482
unsafe {
484
483
ptr:: copy_nonoverlapping (
485
484
bytes. as_ptr ( ) ,
486
- storage. sun_path . as_mut_ptr ( ) as * mut u8 ,
485
+ storage. sun_path . as_mut_ptr ( ) . cast ( ) ,
487
486
bytes. len ( ) ,
488
487
)
489
488
} ;
490
489
491
490
let base = storage as * const _ as usize ;
492
- let path = & storage. sun_path as * const _ as usize ;
491
+ let path = ptr :: addr_of! ( storage. sun_path) as usize ;
493
492
let sun_path_offset = path - base;
494
493
sun_path_offset
495
494
+ bytes. len ( )
@@ -955,7 +954,7 @@ pub(crate) unsafe fn setsockopt<T>(
955
954
val : c_int ,
956
955
payload : T ,
957
956
) -> io:: Result < ( ) > {
958
- let payload = & payload as * const T as * const c_void ;
957
+ let payload = ptr :: addr_of! ( payload) . cast ( ) ;
959
958
syscall ! ( setsockopt(
960
959
fd,
961
960
opt,
0 commit comments