Move the maxevents.try_into().unwrap() after value check
This commit is contained in:
parent
c0e799db1a
commit
8ae118dc0a
2 changed files with 9 additions and 8 deletions
|
@ -403,18 +403,20 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
|
||||||
|
|
||||||
let epfd = this.read_scalar(epfd)?.to_i32()?;
|
let epfd = this.read_scalar(epfd)?.to_i32()?;
|
||||||
let maxevents = this.read_scalar(maxevents)?.to_i32()?;
|
let maxevents = this.read_scalar(maxevents)?.to_i32()?;
|
||||||
let event = this.deref_pointer_as(
|
|
||||||
events_op,
|
|
||||||
this.libc_array_ty_layout("epoll_event", maxevents.try_into().unwrap()),
|
|
||||||
)?;
|
|
||||||
let timeout = this.read_scalar(timeout)?.to_i32()?;
|
let timeout = this.read_scalar(timeout)?.to_i32()?;
|
||||||
|
|
||||||
if epfd <= 0 || maxevents <= 0 {
|
if epfd <= 0 || maxevents <= 0 {
|
||||||
let einval = this.eval_libc("EINVAL");
|
let einval = this.eval_libc("EINVAL");
|
||||||
this.set_last_error(einval)?;
|
this.set_last_error(einval)?;
|
||||||
return Ok(Scalar::from_i32(-1));
|
return Ok(Scalar::from_i32(-1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This needs to come after the maxevents value check, or else maxevents.try_into().unwrap()
|
||||||
|
// will fail.
|
||||||
|
let event = this.deref_pointer_as(
|
||||||
|
events_op,
|
||||||
|
this.libc_array_ty_layout("epoll_event", maxevents.try_into().unwrap()),
|
||||||
|
)?;
|
||||||
|
|
||||||
// FIXME: Implement blocking support
|
// FIXME: Implement blocking support
|
||||||
if timeout != 0 {
|
if timeout != 0 {
|
||||||
throw_unsup_format!("epoll_wait: timeout value can only be 0");
|
throw_unsup_format!("epoll_wait: timeout value can only be 0");
|
||||||
|
|
|
@ -19,7 +19,7 @@ fn main() {
|
||||||
test_epoll_ctl_del();
|
test_epoll_ctl_del();
|
||||||
test_pointer();
|
test_pointer();
|
||||||
test_two_same_fd_in_same_epoll_instance();
|
test_two_same_fd_in_same_epoll_instance();
|
||||||
test_epoll_wait_less_maxevent_zero();
|
test_epoll_wait_maxevent_zero();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Using `as` cast since `EPOLLET` wraps around
|
// Using `as` cast since `EPOLLET` wraps around
|
||||||
|
@ -530,8 +530,7 @@ fn test_no_notification_for_unregister_flag() {
|
||||||
check_epoll_wait::<8>(epfd, &[(expected_event, expected_value)]);
|
check_epoll_wait::<8>(epfd, &[(expected_event, expected_value)]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn test_epoll_wait_maxevent_zero() {
|
||||||
fn test_epoll_wait_less_maxevent_zero() {
|
|
||||||
// Create an epoll instance.
|
// Create an epoll instance.
|
||||||
let epfd = unsafe { libc::epoll_create1(0) };
|
let epfd = unsafe { libc::epoll_create1(0) };
|
||||||
assert_ne!(epfd, -1);
|
assert_ne!(epfd, -1);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue