Skip to content

Commit

Permalink
Merge #2076
Browse files Browse the repository at this point in the history
2076: Clippy cleanup r=asomers a=asomers



Co-authored-by: Alan Somers <asomers@gmail.com>
  • Loading branch information
bors[bot] and asomers authored Jul 15, 2023
2 parents 75a26cd + 4589411 commit b12aeb7
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/mount/bsd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ impl<'a> Nmount<'a> {
});

let niov = self.iov.len() as c_uint;
let iovp = self.iov.as_mut_ptr() as *mut libc::iovec;
let iovp = self.iov.as_mut_ptr();
let res = unsafe { libc::nmount(iovp, niov, flags.bits()) };
match Errno::result(res) {
Ok(_) => Ok(()),
Expand Down
3 changes: 3 additions & 0 deletions src/sys/socket/addr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,7 @@ enum UnixAddrKind<'a> {
}
impl<'a> UnixAddrKind<'a> {
/// Safety: sun & sun_len must be valid
#[allow(clippy::unnecessary_cast)] // Not unnecessary on all platforms
unsafe fn get(sun: &'a libc::sockaddr_un, sun_len: u8) -> Self {
assert!(sun_len as usize >= offset_of!(libc::sockaddr_un, sun_path));
let path_len =
Expand Down Expand Up @@ -520,6 +521,7 @@ impl<'a> UnixAddrKind<'a> {

impl UnixAddr {
/// Create a new sockaddr_un representing a filesystem path.
#[allow(clippy::unnecessary_cast)] // Not unnecessary on all platforms
pub fn new<P: ?Sized + NixPath>(path: &P) -> Result<UnixAddr> {
path.with_nix_path(|cstr| unsafe {
let mut ret = libc::sockaddr_un {
Expand Down Expand Up @@ -567,6 +569,7 @@ impl UnixAddr {
/// processes to communicate with processes having a different filesystem view.
#[cfg(any(target_os = "android", target_os = "linux"))]
#[cfg_attr(docsrs, doc(cfg(all())))]
#[allow(clippy::unnecessary_cast)] // Not unnecessary on all platforms
pub fn new_abstract(path: &[u8]) -> Result<UnixAddr> {
unsafe {
let mut ret = libc::sockaddr_un {
Expand Down
2 changes: 1 addition & 1 deletion src/sys/socket/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2234,7 +2234,7 @@ pub fn recvfrom<T: SockaddrLike>(
Ok((
ret,
T::from_raw(
addr.assume_init().as_ptr() as *const sockaddr,
addr.assume_init().as_ptr(),
Some(len),
),
))
Expand Down
2 changes: 1 addition & 1 deletion test/test_fcntl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ mod linux_android {

let buf1 = b"abcdef";
let buf2 = b"defghi";
let iovecs = vec![IoSlice::new(&buf1[0..3]), IoSlice::new(&buf2[0..3])];
let iovecs = [IoSlice::new(&buf1[0..3]), IoSlice::new(&buf2[0..3])];

let res = vmsplice(wr, &iovecs[..], SpliceFFlags::empty()).unwrap();

Expand Down
8 changes: 4 additions & 4 deletions test/test_sendfile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ fn test_sendfile64_linux() {
fn test_sendfile_freebsd() {
// 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 Expand Up @@ -123,10 +123,10 @@ fn test_sendfile_freebsd() {
fn test_sendfile_dragonfly() {
// 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

0 comments on commit b12aeb7

Please sign in to comment.