@@ -7,34 +7,45 @@ use std::io::{Read, Seek, Write};
77use std:: os:: fd:: { AsFd , FromRawFd , IntoRawFd } ;
88use std:: rc:: Rc ;
99pub unsafe fn check_name_0 ( mut fd : i32 , mut path : * const libc:: c_char ) {
10- let mut full: libc:: sockaddr_un = unsafe { std:: mem:: zeroed ( ) } ;
11- match ( { ( ( & mut full as * mut libc:: sockaddr_un ) as * mut :: libc:: c_void ) } , ) {
10+ let mut full: libc:: sockaddr_storage = unsafe { std:: mem:: zeroed ( ) } ;
11+ match ( { ( ( & mut full as * mut libc:: sockaddr_storage ) as * mut :: libc:: c_void ) } , ) {
1212 ( mut __tmp_0, ) => {
1313 let byte_0 = __tmp_0 as * mut u8 ;
14- for offset in 0 ..:: std:: mem:: size_of :: < libc:: sockaddr_un > ( ) {
14+ for offset in 0 ..:: std:: mem:: size_of :: < libc:: sockaddr_storage > ( ) {
1515 * byte_0. offset ( offset as isize ) = 165 as u8 ;
1616 }
1717 __tmp_0
1818 }
1919 } ;
2020 let mut actual: libc:: socklen_t =
21- ( :: std:: mem:: size_of :: < libc:: sockaddr_un > ( ) as libc:: socklen_t ) ;
21+ ( :: std:: mem:: size_of :: < libc:: sockaddr_storage > ( ) as libc:: socklen_t ) ;
2222 assert ! (
2323 ( ( ( ( libc:: getsockname(
2424 fd,
25- ( ( & mut full as * mut libc:: sockaddr_un ) as * mut libc:: sockaddr) ,
25+ ( ( & mut full as * mut libc:: sockaddr_storage ) as * mut libc:: sockaddr) ,
2626 ( & mut actual as * mut libc:: socklen_t)
2727 ) ) == ( 0 ) ) as i32 )
2828 != 0 )
2929 ) ;
30- assert ! ( ( ( ( ( full. sun_family as i32 ) == ( 1 ) ) as i32 ) != 0 ) ) ;
30+ assert ! ( ( ( ( ( full. ss_family as i32 ) == ( 1 ) ) as i32 ) != 0 ) ) ;
31+ assert ! (
32+ ( ( ( ( actual as usize ) >= ( :: std:: mem:: offset_of!( libc:: sockaddr_un, sun_path) ) ) as i32 )
33+ != 0 )
34+ ) ;
35+ assert ! (
36+ ( ( ( ( actual as usize ) < ( :: std:: mem:: size_of:: <libc:: sockaddr_storage>( ) ) ) as i32 ) != 0 )
37+ ) ;
3138 if !( path) . is_null ( ) {
3239 assert ! (
3340 ( ( ( ( match ( { libc:: strlen( path) } , ) {
3441 ( mut __tmp_1, ) => {
3542 {
3643 let sa = core:: slice:: from_raw_parts(
37- ( full. sun_path. as_mut_ptr( ) as * const :: libc:: c_void) as * const u8 ,
44+ ( ( * ( ( & mut full as * mut libc:: sockaddr_storage)
45+ as * mut libc:: sockaddr_un) )
46+ . sun_path
47+ . as_mut_ptr( ) as * const :: libc:: c_void)
48+ as * const u8 ,
3849 __tmp_1 as usize ,
3950 ) ;
4051 let sb = core:: slice:: from_raw_parts(
@@ -54,18 +65,7 @@ pub unsafe fn check_name_0(mut fd: i32, mut path: *const libc::c_char) {
5465 } ) == ( 0 ) ) as i32 )
5566 != 0 )
5667 ) ;
57- } else {
58- assert ! (
59- ( ( ( ( actual as usize ) == ( :: std:: mem:: offset_of!( libc:: sockaddr_un, sun_path) ) ) as i32 )
60- != 0 )
61- ) ;
6268 }
63- ( unsafe {
64- libc:: printf (
65- ( c"%u\n " . as_ptr ( ) . cast_mut ( ) ) . cast_const ( ) as * const libc:: c_char ,
66- ( actual as u32 ) ,
67- )
68- } ) ;
6969 let mut capacities: [ libc:: socklen_t ; 6 ] = [
7070 ( 0 as libc:: socklen_t ) ,
7171 ( 1 as libc:: socklen_t ) ,
@@ -81,11 +81,11 @@ pub unsafe fn check_name_0(mut fd: i32, mut path: *const libc::c_char) {
8181 as i32 )
8282 != 0 )
8383 {
84- let mut out: [ u8 ; 118 ] = [ 0_u8 ; 118 ] ;
84+ let mut out: [ u8 ; 136 ] = [ 0_u8 ; 136 ] ;
8585 match ( { ( out. as_mut_ptr ( ) as * mut :: libc:: c_void ) } , ) {
8686 ( mut __tmp_2, ) => {
8787 let byte_0 = __tmp_2 as * mut u8 ;
88- for offset in 0 ..:: std:: mem:: size_of :: < [ u8 ; 118 ] > ( ) {
88+ for offset in 0 ..:: std:: mem:: size_of :: < [ u8 ; 136 ] > ( ) {
8989 * byte_0. offset ( offset as isize ) = 165 as u8 ;
9090 }
9191 __tmp_2
@@ -115,7 +115,7 @@ pub unsafe fn check_name_0(mut fd: i32, mut path: *const libc::c_char) {
115115 __tmp_3 as usize ,
116116 ) ;
117117 let sb = core:: slice:: from_raw_parts(
118- ( ( & mut full as * mut libc:: sockaddr_un ) as * const :: libc:: c_void)
118+ ( ( & mut full as * mut libc:: sockaddr_storage ) as * const :: libc:: c_void)
119119 as * const u8 ,
120120 __tmp_3 as usize ,
121121 ) ;
@@ -133,7 +133,7 @@ pub unsafe fn check_name_0(mut fd: i32, mut path: *const libc::c_char) {
133133 != 0 )
134134 ) ;
135135 let mut j: u32 = copied;
136- ' loop_: while ( ( ( ( j as usize ) < ( :: std:: mem:: size_of :: < [ u8 ; 118 ] > ( ) ) ) as i32 ) != 0 ) {
136+ ' loop_: while ( ( ( ( j as usize ) < ( :: std:: mem:: size_of :: < [ u8 ; 136 ] > ( ) ) ) as i32 ) != 0 ) {
137137 assert ! ( ( ( ( ( out[ ( j) as usize ] as i32 ) == ( 165 ) ) as i32 ) != 0 ) ) ;
138138 j. prefix_inc ( ) ;
139139 }
@@ -150,18 +150,29 @@ unsafe fn main_0() -> i32 {
150150 let mut fd: i32 = libc:: socket ( 1 , libc:: SOCK_DGRAM , 0 ) ;
151151 assert ! ( ( ( ( ( fd) >= ( 0 ) ) as i32 ) != 0 ) ) ;
152152 ( unsafe { check_name_0 ( fd, std:: ptr:: null ( ) ) } ) ;
153- let mut addr: libc:: sockaddr_un = unsafe { std:: mem:: zeroed ( ) } ;
154- match ( { ( ( & mut addr as * mut libc:: sockaddr_un ) as * mut :: libc:: c_void ) } , ) {
153+ let mut addr: libc:: sockaddr_storage = unsafe { std:: mem:: zeroed ( ) } ;
154+ match ( { ( ( & mut addr as * mut libc:: sockaddr_storage ) as * mut :: libc:: c_void ) } , ) {
155155 ( mut __tmp_4, ) => {
156156 let byte_0 = __tmp_4 as * mut u8 ;
157- for offset in 0 ..:: std:: mem:: size_of :: < libc:: sockaddr_un > ( ) {
157+ for offset in 0 ..:: std:: mem:: size_of :: < libc:: sockaddr_storage > ( ) {
158158 * byte_0. offset ( offset as isize ) = 0 as u8 ;
159159 }
160160 __tmp_4
161161 }
162162 } ;
163- addr. sun_family = ( 1 as libc:: sa_family_t ) ;
164- match ( { ( addr. sun_path . as_mut_ptr ( ) as * mut :: libc:: c_void ) } , ) {
163+ let mut len: libc:: socklen_t =
164+ ( :: std:: mem:: size_of :: < libc:: sockaddr_storage > ( ) as libc:: socklen_t ) ;
165+ assert ! (
166+ ( ( ( ( libc:: getsockname(
167+ fd,
168+ ( ( & mut addr as * mut libc:: sockaddr_storage) as * mut libc:: sockaddr) ,
169+ ( & mut len as * mut libc:: socklen_t)
170+ ) ) == ( 0 ) ) as i32 )
171+ != 0 )
172+ ) ;
173+ let mut un: * mut libc:: sockaddr_un =
174+ ( ( & mut addr as * mut libc:: sockaddr_storage ) as * mut libc:: sockaddr_un ) ;
175+ match ( { ( ( * un) . sun_path . as_mut_ptr ( ) as * mut :: libc:: c_void ) } , ) {
165176 ( mut __tmp_5, ) => {
166177 if :: std:: mem:: size_of :: < [ libc:: c_char ; 17 ] > ( ) != 0 {
167178 :: std:: ptr:: copy_nonoverlapping (
@@ -176,16 +187,16 @@ unsafe fn main_0() -> i32 {
176187 assert ! (
177188 ( ( ( ( libc:: bind(
178189 fd,
179- ( ( & mut addr as * mut libc:: sockaddr_un ) as * mut libc:: sockaddr) . cast_const( ) ,
190+ ( ( & mut addr as * mut libc:: sockaddr_storage ) as * mut libc:: sockaddr) . cast_const( ) ,
180191 ( ( ( :: std:: mem:: offset_of!( libc:: sockaddr_un, sun_path) as usize )
181- . wrapping_add( libc:: strlen( ( addr . sun_path. as_mut_ptr( ) ) . cast_const( ) ) ) )
192+ . wrapping_add( libc:: strlen( ( ( * un ) . sun_path. as_mut_ptr( ) ) . cast_const( ) ) ) )
182193 as libc:: socklen_t)
183194 ) ) == ( 0 ) ) as i32 )
184195 != 0 )
185196 ) ;
186- ( unsafe { check_name_0 ( fd, ( addr . sun_path . as_mut_ptr ( ) ) . cast_const ( ) ) } ) ;
197+ ( unsafe { check_name_0 ( fd, ( ( * un ) . sun_path . as_mut_ptr ( ) ) . cast_const ( ) ) } ) ;
187198 assert ! ( ( ( ( ( libc:: close( fd) ) == ( 0 ) ) as i32 ) != 0 ) ) ;
188- assert ! ( ( ( ( ( libc:: unlink( ( addr . sun_path. as_mut_ptr( ) ) . cast_const( ) ) ) == ( 0 ) ) as i32 ) != 0 ) ) ;
199+ assert ! ( ( ( ( ( libc:: unlink( ( ( * un ) . sun_path. as_mut_ptr( ) ) . cast_const( ) ) ) == ( 0 ) ) as i32 ) != 0 ) ) ;
189200 return 0 ;
190201}
191202pub unsafe fn __cpp2rust_init_globals ( ) { }
0 commit comments