Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable fcntl OFD commands on macos #2300

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
clippy
  • Loading branch information
anacrolix committed Jan 28, 2024
commit a8e2a3364c3e4641fc9e177afd10e87aae796733
8 changes: 2 additions & 6 deletions src/sys/select.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use crate::errno::Errno;
use crate::sys::time::{TimeSpec, TimeVal};
use crate::Result;
use libc::{self, c_int};
use std::convert::TryFrom;
use std::iter::FusedIterator;
use std::mem;
use std::ops::Range;
Expand All @@ -21,10 +20,7 @@ pub struct FdSet<'fd> {
}

fn assert_fd_valid(fd: RawFd) {
assert!(
usize::try_from(fd).map_or(false, |fd| fd < FD_SETSIZE),
"fd must be in the range 0..FD_SETSIZE",
);
assert!(fd < FD_SETSIZE, "fd must be in the range 0..FD_SETSIZE",);
}

impl<'fd> FdSet<'fd> {
Expand Down Expand Up @@ -110,7 +106,7 @@ impl<'fd> FdSet<'fd> {
pub fn fds(&self, highest: Option<RawFd>) -> Fds {
Fds {
set: self,
range: 0..highest.map(|h| h as usize + 1).unwrap_or(FD_SETSIZE),
range: 0..highest.map(|h| h + 1).unwrap_or(FD_SETSIZE) as usize,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting, they changed the type of this constant from usize to c_int: https://github.com/rust-lang/libc/pull/3356/files

}
}
}
Expand Down
8 changes: 1 addition & 7 deletions test/sys/test_select.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,7 @@ macro_rules! generate_fdset_bad_fd_tests {

mod test_fdset_too_large_fd {
use super::*;
use std::convert::TryInto;
generate_fdset_bad_fd_tests!(
FD_SETSIZE.try_into().unwrap(),
insert,
remove,
contains,
);
generate_fdset_bad_fd_tests!(FD_SETSIZE, insert, remove, contains,);
}

#[test]
Expand Down
4 changes: 2 additions & 2 deletions test/test_sendfile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,10 @@ fn test_sendfile_dragonfly() {
fn test_sendfile_darwin() {
// Declare the content
let header_strings =
vec!["HTTP/1.1 200 OK\n", "Content-Type: text/plain\n", "\n"];
["HTTP/1.1 200 OK\n", "Content-Type: text/plain\n", "\n"];
let body = "Xabcdef123456";
let body_offset = 1;
let trailer_strings = vec!["\n", "Served by Make Believe\n"];
let trailer_strings = ["\n", "Served by Make Believe\n"];

// Write the body to a file
let mut tmp = tempfile().unwrap();
Expand Down