Skip to content

Commit 25c54dc

Browse files
authored
Miscellaneous clippy fixes. (#1128)
1 parent 4971c51 commit 25c54dc

34 files changed

+108
-82
lines changed

src/backend/libc/event/epoll.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,11 @@ impl<'a> Iterator for Iter<'a> {
294294
fn next(&mut self) -> Option<Self::Item> {
295295
self.iter.next()
296296
}
297+
298+
#[inline]
299+
fn size_hint(&self) -> (usize, Option<usize>) {
300+
self.iter.size_hint()
301+
}
297302
}
298303

299304
/// A record of an event that occurred.

src/backend/libc/event/poll_fd.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ pub struct PollFd<'fd> {
6363
}
6464

6565
impl<'fd> fmt::Debug for PollFd<'fd> {
66-
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
67-
fmt.debug_struct("PollFd")
66+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
67+
f.debug_struct("PollFd")
6868
.field("fd", &self.pollfd.fd)
6969
.field("events", &self.pollfd.events)
7070
.field("revents", &self.pollfd.revents)

src/backend/libc/net/addr.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -194,16 +194,16 @@ impl Hash for SocketAddrUnix {
194194

195195
#[cfg(unix)]
196196
impl fmt::Debug for SocketAddrUnix {
197-
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
197+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
198198
if let Some(path) = self.path() {
199-
path.fmt(fmt)
199+
path.fmt(f)
200200
} else {
201201
#[cfg(linux_kernel)]
202202
if let Some(name) = self.abstract_name() {
203-
return name.fmt(fmt);
203+
return name.fmt(f);
204204
}
205205

206-
"(unnamed)".fmt(fmt)
206+
"(unnamed)".fmt(f)
207207
}
208208
}
209209
}

src/backend/libc/net/sockopt.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -915,9 +915,10 @@ pub(crate) fn set_tcp_congestion(fd: BorrowedFd<'_>, value: &str) -> io::Result<
915915
))]
916916
#[inline]
917917
pub(crate) fn get_tcp_congestion(fd: BorrowedFd<'_>) -> io::Result<String> {
918+
const OPTLEN: c::socklen_t = 16;
919+
918920
let level = c::IPPROTO_TCP;
919921
let optname = c::TCP_CONGESTION;
920-
const OPTLEN: c::socklen_t = 16;
921922
let mut value = MaybeUninit::<[MaybeUninit<u8>; OPTLEN as usize]>::uninit();
922923
let mut optlen = OPTLEN;
923924
getsockopt_raw(fd, level, optname, &mut value, &mut optlen)?;

src/backend/libc/pipe/syscalls.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ pub(crate) fn pipe_with(flags: PipeFlags) -> io::Result<(OwnedFd, OwnedFd)> {
5454

5555
#[cfg(linux_kernel)]
5656
#[inline]
57-
pub fn splice(
57+
pub(crate) fn splice(
5858
fd_in: BorrowedFd<'_>,
5959
off_in: Option<&mut u64>,
6060
fd_out: BorrowedFd<'_>,
@@ -79,7 +79,7 @@ pub fn splice(
7979

8080
#[cfg(linux_kernel)]
8181
#[inline]
82-
pub unsafe fn vmsplice(
82+
pub(crate) unsafe fn vmsplice(
8383
fd: BorrowedFd<'_>,
8484
bufs: &[IoSliceRaw<'_>],
8585
flags: SpliceFlags,
@@ -94,7 +94,7 @@ pub unsafe fn vmsplice(
9494

9595
#[cfg(linux_kernel)]
9696
#[inline]
97-
pub fn tee(
97+
pub(crate) fn tee(
9898
fd_in: BorrowedFd<'_>,
9999
fd_out: BorrowedFd<'_>,
100100
len: usize,

src/backend/linux_raw/event/epoll.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,11 @@ impl<'a> Iterator for Iter<'a> {
304304
fn next(&mut self) -> Option<Self::Item> {
305305
self.iter.next()
306306
}
307+
308+
#[inline]
309+
fn size_hint(&self) -> (usize, Option<usize>) {
310+
self.iter.size_hint()
311+
}
307312
}
308313

309314
/// A record of an event that occurred.

src/backend/linux_raw/io/syscalls.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ pub(crate) fn is_read_write(fd: BorrowedFd<'_>) -> io::Result<(bool, bool)> {
277277
match unsafe {
278278
crate::backend::net::syscalls::recv(
279279
fd,
280-
buf.as_mut_ptr() as *mut u8,
280+
buf.as_mut_ptr().cast::<u8>(),
281281
1,
282282
RecvFlags::PEEK | RecvFlags::DONTWAIT,
283283
)

src/backend/linux_raw/net/addr.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,13 +152,13 @@ impl Hash for SocketAddrUnix {
152152
}
153153

154154
impl fmt::Debug for SocketAddrUnix {
155-
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
155+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
156156
if let Some(path) = self.path() {
157-
path.fmt(fmt)
157+
path.fmt(f)
158158
} else if let Some(name) = self.abstract_name() {
159-
name.fmt(fmt)
159+
name.fmt(f)
160160
} else {
161-
"(unnamed)".fmt(fmt)
161+
"(unnamed)".fmt(f)
162162
}
163163
}
164164
}

src/backend/linux_raw/net/netdevice.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
use crate::backend::io::syscalls::ioctl;
44
use crate::fd::AsFd;
55
use crate::io;
6+
use core::ptr::addr_of_mut;
67
use core::{slice, str};
78
use linux_raw_sys::ctypes::c_char;
89
use linux_raw_sys::ioctl::SIOCGIFINDEX;
@@ -32,7 +33,7 @@ pub(crate) fn name_to_index(fd: impl AsFd, if_name: &str) -> io::Result<u32> {
3233
};
3334
unsafe { ifreq.ifr_ifrn.ifrn_name[..if_name_bytes.len()].copy_from_slice(if_name_bytes) };
3435

35-
unsafe { ioctl(fd.as_fd(), SIOCGIFINDEX, &mut ifreq as *mut ifreq as _) }?;
36+
unsafe { ioctl(fd.as_fd(), SIOCGIFINDEX, addr_of_mut!(ifreq).cast()) }?;
3637
let index = unsafe { ifreq.ifr_ifru.ifru_ivalue };
3738
Ok(index as u32)
3839
}
@@ -46,7 +47,7 @@ pub(crate) fn index_to_name(fd: impl AsFd, index: u32) -> io::Result<String> {
4647
},
4748
};
4849

49-
unsafe { ioctl(fd.as_fd(), SIOCGIFNAME, &mut ifreq as *mut ifreq as _) }?;
50+
unsafe { ioctl(fd.as_fd(), SIOCGIFNAME, addr_of_mut!(ifreq).cast()) }?;
5051

5152
if let Some(nul_byte) = unsafe { ifreq.ifr_ifrn.ifrn_name }
5253
.iter()

src/backend/linux_raw/net/sockopt.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -709,7 +709,7 @@ pub(crate) fn set_tcp_keepidle(fd: BorrowedFd<'_>, duration: Duration) -> io::Re
709709
#[inline]
710710
pub(crate) fn get_tcp_keepidle(fd: BorrowedFd<'_>) -> io::Result<Duration> {
711711
let secs: c::c_uint = getsockopt(fd, c::IPPROTO_TCP, c::TCP_KEEPIDLE)?;
712-
Ok(Duration::from_secs(secs as u64))
712+
Ok(Duration::from_secs(secs.into()))
713713
}
714714

715715
#[inline]
@@ -721,7 +721,7 @@ pub(crate) fn set_tcp_keepintvl(fd: BorrowedFd<'_>, duration: Duration) -> io::R
721721
#[inline]
722722
pub(crate) fn get_tcp_keepintvl(fd: BorrowedFd<'_>) -> io::Result<Duration> {
723723
let secs: c::c_uint = getsockopt(fd, c::IPPROTO_TCP, c::TCP_KEEPINTVL)?;
724-
Ok(Duration::from_secs(secs as u64))
724+
Ok(Duration::from_secs(secs.into()))
725725
}
726726

727727
#[inline]
@@ -755,9 +755,10 @@ pub(crate) fn set_tcp_congestion(fd: BorrowedFd<'_>, value: &str) -> io::Result<
755755
#[cfg(feature = "alloc")]
756756
#[inline]
757757
pub(crate) fn get_tcp_congestion(fd: BorrowedFd<'_>) -> io::Result<String> {
758+
const OPTLEN: c::socklen_t = 16;
759+
758760
let level = c::IPPROTO_TCP;
759761
let optname = c::TCP_CONGESTION;
760-
const OPTLEN: c::socklen_t = 16;
761762
let mut value = MaybeUninit::<[MaybeUninit<u8>; OPTLEN as usize]>::uninit();
762763
let mut optlen = OPTLEN;
763764
getsockopt_raw(fd, level, optname, &mut value, &mut optlen)?;

0 commit comments

Comments
 (0)