mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-04-01 18:25:30 +00:00
aquatic_common: fix clippy warnings
This commit is contained in:
parent
746aa47cce
commit
2dd3ab8682
6 changed files with 23 additions and 23 deletions
|
|
@ -71,7 +71,7 @@ impl AccessList {
|
||||||
}
|
}
|
||||||
|
|
||||||
new_list
|
new_list
|
||||||
.insert_from_line(&line)
|
.insert_from_line(line)
|
||||||
.with_context(|| format!("Invalid line in access list: {}", 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 {
|
pub fn len(&self) -> usize {
|
||||||
self.0.len()
|
self.0.len()
|
||||||
}
|
}
|
||||||
|
|
@ -155,10 +156,10 @@ mod tests {
|
||||||
fn test_parse_info_hash() {
|
fn test_parse_info_hash() {
|
||||||
let f = parse_info_hash;
|
let f = parse_info_hash;
|
||||||
|
|
||||||
assert!(f("aaaabbbbccccddddeeeeaaaabbbbccccddddeeee".into()).is_ok());
|
assert!(f("aaaabbbbccccddddeeeeaaaabbbbccccddddeeee").is_ok());
|
||||||
assert!(f("aaaabbbbccccddddeeeeaaaabbbbccccddddeeeef".into()).is_err());
|
assert!(f("aaaabbbbccccddddeeeeaaaabbbbccccddddeeeef").is_err());
|
||||||
assert!(f("aaaabbbbccccddddeeeeaaaabbbbccccddddeee".into()).is_err());
|
assert!(f("aaaabbbbccccddddeeeeaaaabbbbccccddddeee").is_err());
|
||||||
assert!(f("aaaabbbbccccddddeeeeaaaabbbbccccddddeeeö".into()).is_err());
|
assert!(f("aaaabbbbccccddddeeeeaaaabbbbccccddddeeeö").is_err());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,7 @@ impl Options {
|
||||||
{
|
{
|
||||||
let mut options = Options::default();
|
let mut options = Options::default();
|
||||||
|
|
||||||
|
#[allow(clippy::while_let_loop)] // False positive
|
||||||
loop {
|
loop {
|
||||||
if let Some(arg) = arg_iter.next() {
|
if let Some(arg) = arg_iter.next() {
|
||||||
match arg.as_str() {
|
match arg.as_str() {
|
||||||
|
|
|
||||||
|
|
@ -296,12 +296,12 @@ pub fn pin_current_if_configured_to<C: CpuPinningConfig>(
|
||||||
|
|
||||||
let cpu_set = core_cpu_sets
|
let cpu_set = core_cpu_sets
|
||||||
.get(core_index)
|
.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();
|
.to_owned();
|
||||||
|
|
||||||
topology
|
topology
|
||||||
.set_cpubind(cpu_set, CPUBIND_THREAD)
|
.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!(
|
::log::info!(
|
||||||
"Pinned worker {:?} to cpu core {}",
|
"Pinned worker {:?} to cpu core {}",
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,7 @@ impl ValidUntil {
|
||||||
pub struct ServerStartInstant(Instant);
|
pub struct ServerStartInstant(Instant);
|
||||||
|
|
||||||
impl ServerStartInstant {
|
impl ServerStartInstant {
|
||||||
|
#[allow(clippy::new_without_default)] // I prefer ::new here
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self(Instant::now())
|
Self(Instant::now())
|
||||||
}
|
}
|
||||||
|
|
@ -82,13 +83,11 @@ impl Drop for PanicSentinel {
|
||||||
if ::std::thread::panicking() {
|
if ::std::thread::panicking() {
|
||||||
let already_triggered = self.0.fetch_or(true, Ordering::SeqCst);
|
let already_triggered = self.0.fetch_or(true, Ordering::SeqCst);
|
||||||
|
|
||||||
if !already_triggered {
|
if !already_triggered && unsafe { libc::raise(15) } == -1 {
|
||||||
if unsafe { libc::raise(15) } == -1 {
|
panic!(
|
||||||
panic!(
|
"Could not raise SIGTERM: {:#}",
|
||||||
"Could not raise SIGTERM: {:#}",
|
::std::io::Error::last_os_error()
|
||||||
::std::io::Error::last_os_error()
|
)
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -48,15 +48,13 @@ impl PrivilegeDropper {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn after_socket_creation(self) -> anyhow::Result<()> {
|
pub fn after_socket_creation(self) -> anyhow::Result<()> {
|
||||||
if self.config.drop_privileges {
|
if self.config.drop_privileges && self.barrier.wait().is_leader() {
|
||||||
if self.barrier.wait().is_leader() {
|
PrivDrop::default()
|
||||||
PrivDrop::default()
|
.chroot(self.config.chroot_path.clone())
|
||||||
.chroot(self.config.chroot_path.clone())
|
.group(self.config.group.clone())
|
||||||
.group(self.config.group.clone())
|
.user(self.config.user.clone())
|
||||||
.user(self.config.user.clone())
|
.apply()
|
||||||
.apply()
|
.with_context(|| "couldn't drop privileges after socket creation")?;
|
||||||
.with_context(|| "couldn't drop privileges after socket creation")?;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,7 @@ pub fn create_rustls_config(
|
||||||
.next()
|
.next()
|
||||||
.ok_or(anyhow::anyhow!("No private keys in file"))??;
|
.ok_or(anyhow::anyhow!("No private keys in file"))??;
|
||||||
|
|
||||||
|
#[allow(clippy::let_and_return)] // Using temporary variable fixes lifetime issue
|
||||||
key
|
key
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue