Skip to content

Commit fe7d977

Browse files
committed
Fix socketpair and epoll_create1's throw_unsup_format wording
1 parent c5e9424 commit fe7d977

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

src/tools/miri/src/shims/unix/linux/epoll.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,13 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
5757
let flags = this.read_scalar(flags)?.to_i32()?;
5858

5959
let epoll_cloexec = this.eval_libc_i32("EPOLL_CLOEXEC");
60-
if flags == epoll_cloexec {
61-
// Miri does not support exec, so this flag has no effect.
62-
} else if flags != 0 {
63-
throw_unsup_format!("epoll_create1 flags {flags} are not implemented");
60+
61+
// Miri does not support exec, so EPOLL_CLOEXEC flag has no effect.
62+
if flags != epoll_cloexec && flags != 0 {
63+
throw_unsup_format!(
64+
"epoll_create1: flag {:#x} is unsupported, only 0 or EPOLL_CLOEXEC are allowed",
65+
flags
66+
);
6467
}
6568

6669
let fd = this.machine.fds.insert_fd(FileDescriptor::new(Epoll::default()));

src/tools/miri/src/shims/unix/socket.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,19 +179,19 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
179179
// their values differ.
180180
if domain != this.eval_libc_i32("AF_UNIX") && domain != this.eval_libc_i32("AF_LOCAL") {
181181
throw_unsup_format!(
182-
"socketpair: Unsupported domain {:#x} is used, only AF_UNIX \
182+
"socketpair: domain {:#x} is unsupported, only AF_UNIX \
183183
and AF_LOCAL are allowed",
184184
domain
185185
);
186186
} else if type_ != 0 {
187187
throw_unsup_format!(
188-
"socketpair: Unsupported type {:#x} is used, only SOCK_STREAM, \
188+
"socketpair: type {:#x} is unsupported, only SOCK_STREAM, \
189189
SOCK_CLOEXEC and SOCK_NONBLOCK are allowed",
190190
type_
191191
);
192192
} else if protocol != 0 {
193193
throw_unsup_format!(
194-
"socketpair: Unsupported socket protocol {protocol} is used, \
194+
"socketpair: socket protocol {protocol} is unsupported, \
195195
only 0 is allowed",
196196
);
197197
}

0 commit comments

Comments
 (0)