From ca563a8cfd4c5aef0c446d9d20adb3a649a61ccc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Gr=C3=BCnbichler?= Date: Tue, 8 Feb 2022 14:23:36 +0100 Subject: [PATCH] misc clippy fixes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Fabian Grünbichler --- proxmox-http/src/websocket/mod.rs | 4 ++-- proxmox-metrics/src/influxdb/utils.rs | 2 +- proxmox-serde/src/lib.rs | 4 ++-- proxmox-shared-memory/tests/raw_shared_mutex.rs | 4 ++-- proxmox-sys/src/linux/procfs/mountinfo.rs | 4 ++-- proxmox-tfa/src/totp.rs | 6 +++--- proxmox-tfa/src/u2f.rs | 4 ++-- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/proxmox-http/src/websocket/mod.rs b/proxmox-http/src/websocket/mod.rs index a9d21dfc..cb17776f 100644 --- a/proxmox-http/src/websocket/mod.rs +++ b/proxmox-http/src/websocket/mod.rs @@ -742,7 +742,7 @@ impl WebSocket { async fn copy_to_websocket( &self, mut reader: &mut R, - mut writer: &mut WebSocketWriter, + writer: &mut WebSocketWriter, receiver: &mut mpsc::UnboundedReceiver, ) -> Result where @@ -757,7 +757,7 @@ impl WebSocket { res = buf.read_from_async(&mut reader).fuse() => res?, res = receiver.recv().fuse() => { let res = res.ok_or_else(|| format_err!("control channel closed"))?; - match self.handle_channel_message(res, &mut writer).await? { + match self.handle_channel_message(res, writer).await? { OpCode::Close => return Ok(true), _ => { continue; }, } diff --git a/proxmox-metrics/src/influxdb/utils.rs b/proxmox-metrics/src/influxdb/utils.rs index 3507e61b..05e304f4 100644 --- a/proxmox-metrics/src/influxdb/utils.rs +++ b/proxmox-metrics/src/influxdb/utils.rs @@ -29,7 +29,7 @@ pub(crate) fn format_influxdb_line(data: &MetricsData) -> Result line.push(','); } first = false; - write!(line, "{}={}", escape_key(key), value.to_string())?; + write!(line, "{}={}", escape_key(key), value)?; } // nanosecond precision diff --git a/proxmox-serde/src/lib.rs b/proxmox-serde/src/lib.rs index b9aa787c..79c7401e 100644 --- a/proxmox-serde/src/lib.rs +++ b/proxmox-serde/src/lib.rs @@ -123,12 +123,12 @@ pub mod string_as_base64 { use serde::de::Error; let bytes = base64::decode(&string).map_err(|err| { - let msg = format!("base64 decode: {}", err.to_string()); + let msg = format!("base64 decode: {}", err); Error::custom(msg) })?; String::from_utf8(bytes).map_err(|err| { - let msg = format!("utf8 decode: {}", err.to_string()); + let msg = format!("utf8 decode: {}", err); Error::custom(msg) }) } diff --git a/proxmox-shared-memory/tests/raw_shared_mutex.rs b/proxmox-shared-memory/tests/raw_shared_mutex.rs index fc46a8db..204cbc87 100644 --- a/proxmox-shared-memory/tests/raw_shared_mutex.rs +++ b/proxmox-shared-memory/tests/raw_shared_mutex.rs @@ -100,7 +100,7 @@ fn create_test_dir(filename: &str) -> Option { } #[test] fn test_shared_memory_mutex() -> Result<(), Error> { - let path = match create_test_dir::(&"data1.shm") { + let path = match create_test_dir::("data1.shm") { None => { return Ok(()); }, // no O_TMPFILE support, can't run test Some(path) => path, }; @@ -136,7 +136,7 @@ fn test_shared_memory_mutex() -> Result<(), Error> { #[test] fn test_shared_memory_multi_mutex() -> Result<(), Error> { - let path = match create_test_dir::(&"data2.shm") { + let path = match create_test_dir::("data2.shm") { None => { return Ok(()); }, // no O_TMPFILE support, can't run test Some(path) => path, }; diff --git a/proxmox-sys/src/linux/procfs/mountinfo.rs b/proxmox-sys/src/linux/procfs/mountinfo.rs index 48ec1128..2848425c 100644 --- a/proxmox-sys/src/linux/procfs/mountinfo.rs +++ b/proxmox-sys/src/linux/procfs/mountinfo.rs @@ -312,7 +312,7 @@ fn test_entry() { ); assert_eq!(entry.fs_type, "cgroup"); assert_eq!( - entry.mount_source.as_ref().map(|s| s.as_os_str()), + entry.mount_source.as_deref(), Some(OsStr::new("cgroup")) ); assert_eq!(entry.super_options, "rw,blkio"); @@ -341,7 +341,7 @@ fn test_entry() { ); assert_eq!(entry.fs_type, "autofs"); assert_eq!( - entry.mount_source.as_ref().map(|s| s.as_os_str()), + entry.mount_source.as_deref(), Some(OsStr::new("systemd-1")) ); assert_eq!( diff --git a/proxmox-tfa/src/totp.rs b/proxmox-tfa/src/totp.rs index 1e342c40..b0c417fc 100644 --- a/proxmox-tfa/src/totp.rs +++ b/proxmox-tfa/src/totp.rs @@ -525,7 +525,7 @@ fn test_otp() { assert_eq!(parsed, hotp); assert_eq!(parsed.issuer, None); assert_eq!( - parsed.account_name.as_ref().map(String::as_str), + parsed.account_name.as_deref(), Some("My Account") ); @@ -558,11 +558,11 @@ fn test_otp() { let parsed: Totp = uri.parse().expect("failed to parse otp uri"); assert_eq!(parsed, totp); assert_eq!( - parsed.issuer.as_ref().map(String::as_str), + parsed.issuer.as_deref(), Some("An Issuer") ); assert_eq!( - parsed.account_name.as_ref().map(String::as_str), + parsed.account_name.as_deref(), Some("The Account Name") ); } diff --git a/proxmox-tfa/src/u2f.rs b/proxmox-tfa/src/u2f.rs index 732b95c5..f543c63f 100644 --- a/proxmox-tfa/src/u2f.rs +++ b/proxmox-tfa/src/u2f.rs @@ -522,7 +522,7 @@ mod test { } let ts: TestChallenge = - serde_json::from_str(&data).expect("failed to parse json test data"); + serde_json::from_str(data).expect("failed to parse json test data"); let context = super::U2f::new(TEST_APPID.to_string(), TEST_APPID.to_string()); let res = context @@ -546,7 +546,7 @@ mod test { } let ts: TestChallenge = - serde_json::from_str(&data).expect("failed to parse json test data"); + serde_json::from_str(data).expect("failed to parse json test data"); let context = super::U2f::new(TEST_APPID.to_string(), TEST_APPID.to_string()); let res = context