Skip to content

Commit

Permalink
Address clippy lints
Browse files Browse the repository at this point in the history
  • Loading branch information
mahkoh committed Mar 6, 2024
1 parent 7b9f338 commit c33eadd
Show file tree
Hide file tree
Showing 17 changed files with 11 additions and 24 deletions.
6 changes: 2 additions & 4 deletions uapi-proc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,7 @@ pub fn sock_opt(item: proc_macro::TokenStream) -> proc_macro::TokenStream {
if get {
let man = format!(
"getsockopt(2) with level = `{}` and optname = `{}`",
level.to_string(),
optname.to_string()
level, optname
);
let fnname = Ident::new(
&format!("getsockopt_{}", optname.to_string().to_lowercase()),
Expand All @@ -291,8 +290,7 @@ pub fn sock_opt(item: proc_macro::TokenStream) -> proc_macro::TokenStream {
if set {
let man = format!(
"setsockopt(2) with level = `{}` and optname = `{}`",
level.to_string(),
optname.to_string()
level, optname
);
let fnname = Ident::new(
&format!("setsockopt_{}", optname.to_string().to_lowercase()),
Expand Down
2 changes: 1 addition & 1 deletion uapi-testutils/src/strace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pub fn strace<T, F: FnOnce() -> T>(trace: bool, f: F) -> T {
let mut pipe = || loop {
let res = read(*stderr, &mut buf[..]);
match res {
Ok(buf) if buf.is_empty() => break,
Ok([]) => break,
Err(Errno(c::EAGAIN)) => break,
Ok(buf) => {
// std::io::Write::write_all(&mut Fd::new(2), &buf[..n]).unwrap();
Expand Down
2 changes: 1 addition & 1 deletion uapi/src/file/linux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub fn copy_file_range(
off_in.map(|p| p as *mut _).unwrap_or(ptr::null_mut()) as usize,
fd_out as usize,
off_out.map(|p| p as *mut _).unwrap_or(ptr::null_mut()) as usize,
len as usize,
len,
flags as usize,
)
};
Expand Down
6 changes: 3 additions & 3 deletions uapi/src/ioctl/linux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ pub const _IOC_TYPEBITS: u64 = 8;
/// [`_IOC_NRSHIFT`](https://github.com/torvalds/linux/blob/v5.6/include/uapi/asm-generic/ioctl.h)
pub const _IOC_NRSHIFT: u64 = 0;
/// [`_IOC_TYPESHIFT`](https://github.com/torvalds/linux/blob/v5.6/include/uapi/asm-generic/ioctl.h)
pub const _IOC_TYPESHIFT: u64 = _IOC_NRSHIFT + _IOC_NRBITS as u64;
pub const _IOC_TYPESHIFT: u64 = _IOC_NRSHIFT + _IOC_NRBITS;
/// [`_IOC_SIZESHIFT`](https://github.com/torvalds/linux/blob/v5.6/include/uapi/asm-generic/ioctl.h)
pub const _IOC_SIZESHIFT: u64 = _IOC_TYPESHIFT + _IOC_TYPEBITS as u64;
pub const _IOC_SIZESHIFT: u64 = _IOC_TYPESHIFT + _IOC_TYPEBITS;
/// [`_IOC_DIRSHIFT`](https://github.com/torvalds/linux/blob/v5.6/include/uapi/asm-generic/ioctl.h)
pub const _IOC_DIRSHIFT: u64 = _IOC_SIZESHIFT + _IOC_SIZEBITS as u64;
pub const _IOC_DIRSHIFT: u64 = _IOC_SIZESHIFT + _IOC_SIZEBITS;
/// [`_IOC_NRMASK`](https://github.com/torvalds/linux/blob/v5.6/include/uapi/asm-generic/ioctl.h)
pub const _IOC_NRMASK: u64 = (1 << _IOC_NRBITS) - 1;
/// [`_IOC_TYPEMASK`](https://github.com/torvalds/linux/blob/v5.6/include/uapi/asm-generic/ioctl.h)
Expand Down
4 changes: 2 additions & 2 deletions uapi/src/sched/linux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pub fn sched_setaffinity(pid: c::pid_t, mask: &[usize]) -> Result<()> {
let res = c::syscall(
c::SYS_sched_setaffinity,
pid as usize,
mem::size_of_val(mask) as usize,
mem::size_of_val(mask),
mask.as_ptr() as usize,
);
map_err!(res).map(drop)
Expand All @@ -20,7 +20,7 @@ pub fn sched_getaffinity(pid: c::pid_t, mask: &mut [usize]) -> Result<usize> {
let res = c::syscall(
c::SYS_sched_getaffinity,
pid as usize,
mem::size_of_val(mask) as usize,
mem::size_of_val(mask),
mask.as_mut_ptr() as usize,
);
map_err!(res).map(|v| v as usize)
Expand Down
2 changes: 1 addition & 1 deletion uapi/src/socket/cmsg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,6 @@ pub fn cmsg_write<T: ?Sized>(
ptr.add(HDR_SPACE)
.copy_from_nonoverlapping(data as *const _ as *const _, data_size);
}
*buf = &mut mem::replace(buf, &mut [])[cmsg_space..];
*buf = &mut mem::take(buf)[cmsg_space..];
Ok(cmsg_space)
}
3 changes: 1 addition & 2 deletions uapi/src/ustr/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
pub use self::{
as_ustr::*, bstr::*, bytes::*, eq::*, into::*, read::*, ustr::*, ustring::*,
ustrptr::*,
as_ustr::*, bstr::*, bytes::*, into::*, read::*, ustr::*, ustring::*, ustrptr::*,
};

mod as_ustr;
Expand Down
1 change: 0 additions & 1 deletion uapi/tests/main/fcntl/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use uapi::*;
cfg_if::cfg_if! {
if #[cfg(target_os = "linux")] {
mod linux;
pub use linux::*;
}
}

Expand Down
1 change: 0 additions & 1 deletion uapi/tests/main/file/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ use uapi::*;
cfg_if! {
if #[cfg(target_os = "linux")] {
mod linux;
pub use linux::*;
}
}

Expand Down
1 change: 0 additions & 1 deletion uapi/tests/main/ioctl/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@ use cfg_if::cfg_if;
cfg_if! {
if #[cfg(any(target_os = "linux", target_os = "android"))] {
mod linux;
pub use linux::*;
}
}
1 change: 0 additions & 1 deletion uapi/tests/main/mount/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@ use cfg_if::cfg_if;
cfg_if! {
if #[cfg(target_os = "linux")] {
mod linux;
pub use linux::*;
}
}
1 change: 0 additions & 1 deletion uapi/tests/main/other/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use uapi::*;
cfg_if::cfg_if! {
if #[cfg(target_os = "linux")] {
mod linux;
pub use linux::*;
}
}

Expand Down
1 change: 0 additions & 1 deletion uapi/tests/main/poll/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use uapi::*;
cfg_if::cfg_if! {
if #[cfg(target_os = "linux")] {
mod linux;
pub use linux::*;
}
}

Expand Down
1 change: 0 additions & 1 deletion uapi/tests/main/process/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use uapi::*;
cfg_if::cfg_if! {
if #[cfg(target_os = "linux")] {
mod linux;
pub use linux::*;
}
}

Expand Down
1 change: 0 additions & 1 deletion uapi/tests/main/sched/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use uapi::*;
cfg_if::cfg_if! {
if #[cfg(target_os = "linux")] {
mod linux;
pub use linux::*;
}
}

Expand Down
1 change: 0 additions & 1 deletion uapi/tests/main/socket/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ use uapi::*;
cfg_if::cfg_if! {
if #[cfg(target_os = "linux")] {
mod linux;
pub use linux::*;
}
}

Expand Down
1 change: 0 additions & 1 deletion uapi/tests/main/timer/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
cfg_if::cfg_if! {
if #[cfg(target_os = "linux")] {
mod linux;
pub use linux::*;
}
}

0 comments on commit c33eadd

Please sign in to comment.