Skip to content

Commit 72bc1d8

Browse files
authored
Miscellaneous clippy fixes. (#1366)
1 parent 94ba12b commit 72bc1d8

File tree

11 files changed

+59
-47
lines changed

11 files changed

+59
-47
lines changed

src/backend/libc/conv.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,13 @@ pub(super) fn c_str(c: &CStr) -> *const c::c_char {
1616
c.as_ptr().cast()
1717
}
1818

19-
#[cfg(not(any(windows, target_os = "espidf", target_os = "vita", target_os = "wasi")))]
19+
#[cfg(not(any(
20+
windows,
21+
target_os = "espidf",
22+
target_os = "horizon",
23+
target_os = "vita",
24+
target_os = "wasi"
25+
)))]
2026
#[inline]
2127
pub(super) fn no_fd() -> LibcFd {
2228
-1

src/backend/libc/fs/syscalls.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -879,10 +879,8 @@ pub(crate) fn utimensat(
879879
{
880880
#[cfg(target_env = "gnu")]
881881
if let Some(libc_utimensat) = __utimensat64.get() {
882-
let libc_times: [LibcTimespec; 2] = [
883-
times.last_access.clone().into(),
884-
times.last_modification.clone().into(),
885-
];
882+
let libc_times: [LibcTimespec; 2] =
883+
[times.last_access.into(), times.last_modification.into()];
886884

887885
unsafe {
888886
return ret(libc_utimensat(
@@ -1631,10 +1629,8 @@ pub(crate) fn futimens(fd: BorrowedFd<'_>, times: &Timestamps) -> io::Result<()>
16311629
{
16321630
#[cfg(target_env = "gnu")]
16331631
if let Some(libc_futimens) = __futimens64.get() {
1634-
let libc_times: [LibcTimespec; 2] = [
1635-
times.last_access.clone().into(),
1636-
times.last_modification.clone().into(),
1637-
];
1632+
let libc_times: [LibcTimespec; 2] =
1633+
[times.last_access.into(), times.last_modification.into()];
16381634

16391635
unsafe {
16401636
return ret(libc_futimens(borrowed_fd(fd), libc_times.as_ptr()));

src/backend/libc/termios/types.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
#![allow(non_camel_case_types)]
44

5-
#[cfg(not(target_os = "redox"))]
5+
#[cfg(not(any(target_os = "espidf", target_os = "redox")))]
66
use crate::ffi;
77

88
// We don't want to use `tcflag_t` directly so we don't expose libc
@@ -13,5 +13,5 @@ use crate::ffi;
1313
pub type tcflag_t = ffi::c_ulong;
1414
#[cfg(target_os = "redox")]
1515
pub type tcflag_t = u32;
16-
#[cfg(not(any(apple, target_os = "redox", target_os = "wasi")))]
16+
#[cfg(not(any(apple, target_os = "espidf", target_os = "redox", target_os = "wasi")))]
1717
pub type tcflag_t = ffi::c_uint;

src/backend/libc/thread/syscalls.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -179,14 +179,12 @@ pub(crate) fn clock_nanosleep_absolute(id: ClockId, request: &Timespec) -> io::R
179179
if let Some(libc_clock_nanosleep) = __clock_nanosleep_time64.get() {
180180
let flags = c::TIMER_ABSTIME;
181181
unsafe {
182-
return match {
183-
libc_clock_nanosleep(
184-
id as c::clockid_t,
185-
flags,
186-
&request.clone().into(),
187-
core::ptr::null_mut(),
188-
)
189-
} {
182+
return match libc_clock_nanosleep(
183+
id as c::clockid_t,
184+
flags,
185+
&request.clone().into(),
186+
core::ptr::null_mut(),
187+
) {
190188
0 => Ok(()),
191189
err => Err(io::Errno(err)),
192190
};

src/maybe_polyfill/no_std/os/fd/owned.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ impl OwnedFd {
114114
// no capabilities for multi-process execution. While F_DUPFD is also
115115
// not supported yet, it might be (currently it returns ENOSYS).
116116
#[cfg(target_os = "espidf")]
117-
let fd = crate::io::fcntl_dupfd(self)?;
117+
let fd = crate::io::fcntl_dupfd(self, 0)?;
118118

119119
Ok(fd.into())
120120
}

src/path/arg.rs

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1019,7 +1019,7 @@ where
10191019
// for `bytes.len() + 1` `u8`s:
10201020
unsafe {
10211021
ptr::copy_nonoverlapping(bytes.as_ptr(), buf_ptr, bytes.len());
1022-
buf_ptr.add(bytes.len()).write(0);
1022+
buf_ptr.add(bytes.len()).write(b'\0');
10231023
}
10241024

10251025
// SAFETY: We just wrote the bytes above and they will remain valid for the
@@ -1046,11 +1046,26 @@ where
10461046

10471047
#[cfg(not(feature = "alloc"))]
10481048
{
1049-
#[cfg(all(libc, not(any(target_os = "hurd", target_os = "wasi"))))]
1049+
#[cfg(all(
1050+
libc,
1051+
not(any(
1052+
target_os = "espidf",
1053+
target_os = "horizon",
1054+
target_os = "hurd",
1055+
target_os = "vita",
1056+
target_os = "wasi"
1057+
))
1058+
))]
10501059
const LARGE_PATH_BUFFER_SIZE: usize = libc::PATH_MAX as usize;
10511060
#[cfg(linux_raw)]
10521061
const LARGE_PATH_BUFFER_SIZE: usize = linux_raw_sys::general::PATH_MAX as usize;
1053-
#[cfg(any(target_os = "hurd", target_os = "wasi"))]
1062+
#[cfg(any(
1063+
target_os = "espidf",
1064+
target_os = "horizon",
1065+
target_os = "hurd",
1066+
target_os = "vita",
1067+
target_os = "wasi"
1068+
))]
10541069
const LARGE_PATH_BUFFER_SIZE: usize = 4096 as usize; // TODO: upstream this
10551070

10561071
// Taken from
@@ -1067,7 +1082,7 @@ where
10671082
// space for `bytes.len() + 1` `u8`s:
10681083
unsafe {
10691084
ptr::copy_nonoverlapping(bytes.as_ptr(), buf_ptr, bytes.len());
1070-
buf_ptr.add(bytes.len()).write(0);
1085+
buf_ptr.add(bytes.len()).write(b'\0');
10711086
}
10721087

10731088
// SAFETY: We just wrote the bytes above and they will remain valid for

src/process/ioctl.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,13 @@ pub fn ioctl_tiocsctty<Fd: AsFd>(fd: Fd) -> io::Result<()> {
3535
unsafe { ioctl::ioctl(fd, Tiocsctty) }
3636
}
3737

38-
#[cfg(not(any(windows, target_os = "aix", target_os = "redox", target_os = "wasi")))]
38+
#[cfg(not(any(
39+
windows,
40+
target_os = "aix",
41+
target_os = "horizon",
42+
target_os = "redox",
43+
target_os = "wasi"
44+
)))]
3945
struct Tiocsctty;
4046

4147
#[cfg(not(any(

src/process/mod.rs

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,7 @@ mod pidfd_getfd;
2929
mod pivot_root;
3030
#[cfg(linux_kernel)]
3131
mod prctl;
32-
#[cfg(not(any(
33-
target_os = "fuchsia",
34-
target_os = "horizon",
35-
target_os = "vita",
36-
target_os = "wasi"
37-
)))]
32+
#[cfg(not(any(target_os = "fuchsia", target_os = "vita", target_os = "wasi")))]
3833
// WASI doesn't have [gs]etpriority.
3934
mod priority;
4035
#[cfg(freebsdlike)]
@@ -91,12 +86,7 @@ pub use pidfd_getfd::*;
9186
pub use pivot_root::*;
9287
#[cfg(linux_kernel)]
9388
pub use prctl::*;
94-
#[cfg(not(any(
95-
target_os = "fuchsia",
96-
target_os = "horizon",
97-
target_os = "vita",
98-
target_os = "wasi"
99-
)))]
89+
#[cfg(not(any(target_os = "fuchsia", target_os = "vita", target_os = "wasi")))]
10090
pub use priority::*;
10191
#[cfg(freebsdlike)]
10292
pub use procctl::*;

src/process/priority.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#[cfg(not(target_os = "espidf"))]
1+
#[cfg(not(any(target_os = "espidf", target_os = "horizon")))]
22
use crate::process::{Pid, Uid};
33
use crate::{backend, io};
44

@@ -26,7 +26,7 @@ pub fn nice(inc: i32) -> io::Result<i32> {
2626
/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9799919799/functions/getpriority.html
2727
/// [Linux]: https://man7.org/linux/man-pages/man2/getpriority.2.html
2828
/// [Apple]: https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/setpriority.2.html
29-
#[cfg(not(target_os = "espidf"))]
29+
#[cfg(not(any(target_os = "espidf", target_os = "horizon")))]
3030
#[inline]
3131
#[doc(alias = "getpriority")]
3232
pub fn getpriority_user(uid: Uid) -> io::Result<i32> {
@@ -46,7 +46,7 @@ pub fn getpriority_user(uid: Uid) -> io::Result<i32> {
4646
/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9799919799/functions/getpriority.html
4747
/// [Linux]: https://man7.org/linux/man-pages/man2/getpriority.2.html
4848
/// [Apple]: https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/setpriority.2.html
49-
#[cfg(not(target_os = "espidf"))]
49+
#[cfg(not(any(target_os = "espidf", target_os = "horizon")))]
5050
#[inline]
5151
#[doc(alias = "getpriority")]
5252
pub fn getpriority_pgrp(pgid: Option<Pid>) -> io::Result<i32> {
@@ -66,7 +66,7 @@ pub fn getpriority_pgrp(pgid: Option<Pid>) -> io::Result<i32> {
6666
/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9799919799/functions/getpriority.html
6767
/// [Linux]: https://man7.org/linux/man-pages/man2/getpriority.2.html
6868
/// [Apple]: https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/setpriority.2.html
69-
#[cfg(not(target_os = "espidf"))]
69+
#[cfg(not(any(target_os = "espidf", target_os = "horizon")))]
7070
#[inline]
7171
#[doc(alias = "getpriority")]
7272
pub fn getpriority_process(pid: Option<Pid>) -> io::Result<i32> {
@@ -84,7 +84,7 @@ pub fn getpriority_process(pid: Option<Pid>) -> io::Result<i32> {
8484
/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9799919799/functions/setpriority.html
8585
/// [Linux]: https://man7.org/linux/man-pages/man2/setpriority.2.html
8686
/// [Apple]: https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/setpriority.2.html
87-
#[cfg(not(target_os = "espidf"))]
87+
#[cfg(not(any(target_os = "espidf", target_os = "horizon")))]
8888
#[inline]
8989
#[doc(alias = "setpriority")]
9090
pub fn setpriority_user(uid: Uid, priority: i32) -> io::Result<()> {
@@ -104,7 +104,7 @@ pub fn setpriority_user(uid: Uid, priority: i32) -> io::Result<()> {
104104
/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9799919799/functions/setpriority.html
105105
/// [Linux]: https://man7.org/linux/man-pages/man2/setpriority.2.html
106106
/// [Apple]: https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/setpriority.2.html
107-
#[cfg(not(target_os = "espidf"))]
107+
#[cfg(not(any(target_os = "espidf", target_os = "horizon")))]
108108
#[inline]
109109
#[doc(alias = "setpriority")]
110110
pub fn setpriority_pgrp(pgid: Option<Pid>, priority: i32) -> io::Result<()> {
@@ -124,7 +124,7 @@ pub fn setpriority_pgrp(pgid: Option<Pid>, priority: i32) -> io::Result<()> {
124124
/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9799919799/functions/setpriority.html
125125
/// [Linux]: https://man7.org/linux/man-pages/man2/setpriority.2.html
126126
/// [Apple]: https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/setpriority.2.html
127-
#[cfg(not(target_os = "espidf"))]
127+
#[cfg(not(any(target_os = "espidf", target_os = "horizon")))]
128128
#[inline]
129129
#[doc(alias = "setpriority")]
130130
pub fn setpriority_process(pid: Option<Pid>, priority: i32) -> io::Result<()> {

tests/process/prctl.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,11 @@ fn test_enabled_pointer_authentication_keys() {
7070
}
7171

7272
#[test]
73-
#[ignore = "?"]
7473
fn test_child_subreaper() {
7574
dbg!(child_subreaper().unwrap());
7675
}
7776

7877
#[test]
79-
#[ignore = "?"]
8078
fn test_speculative_feature_state() {
8179
dbg!(speculative_feature_state(SpeculationFeature::SpeculativeStoreBypass).unwrap());
8280
dbg!(speculative_feature_state(SpeculationFeature::IndirectBranchSpeculation).unwrap());

0 commit comments

Comments
 (0)