1
1
//@only-target-linux
2
2
3
- #![ feature( exposed_provenance ) ] // Needed for fn test_pointer()
3
+ #![ feature( strict_provenance ) ]
4
4
use std:: convert:: TryInto ;
5
- use std:: mem:: MaybeUninit ;
6
5
7
6
fn main ( ) {
8
7
test_epoll_socketpair ( ) ;
@@ -17,7 +16,6 @@ fn main() {
17
16
test_no_notification_for_unregister_flag ( ) ;
18
17
test_epoll_ctl_mod ( ) ;
19
18
test_epoll_ctl_del ( ) ;
20
- test_pointer ( ) ;
21
19
test_two_same_fd_in_same_epoll_instance ( ) ;
22
20
test_epoll_wait_maxevent_zero ( ) ;
23
21
test_socketpair_epollerr ( ) ;
@@ -261,24 +259,6 @@ fn test_epoll_eventfd() {
261
259
check_epoll_wait :: < 8 > ( epfd, & [ ( expected_event, expected_value) ] ) ;
262
260
}
263
261
264
- fn test_pointer ( ) {
265
- // Create an epoll instance.
266
- let epfd = unsafe { libc:: epoll_create1 ( 0 ) } ;
267
- assert_ne ! ( epfd, -1 ) ;
268
-
269
- // Create a socketpair instance.
270
- let mut fds = [ -1 , -1 ] ;
271
- let res = unsafe { libc:: socketpair ( libc:: AF_UNIX , libc:: SOCK_STREAM , 0 , fds. as_mut_ptr ( ) ) } ;
272
- assert_eq ! ( res, 0 ) ;
273
-
274
- // Register fd[1] with EPOLLIN|EPOLLOUT|EPOLLET
275
- let data = MaybeUninit :: < u64 > :: uninit ( ) . as_ptr ( ) ;
276
- let mut ev =
277
- libc:: epoll_event { events : EPOLL_IN_OUT_ET , u64 : data. expose_provenance ( ) as u64 } ;
278
- let res = unsafe { libc:: epoll_ctl ( epfd, libc:: EPOLL_CTL_ADD , fds[ 1 ] , & mut ev) } ;
279
- assert_eq ! ( res, 0 ) ;
280
- }
281
-
282
262
// When read/write happened on one side of the socketpair, only the other side will be notified.
283
263
fn test_epoll_socketpair_both_sides ( ) {
284
264
// Create an epoll instance.
@@ -543,9 +523,9 @@ fn test_epoll_wait_maxevent_zero() {
543
523
// Create an epoll instance.
544
524
let epfd = unsafe { libc:: epoll_create1 ( 0 ) } ;
545
525
assert_ne ! ( epfd, -1 ) ;
546
- // It is ok to use uninitialised pointer here because it will error out before the
547
- // pointer actually get accessed.
548
- let array_ptr = MaybeUninit :: < libc:: epoll_event > :: uninit ( ) . as_mut_ptr ( ) ;
526
+ // It is ok to use a dangling pointer here because it will error out before the
527
+ // pointer actually gets accessed.
528
+ let array_ptr = std :: ptr :: without_provenance_mut :: < libc:: epoll_event > ( 0x100 ) ;
549
529
let res = unsafe { libc:: epoll_wait ( epfd, array_ptr, 0 , 0 ) } ;
550
530
let e = std:: io:: Error :: last_os_error ( ) ;
551
531
assert_eq ! ( e. raw_os_error( ) , Some ( libc:: EINVAL ) ) ;
0 commit comments