@@ -262,10 +262,8 @@ fn test_epoll_eventfd() {
262262 let flags = libc:: EFD_NONBLOCK | libc:: EFD_CLOEXEC ;
263263 let fd = unsafe { libc:: eventfd ( 0 , flags) } ;
264264
265- // Write to the eventfd instance.
266- let sized_8_data: [ u8 ; 8 ] = 1_u64 . to_ne_bytes ( ) ;
267- let res = unsafe { libc_utils:: write_all ( fd, sized_8_data. as_ptr ( ) as * const libc:: c_void , 8 ) } ;
268- assert_eq ! ( res, 8 ) ;
265+ // Write 1 to the eventfd instance.
266+ libc_utils:: write_all_from_slice ( fd, & 1_u64 . to_ne_bytes ( ) ) . unwrap ( ) ;
269267
270268 // Create an epoll instance.
271269 let epfd = unsafe { libc:: epoll_create1 ( 0 ) } ;
@@ -281,18 +279,15 @@ fn test_epoll_eventfd() {
281279 let expected_value = u64:: try_from ( fd) . unwrap ( ) ;
282280 check_epoll_wait :: < 8 > ( epfd, & [ ( expected_event, expected_value) ] ) ;
283281
284- // Write to the eventfd again.
285- let res = unsafe { libc_utils:: write_all ( fd, sized_8_data. as_ptr ( ) as * const libc:: c_void , 8 ) } ;
286- assert_eq ! ( res, 8 ) ;
282+ // Write 0 to the eventfd.
283+ libc_utils:: write_all_from_slice ( fd, & 0_u64 . to_ne_bytes ( ) ) . unwrap ( ) ;
287284
288285 // This does not change the status, so we should get no event.
289286 // However, Linux performs a spurious wakeup.
290287 check_epoll_wait :: < 8 > ( epfd, & [ ( expected_event, expected_value) ] ) ;
291288
292289 // Read from the eventfd.
293- let mut buf = [ 0u8 ; 8 ] ;
294- let res = unsafe { libc_utils:: read_all ( fd, buf. as_mut_ptr ( ) . cast ( ) , 8 ) } ;
295- assert_eq ! ( res, 8 ) ;
290+ libc_utils:: read_all_into_array :: < 8 > ( fd) . unwrap ( ) ;
296291
297292 // This consumes the event, so the read status is gone. However, deactivation
298293 // does not trigger an event.
0 commit comments