chiark / gitweb /
clippy (mostly suppressions)
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Wed, 14 Dec 2022 23:34:17 +0000 (23:34 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Wed, 14 Dec 2022 23:54:12 +0000 (23:54 +0000)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
client/client.rs
macros/macros.rs
server/server.rs
server/sweb.rs
src/config.rs
src/ipif.rs
src/lib.rs
src/multipart.rs
src/queue.rs
src/slip.rs
src/utils.rs

index 5a58c4222e1db341122a0ec7c8c74f65137718d8..e3826564c763656dc5abe5cacfa9d1712d879a25 100644 (file)
@@ -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<Box<
     dyn Future<Output=Option<Box<[u8]>>> + Send + 'r
     >>;
 
-impl<T> HCC for T where
+impl<T> 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<C>,
   req_num: &mut ReqNum,
   reqs: &mut Vec<OutstandingRequest<'r>>,
@@ -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<C:HCC>(
+async fn run_client<C:Hcc>(
   ic: InstanceConfig,
   hclient: Arc<hyper::Client<C>>
 ) -> Result<Void, AE>
index 6ba21ce5668954751dda55f3f0c2618240a9666a..56510ba68cfb336fdbea7affd3aa44fe249dec85 100644 (file)
@@ -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!(),
index 590f16f57e49e3f218d17da5e822374045a410aa..46bc7da0464d74cd4cdb96b08637510831c8a550 100644 (file)
@@ -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<Daemoniser>) {
       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()
index ecdcc57aaff8455c7cabbe5c86dfe129db7f205c..3d0c29eed1ce51bc781ef95b92eb0272863428b6 100644 (file)
@@ -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)
index 6e2a70a74375936213abc43f3fe9b1d1cbce3823..b659ceb66822635e9188bd236a3b8db4327c4264 100644 (file)
@@ -783,7 +783,7 @@ impl InstanceConfig {
 
     match end {
       LinkEnd::Client => {
-        if &self.url == &default::<Uri>() {
+        if self.url == default::<Uri>() {
           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 != "") {
index 27432a71b1fb754ac340f0ff494deee2664d9c70..e23e04a19ced3aed03863fd50facde046e79220a 100644 (file)
@@ -17,7 +17,7 @@ impl Ipif {
   #[throws(AE)]
   pub fn start(cmd: &str, ic_name: Option<String>) -> 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())
index 06a3c08c542cc25d026d7487d85cd05fec290927..b6aa60f2ee39fe756b50dd8fc33eafbce1d5d13c 100644 (file)
 //! 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;
index d66342b66faa5512234815054eaab26d058eb614..a3ca93210994da86ad1767bd39162e96906161c6 100644 (file)
@@ -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..];
index d381a785afce0e113a6104f207cf901eeb346a78..34dd2a515ec87af931e89b4844120a91b5c243e3 100644 (file)
@@ -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]>) {
index c70d6583528e7546687a91bfd0bfb563563daa04..d50d69eb0d9ae6610b10c692da091e527e27c76c 100644 (file)
@@ -117,7 +117,7 @@ where AC: Fn(&[u8]) -> Result<ACR, PacketError>,
     throw!(PacketError::MTU { len: decoded_len, mtu });
   }
 
-  let acr = addr_chk(&header)?;
+  let acr = addr_chk(header)?;
 
   (packet, acr)
 }
index 827b082aa2ad12402bce32d588b61879921624a4..03409fbed5007a3ab5453cdad2e3d8a526ac1cfe 100644 (file)
@@ -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()