From 388e7c29d7857e3b941f41455fac0ba0492fd177 Mon Sep 17 00:00:00 2001 From: Matt Bilker Date: Sun, 9 Jan 2022 13:32:35 +0000 Subject: [PATCH] fix clippy warnings --- src/dump.rs | 2 +- src/format.rs | 2 +- src/lib.rs | 6 +++--- src/log.rs | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/dump.rs b/src/dump.rs index d3f0083..7f8a37e 100644 --- a/src/dump.rs +++ b/src/dump.rs @@ -26,7 +26,7 @@ pub fn dump(data: &[u8]) -> String { output.push(' '); output.extend(data.iter().map(|&c| { - if c < 0x20 || c >= 0x7f { + if !(0x20..0x7f).contains(&c) { '.' } else { c as char diff --git a/src/format.rs b/src/format.rs index bea85de..6d910a1 100644 --- a/src/format.rs +++ b/src/format.rs @@ -13,7 +13,7 @@ impl<'a> fmt::Debug for CStrFormat<'a> { impl<'a> fmt::Display for CStrFormat<'a> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - let s = crate::from_c_str(&self.0); + let s = crate::from_c_str(self.0); fmt::Debug::fmt(&s, f) } diff --git a/src/lib.rs b/src/lib.rs index 772805a..e178ab4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -55,8 +55,8 @@ static CONFIG: Config = { } }; -const DEFAULT_CONFIG_PATH: &'static str = "/etc/vgpu_unlock/config.toml"; -const DEFAULT_PROFILE_OVERRIDE_CONFIG_PATH: &'static str = "/etc/vgpu_unlock/profile_override.toml"; +const DEFAULT_CONFIG_PATH: &str = "/etc/vgpu_unlock/config.toml"; +const DEFAULT_PROFILE_OVERRIDE_CONFIG_PATH: &str = "/etc/vgpu_unlock/profile_override.toml"; /// Value of the "request" argument used by `nvidia-vgpud` and `nvidia-vgpu-mgr` when calling /// ioctl to read the PCI device ID and type (and possibly other things) from the GPU. @@ -380,7 +380,7 @@ pub unsafe extern "C" fn ioctl(fd: RawFd, request: c_ulong, argp: *mut c_void) - ret } -pub fn from_c_str<'a>(value: &'a [u8]) -> Cow<'a, str> { +pub fn from_c_str(value: &[u8]) -> Cow<'_, str> { let len = value.iter().position(|&c| c == 0).unwrap_or(value.len()); String::from_utf8_lossy(&value[..len]) diff --git a/src/log.rs b/src/log.rs index 29c43bf..d554035 100644 --- a/src/log.rs +++ b/src/log.rs @@ -25,7 +25,7 @@ pub(crate) fn syslog(level: c_int, args: fmt::Arguments<'_>) { let _ = msg_buffer.write_all(b"Failed to format message: "); - if let Err(_) = write!(&mut msg_buffer, "{}", e) { + if write!(&mut msg_buffer, "{}", e).is_err() { msg_buffer.clear(); let _ = msg_buffer.write_all(b"Failed to format message and error message");