diff --git a/crates/common/src/access_list.rs b/crates/common/src/access_list.rs index 459c5ca..5ba7ea8 100644 --- a/crates/common/src/access_list.rs +++ b/crates/common/src/access_list.rs @@ -71,7 +71,7 @@ impl AccessList { } new_list - .insert_from_line(&line) + .insert_from_line(line) .with_context(|| format!("Invalid line in access list: {}", line))?; } @@ -86,6 +86,7 @@ impl AccessList { } } + #[allow(clippy::len_without_is_empty)] pub fn len(&self) -> usize { self.0.len() } @@ -155,10 +156,10 @@ mod tests { fn test_parse_info_hash() { let f = parse_info_hash; - assert!(f("aaaabbbbccccddddeeeeaaaabbbbccccddddeeee".into()).is_ok()); - assert!(f("aaaabbbbccccddddeeeeaaaabbbbccccddddeeeef".into()).is_err()); - assert!(f("aaaabbbbccccddddeeeeaaaabbbbccccddddeee".into()).is_err()); - assert!(f("aaaabbbbccccddddeeeeaaaabbbbccccddddeeeö".into()).is_err()); + assert!(f("aaaabbbbccccddddeeeeaaaabbbbccccddddeeee").is_ok()); + assert!(f("aaaabbbbccccddddeeeeaaaabbbbccccddddeeeef").is_err()); + assert!(f("aaaabbbbccccddddeeeeaaaabbbbccccddddeee").is_err()); + assert!(f("aaaabbbbccccddddeeeeaaaabbbbccccddddeeeö").is_err()); } #[test] diff --git a/crates/common/src/cli.rs b/crates/common/src/cli.rs index db18f09..d935285 100644 --- a/crates/common/src/cli.rs +++ b/crates/common/src/cli.rs @@ -47,6 +47,7 @@ impl Options { { let mut options = Options::default(); + #[allow(clippy::while_let_loop)] // False positive loop { if let Some(arg) = arg_iter.next() { match arg.as_str() { diff --git a/crates/common/src/cpu_pinning.rs b/crates/common/src/cpu_pinning.rs index 870ea59..529f15c 100644 --- a/crates/common/src/cpu_pinning.rs +++ b/crates/common/src/cpu_pinning.rs @@ -296,12 +296,12 @@ pub fn pin_current_if_configured_to( let cpu_set = core_cpu_sets .get(core_index) - .expect(&format!("get cpu set for core {}", core_index)) + .unwrap_or_else(|| panic!("get cpu set for core {}", core_index)) .to_owned(); topology .set_cpubind(cpu_set, CPUBIND_THREAD) - .expect(&format!("bind thread to core {}", core_index)); + .unwrap_or_else(|err| panic!("bind thread to core {}: {:?}", core_index, err)); ::log::info!( "Pinned worker {:?} to cpu core {}", diff --git a/crates/common/src/lib.rs b/crates/common/src/lib.rs index 44f25f5..6d0dbb6 100644 --- a/crates/common/src/lib.rs +++ b/crates/common/src/lib.rs @@ -39,6 +39,7 @@ impl ValidUntil { pub struct ServerStartInstant(Instant); impl ServerStartInstant { + #[allow(clippy::new_without_default)] // I prefer ::new here pub fn new() -> Self { Self(Instant::now()) } @@ -82,13 +83,11 @@ impl Drop for PanicSentinel { if ::std::thread::panicking() { let already_triggered = self.0.fetch_or(true, Ordering::SeqCst); - if !already_triggered { - if unsafe { libc::raise(15) } == -1 { - panic!( - "Could not raise SIGTERM: {:#}", - ::std::io::Error::last_os_error() - ) - } + if !already_triggered && unsafe { libc::raise(15) } == -1 { + panic!( + "Could not raise SIGTERM: {:#}", + ::std::io::Error::last_os_error() + ) } } } diff --git a/crates/common/src/privileges.rs b/crates/common/src/privileges.rs index 907d80b..10731ca 100644 --- a/crates/common/src/privileges.rs +++ b/crates/common/src/privileges.rs @@ -48,15 +48,13 @@ impl PrivilegeDropper { } pub fn after_socket_creation(self) -> anyhow::Result<()> { - if self.config.drop_privileges { - if self.barrier.wait().is_leader() { - PrivDrop::default() - .chroot(self.config.chroot_path.clone()) - .group(self.config.group.clone()) - .user(self.config.user.clone()) - .apply() - .with_context(|| "couldn't drop privileges after socket creation")?; - } + if self.config.drop_privileges && self.barrier.wait().is_leader() { + PrivDrop::default() + .chroot(self.config.chroot_path.clone()) + .group(self.config.group.clone()) + .user(self.config.user.clone()) + .apply() + .with_context(|| "couldn't drop privileges after socket creation")?; } Ok(()) diff --git a/crates/common/src/rustls_config.rs b/crates/common/src/rustls_config.rs index 56b8336..86d2bd0 100644 --- a/crates/common/src/rustls_config.rs +++ b/crates/common/src/rustls_config.rs @@ -46,6 +46,7 @@ pub fn create_rustls_config( .next() .ok_or(anyhow::anyhow!("No private keys in file"))??; + #[allow(clippy::let_and_return)] // Using temporary variable fixes lifetime issue key };