Skip to content

Commit

Permalink
Auto merge of rust-lang#3671 - tiif:epoll_create1_minor_fix, r=RalfJung
Browse files Browse the repository at this point in the history
Minor fix: Change wording of epoll_create1 and socketpair's throw_unsup_format

This PR slightly changes the wording and format of ``epoll_create1``'s ``throw_unsup_format`` to match other shims. It is just a minor detail that I couldn't help but want to change while reading it. Sorry if it is not appropriate to open a PR for such minor detail.
  • Loading branch information
bors committed Jun 13, 2024
2 parents c5e9424 + fe7d977 commit ccb5f52
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
11 changes: 7 additions & 4 deletions src/tools/miri/src/shims/unix/linux/epoll.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,13 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
let flags = this.read_scalar(flags)?.to_i32()?;

let epoll_cloexec = this.eval_libc_i32("EPOLL_CLOEXEC");
if flags == epoll_cloexec {
// Miri does not support exec, so this flag has no effect.
} else if flags != 0 {
throw_unsup_format!("epoll_create1 flags {flags} are not implemented");

// Miri does not support exec, so EPOLL_CLOEXEC flag has no effect.
if flags != epoll_cloexec && flags != 0 {
throw_unsup_format!(
"epoll_create1: flag {:#x} is unsupported, only 0 or EPOLL_CLOEXEC are allowed",
flags
);
}

let fd = this.machine.fds.insert_fd(FileDescriptor::new(Epoll::default()));
Expand Down
6 changes: 3 additions & 3 deletions src/tools/miri/src/shims/unix/socket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,19 +179,19 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
// their values differ.
if domain != this.eval_libc_i32("AF_UNIX") && domain != this.eval_libc_i32("AF_LOCAL") {
throw_unsup_format!(
"socketpair: Unsupported domain {:#x} is used, only AF_UNIX \
"socketpair: domain {:#x} is unsupported, only AF_UNIX \
and AF_LOCAL are allowed",
domain
);
} else if type_ != 0 {
throw_unsup_format!(
"socketpair: Unsupported type {:#x} is used, only SOCK_STREAM, \
"socketpair: type {:#x} is unsupported, only SOCK_STREAM, \
SOCK_CLOEXEC and SOCK_NONBLOCK are allowed",
type_
);
} else if protocol != 0 {
throw_unsup_format!(
"socketpair: Unsupported socket protocol {protocol} is used, \
"socketpair: socket protocol {protocol} is unsupported, \
only 0 is allowed",
);
}
Expand Down

0 comments on commit ccb5f52

Please sign in to comment.