Skip to content

Commit

Permalink
Shift comment to the right place
Browse files Browse the repository at this point in the history
  • Loading branch information
tiif committed Feb 26, 2025
1 parent 5bc4382 commit 62510f7
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/shims/unix/fd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,32 +179,30 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
}
}
cmd if cmd == f_getfl => {
// We only support F_GETFL for socketpair and pipe.

// Check if this is a valid open file descriptor.
let Some(fd) = this.machine.fds.get(fd_num) else {
return this.set_last_error_and_return_i32(LibcError("EBADF"));
};

// We only support F_GETFL for socketpair and pipe.
let anonsocket_fd = fd.downcast::<AnonSocket>().ok_or_else(|| {
err_unsup_format!("fcntl: only socketpair / pipe are supported for F_SETFL")
})?;

if anonsocket_fd.is_nonblock() {
if anonsocket_fd.is_nonblock.get() {
// socketpair's SOCK_NONBLOCK and pipe's O_NONBLOCK have the same value.
interp_ok(this.eval_libc("O_NONBLOCK"))
} else {
interp_ok(Scalar::from_i32(0))
}
}
cmd if cmd == f_setfl => {
// We only support F_SETFL for socketpair and pipe.

// Check if this is a valid open file descriptor.
let Some(fd) = this.machine.fds.get(fd_num) else {
return this.set_last_error_and_return_i32(LibcError("EBADF"));
};

// We only support F_SETFL for socketpair and pipe.
let anonsocket_fd = fd.downcast::<AnonSocket>().ok_or_else(|| {
err_unsup_format!("fcntl: only socketpair / pipe are supported for F_GETFL")
})?;
Expand Down

0 comments on commit 62510f7

Please sign in to comment.