@@ -1757,15 +1757,12 @@ mod _socket {
17571757 . map ( |s| s. to_cstring ( vm) )
17581758 . transpose ( ) ?;
17591759 let cstr_proto = cstr_opt_as_ptr ( & cstr_proto) ;
1760- #[ cfg( windows) ]
17611760 let serv = unsafe {
17621761 c:: getservbyname (
1763- cstr_name. as_ptr ( ) as windows_sys :: core :: PCSTR ,
1764- cstr_proto as windows_sys :: core :: PCSTR ,
1762+ cstr_name. as_ptr ( ) as _ ,
1763+ cstr_proto as _ ,
17651764 )
17661765 } ;
1767- #[ cfg( not( windows) ) ]
1768- let serv = unsafe { c:: getservbyname ( cstr_name. as_ptr ( ) , cstr_proto) } ;
17691766 if serv. is_null ( ) {
17701767 return Err ( vm. new_os_error ( "service/proto not found" . to_owned ( ) ) ) ;
17711768 }
@@ -1787,18 +1784,11 @@ mod _socket {
17871784 . map ( |s| s. to_cstring ( vm) )
17881785 . transpose ( ) ?;
17891786 let cstr_proto = cstr_opt_as_ptr ( & cstr_proto) ;
1790- #[ cfg( windows) ]
1791- let serv =
1792- unsafe { c:: getservbyport ( port. to_be ( ) as _ , cstr_proto as windows_sys:: core:: PCSTR ) } ;
1793- #[ cfg( not( windows) ) ]
1794- let serv = unsafe { c:: getservbyport ( port. to_be ( ) as _ , cstr_proto) } ;
1787+ let serv = unsafe { c:: getservbyport ( port. to_be ( ) as _ , cstr_proto as _ ) } ;
17951788 if serv. is_null ( ) {
17961789 return Err ( vm. new_os_error ( "port/proto not found" . to_owned ( ) ) ) ;
17971790 }
1798- #[ cfg( windows) ]
1799- let s = unsafe { ffi:: CStr :: from_ptr ( ( * serv) . s_name as * const i8 ) } ;
1800- #[ cfg( not( windows) ) ]
1801- let s = unsafe { ffi:: CStr :: from_ptr ( ( * serv) . s_name ) } ;
1791+ let s = unsafe { ffi:: CStr :: from_ptr ( ( * serv) . s_name as _ ) } ;
18021792 Ok ( s. to_string_lossy ( ) . into_owned ( ) )
18031793 }
18041794
@@ -2050,10 +2040,7 @@ mod _socket {
20502040 #[ pyfunction]
20512041 fn getprotobyname ( name : PyStrRef , vm : & VirtualMachine ) -> PyResult {
20522042 let cstr = name. to_cstring ( vm) ?;
2053- #[ cfg( windows) ]
2054- let proto = unsafe { c:: getprotobyname ( cstr. as_ptr ( ) as * const u8 ) } ;
2055- #[ cfg( not( windows) ) ]
2056- let proto = unsafe { c:: getprotobyname ( cstr. as_ptr ( ) ) } ;
2043+ let proto = unsafe { c:: getprotobyname ( cstr. as_ptr ( ) as _ ) } ;
20572044 if proto. is_null ( ) {
20582045 return Err ( vm. new_os_error ( "protocol not found" . to_owned ( ) ) ) ;
20592046 }
@@ -2138,10 +2125,7 @@ mod _socket {
21382125 fn if_nametoindex ( name : FsPath , vm : & VirtualMachine ) -> PyResult < IfIndex > {
21392126 let name = name. to_cstring ( vm) ?;
21402127
2141- #[ cfg( windows) ]
2142- let ret = unsafe { c:: if_nametoindex ( name. as_ptr ( ) as * const u8 ) } ;
2143- #[ cfg( not( windows) ) ]
2144- let ret = unsafe { c:: if_nametoindex ( name. as_ptr ( ) ) } ;
2128+ let ret = unsafe { c:: if_nametoindex ( name. as_ptr ( ) as _ ) } ;
21452129 if ret == 0 {
21462130 Err ( vm. new_os_error ( "no interface with this name" . to_owned ( ) ) )
21472131 } else {
@@ -2157,10 +2141,7 @@ mod _socket {
21572141 if ret. is_null ( ) {
21582142 Err ( crate :: vm:: stdlib:: os:: errno_err ( vm) )
21592143 } else {
2160- #[ cfg( windows) ]
2161- let buf = unsafe { ffi:: CStr :: from_ptr ( buf. as_ptr ( ) as * const i8 ) } ;
2162- #[ cfg( not( windows) ) ]
2163- let buf = unsafe { ffi:: CStr :: from_ptr ( buf. as_ptr ( ) ) } ;
2144+ let buf = unsafe { ffi:: CStr :: from_ptr ( buf. as_ptr ( ) as _ ) } ;
21642145 Ok ( buf. to_string_lossy ( ) . into_owned ( ) )
21652146 }
21662147 }
0 commit comments