@@ -424,7 +424,7 @@ entry! {
424424 protos_len: c_uint,
425425 ) -> MysteriouslyOppositeReturnValue {
426426 let ctx = try_clone_arc!( ctx) ;
427- let slice = try_slice!( protos, protos_len) ;
427+ let slice = try_slice!( protos, c_uint_into_usize ( protos_len) ) ;
428428
429429 let alpn = match crate :: parse_alpn( slice) {
430430 Some ( alpn) => alpn,
@@ -689,7 +689,7 @@ entry! {
689689 sid_ctx: * const c_uchar,
690690 sid_ctx_len: c_uint,
691691 ) -> c_int {
692- let sid_ctx = try_slice!( sid_ctx, sid_ctx_len) ;
692+ let sid_ctx = try_slice!( sid_ctx, c_uint_into_usize ( sid_ctx_len) ) ;
693693 if sid_ctx. len( ) > SSL_MAX_SID_CTX_LENGTH {
694694 return Error :: not_supported( "excess sid_ctx_len" ) . raise( ) . into( ) ;
695695 }
@@ -937,7 +937,7 @@ entry! {
937937 protos_len: c_uint,
938938 ) -> MysteriouslyOppositeReturnValue {
939939 let ssl = try_clone_arc!( ssl) ;
940- let slice = try_slice!( protos, protos_len) ;
940+ let slice = try_slice!( protos, c_uint_into_usize ( protos_len) ) ;
941941
942942 let alpn = match crate :: parse_alpn( slice) {
943943 Some ( alpn) => alpn,
@@ -1131,8 +1131,8 @@ entry! {
11311131 ERROR
11321132 }
11331133 Ok ( result) => match result {
1134- ShutdownResult :: Sent => 0 as c_int ,
1135- ShutdownResult :: Received => 1 as c_int ,
1134+ ShutdownResult :: Sent => 0 ,
1135+ ShutdownResult :: Received => 1 ,
11361136 } ,
11371137 }
11381138 }
@@ -1170,7 +1170,7 @@ entry! {
11701170
11711171entry ! {
11721172 pub fn _SSL_get_error( ssl: * const SSL , _ret_code: c_int) -> c_int {
1173- try_clone_arc!( ssl) . get_mut( ) . get_error( ) as c_int
1173+ try_clone_arc!( ssl) . get_mut( ) . get_error( )
11741174 }
11751175}
11761176
@@ -1595,7 +1595,7 @@ entry! {
15951595 }
15961596
15971597 unsafe {
1598- ptr:: copy_nonoverlapping( description. as_ptr( ) , buf, required_len as usize ) ;
1598+ ptr:: copy_nonoverlapping( description. as_ptr( ) , buf, required_len) ;
15991599 } ;
16001600 buf
16011601 }
@@ -1615,8 +1615,8 @@ entry! {
16151615 client: * const c_uchar,
16161616 client_len: c_uint,
16171617 ) -> c_int {
1618- let server = try_slice!( server, server_len) ;
1619- let client = try_slice!( client, client_len) ;
1618+ let server = try_slice!( server, c_uint_into_usize ( server_len) ) ;
1619+ let client = try_slice!( client, c_uint_into_usize ( client_len) ) ;
16201620
16211621 if out. is_null( ) || out_len. is_null( ) {
16221622 return 0 ;
@@ -1734,7 +1734,7 @@ entry! {
17341734 sid_ctx: * const c_uchar,
17351735 sid_ctx_len: c_uint,
17361736 ) -> c_int {
1737- let slice = try_slice!( sid_ctx, sid_ctx_len) ;
1737+ let slice = try_slice!( sid_ctx, c_uint_into_usize ( sid_ctx_len) ) ;
17381738 if slice. len( ) > SSL_MAX_SID_CTX_LENGTH {
17391739 return Error :: not_supported( "excess sid_ctx_len" ) . raise( ) . into( ) ;
17401740 }
@@ -2482,6 +2482,13 @@ entry_stub! {
24822482
24832483// ---------------------
24842484
2485+ fn c_uint_into_usize ( v : c_uint ) -> usize {
2486+ const {
2487+ assert ! ( size_of:: <c_uint>( ) <= size_of:: <usize >( ) ) ;
2488+ }
2489+ v as usize
2490+ }
2491+
24852492#[ cfg( test) ]
24862493mod tests {
24872494 use super :: * ;
0 commit comments