@@ -38,13 +38,11 @@ fn test_pipe() {
3838 let data = b"123" ;
3939 write_all_from_slice ( fds[ 1 ] , data) . unwrap ( ) ;
4040 let mut buf4: [ u8 ; 5 ] = [ 0 ; 5 ] ;
41- let res = unsafe { libc:: read ( fds[ 0 ] , buf4. as_mut_ptr ( ) . cast ( ) , buf4. len ( ) as libc:: size_t ) } ;
42- assert ! ( res > 0 && res <= 3 ) ;
43- let res = res as usize ;
41+ let res = read_into_slice ( fds[ 0 ] , & mut buf4) . unwrap ( ) . 0 . len ( ) ;
4442 assert_eq ! ( buf4[ ..res] , data[ ..res] ) ;
4543 if res < 3 {
4644 // Drain the rest from the read end.
47- let res = unsafe { libc_utils :: read_all ( fds[ 0 ] , buf4[ res..] . as_mut_ptr ( ) . cast ( ) , 3 - res ) } ;
45+ let res = read_into_slice ( fds[ 0 ] , & mut buf4[ res..] ) . unwrap ( ) . 0 . len ( ) ;
4846 assert ! ( res > 0 ) ;
4947 }
5048}
@@ -64,8 +62,7 @@ fn test_pipe_threaded() {
6462 // Read and write from different direction
6563 let thread2 = thread:: spawn ( move || {
6664 thread:: yield_now ( ) ;
67- let data = b"12345" ;
68- write_all_from_slice ( fds[ 1 ] , data) . unwrap ( ) ;
65+ write_all_from_slice ( fds[ 1 ] , b"12345" ) . unwrap ( ) ;
6966 } ) ;
7067 let buf = read_all_into_array :: < 5 > ( fds[ 0 ] ) . unwrap ( ) ;
7168 assert_eq ! ( & buf, b"12345" ) ;
@@ -87,8 +84,7 @@ fn test_race() {
8784 unsafe { assert_eq ! ( VAL , 1 ) } ;
8885 } ) ;
8986 unsafe { VAL = 1 } ;
90- let data = b"a" ;
91- write_all_from_slice ( fds[ 1 ] , data) . unwrap ( ) ;
87+ write_all_from_slice ( fds[ 1 ] , b"a" ) . unwrap ( ) ;
9288 thread:: yield_now ( ) ;
9389 thread1. join ( ) . unwrap ( ) ;
9490}
@@ -176,8 +172,7 @@ fn test_pipe_fcntl_threaded() {
176172 // The write below will unblock the `read` in main thread: even though
177173 // the socket is now "non-blocking", the shim needs to deal correctly
178174 // with threads that were blocked before the socket was made non-blocking.
179- let data = b"abcde" ;
180- write_all_from_slice ( fds[ 1 ] , data) . unwrap ( ) ;
175+ write_all_from_slice ( fds[ 1 ] , b"abcde" ) . unwrap ( ) ;
181176 } ) ;
182177 // The `read` below will block.
183178 let buf = read_all_into_array :: < 5 > ( fds[ 0 ] ) . unwrap ( ) ;
0 commit comments