aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJonas Maier <jonas@x77.dev>2026-03-15 21:03:30 +0100
committerJonas Maier <jonas@x77.dev>2026-03-15 21:03:30 +0100
commit7bb25e51a1ad52f043836b425f2e8d3670e96f34 (patch)
tree4396257b4d9a6ef242e32f9599e2102d214c8db1 /src
parent792a675a6422ccb3e8ff8ccbf6d45f0833e0e67c (diff)
downloadpish-7bb25e51a1ad52f043836b425f2e8d3670e96f34.tar.gz
cargo clippy
Diffstat (limited to 'src')
-rw-r--r--src/export_fun.rs2
-rw-r--r--src/run/mod.rs5
-rw-r--r--src/rw.rs31
-rw-r--r--src/wait/child.rs2
4 files changed, 16 insertions, 24 deletions
diff --git a/src/export_fun.rs b/src/export_fun.rs
index 64810eb..cef3492 100644
--- a/src/export_fun.rs
+++ b/src/export_fun.rs
@@ -229,7 +229,7 @@ pub fn maybe_run_defined_function() {
let uid: uid_t = String::from_utf8_lossy(it.next().unwrap()).parse().unwrap();
let gid: gid_t = String::from_utf8_lossy(it.next().unwrap()).parse().unwrap();
- if let Ok(stream) = UnixStream::connect(OsStr::from_bytes(&socket)) {
+ if let Ok(stream) = UnixStream::connect(OsStr::from_bytes(socket)) {
let _ = handle_client(stream, uid, gid);
}
diff --git a/src/run/mod.rs b/src/run/mod.rs
index 679dd44..1133ddb 100644
--- a/src/run/mod.rs
+++ b/src/run/mod.rs
@@ -140,10 +140,7 @@ impl SpawnedCmd {
match self {
SpawnedCmd::Builtin(tw) => tw.try_join(timeout_ms),
SpawnedCmd::Fun(tw) => tw.try_join(timeout_ms),
- SpawnedCmd::Child(child) => match child.wait(timeout_ms) {
- Ok(None) => false,
- _ => true,
- },
+ SpawnedCmd::Child(child) => !matches!(child.wait(timeout_ms), Ok(None)),
SpawnedCmd::SpawnError(_) => true,
SpawnedCmd::Joined(_) => true,
SpawnedCmd::Pipeline(pipes) => pipes
diff --git a/src/rw.rs b/src/rw.rs
index 96031cc..601a2ec 100644
--- a/src/rw.rs
+++ b/src/rw.rs
@@ -133,17 +133,17 @@ fn check<'a>(
return PollStatus::Cancel;
};
- if let Some(event) = poll_fds[0].revents() {
- if event.contains(PollFlags::POLLIN) {
- canceled.store(true, SeqCst);
- return PollStatus::Cancel;
- }
+ if let Some(event) = poll_fds[0].revents()
+ && event.contains(PollFlags::POLLIN)
+ {
+ canceled.store(true, SeqCst);
+ return PollStatus::Cancel;
}
- if let Some(event) = poll_fds[1].revents() {
- if event.contains(flags) {
- return PollStatus::Ready;
- }
+ if let Some(event) = poll_fds[1].revents()
+ && event.contains(flags)
+ {
+ return PollStatus::Ready;
}
PollStatus::Wait
@@ -157,7 +157,7 @@ impl InputReader {
Input::Pipe(pipe) => pipe.as_fd(),
Input::File(file) => file.as_fd(),
};
- check(&*self.canceled, &self.cancel, read_fd, PollFlags::POLLIN)
+ check(&self.canceled, &self.cancel, read_fd, PollFlags::POLLIN)
}
}
@@ -176,7 +176,7 @@ impl Read for InputReader {
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
loop {
match self.poll() {
- PollStatus::Cancel => return Err(io::Error::new(io::ErrorKind::Other, Canceled)),
+ PollStatus::Cancel => return Err(io::Error::other(Canceled)),
PollStatus::Ready => (),
PollStatus::Wait => continue,
}
@@ -214,12 +214,7 @@ impl OutputWriter {
Output::Pipe(pipe) => pipe.as_fd(),
Output::File(file) => file.as_fd(),
};
- check(
- &mut self.canceled,
- &self.cancel,
- write_fd,
- PollFlags::POLLOUT,
- )
+ check(&self.canceled, &self.cancel, write_fd, PollFlags::POLLOUT)
}
pub fn try_clone(&self) -> io::Result<Self> {
let output = self.output.try_clone()?;
@@ -237,7 +232,7 @@ impl Write for OutputWriter {
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
loop {
match self.poll() {
- PollStatus::Cancel => return Err(io::Error::new(io::ErrorKind::Other, Canceled)),
+ PollStatus::Cancel => return Err(io::Error::other(Canceled)),
PollStatus::Ready => (),
PollStatus::Wait => continue,
}
diff --git a/src/wait/child.rs b/src/wait/child.rs
index 29a7d70..8859eb4 100644
--- a/src/wait/child.rs
+++ b/src/wait/child.rs
@@ -33,7 +33,7 @@ impl ChildWaiter {
pub fn new(child: Child) -> io::Result<Self> {
let fd = unsafe { syscall(SYS_pidfd_open, child.id(), 0) };
if fd < 0 {
- Err(io::Error::new(io::ErrorKind::Other, PidFdOpenError))
+ Err(io::Error::other(PidFdOpenError))
} else {
let fd = fd as RawFd;
Ok(Self { child, fd })