@@ -16,9 +16,7 @@ use std::io;
1616
1717fn syscall_getrandom ( dest : & mut [ u8 ] , block : bool ) -> Result < usize , io:: Error > {
1818 let flags = if block { 0 } else { libc:: GRND_NONBLOCK } ;
19- let ret = unsafe {
20- libc:: syscall ( libc:: SYS_getrandom , dest. as_mut_ptr ( ) , dest. len ( ) , flags)
21- } ;
19+ let ret = unsafe { libc:: syscall ( libc:: SYS_getrandom , dest. as_mut_ptr ( ) , dest. len ( ) , flags) } ;
2220 if ret < 0 {
2321 let err = io:: Error :: last_os_error ( ) ;
2422 if err. raw_os_error ( ) == Some ( libc:: EINTR ) {
@@ -31,15 +29,17 @@ fn syscall_getrandom(dest: &mut [u8], block: bool) -> Result<usize, io::Error> {
3129}
3230
3331pub fn getrandom_inner ( dest : & mut [ u8 ] ) -> Result < ( ) , Error > {
34- lazy_static ! { static ref HAS_GETRANDOM : bool = is_getrandom_available( ) ; }
32+ lazy_static ! {
33+ static ref HAS_GETRANDOM : bool = is_getrandom_available( ) ;
34+ }
3535 match * HAS_GETRANDOM {
3636 true => {
3737 let mut start = 0 ;
3838 while start < dest. len ( ) {
3939 start += syscall_getrandom ( & mut dest[ start..] , true ) ?;
4040 }
4141 Ok ( ( ) )
42- } ,
42+ }
4343 false => use_file:: getrandom_inner ( dest) ,
4444 }
4545}
@@ -48,12 +48,14 @@ fn is_getrandom_available() -> bool {
4848 match syscall_getrandom ( & mut [ ] , false ) {
4949 Err ( err) => match err. raw_os_error ( ) {
5050 Some ( libc:: ENOSYS ) => false , // No kernel support
51- Some ( libc:: EPERM ) => false , // Blocked by seccomp
51+ Some ( libc:: EPERM ) => false , // Blocked by seccomp
5252 _ => true ,
53- }
53+ } ,
5454 Ok ( _) => true ,
5555 }
5656}
5757
5858#[ inline( always) ]
59- pub fn error_msg_inner ( _: NonZeroU32 ) -> Option < & ' static str > { None }
59+ pub fn error_msg_inner ( _: NonZeroU32 ) -> Option < & ' static str > {
60+ None
61+ }
0 commit comments