@@ -190,7 +190,7 @@ cfg_if! {
190190 /// Unix credentials of the sending process.
191191 ///
192192 /// This struct is used with the `SO_PEERCRED` ancillary message for UNIX sockets.
193- #[ repr( C ) ]
193+ #[ repr( transparent ) ]
194194 #[ derive( Clone , Copy , Debug , Eq , PartialEq ) ]
195195 pub struct UnixCredentials ( libc:: ucred) ;
196196
@@ -368,7 +368,7 @@ pub enum ControlMessageOwned {
368368 /// Received version of
369369 /// [`ControlMessage::ScmCredentials`][#enum.ControlMessage.html#variant.ScmCredentials]
370370 #[ cfg( any( target_os = "android" , target_os = "linux" ) ) ]
371- ScmCredentials ( libc :: ucred ) ,
371+ ScmCredentials ( UnixCredentials ) ,
372372 /// A message of type `SCM_TIMESTAMP`, containing the time the
373373 /// packet was received by the kernel.
374374 ///
@@ -496,7 +496,7 @@ impl ControlMessageOwned {
496496 #[ cfg( any( target_os = "android" , target_os = "linux" ) ) ]
497497 ( libc:: SOL_SOCKET , libc:: SCM_CREDENTIALS ) => {
498498 let cred: libc:: ucred = ptr:: read_unaligned ( p as * const _ ) ;
499- ControlMessageOwned :: ScmCredentials ( cred)
499+ ControlMessageOwned :: ScmCredentials ( cred. into ( ) )
500500 }
501501 ( libc:: SOL_SOCKET , libc:: SCM_TIMESTAMP ) => {
502502 let tv: libc:: timeval = ptr:: read_unaligned ( p as * const _ ) ;
@@ -584,10 +584,8 @@ pub enum ControlMessage<'a> {
584584 ///
585585 /// For further information, please refer to the
586586 /// [`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.
589587 #[ cfg( any( target_os = "android" , target_os = "linux" ) ) ]
590- ScmCredentials ( & ' a libc :: ucred ) ,
588+ ScmCredentials ( & ' a UnixCredentials ) ,
591589
592590 /// Set IV for `AF_ALG` crypto API.
593591 ///
@@ -655,7 +653,7 @@ impl<'a> ControlMessage<'a> {
655653 } ,
656654 #[ cfg( any( target_os = "android" , target_os = "linux" ) ) ]
657655 ControlMessage :: ScmCredentials ( creds) => {
658- creds as * const libc:: ucred as * const u8
656+ & creds. 0 as * const libc:: ucred as * const u8
659657 }
660658 #[ cfg( any( target_os = "android" , target_os = "linux" ) ) ]
661659 ControlMessage :: AlgSetIv ( iv) => {
0 commit comments