@@ -190,7 +190,7 @@ cfg_if! {
190
190
/// Unix credentials of the sending process.
191
191
///
192
192
/// This struct is used with the `SO_PEERCRED` ancillary message for UNIX sockets.
193
- #[ repr( C ) ]
193
+ #[ repr( transparent ) ]
194
194
#[ derive( Clone , Copy , Debug , Eq , PartialEq ) ]
195
195
pub struct UnixCredentials ( libc:: ucred) ;
196
196
@@ -368,7 +368,7 @@ pub enum ControlMessageOwned {
368
368
/// Received version of
369
369
/// [`ControlMessage::ScmCredentials`][#enum.ControlMessage.html#variant.ScmCredentials]
370
370
#[ cfg( any( target_os = "android" , target_os = "linux" ) ) ]
371
- ScmCredentials ( libc :: ucred ) ,
371
+ ScmCredentials ( UnixCredentials ) ,
372
372
/// A message of type `SCM_TIMESTAMP`, containing the time the
373
373
/// packet was received by the kernel.
374
374
///
@@ -496,7 +496,7 @@ impl ControlMessageOwned {
496
496
#[ cfg( any( target_os = "android" , target_os = "linux" ) ) ]
497
497
( libc:: SOL_SOCKET , libc:: SCM_CREDENTIALS ) => {
498
498
let cred: libc:: ucred = ptr:: read_unaligned ( p as * const _ ) ;
499
- ControlMessageOwned :: ScmCredentials ( cred)
499
+ ControlMessageOwned :: ScmCredentials ( cred. into ( ) )
500
500
}
501
501
( libc:: SOL_SOCKET , libc:: SCM_TIMESTAMP ) => {
502
502
let tv: libc:: timeval = ptr:: read_unaligned ( p as * const _ ) ;
@@ -584,10 +584,8 @@ pub enum ControlMessage<'a> {
584
584
///
585
585
/// For further information, please refer to the
586
586
/// [`unix(7)`](http://man7.org/linux/man-pages/man7/unix.7.html) man page.
587
- // FIXME: When `#[repr(transparent)]` is stable, use it on `UnixCredentials`
588
- // and put that in here instead of a raw ucred.
589
587
#[ cfg( any( target_os = "android" , target_os = "linux" ) ) ]
590
- ScmCredentials ( & ' a libc :: ucred ) ,
588
+ ScmCredentials ( & ' a UnixCredentials ) ,
591
589
592
590
/// Set IV for `AF_ALG` crypto API.
593
591
///
@@ -655,7 +653,7 @@ impl<'a> ControlMessage<'a> {
655
653
} ,
656
654
#[ cfg( any( target_os = "android" , target_os = "linux" ) ) ]
657
655
ControlMessage :: ScmCredentials ( creds) => {
658
- creds as * const libc:: ucred as * const u8
656
+ & creds. 0 as * const libc:: ucred as * const u8
659
657
}
660
658
#[ cfg( any( target_os = "android" , target_os = "linux" ) ) ]
661
659
ControlMessage :: AlgSetIv ( iv) => {
0 commit comments