Skip to content

Clippy cleanup #2076

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

Merged
merged 1 commit into from
Jul 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
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