aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorReiner Herrmann <reiner@reiner-h.de>2026-06-04 20:41:18 +0200
committerReiner Herrmann <reiner@reiner-h.de>2026-06-04 20:41:18 +0200
commit8aa4e4dfec6ac455fd7f4f3402439648bd4200f1 (patch)
tree95a612fe5e59a401f4f3afb64840f96c8485a6ea
parent4b8f49ad04badb1f8268308dcf02a5c0f9fb7907 (diff)
Fix clippy warnings
-rw-r--r--src/lib.rs5
-rw-r--r--src/tftpd.rs16
2 files changed, 11 insertions, 10 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 94de64d..bae5190 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -16,6 +16,7 @@ pub static VERSION: Option<&str> = option_env!("CARGO_PKG_VERSION");
/// * `cur` - current number of bytes
/// * `total` - total number of bytes; 0 if unknown
/// * `state` - state that was returned in previous call
+///
/// Returns state that should get passed in next invocation
type ProgressCallback = fn(cur: u64, total: u64, state: u64) -> u64;
@@ -516,7 +517,7 @@ impl Tftp {
match u16::from_be_bytes([buf[0], buf[1]]) { // opcode
opc if opc == Opcode::DATA as u16 => (),
opc if opc == Opcode::ERROR as u16 => return Err(self.parse_error(&buf[..len])),
- _ => return Err(io::Error::new(io::ErrorKind::Other, "unexpected opcode")),
+ _ => return Err(io::Error::other("unexpected opcode")),
};
if u16::from_be_bytes([buf[2], buf[3]]) != block_nr {
/* already received or packets were missed, re-acknowledge */
@@ -550,7 +551,7 @@ impl Tftp {
if netascii_state {
/* the file ended with an incomplete \r encoding */
- file.write_all(&[b'\r'])?;
+ file.write_all(b"\r")?;
}
file.flush()?;
diff --git a/src/tftpd.rs b/src/tftpd.rs
index 24877be..ae719de 100644
--- a/src/tftpd.rs
+++ b/src/tftpd.rs
@@ -62,7 +62,7 @@ impl Tftpd {
}
fn file_allowed(&self, filename: &Path) -> Option<PathBuf> {
- if self.conf.dir == PathBuf::from("/") {
+ if self.conf.dir == *"/" {
/* running either chrooted in requested directory,
or whole root is being served */
return Some(filename.to_path_buf());
@@ -90,7 +90,7 @@ impl Tftpd {
"netascii" => self.tftp.set_mode(rtftp::Mode::NETASCII),
_ => {
self.tftp.send_error(socket, 0, "Unsupported mode")?;
- return Err(io::Error::new(io::ErrorKind::Other, "unsupported mode"));
+ return Err(io::Error::other("unsupported mode"));
}
}
@@ -137,7 +137,7 @@ impl Tftpd {
"netascii" => self.tftp.set_mode(rtftp::Mode::NETASCII),
_ => {
self.tftp.send_error(socket, 0, "Unsupported mode")?;
- return Err(io::Error::new(io::ErrorKind::Other, "unsupported mode"));
+ return Err(io::Error::other("unsupported mode"));
}
}
@@ -188,14 +188,14 @@ impl Tftpd {
if buf.len() < 2 {
self.tftp.send_error(&socket, 0, "Invalid request length")?;
- return Err(io::Error::new(io::ErrorKind::Other, "invalid request length"));
+ return Err(io::Error::other("invalid request length"));
}
match u16::from_be_bytes([buf[0], buf[1]]) { // opcode
o if o == rtftp::Opcode::RRQ as u16 => {
if self.conf.wo {
self.tftp.send_error(&socket, 4, "reading not allowed")?;
- Err(io::Error::new(io::ErrorKind::Other, "unallowed mode"))
+ Err(io::Error::other("unallowed mode"))
} else {
self.handle_rrq(&socket, cl, &buf[2..])
}
@@ -203,7 +203,7 @@ impl Tftpd {
o if o == rtftp::Opcode::WRQ as u16 => {
if self.conf.ro {
self.tftp.send_error(&socket, 4, "writing not allowed")?;
- Err(io::Error::new(io::ErrorKind::Other, "unallowed mode"))
+ Err(io::Error::other("unallowed mode"))
} else {
self.handle_wrq(&socket, cl, &buf[2..])
}
@@ -211,7 +211,7 @@ impl Tftpd {
o if o == rtftp::Opcode::ERROR as u16 => Ok(format!("Received ERROR from {}", cl)),
_ => {
self.tftp.send_error(&socket, 4, "Unexpected opcode")?;
- Err(io::Error::new(io::ErrorKind::Other, "unexpected opcode"))
+ Err(io::Error::other("unexpected opcode"))
}
}
}
@@ -252,7 +252,7 @@ impl Tftpd {
self.conf.dir = PathBuf::from("/");
Ok(())
},
- Err(err) if err == nix::errno::Errno::EPERM => Ok(()),
+ Err(nix::errno::Errno::EPERM) => Ok(()),
Err(err) if Uid::effective() == ROOT => Err(err),
Err(_) => Ok(()),
}