Skip to content

Commit c8339a6

Browse files
committed
Fix some clippy lints.
1 parent 750add1 commit c8339a6

File tree

23 files changed

+72
-64
lines changed

23 files changed

+72
-64
lines changed

examples/stdio.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -336,11 +336,11 @@ fn show<Fd: AsFd>(fd: Fd) -> io::Result<()> {
336336
#[cfg(not(windows))]
337337
fn key(b: u8) -> String {
338338
if b == 0 {
339-
format!("<undef>")
339+
"<undef>".to_string()
340340
} else if b < 0x20 {
341341
format!("^{}", (b + 0x40) as char)
342342
} else if b == 0x7f {
343-
format!("^?")
343+
"^?".to_string()
344344
} else {
345345
format!("{}", b as char)
346346
}

src/backend/libc/thread/syscalls.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ use {
1212
super::super::conv::{borrowed_fd, ret_c_int, syscall_ret},
1313
crate::fd::BorrowedFd,
1414
crate::process::{Pid, RawNonZeroPid},
15+
crate::utils::as_mut_ptr,
1516
};
1617
#[cfg(not(any(
1718
apple,
@@ -308,8 +309,13 @@ pub(crate) fn capget(
308309
header: &mut linux_raw_sys::general::__user_cap_header_struct,
309310
data: &mut [MaybeUninit<linux_raw_sys::general::__user_cap_data_struct>],
310311
) -> io::Result<()> {
311-
let header: *mut _ = header;
312-
unsafe { syscall_ret(c::syscall(c::SYS_capget, header, data.as_mut_ptr())) }
312+
unsafe {
313+
syscall_ret(c::syscall(
314+
c::SYS_capget,
315+
as_mut_ptr(header),
316+
data.as_mut_ptr(),
317+
))
318+
}
313319
}
314320

315321
#[cfg(linux_kernel)]
@@ -318,8 +324,7 @@ pub(crate) fn capset(
318324
header: &mut linux_raw_sys::general::__user_cap_header_struct,
319325
data: &[linux_raw_sys::general::__user_cap_data_struct],
320326
) -> io::Result<()> {
321-
let header: *mut _ = header;
322-
unsafe { syscall_ret(c::syscall(c::SYS_capset, header, data.as_ptr())) }
327+
unsafe { syscall_ret(c::syscall(c::SYS_capset, as_mut_ptr(header), data.as_ptr())) }
323328
}
324329

325330
#[cfg(linux_kernel)]

src/backend/libc/time/syscalls.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,6 @@ pub(crate) fn clock_settime(id: ClockId, timespec: Timespec) -> io::Result<()> {
277277
any(target_arch = "arm", target_arch = "mips", target_arch = "x86"),
278278
target_env = "gnu",
279279
))]
280-
#[must_use]
281280
unsafe fn clock_settime_old(id: ClockId, timespec: Timespec) -> io::Result<()> {
282281
use core::convert::TryInto;
283282
let old_timespec = c::timespec {

src/backend/linux_raw/arch/inline/x86.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ pub(in crate::backend) unsafe fn indirect_syscall4(
113113
) -> RetReg<R0> {
114114
let r0;
115115
// a3 should go in esi, but `asm!` won't let us use it as an operand.
116-
// temporarily swap it into place, and then swap it back afterward.
116+
// Temporarily swap it into place, and then swap it back afterward.
117117
//
118118
// We hard-code the callee operand to use edi instead of `in(reg)` because
119119
// even though we can't name esi as an operand, the compiler can use esi to

src/backend/linux_raw/elf.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//! The ELF ABI.
1+
//! The ELF ABI. 🧝
22
33
#![allow(non_snake_case)]
44
#![cfg_attr(

src/backend/linux_raw/fs/inotify.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ bitflags! {
7676
/// Use the [`CreateFlags::CLOEXEC`] flag to prevent the resulting file
7777
/// descriptor from being implicitly passed across `exec` boundaries.
7878
#[doc(alias = "inotify_init1")]
79+
#[inline]
7980
pub fn inotify_init(flags: CreateFlags) -> io::Result<OwnedFd> {
8081
syscalls::inotify_init1(flags)
8182
}
@@ -89,6 +90,7 @@ pub fn inotify_init(flags: CreateFlags) -> io::Result<OwnedFd> {
8990
/// different paths to this method may result in it returning
9091
/// the same watch descriptor. An application should keep track of this
9192
/// externally to avoid logic errors.
93+
#[inline]
9294
pub fn inotify_add_watch<P: crate::path::Arg>(
9395
inot: BorrowedFd<'_>,
9496
path: P,
@@ -103,6 +105,7 @@ pub fn inotify_add_watch<P: crate::path::Arg>(
103105
/// The watch descriptor provided should have previously been returned
104106
/// by [`inotify_add_watch`] and not previously have been removed.
105107
#[doc(alias = "inotify_rm_watch")]
108+
#[inline]
106109
pub fn inotify_remove_watch(inot: BorrowedFd<'_>, wd: i32) -> io::Result<()> {
107110
syscalls::inotify_rm_watch(inot, wd)
108111
}

src/backend/linux_raw/fs/types.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ impl From<RawMode> for Mode {
136136
}
137137

138138
impl From<Mode> for RawMode {
139-
/// Support conversions from `Mode to raw mode values.
139+
/// Support conversions from `Mode` to raw mode values.
140140
///
141141
/// ```
142142
/// use rustix::fs::{Mode, RawMode};

src/backend/linux_raw/io/epoll.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ pub fn epoll_create(flags: CreateFlags) -> io::Result<OwnedFd> {
160160
/// is an `Arc<dyn SystemResource>`, then `epoll` can be thought to maintain
161161
/// a `Weak<dyn SystemResource>` to the file descriptor.
162162
#[doc(alias = "epoll_ctl")]
163+
#[inline]
163164
pub fn epoll_add(
164165
epoll: impl AsFd,
165166
source: impl AsFd,
@@ -185,6 +186,7 @@ pub fn epoll_add(
185186
///
186187
/// This sets the events of interest with `target` to `events`.
187188
#[doc(alias = "epoll_ctl")]
189+
#[inline]
188190
pub fn epoll_mod(
189191
epoll: impl AsFd,
190192
source: impl AsFd,
@@ -211,6 +213,7 @@ pub fn epoll_mod(
211213
///
212214
/// This also returns the owning `Data`.
213215
#[doc(alias = "epoll_ctl")]
216+
#[inline]
214217
pub fn epoll_del(epoll: impl AsFd, source: impl AsFd) -> io::Result<()> {
215218
// SAFETY: We're calling `epoll_ctl` via FFI and we know how it
216219
// behaves.
@@ -225,6 +228,7 @@ pub fn epoll_del(epoll: impl AsFd, source: impl AsFd) -> io::Result<()> {
225228
///
226229
/// For each event of interest, an element is written to `events`. On
227230
/// success, this returns the number of written elements.
231+
#[inline]
228232
pub fn epoll_wait(
229233
epoll: impl AsFd,
230234
event_list: &mut EventVec,
@@ -254,6 +258,7 @@ pub struct Iter<'a> {
254258
impl<'a> Iterator for Iter<'a> {
255259
type Item = (EventFlags, u64);
256260

261+
#[inline]
257262
fn next(&mut self) -> Option<Self::Item> {
258263
self.iter
259264
.next()

src/backend/linux_raw/io/types.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ impl<'a> IoSliceRaw<'a> {
109109
pub fn from_slice(buf: &'a [u8]) -> Self {
110110
IoSliceRaw {
111111
_buf: c::iovec {
112-
iov_base: buf.as_ptr() as *mut u8 as *mut c::c_void,
112+
iov_base: (buf.as_ptr() as *mut u8).cast::<c::c_void>(),
113113
iov_len: buf.len() as _,
114114
},
115115
_lifetime: PhantomData,
@@ -120,7 +120,7 @@ impl<'a> IoSliceRaw<'a> {
120120
pub fn from_slice_mut(buf: &'a mut [u8]) -> Self {
121121
IoSliceRaw {
122122
_buf: c::iovec {
123-
iov_base: buf.as_mut_ptr() as *mut c::c_void,
123+
iov_base: buf.as_mut_ptr().cast::<c::c_void>(),
124124
iov_len: buf.len() as _,
125125
},
126126
_lifetime: PhantomData,

src/backend/linux_raw/net/addr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ impl SocketAddrUnix {
5959
}
6060
}
6161

62-
fn init() -> c::sockaddr_un {
62+
const fn init() -> c::sockaddr_un {
6363
c::sockaddr_un {
6464
sun_family: c::AF_UNIX as _,
6565
sun_path: [0; 108],

0 commit comments

Comments
 (0)