From 0f3bfe6dfceddb692623c762269507406b2ea4c3 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Wed, 14 Dec 2022 23:34:17 +0000 Subject: [PATCH] clippy (mostly suppressions) Signed-off-by: Ian Jackson --- client/client.rs | 16 +++++++++++----- macros/macros.rs | 18 ++++++++++++------ server/server.rs | 8 +++++++- server/sweb.rs | 2 +- src/config.rs | 4 ++-- src/ipif.rs | 2 +- src/lib.rs | 9 +++++++++ src/multipart.rs | 2 +- src/queue.rs | 4 ++-- src/slip.rs | 2 +- src/utils.rs | 4 ++-- 11 files changed, 49 insertions(+), 22 deletions(-) diff --git a/client/client.rs b/client/client.rs index 5a58c42..e382656 100644 --- a/client/client.rs +++ b/client/client.rs @@ -2,6 +2,12 @@ // SPDX-License-Identifier: GPL-3.0-or-later WITH LicenseRef-Hippotat-OpenSSL-Exception // There is NO WARRANTY. +#![allow(clippy::style)] + +#![allow(clippy::unit_arg)] +#![allow(clippy::useless_format)] +#![allow(clippy::while_let_loop)] + use hippotat::prelude::*; use hippotat_macros::into_crlfs; @@ -18,9 +24,9 @@ type OutstandingRequest<'r> = Pin>> + Send + 'r >>; -impl HCC for T where +impl Hcc for T where T: hyper::client::connect::Connect + Clone + Send + Sync + 'static { } -trait HCC: hyper::client::connect::Connect + Clone + Send + Sync + 'static { } +trait Hcc: hyper::client::connect::Connect + Clone + Send + Sync + 'static { } struct ClientContext<'c,C> { ic: &'c InstanceConfig, @@ -35,7 +41,7 @@ struct TxQueued { } #[throws(AE)] -fn submit_request<'r, 'c:'r, C:HCC>( +fn submit_request<'r, 'c:'r, C:Hcc>( c: &'c ClientContext, req_num: &mut ReqNum, reqs: &mut Vec>, @@ -51,7 +57,7 @@ fn submit_request<'r, 'c:'r, C:HCC>( //dbg!(DumpHex(&hmac)); let mut token = time_t; write!(token, " ").unwrap(); - base64::encode_config_buf(&hmac, BASE64_CONFIG, &mut token); + base64::encode_config_buf(hmac, BASE64_CONFIG, &mut token); let req_num = { *req_num += 1; *req_num }; @@ -167,7 +173,7 @@ fn submit_request<'r, 'c:'r, C:HCC>( reqs.push(fut); } -async fn run_client( +async fn run_client( ic: InstanceConfig, hclient: Arc> ) -> Result diff --git a/macros/macros.rs b/macros/macros.rs index 6ba21ce..56510ba 100644 --- a/macros/macros.rs +++ b/macros/macros.rs @@ -7,6 +7,12 @@ //! This crate is an internal detail of hippotat. //! It does not adhere to semver. +#![allow(clippy::style)] + +#![allow(clippy::expect_fun_call)] +#![allow(clippy::map_flatten)] +#![allow(clippy::single_char_pattern)] + use syn::{parse_macro_input, parse_quote}; use syn::{Data, DataStruct, DeriveInput, LitStr, Meta, NestedMeta}; use quote::{quote, quote_spanned, ToTokens}; @@ -103,10 +109,10 @@ pub fn resolve(input: proc_macro::TokenStream) -> proc_macro::TokenStream { for attr in &field.attrs { let atspan = attr.path.segments.last().unwrap().ident.span(); if attr.tokens.is_empty() { - if &attr.path == &parse_quote!{ per_client } { + if attr.path == parse_quote!{ per_client } { set_skl(quote_spanned!{fname_span=> SectionKindList::PerClient }); continue; - } else if &attr.path == &parse_quote!{ global } { + } else if attr.path == parse_quote!{ global } { set_skl(quote_spanned!{fname_span=> SectionKindList::Global }); global_fields.push(syn::Field { attrs: vec![], @@ -122,14 +128,14 @@ pub fn resolve(input: proc_macro::TokenStream) -> proc_macro::TokenStream { continue; } method = attr.path.to_token_stream(); - if &attr.path == &parse_quote!{ limited } { + if attr.path == parse_quote!{ limited } { set_skl(quote_spanned!{atspan=> SectionKindList::Limited }); - } else if &attr.path == &parse_quote!{ client } { + } else if attr.path == parse_quote!{ client } { set_skl(quote_spanned!{atspan=> SectionKindList::PerClient }); - } else if &attr.path == &parse_quote!{ computed } { + } else if attr.path == parse_quote!{ computed } { set_skl(quote_spanned!{atspan=> SectionKindList::None }); } - } else if &attr.path == &parse_quote!{ special } { + } else if attr.path == parse_quote!{ special } { let meta = match attr.parse_meta().unwrap() { Meta::List(list) => list, _ => panic!(), diff --git a/server/server.rs b/server/server.rs index 590f16f..46bc7da 100644 --- a/server/server.rs +++ b/server/server.rs @@ -2,6 +2,12 @@ // SPDX-License-Identifier: GPL-3.0-or-later WITH LicenseRef-Hippotat-OpenSSL-Exception // There is NO WARRANTY. +#![allow(clippy::style)] + +#![allow(clippy::unit_arg)] +#![allow(clippy::useless_format)] +#![allow(clippy::while_let_loop)] + use hippotat::prelude::*; mod daemon; @@ -253,7 +259,7 @@ async fn async_main(opts: Opts, daemon: Option) { tasks.push((task, format!("http server {}", addr))); } - let global_ = global.clone(); + #[allow(clippy::redundant_clone)] let global_ = global.clone(); let ipif = tokio::task::spawn(async move { slocal::run(global_, local_tx_recv, ipif).await .void_unwrap_err() diff --git a/server/sweb.rs b/server/sweb.rs index ecdcc57..3d0c29e 100644 --- a/server/sweb.rs +++ b/server/sweb.rs @@ -217,7 +217,7 @@ pub async fn handle( debug!("{} error {}", &conn, &e); let mut errmsg = format!("ERROR\n\n{:?}\n\n", &e); for w in warnings.warnings { - write!(errmsg, "warning: {}\n", w).unwrap(); + writeln!(errmsg, "warning: {}", w).unwrap(); } hyper::Response::builder() .status(hyper::StatusCode::BAD_REQUEST) diff --git a/src/config.rs b/src/config.rs index 6e2a70a..b659ceb 100644 --- a/src/config.rs +++ b/src/config.rs @@ -783,7 +783,7 @@ impl InstanceConfig { match end { LinkEnd::Client => { - if &self.url == &default::() { + if self.url == default::() { let addr = self.addrs.get(0).ok_or_else( || anyhow!("client needs addrs or url set") )?; @@ -838,7 +838,7 @@ impl InstanceConfig { let bad = parking_lot::Mutex::new(vec![]); *var = regex_replace_all!( r#"%(?:%|\((\w+)\)s|\{(\w+)\}|.)"#, - &var, + var, |whole, k1, k2| (|| Ok::<_,String>({ if whole == "%%" { "%" } else if let Some(&k) = [k1,k2].iter().find(|&&s| s != "") { diff --git a/src/ipif.rs b/src/ipif.rs index 27432a7..e23e04a 100644 --- a/src/ipif.rs +++ b/src/ipif.rs @@ -17,7 +17,7 @@ impl Ipif { #[throws(AE)] pub fn start(cmd: &str, ic_name: Option) -> Self { let mut child = tokio::process::Command::new("sh") - .args(&["-c", cmd]) + .args(["-c", cmd]) .stdin (process::Stdio::piped()) .stdout(process::Stdio::piped()) .stderr(process::Stdio::piped()) diff --git a/src/lib.rs b/src/lib.rs index 06a3c08..b6aa60f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -10,6 +10,15 @@ //! Please refer to the //! [project documentation](https://www.chiark.greenend.org.uk/~ianmdlvl/hippotat/current/docs/) +#![allow(clippy::style)] + +#![allow(clippy::clone_on_copy)] +#![allow(clippy::map_flatten)] +#![allow(clippy::match_single_binding)] +#![allow(clippy::single_char_pattern)] +#![allow(clippy::unit_arg)] +#![allow(clippy::useless_format)] + pub mod prelude; pub mod config; diff --git a/src/multipart.rs b/src/multipart.rs index d66342b..a3ca932 100644 --- a/src/multipart.rs +++ b/src/multipart.rs @@ -136,7 +136,7 @@ impl<'b> ComponentIterator<'b> { Some(c) => c, }; - let next_boundary = self.boundary_finder.find(&comp.payload) + let next_boundary = self.boundary_finder.find(comp.payload) .ok_or(MissingBoundary)?; self.at_boundary = &comp.payload[next_boundary..]; diff --git a/src/queue.rs b/src/queue.rs index d381a78..34dd2a5 100644 --- a/src/queue.rs +++ b/src/queue.rs @@ -78,10 +78,10 @@ impl FrameQueueBuf { } fn push_esc_(&mut self, b: Box<[u8]>) { self.queue.push_( QueuedBytesOwned(b)); - self.queue.push_(QueuedBytesBorrowed(&SLIP_END_SLICE)); + self.queue.push_(QueuedBytesBorrowed(SLIP_END_SLICE)); } pub fn esc_push(&mut self, b: Box<[u8]>) { - self.queue.push_(QueuedBytesBorrowed(&SLIP_END_SLICE)); + self.queue.push_(QueuedBytesBorrowed(SLIP_END_SLICE)); self.queue.push_(QueuedBytesOwned(b)); } pub fn push_raw(&mut self, b: Box<[u8]>) { diff --git a/src/slip.rs b/src/slip.rs index c70d658..d50d69e 100644 --- a/src/slip.rs +++ b/src/slip.rs @@ -117,7 +117,7 @@ where AC: Fn(&[u8]) -> Result, throw!(PacketError::MTU { len: decoded_len, mtu }); } - let acr = addr_chk(&header)?; + let acr = addr_chk(header)?; (packet, acr) } diff --git a/src/utils.rs b/src/utils.rs index 827b082..03409fb 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -104,11 +104,11 @@ pub fn token_hmac(key: &[u8], message: &[u8]) -> [u8; HMAC_L] { //dbg!(DumpHex(&key), DumpHex(message), DumpHex(&ikey), DumpHex(&okey)); let h1 = HmacH::new() - .chain(&ikey) + .chain(ikey) .chain(message) .finalize(); let h2 = HmacH::new() - .chain(&okey) + .chain(okey) .chain(h1) .finalize(); h2.into() -- 2.30.2