Skip to content

Commit ca3a5b6

Browse files
authored
Fix the sys::test_aio::aio_fsync::error test on recent rust nightly (#2651)
* Fix the sys::test_aio::aio_fsync::error test on recent rust nightly This test deliberately makes an invalid syscall. Rust no longer allows us to even construct an invalid enum (even with `unsafe`), so alter the test to get EBADF instead of EINVAL. * Fix an unresolved rustdoc link This unresolved link was only revealed by a recent change to the nightly compiler.
1 parent a72936d commit ca3a5b6

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

src/sys/signal.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -929,7 +929,7 @@ pub unsafe fn sigaction(signal: Signal, sigaction: &SigAction) -> Result<SigActi
929929
///
930930
/// # Errors
931931
///
932-
/// Returns [`Error(Errno::EOPNOTSUPP)`] if `handler` is
932+
/// Returns [`Error(Errno::EOPNOTSUPP)`](Errno::EOPNOTSUPP) if `handler` is
933933
/// [`SigAction`][SigActionStruct]. Use [`sigaction`][SigActionFn] instead.
934934
///
935935
/// `signal` also returns any error from `libc::signal`, such as when an attempt

test/sys/test_aio.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,11 @@ mod aio_fsync {
7070
#[test]
7171
#[cfg_attr(any(target_os = "android", target_os = "linux"), ignore)]
7272
fn error() {
73-
use std::mem;
74-
75-
const INITIAL: &[u8] = b"abcdef123456";
76-
// Create an invalid AioFsyncMode
77-
let mode = unsafe { mem::transmute::<i32, AioFsyncMode>(666) };
78-
let mut f = tempfile().unwrap();
79-
f.write_all(INITIAL).unwrap();
73+
let mode = AioFsyncMode::O_SYNC;
74+
// Operate on an invalid file descriptor. Should get EBADF
75+
let fd = unsafe { BorrowedFd::borrow_raw(i32::MAX) };
8076
let mut aiof =
81-
Box::pin(AioFsync::new(f.as_fd(), mode, 0, SigevNotify::SigevNone));
77+
Box::pin(AioFsync::new(fd, mode, 0, SigevNotify::SigevNone));
8278
let err = aiof.as_mut().submit();
8379
err.expect_err("assertion failed");
8480
}

0 commit comments

Comments
 (0)