Skip to content

Commit f8448f9

Browse files
committed
Auto merge of rust-lang#3982 - RalfJung:epoll_ctl, r=RalfJung
epoll_ctl: throw unsupported error on unsupported opcode `@tiif` this is a somewhat suspicious "return -1" without setting the `errno` -- what is the reasoning behind that? Throwing a clear error seems better to me.
2 parents 3d9d393 + e51eded commit f8448f9

File tree

1 file changed

+4
-11
lines changed
  • src/tools/miri/src/shims/unix/linux

1 file changed

+4
-11
lines changed

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

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -256,14 +256,6 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
256256
let epollhup = this.eval_libc_u32("EPOLLHUP");
257257
let epollerr = this.eval_libc_u32("EPOLLERR");
258258

259-
// Fail on unsupported operations.
260-
if op & epoll_ctl_add != epoll_ctl_add
261-
&& op & epoll_ctl_mod != epoll_ctl_mod
262-
&& op & epoll_ctl_del != epoll_ctl_del
263-
{
264-
throw_unsup_format!("epoll_ctl: encountered unknown unsupported operation {:#x}", op);
265-
}
266-
267259
// Throw EINVAL if epfd and fd have the same value.
268260
if epfd_value == fd {
269261
return this.set_last_error_and_return_i32(LibcError("EINVAL"));
@@ -363,7 +355,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
363355
// Notification will be returned for current epfd if there is event in the file
364356
// descriptor we registered.
365357
check_and_update_one_event_interest(&fd_ref, interest, id, this)?;
366-
return interp_ok(Scalar::from_i32(0));
358+
interp_ok(Scalar::from_i32(0))
367359
} else if op == epoll_ctl_del {
368360
let epoll_key = (id, fd);
369361

@@ -387,9 +379,10 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
387379
.unwrap()
388380
.retain(|event| event.upgrade().is_some());
389381

390-
return interp_ok(Scalar::from_i32(0));
382+
interp_ok(Scalar::from_i32(0))
383+
} else {
384+
throw_unsup_format!("unsupported epoll_ctl operation: {op}");
391385
}
392-
interp_ok(Scalar::from_i32(-1))
393386
}
394387

395388
/// The `epoll_wait()` system call waits for events on the `Epoll`

0 commit comments

Comments
 (0)